當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.invalidateSelf方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:25,代碼來源:TintManager.java

示例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();
    }
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:23,代碼來源:TintManager.java

示例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();
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:28,代碼來源:MainActivity.java

示例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.");
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:16,代碼來源:AppCompatDrawableManager.java

示例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));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:GenericDraweeHierarchyTest.java


注:本文中的android.graphics.drawable.Drawable.invalidateSelf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。