Example usage for android.support.v4.graphics.drawable DrawableCompat setTint

List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint

Introduction

In this page you can find the example usage for android.support.v4.graphics.drawable DrawableCompat setTint.

Prototype

public static void setTint(Drawable drawable, int i) 

Source Link

Usage

From source file:com.alibaba.weex.extend.module.WXTitleBar.java

@JSMethod
public void setStyle(JSONObject object) {
    String bgColor = object.getString("backgroundColor");
    String color = object.getString("foregroundColor");
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        if (bgColor != null) {
            int c = WXResourceUtils.getColor(bgColor);
            actionBar.setBackgroundDrawable(new ColorDrawable(c));
        }/*from w  w w . j  a va  2  s  .c om*/

        if (color != null) {
            int c = WXResourceUtils.getColor(color);

            Toolbar toolbar = (Toolbar) ((Activity) mWXSDKInstance.getContext()).findViewById(R.id.toolbar);
            if (toolbar != null) {
                toolbar.setTitleTextColor(c);
                toolbar.setSubtitleTextColor(c);

                Drawable upNavigation = toolbar.getNavigationIcon();
                if (null != upNavigation) {
                    upNavigation = DrawableCompat.wrap(upNavigation);
                    upNavigation = upNavigation.mutate();
                    DrawableCompat.setTint(upNavigation, c);
                    toolbar.setNavigationIcon(upNavigation);
                }

                Drawable overflowIcon = toolbar.getOverflowIcon();
                if (null != overflowIcon) {
                    overflowIcon = DrawableCompat.wrap(overflowIcon);
                    overflowIcon = overflowIcon.mutate();
                    DrawableCompat.setTint(overflowIcon, c);
                    toolbar.setOverflowIcon(overflowIcon);
                }

                Menu menu = toolbar.getMenu();
                if (menu != null && menu.size() > 0) {
                    for (int i = 0; i < menu.size(); i++) {
                        MenuItem item = menu.getItem(i);
                        if (item != null && item.getIcon() != null) {
                            Drawable drawable = item.getIcon();
                            if (null != drawable) {
                                drawable = DrawableCompat.wrap(drawable);
                                drawable = drawable.mutate();
                                DrawableCompat.setTint(drawable, c);
                                item.setIcon(drawable);
                            }
                        }
                    }
                    ((Activity) mWXSDKInstance.getContext()).invalidateOptionsMenu();
                }
            }
        }
    }
}

From source file:com.cryart.sabbathschool.view.SSAboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SsAboutActivityBinding binding = DataBindingUtil.setContentView(this, R.layout.ss_about_activity);
    setSupportActionBar(binding.ssAppBar.ssToolbar);
    ActionBar ssToolbar = getSupportActionBar();
    if (ssToolbar != null) {
        ssToolbar.setDisplayShowCustomEnabled(true);
        ssToolbar.setDisplayShowTitleEnabled(false);
        ssToolbar.setDisplayHomeAsUpEnabled(true);
    }//from   w w  w  .  j  ava  2  s.c  o m
    binding.ssAppBar.toolbarTitle.setText(getString(R.string.ss_about));
    binding.setViewModel(new SSAboutViewModel(this));

    int primaryColor = Color.parseColor(SSColorTheme.getInstance().getColorPrimary());

    DrawableCompat.setTint(binding.ssLogo.getDrawable(), primaryColor);
    binding.ssAppTitle.setTextColor(primaryColor);
    binding.ssAppBar.ssToolbar.setBackgroundColor(primaryColor);

    this.ssFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    this.ssFirebaseAuth = FirebaseAuth.getInstance();

    SSEvent.track(SSConstants.SS_EVENT_ABOUT_OPEN);

    updateWindowColorScheme();
}

From source file:com.bilibili.magicasakura.utils.ThemeUtils.java

public static Drawable tintDrawable(Drawable drawable, @ColorInt int color, PorterDuff.Mode mode) {
    if (drawable == null)
        return null;
    Drawable wrapper = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTint(wrapper, color);
    DrawableCompat.setTintMode(drawable, mode);
    return wrapper;
}

From source file:com.grarak.kerneladiutor.fragments.tools.BuildpropFragment.java

@Override
protected Drawable getBottomFabDrawable() {
    Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(getActivity(), R.drawable.ic_add));
    DrawableCompat.setTint(drawable, Color.WHITE);
    return drawable;
}

From source file:com.grarak.kerneladiutor.fragments.tools.BackupFragment.java

