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.armani2015.android.common.widget.ExpandableItemIndicatorImplAnim.java

@Override
public void setExpandedState(boolean isExpanded, boolean animate) {
    if (animate) {
        int resId = isExpanded ? R.drawable.ic_expand_more_to_expand_less
                : R.drawable.ic_expand_less_to_expand_more;
        mImageView.setImageResource(resId);
        DrawableCompat.setTint(mImageView.getDrawable(), mColor);
        ((Animatable) mImageView.getDrawable()).start();
    } else {//www . j a v  a 2s  . c o  m
        int resId = isExpanded ? R.drawable.ic_expand_less_vector : R.drawable.ic_expand_more_vector;
        mImageView.setImageResource(resId);
        DrawableCompat.setTint(mImageView.getDrawable(), mColor);
    }
}

From source file:com.tafayor.selfcamerashot.taflib.helpers.GraphicsHelper.java

public static Drawable tintDrawable(Drawable img, int color) {

    Drawable tinted = DrawableCompat.wrap(img);
    DrawableCompat.setTint(tinted, color);

    return tinted;
}

From source file:io.github.hidroh.materialistic.MenuTintDelegate.java

@SuppressWarnings("unused")
public void setIcon(MenuItem item, @DrawableRes int icon) {
    item.setIcon(icon);/* ww w . j  av a2 s  .c  o  m*/
    Drawable drawable = item.getIcon();
    drawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(drawable, mTextColorPrimary);
}

From source file:ro.expectations.expenses.ui.backup.BackupActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mMainContent.setLayoutResource(R.layout.content_backup);
    mMainContent.inflate();/*w  w w.j  av a2s .  c  o  m*/

    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
    Drawable icon = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.ic_cloud_upload_black_24dp));
    DrawableCompat.setTint(icon, ContextCompat.getColor(this, R.color.colorWhite));
    mFloatingActionButton.setImageDrawable(icon);
    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            BackupFragment backupFragment = (BackupFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.fragment);
            if (backupFragment != null && backupFragment.isVisible()) {
                backupFragment.fabAction();
            }
        }
    });

    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);

    if (savedInstanceState == null) {
        BackupFragment fragment = BackupFragment.newInstance();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.fragment, fragment);
        transaction.commit();
    }
}

From source file:im.getsocial.testapp.ConsoleActivity.java

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

    consoleTextView = (TextView) findViewById(R.id.console_textView);
    scrollView = (ScrollView) findViewById(R.id.console_scrollView);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Drawable clearIcon = getResources().getDrawable(R.drawable.ic_clear);
    Drawable wrappedClearIcon = DrawableCompat.wrap(clearIcon);
    DrawableCompat.setTint(wrappedClearIcon, getResources().getColor(R.color.icons));
    getSupportActionBar().setHomeAsUpIndicator(wrappedClearIcon);

    populateConsoleContent();/*  www  .  j  av a 2 s. com*/

    scrollToBottom();
}

From source file:com.xw.project.gracefulmovies.view.activity.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    transparentStatusBar();//  w ww  .  ja  va 2s  .  co  m

    setContentView(R.layout.activity_about);
    ButterKnife.bind(this);

    initializeToolbar();

    Glide.with(this).load(R.drawable.pic_movie_projector).into(mHeaderImg);
    try {
        PackageManager manager = getPackageManager();
        PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
        String s = String.format(Locale.CHINA, "%sBuild %d", info.versionName, info.versionCode);
        mVersionNameText.setText(s);
    } catch (Exception e) {
        e.printStackTrace();
        mVersionNameText.setText("");
    }
    if (Colorful.getThemeDelegate().isNight()) {
        Drawable drawable = mGitHubImg.getDrawable();
        if (drawable != null) {
            DrawableCompat.setTint(drawable, Color.WHITE);
            mGitHubImg.setImageDrawable(drawable);
        }
    }
    mLicenseText.setText(Html.fromHtml(getString(R.string.license)));
}

From source file:com.bzu.yhd.pocketcampus.main.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    mUnbinder = ButterKnife.bind(this);
    initializeToolbar();/*from   ww w  .jav  a  2s.co m*/
    BaseApplication.getInstance().addActivity(this);

    Glide.with(this).load(R.mipmap.flowbloom).into(mHeaderImg);
    try {
        PackageManager manager = getPackageManager();
        PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
        String s = String.format(Locale.CHINA, "%sBuild %d", info.versionName, info.versionCode);
        mVersionNameText.setText(s);
    } catch (Exception e) {
        e.printStackTrace();
        mVersionNameText.setText("");
    }
    if (Colorful.getThemeDelegate().isNight()) {
        Drawable drawable = mGitHubImg.getDrawable();
        if (drawable != null) {
            DrawableCompat.setTint(drawable, Color.WHITE);
            mGitHubImg.setImageDrawable(drawable);
        }
    }
    mLicenseText.setText(Html.fromHtml(getString(R.string.license)));
}

From source file:me.selinali.tribbble.utils.ViewUtils.java

public static void tintDrawable(TextView textView, int position) {
    DrawableCompat.setTint(textView.getCompoundDrawables()[position], color(R.color.textNormal));
}

From source file:jahirfiquitiva.iconshowcase.utilities.utils.IconUtils.java

@CheckResult
@Nullable//from www  . j ava2 s. co m
public static Drawable getTintedIcon(Drawable drawable, int color) {
    if (drawable != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (drawable instanceof VectorDrawable) {
                drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
            }
            drawable = DrawableCompat.wrap(drawable.mutate());
        } else {
            drawable = DrawableCompat.wrap(drawable);
        }
        DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
        DrawableCompat.setTint(drawable, color);
        return drawable;
    } else {
        return null;
    }
}

From source file:xyz.klinker.android.article.Utils.java

/**
 * Changes the progress bar's color./*from   www.ja  v  a2  s . c  o  m*/
 */
static void changeProgressBarColors(ProgressBar progressBar, int color) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        Drawable wrapDrawable = DrawableCompat.wrap(progressBar.getIndeterminateDrawable());
        DrawableCompat.setTint(wrapDrawable, color);
        progressBar.setIndeterminateDrawable(DrawableCompat.unwrap(wrapDrawable));
    } else {
        progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
    }
}