Example usage for android.support.v4.content.res ResourcesCompat getDrawable

List of usage examples for android.support.v4.content.res ResourcesCompat getDrawable

Introduction

In this page you can find the example usage for android.support.v4.content.res ResourcesCompat getDrawable.

Prototype

public static Drawable getDrawable(Resources resources, int i, Theme theme) throws NotFoundException 

Source Link

Usage

From source file:com.waz.zclient.PopupActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ViewUtils.unlockOrientation(this);
    setContentView(R.layout.popup_reply);

    final Toolbar toolbar = ViewUtils.getView(this, R.id.toolbar);
    setSupportActionBar(toolbar);/* w ww.  jav a 2s  .  co  m*/
    setTitle("");
    toolbar.setNavigationIcon(
            ResourcesCompat.getDrawable(getResources(), R.drawable.action_back_light, getTheme()));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            KeyboardUtils.closeKeyboardIfShown(PopupActivity.this);
            onBackPressed();
        }
    });

    final Intent intent = getIntent();
    if (intent == null) {
        finish();
        return;
    }

    final String conversationId = IntentUtils.getLaunchConversationId(intent);
    if (conversationId == null) {
        finish();
        return;
    }

    getSupportFragmentManager().beginTransaction().replace(R.id.fl__quick_reply__container,
            QuickReplyFragment.newInstance(conversationId), QuickReplyFragment.TAG).commit();
}

From source file:com.github.amlcurran.showcaseview.StandardShowcaseDrawer.java

public StandardShowcaseDrawer(Resources resources, Resources.Theme theme) {
    PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY);
    eraserPaint = new Paint();
    eraserPaint.setColor(0xFFFFFF);//from ww  w .  ja  va  2s  .  c o  m
    eraserPaint.setAlpha(0);
    eraserPaint.setXfermode(xfermode);
    eraserPaint.setAntiAlias(true);
    basicPaint = new Paint();
    showcaseRadius = resources.getDimension(R.dimen.showcase_radius);
    showcaseDrawable = ResourcesCompat.getDrawable(resources, R.drawable.cling_bleached, theme);
}

From source file:neu.showcaseview.StandardShowcaseDrawer.java

public StandardShowcaseDrawer(Resources resources, Resources.Theme theme, float factor) {
    PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY);
    eraserPaint = new Paint();
    eraserPaint.setColor(0xFFFFFF);/*from w  w w .  j  a  va2 s .  c om*/
    eraserPaint.setAlpha(0);
    eraserPaint.setXfermode(xfermode);
    eraserPaint.setAntiAlias(true);
    basicPaint = new Paint();
    this.factor = factor;
    showcaseRadius = resources.getDimension(R.dimen.showcase_radius) * factor;
    showcaseDrawable = ResourcesCompat.getDrawable(resources, R.drawable.cling_bleached, theme);
}

From source file:com.benny.openlauncher.activity.AboutActivity.java

