android.widget.ProgressBar#getIndeterminateDrawable ( )源码实例Demo

下面列出了android.widget.ProgressBar#getIndeterminateDrawable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void setColor(ProgressBar progressBar) {
  Drawable drawable;
  if (progressBar.isIndeterminate()) {
    drawable = progressBar.getIndeterminateDrawable();
  } else {
    drawable = progressBar.getProgressDrawable();
  }

  if (drawable == null) {
    return;
  }

  if (mColor != null) {
    drawable.setColorFilter(mColor, PorterDuff.Mode.SRC_IN);
  } else {
    drawable.clearColorFilter();
  }
}
 
private void setColor(ProgressBar progressBar) {
  Drawable drawable;
  if (progressBar.isIndeterminate()) {
    drawable = progressBar.getIndeterminateDrawable();
  } else {
    drawable = progressBar.getProgressDrawable();
  }

  if (drawable == null) {
    return;
  }

  if (mColor != null) {
    drawable.setColorFilter(mColor, PorterDuff.Mode.SRC_IN);
  } else {
    drawable.clearColorFilter();
  }
}
 
源代码3 项目: litho   文件: ProgressSpec.java
@OnMount
static void onMount(
    ComponentContext c,
    ProgressBar progressBar,
    @Prop(optional = true, resType = ResType.COLOR) int color,
    @FromPrepare Drawable resolvedIndeterminateDrawable) {

  if (resolvedIndeterminateDrawable != null) {
    progressBar.setIndeterminateDrawable(resolvedIndeterminateDrawable);
  }

  if (color != Color.TRANSPARENT && progressBar.getIndeterminateDrawable() != null) {
    progressBar
        .getIndeterminateDrawable()
        .mutate()
        .setColorFilter(color, PorterDuff.Mode.MULTIPLY);
  }
}
 
源代码4 项目: andela-crypto-app   文件: Easel.java
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);
    }
}
 
源代码5 项目: NewsMe   文件: MDTintHelper.java
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);
    }
}
 
源代码6 项目: talk-android   文件: MDTintHelper.java
@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);
    }
}
 
源代码7 项目: APlayer   文件: TintHelper.java
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);
    }
  }
}
 
源代码8 项目: AndroidTint   文件: EmTintUtils.java
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);
    }
}
 
源代码9 项目: a   文件: TintHelper.java
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);
    }
}
 
源代码10 项目: MyBookshelf   文件: TintHelper.java
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);
    }
}
 
源代码11 项目: litho   文件: ProgressSpec.java
@OnUnmount
static void onUnmount(
    ComponentContext c,
    ProgressBar progressBar,
    @Prop(optional = true, resType = ResType.COLOR) int color,
    @FromPrepare Drawable resolvedIndeterminateDrawable) {

  // restore the color first, since it acts on the indeterminateDrawable
  if (color != Color.TRANSPARENT && progressBar.getIndeterminateDrawable() != null) {
    progressBar.getIndeterminateDrawable().mutate().clearColorFilter();
  }

  progressBar.setIndeterminateDrawable(null);
}
 
源代码12 项目: leanback-extensions   文件: LoadingFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_loading, container, false);

	FrameLayout loadingContainer = (FrameLayout) view.findViewById(R.id.fragment_loading_container);
	loadingContainer.setBackgroundColor(backgroundColor);

	progressBar = new ProgressBar(container.getContext());
	if (container instanceof FrameLayout) {
		FrameLayout.LayoutParams layoutParams =
				new FrameLayout.LayoutParams(progressWidth, progressHeight, Gravity.CENTER);
		progressBar.setLayoutParams(layoutParams);
	}

	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		if (progressBar.getIndeterminateDrawable() != null) {
			progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(progressColor),
					PorterDuff.Mode.SRC_IN);
		}
	} else {
		ColorStateList stateList = ColorStateList.valueOf(progressColor);
		progressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
		progressBar.setIndeterminateTintList(stateList);
		progressBar.setProgressBackgroundTintMode(PorterDuff.Mode.SRC_IN);
		progressBar.setProgressBackgroundTintList(stateList);
		progressBar.setIndeterminate(true);
	}

	loadingContainer.addView(progressBar);

	return view;
}