Example usage for android.graphics.drawable InsetDrawable InsetDrawable

List of usage examples for android.graphics.drawable InsetDrawable InsetDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable InsetDrawable InsetDrawable.

Prototype

private InsetDrawable(@NonNull InsetState state, @Nullable Resources res) 

Source Link

Document

The one constructor to rule them all.

Usage

From source file:edu.mit.mobile.android.livingpostcards.CardListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    getActivity().getMenuInflater().inflate(R.menu.activity_card_view, menu);

    final Cursor c = mAdapter.getCursor();
    if (c == null) {
        return;/*from  w w  w. ja v a  2  s. c om*/
    }

    final String myUserUri = Authenticator.getUserUri(getActivity());

    final boolean isEditable = PrivatelyAuthorable.canEdit(myUserUri, c);

    menu.findItem(R.id.delete).setVisible(isEditable);
    menu.findItem(R.id.edit).setVisible(isEditable);

    menu.setHeaderTitle(Card.getTitle(getActivity(), c));
    Drawable icon;
    try {
        String iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_COVER_PHOTO));
        if (iconUrl == null || iconUrl.length() == 0) {
            iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_THUMBNAIL));
        }
        icon = mImageCache.loadImage(0, Uri.parse(iconUrl), (int) (133 * mDensity), (int) (100 * mDensity));

        if (icon != null) {
            menu.setHeaderIcon(new InsetDrawable(icon, (int) (5 * mDensity)));
        }
    } catch (final IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.esminis.server.library.activity.main.MainViewImpl.java

@Override
public boolean createMenu(MenuInflater inflater, Menu menu) {
    inflater.inflate(R.menu.main, menu);
    final Activity activity = this.activity.get();
    if (activity != null) {
        menu.findItem(R.id.menu_about).setIcon(new InsetDrawable(
                VectorDrawableCompat.create(activity.getResources(), R.drawable.ic_info, null), 0));
    }/*from   w ww.  j  av a2s .  c o m*/
    return true;
}

From source file:com.esminis.server.library.activity.main.MainViewImpl.java

private void setupToolbar(@NonNull AppCompatActivity activity) {
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
    if (toolbar != null) {
        toolbar.setLogo(VectorDrawableCompat.create(activity.getResources(), R.drawable.ic_toolbar, null));
        toolbar.inflateMenu(R.menu.main);
        TypedValue attribute = new TypedValue();
        activity.getTheme().resolveAttribute(android.R.attr.textColorPrimary, attribute, true);
        if (attribute.resourceId > 0) {
            final VectorDrawableCompat icon = VectorDrawableCompat.create(activity.getResources(),
                    R.drawable.ic_info, null);
            if (icon != null) {
                icon.setTint(ContextCompat.getColor(activity, attribute.resourceId));
                toolbar.getMenu().findItem(R.id.menu_about).setIcon(new InsetDrawable(icon, 0));
            }// ww  w. j  a  va2s .com
        }
        activity.setSupportActionBar(toolbar);
    }
}

From source file:com.android.mail.browse.ConversationItemView.java

@Override
public void setBackgroundResource(int resourceId) {
    Utils.traceBeginSection("set background resource");
    Drawable drawable = mBackgrounds.get(resourceId);
    if (drawable == null) {
        drawable = getResources().getDrawable(resourceId);
        final int insetPadding = mHeader.insetPadding;
        if (insetPadding > 0) {
            drawable = new InsetDrawable(drawable, insetPadding);
        }//from   w  ww  . ja  v a  2s .c om
        mBackgrounds.put(resourceId, drawable);
    }
    if (getBackground() != drawable) {
        super.setBackgroundDrawable(drawable);
    }
    Utils.traceEndSection();
}