@Override
protected MaterialAboutList getMaterialAboutList(Context context) {
    runOnUiThread(new Runnable() {
        @Override//from w ww  . j a v a2  s.co  m
        public void run() {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    });

    MaterialAboutCard.Builder titleCard = new MaterialAboutCard.Builder();
    titleCard.addItem(new MaterialAboutTitleItem(R.string.app_name, R.drawable.ic_launcher));
    try {
        titleCard.addItem(ConvenienceBuilder.createVersionActionItem(this,
                ResourcesCompat.getDrawable(getResources(), R.drawable.ic_info_outline_24dp, null), "Version",
                true));
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    titleCard.addItem(ConvenienceBuilder.createWebsiteActionItem(this,
            ResourcesCompat.getDrawable(getResources(), R.drawable.ic_github, null), "GitHub", false,
            Uri.parse("https://github.com/BennyKok/OpenLauncher")));
    titleCard.addItem(new MaterialAboutActionItem(getString(R.string.about_libs), null,
            ResourcesCompat.getDrawable(getResources(), R.drawable.ic_github, null),
            new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    final Notices notices = new Notices();
                    notices.addNotice(new Notice("FastAdapter", "https://github.com/mikepenz/FastAdapter",
                            "Mike Penz", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("CircularReveal", "https://github.com/ozodrukh/CircularReveal",
                            "Abdullaev Ozodrukh", new MITLicense()));
                    notices.addNotice(
                            new Notice("MaterialScrollBar", "https://github.com/turing-tech/MaterialScrollBar",
                                    "Turing Technologies", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("Material About Library",
                            "https://github.com/daniel-stoneuk/material-about-library", "Daniel Stone",
                            new ApacheSoftwareLicense20()));
                    notices.addNotice(
                            new Notice("Material Dialogs", "https://github.com/afollestad/material-dialogs",
                                    "Aidan Follestad", new MITLicense()));
                    notices.addNotice(
                            new Notice("Material Ripple Layout", "https://github.com/balysv/material-ripple",
                                    "Balys Valentukevicius", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("ImageBlurring ", "https://github.com/qiujuer/ImageBlurring",
                            "Qiujuer", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("SimpleFingerGestures",
                            "https://github.com/championswimmer/SimpleFingerGestures_Android_Library",
                            "Arnav Gupta", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("TextDrawable", "https://github.com/amulyakhare/TextDrawable",
                            "Amulya Khare", new MITLicense()));
                    notices.addNotice(
                            new Notice("AndroidOnboarder", "https://github.com/chyrta/AndroidOnboarder",
                                    "Dzmitry Chyrta, Daniel Morales", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("CustomActivityOnCrash",
                            "https://github.com/Ereza/CustomActivityOnCrash", "Eduard Ereza Martnez",
                            new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("Butter Knife", "https://github.com/JakeWharton/butterknife",
                            "Jake Wharton", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("Gson", "url", "Google Inc.", new ApacheSoftwareLicense20()));
                    notices.addNotice(new Notice("Android Support Library",
                            "https://developer.android.com/topic/libraries/support-library/revisions.html",
                            "The Android Open Source Project", new ApacheSoftwareLicense20()));
                    new LicensesDialog.Builder(AboutActivity.this).setNotices(notices)
                            .setIncludeOwnLicense(true).build().show();
                }
            }));
    titleCard.addItem(ConvenienceBuilder.createRateActionItem(this,
            ResourcesCompat.getDrawable(getResources(), R.drawable.ic_thumb_up_24dp, null),
            getString(R.string.about_rate), null));

    MaterialAboutCard.Builder opTeamCard = new MaterialAboutCard.Builder();
    opTeamCard.title(getString(R.string.about_team));

    opTeamCard.addItem(new MaterialAboutActionItem.Builder().icon(R.drawable.person__bennykok).text("BennyKok")
            .subText(getString(R.string.about_credit_text__bennykok)).setOnClickListener(ConvenienceBuilder
                    .createWebsiteOnClickAction(this, Uri.parse("http://bennykok.weebly.com/contact.html")))
            .build());
    opTeamCard.addItem(new MaterialAboutActionItem.Builder().icon(R.drawable.person__dkanada).text("dkanada")
            .subText(getString(R.string.about_credit_text__dkanada)).setOnClickListener(ConvenienceBuilder
                    .createWebsiteOnClickAction(this, Uri.parse("https://github.com/dkanada")))
            .build());
    opTeamCard.addItem(new MaterialAboutActionItem.Builder().icon(R.drawable.person__gsantner)
            .text("Gregor Santner").subText(getString(R.string.about_credit_text__gsantner))
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(this,
                    Uri.parse("https://gsantner.github.io/")))
            .build());
    opTeamCard.addItem(new MaterialAboutActionItem.Builder().icon(R.drawable.person__gaukler_faun)
            .text("Gaukler Faun").subText(getString(R.string.about_credit_text__gaukler_faun))
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(this,
                    Uri.parse("https://github.com/scoute-dich")))
            .build());

    MaterialAboutCard.Builder contributorsCard = new MaterialAboutCard.Builder();
    contributorsCard.title(getString(R.string.about_credit));
    contributorsCard.addItem(new MaterialAboutActionItem.Builder().icon(R.drawable.person__chris_debrodie)
            .text("Chris DeBrodie").subText(getString(R.string.about_credit_text__chris_debrodie))
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(this,
                    Uri.parse("https://plus.google.com/111923938461696019967")))
            .build());

    //authorCard.addItem(ConvenienceBuilder.createWebsiteActionItem(this, ResourcesCompat.getDrawable(),"Chris DeBrodie",false, Uri.parse("")));

    return new MaterialAboutList.Builder().addCard(titleCard.build()).addCard(opTeamCard.build())
            .addCard(contributorsCard.build()).build();
}

From source file:nya.miku.wishmaster.chans.mewchnet.MewchnetModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_mewch, null);
}

From source file:com.example.dany.jjdraw.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    drawView = (DrawingView) findViewById(R.id.drawing);
    LinearLayout paintLayout = (LinearLayout) findViewById(R.id.paint_colors);
    currPaint = (ImageButton) paintLayout.getChildAt(0);
    currPaint.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.paint_pressed, null));

    smallBrush = getResources().getInteger(R.integer.small_size);
    mediumBrush = getResources().getInteger(R.integer.medium_size);
    largeBrush = getResources().getInteger(R.integer.large_size);
    drawBtn = (ImageButton) findViewById(R.id.draw_btn);
    drawBtn.setOnClickListener(this);

    drawView.setBrushSize(mediumBrush);//w ww  .j av  a  2s .c o m

    eraseBtn = (ImageButton) findViewById(R.id.erase_btn);
    eraseBtn.setOnClickListener(this);

    newBtn = (ImageButton) findViewById(R.id.new_btn);
    newBtn.setOnClickListener(this);

    saveBtn = (ImageButton) findViewById(R.id.save_btn);
    saveBtn.setOnClickListener(this);

    insertBtn = (ImageButton) findViewById(R.id.insert_btn);
    insertBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {

            Intent i = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

            startActivityForResult(i, RESULT_LOAD_IMAGE);
        }
    });

    undoBtn = (ImageButton) findViewById(R.id.undo_btn);
    undoBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!drawView.onClickUndo()) {
                Toast nothingToast = Toast.makeText(getApplicationContext(), "Nothing to Undo!",
                        Toast.LENGTH_SHORT);
                nothingToast.show();
            }
        }
    });

    redoBtn = (ImageButton) findViewById(R.id.redo_btn);
    redoBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!drawView.onClickRedo()) {
                Toast nothingToast = Toast.makeText(getApplicationContext(), "Nothing to Redo!",
                        Toast.LENGTH_SHORT);
                nothingToast.show();
            }
        }
    });

}

