Java Code Examples for android.widget.ProgressBar#setSecondaryProgressTintList()

The following examples show how to use android.widget.ProgressBar#setSecondaryProgressTintList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Easel.java    From andela-crypto-app with Apache License 2.0 6 votes vote down vote up
public static void tint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 2
Source File: MDTintHelper.java    From NewsMe with Apache License 2.0 6 votes vote down vote up
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 3
Source File: MDTintHelper.java    From talk-android with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
public static void setTint(ProgressBar progressBar, int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 4
Source File: TintHelper.java    From APlayer with GNU General Public License v3.0 6 votes vote down vote up
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color,
    boolean skipIndeterminate) {
  ColorStateList sl = ColorStateList.valueOf(color);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    progressBar.setProgressTintList(sl);
    progressBar.setSecondaryProgressTintList(sl);
    if (!skipIndeterminate) {
      progressBar.setIndeterminateTintList(sl);
    }
  } else {
    PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
      mode = PorterDuff.Mode.MULTIPLY;
    }
    if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null) {
      progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
    }
    if (progressBar.getProgressDrawable() != null) {
      progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
  }
}
 
Example 5
Source File: EmTintUtils.java    From AndroidTint with Apache License 2.0 6 votes vote down vote up
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 6
Source File: TintHelper.java    From a with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
Example 7
Source File: TintHelper.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}