本文整理匯總了Java中android.graphics.drawable.Drawable.invalidateSelf方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.invalidateSelf方法的具體用法?Java Drawable.invalidateSelf怎麽用?Java Drawable.invalidateSelf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.invalidateSelf方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tintViewBackground
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void tintViewBackground(View view, TintInfo tint) {
Drawable background;
if (view == null || (background = view.getBackground()) == null) return;
if (tint.mHasTintList || tint.mHasTintMode) {
background.mutate();
if (background instanceof ColorDrawable) {
((ColorDrawable) background).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor())));
} else {
background.setColorFilter(createTintFilter(view.getContext(),
tint.mHasTintList ? tint.mTintList : null,
tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE,
view.getDrawableState()));
}
} else {
background.clearColorFilter();
}
if (Build.VERSION.SDK_INT <= 23) {
// On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter
// has changed, so we need to force an invalidation
background.invalidateSelf();
}
}
示例2: tintViewDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) {
if (view == null || drawable == null) return;
if (tint.mHasTintList || tint.mHasTintMode) {
drawable.mutate();
if (drawable instanceof ColorDrawable) {
((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor())));
} else {
drawable.setColorFilter(createTintFilter(view.getContext(),
tint.mHasTintList ? tint.mTintList : null,
tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE,
view.getDrawableState()));
}
} else {
drawable.clearColorFilter();
}
if (Build.VERSION.SDK_INT <= 23) {
// On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter
// has changed, so we need to force an invalidation
drawable.invalidateSelf();
}
}
示例3: setLedColor
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* Set status led color
* @param led Led text view
* @param color Color (red, yellow or green)
*/
private void setLedColor(TextView led, int color) {
Drawable l;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
l = led.getCompoundDrawables()[0];
} else {
l = led.getCompoundDrawablesRelative()[0];
}
switch (color) {
case LED_RED:
l.setColorFilter(ContextCompat.getColor(this, R.color.colorRed), PorterDuff.Mode.SRC_ATOP);
break;
case LED_GREEN:
l.setColorFilter(ContextCompat.getColor(this, R.color.colorGreen), PorterDuff.Mode.SRC_ATOP);
break;
case LED_YELLOW:
l.setColorFilter(ContextCompat.getColor(this, R.color.colorYellow), PorterDuff.Mode.SRC_ATOP);
break;
}
l.invalidateSelf();
}
示例4: tintDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void tintDrawable(Drawable drawable, TintInfo tint, int[] state) {
if (!DrawableUtils.canSafelyMutateDrawable(drawable) || drawable.mutate() == drawable) {
if (tint.mHasTintList || tint.mHasTintMode) {
drawable.setColorFilter(createTintFilter(tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, state));
} else {
drawable.clearColorFilter();
}
if (VERSION.SDK_INT <= 23) {
drawable.invalidateSelf();
return;
}
return;
}
Log.d(TAG, "Mutated drawable is not the same instance as the input.");
}
示例5: verifyCallback
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void verifyCallback(Drawable parent, Drawable child) {
Drawable.Callback callback = mock(Drawable.Callback.class);
parent.setCallback(callback);
child.invalidateSelf();
verify(callback).invalidateDrawable(any(Drawable.class));
}