From source file:com.nttec.everychan.chans.clairews.ClairewsModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_clairews, null);
}

From source file:com.yanzhenjie.durban.sample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DisplayUtils.initScreen(this);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*  www.j a v a2  s.  c o m*/

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));

    Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.decoration_white, null);
    mRecyclerView.addItemDecoration(new AlbumVerticalGirdDecoration(drawable));

    assert drawable != null;
    int itemSize = (DisplayUtils.screenWidth - (drawable.getIntrinsicWidth() * 4)) / 3;
    mGridAdapter = new GridAdapter(this, itemSize);
    mRecyclerView.setAdapter(mGridAdapter);

    mImageList = new ArrayList<>();
}

From source file:com.google.android.leanbackjank.presenter.HeaderItemPresenter.java

@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = ((ListRow) item).getHeaderItem();
    View rootView = viewHolder.view;
    rootView.setFocusable(true);//w  w w . j  a  v a2s .  c o m

    ImageView iconView = (ImageView) rootView.findViewById(R.id.header_icon);
    Drawable icon = ResourcesCompat.getDrawable(rootView.getResources(), R.drawable.android_header, null);
    iconView.setImageDrawable(icon);

    TextView label = (TextView) rootView.findViewById(R.id.header_label);
    label.setText(headerItem.getName());
}

From source file:com.example.android.leanback.VerticalGridFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    final Context context = getActivity();
    setBadgeDrawable(// ww  w  . j  a  va2s .  co  m
            ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_title, context.getTheme()));
    setTitle("Leanback Vertical Grid Demo");

    setupFragment();
    if (TEST_ENTRANCE_TRANSITION) {
        // don't run entrance transition if fragment is restored.
        if (savedInstanceState == null) {
            prepareEntranceTransition();
        }
    }
    // simulates in a real world use case  data being loaded two seconds later
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            loadData();
            startEntranceTransition();
        }
    }, 2000);
}