@Override
protected Drawable getTopFabDrawable() {
    Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(getActivity(), R.drawable.ic_add));
    DrawableCompat.setTint(drawable, Color.WHITE);
    return drawable;
}

From source file:com.abhinavjhanwar.android.egg.neko.Cat.java

private static void tint(int color, Drawable... ds) {
    for (Drawable d : ds) {
        if (d != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                d.mutate().setTint(color);
            } else {
                DrawableCompat.setTint(DrawableCompat.wrap(d).mutate(), color);
            }//from  ww  w. j a v  a  2  s .  c  om
        }
    }
}

From source file:com.grarak.kerneladiutor.views.recyclerview.CardView.java

@Override
public void onCreateView(View view) {
    mRootView = (android.support.v7.widget.CardView) view;
    mTitle = (TextView) view.findViewById(R.id.card_title);
    mLayout = (LinearLayout) view.findViewById(R.id.card_layout);
    mMenuButton = (ImageButton) view.findViewById(R.id.menu_button);

    mMenuButton.setRotation(90);/* w ww  .ja va  2  s .c o  m*/
    mMenuButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mPopupMenu != null) {
                mPopupMenu.show();
            }
        }
    });

    Drawable drawable = mMenuButton.getDrawable();
    DrawableCompat.setTint(drawable,
            ContextCompat.getColor(view.getContext(), Utils.DARK_THEME ? R.color.white : R.color.black));
    mMenuButton.setImageDrawable(drawable);

    super.onCreateView(view);
    setupLayout();
}

From source file:org.floens.chan.ui.adapter.FilesAdapter.java

@SuppressWarnings({ "ConstantConditions", "deprecation" })
@Override//from  www.j  a va2s  .c  o m
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    int itemViewType = getItemViewType(position);
    switch (itemViewType) {
    case ITEM_TYPE_FILE:
    case ITEM_TYPE_FOLDER: {
        boolean isFile = itemViewType == ITEM_TYPE_FILE;

        FileItem item = getItem(position);
        FileViewHolder fileViewHolder = ((FileViewHolder) holder);
        fileViewHolder.text.setText(item.file.getName());

        Context context = holder.itemView.getContext();

        if (isFile) {
            fileViewHolder.image.setVisibility(View.GONE);
        } else {
            fileViewHolder.image.setVisibility(View.VISIBLE);
            Drawable drawable = DrawableCompat
                    .wrap(context.getResources().getDrawable(R.drawable.ic_folder_black_24dp));
            DrawableCompat.setTint(drawable, getAttrColor(context, R.attr.text_color_secondary));
            fileViewHolder.image.setImageDrawable(drawable);
        }

        boolean highlighted = highlightedItem != null && highlightedItem.file.equals(item.file);
        if (highlighted) {
            fileViewHolder.itemView.setBackgroundColor(0x0e000000);
        } else {
            fileViewHolder.itemView.setBackgroundResource(R.drawable.item_background);
        }

        break;
    }
    }
}

From source file:com.android.projectz.teamrocket.thebusapp.adapters.CustomListSettingMain.java

public Drawable changeColorOfIcons(Drawable image, int color) {
    image = DrawableCompat.wrap(image);// w  w w  .j  a va 2s. com
    DrawableCompat.setTint(image, context.getResources().getColor(color));
    return image;
}

From source file:systems.soapbox.ombuds.client.ui.omb.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    mSearchView = (SearchView) findViewById(R.id.search_view);
    setupSearchView();/*  www  .j  a v  a 2s.  c o  m*/
    mSearchResults = (ListView) findViewById(R.id.search_results);
    /*
    mResultsAdapter = new SimpleCursorAdapter(this,
        R.layout.list_item_search_result, null,
        new String[]{ScheduleContract.SearchTopicSessionsColumns.SEARCH_SNIPPET},
        new int[]{R.id.search_result}, 0);
    mSearchResults.setAdapter(mResultsAdapter);
    */
    mSearchResults.setOnItemClickListener(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    Drawable up = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.ic_arrow_back_white_24dp)); // TODO
    DrawableCompat.setTint(up, getResources().getColor(R.color.app_body_text_2)); // TODO
    toolbar.setNavigationIcon(up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dismiss(null);
        }
    });

    String query = getIntent().getStringExtra(SearchManager.QUERY);
    query = query == null ? "" : query;
    mQuery = query;

    if (mSearchView != null) {
        mSearchView.setQuery(query, false);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        doEnterAnim();
    }

    overridePendingTransition(0, 0);
}