当前位置: 首页>>代码示例>>Java>>正文


Java DrawableContainer类代码示例

本文整理汇总了Java中android.graphics.drawable.DrawableContainer的典型用法代码示例。如果您正苦于以下问题:Java DrawableContainer类的具体用法?Java DrawableContainer怎么用?Java DrawableContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DrawableContainer类属于android.graphics.drawable包,在下文中一共展示了DrawableContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: containsNinePatch

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't getBaseApplication containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:25,代码来源:ThemeUtils.java

示例2: setContainerConstantStateV9

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
private static boolean setContainerConstantStateV9(DrawableContainer drawable, ConstantState constantState) {
    if (!sSetConstantStateMethodFetched) {
        try {
            sSetConstantStateMethod = DrawableContainer.class.getDeclaredMethod("setConstantState", new Class[]{DrawableContainerState.class});
            sSetConstantStateMethod.setAccessible(true);
        } catch (NoSuchMethodException e) {
            Log.e(LOG_TAG, "Could not fetch setConstantState(). Oh well.");
        }
        sSetConstantStateMethodFetched = true;
    }
    if (sSetConstantStateMethod != null) {
        try {
            sSetConstantStateMethod.invoke(drawable, new Object[]{constantState});
            return true;
        } catch (Exception e2) {
            Log.e(LOG_TAG, "Could not invoke setConstantState(). Oh well.");
        }
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:DrawableUtils.java

示例3: setContainerConstantStateV7

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
private static boolean setContainerConstantStateV7(DrawableContainer drawable, ConstantState constantState) {
    if (!sDrawableContainerStateFieldFetched) {
        try {
            sDrawableContainerStateField = DrawableContainer.class.getDeclaredField("mDrawableContainerStateField");
            sDrawableContainerStateField.setAccessible(true);
        } catch (NoSuchFieldException e) {
            Log.e(LOG_TAG, "Could not fetch mDrawableContainerStateField. Oh well.");
        }
        sDrawableContainerStateFieldFetched = true;
    }
    if (sDrawableContainerStateField != null) {
        try {
            sDrawableContainerStateField.set(drawable, constantState);
            return true;
        } catch (Exception e2) {
            Log.e(LOG_TAG, "Could not set mDrawableContainerStateField. Oh well.");
        }
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:DrawableUtils.java

示例4: containsNinePatch

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't get containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:Bilibili,项目名称:MagicaSakura,代码行数:25,代码来源:ThemeUtils.java

示例5: onCreateViewHolder

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
/**
 * Inflates the view and creates the ViewHolder
 *
 * @param parent   Get the context from it
 * @param viewType Ignored
 * @return The created ViewHolder
 */
@Override
public ButtonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.multiplechoice_button, parent, false);

    // Clone drawable to allow modifications
    ToggleButton button = (ToggleButton) v.findViewById(R.id.toggleButton);
    StateListDrawable drawable = (StateListDrawable) button.getBackground();
    drawable = (StateListDrawable) drawable.mutate();
    button.setBackgroundDrawable(drawable.getConstantState().newDrawable());
    drawable = (StateListDrawable) button.getBackground();
    // Deep Clone (necessary for API Version 15 apparently)
    DrawableContainer.DrawableContainerState drawableContainerState = (DrawableContainer.DrawableContainerState) drawable.getConstantState();
    for (int i = 0; i < drawableContainerState.getChildren().length; i++) {
        if (drawableContainerState.getChildren()[i] != null) {
            drawableContainerState.getChildren()[i] = drawableContainerState.getChildren()[i].getConstantState().newDrawable().mutate();
        }
    }

    return new ButtonViewHolder(v);
}
 
开发者ID:Kamshak,项目名称:BrainPhaser,代码行数:28,代码来源:ButtonsAdapter.java

示例6: shouldMutateBackground

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
private static boolean shouldMutateBackground(Drawable drawable) {
    if (Build.VERSION.SDK_INT >= 16) {
        // For SDK 16+, we should be fine mutating the drawable
        return true;
    }

    if (drawable instanceof LayerDrawable) {
        return Build.VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return Build.VERSION.SDK_INT >= 14;
    } else if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (Drawable child : containerState.getChildren()) {
                if (!shouldMutateBackground(child)) {
                    return false;
                }
            }
        }
    }
    return true;
}
 
开发者ID:iQuick,项目名称:AndroidTint,代码行数:26,代码来源:EmTintManager.java

示例7: wrapForTinting

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
public static Drawable wrapForTinting(Drawable drawable)
    {
        Object obj;
label0:
        {
            if (!(drawable instanceof GradientDrawable))
            {
                obj = drawable;
                if (!(drawable instanceof DrawableContainer))
                {
                    break label0;
                }
            }
            obj = new DrawableWrapperLollipop(drawable);
        }
        return ((Drawable) (obj));
    }
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:18,代码来源:DrawableCompatLollipop.java

示例8: isEquals

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
/**
 * Check if two Drawables are equal. A regular check for a Drawable equals
 * just checks for the instance reference, while this check is doing a
 * deeper equals when dealing with {@link DrawableContainer} instances. In
 * these cases, the method will run equals on each of the child drawables in
 * the container (order is importance as well).
 * 
 * @param d1
 * @param d2
 * @return <code>true</code> if the drawables are equal, <code>false</code>
 *         otherwise.
 */
public static boolean isEquals(Drawable d1, Drawable d2) {
    if (d1 == d2) {
        return true;
    }
    if (d1 == null || d2 == null) {
        return false;
    }
    if (d1 instanceof DrawableContainer && d2 instanceof DrawableContainer) {
        // Try to match the content of those containers
        DrawableContainerState containerState1 = (DrawableContainerState) ((DrawableContainer) d1)
                .getConstantState();
        DrawableContainerState containerState2 = (DrawableContainerState) ((DrawableContainer) d2)
                .getConstantState();

        return Arrays.equals(containerState1.getChildren(), containerState2.getChildren());
    }
    return d1.equals(d2);
}
 
开发者ID:Pixate,项目名称:pixate-freestyle-android,代码行数:31,代码来源:PXDrawableUtil.java

示例9: canSafelyMutateDrawable

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
        return false;
    }  else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return false;
    } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
        return false;
    }

    if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse its child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (final Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } /*else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    }*/ else if (drawable instanceof ScaleDrawable) {
        return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
    }

    return true;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:42,代码来源:DrawableUtils.java

示例10: ensureBackgroundDrawableStateWorkaround

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
private void ensureBackgroundDrawableStateWorkaround() {
  final int sdk = Build.VERSION.SDK_INT;
  if (sdk != 21 && sdk != 22) {
    // The workaround is only required on API 21-22
    return;
  }
  final Drawable bg = mEditText.getBackground();
  if (bg == null) {
    return;
  }

  if (!mHasReconstructedEditTextBackground) {
    // This is gross. There is an issue in the platform which affects container Drawables
    // where the first drawable retrieved from resources will propagate any changes
    // (like color filter) to all instances from the cache. We'll try to workaround it...

    final Drawable newBg = bg.getConstantState().newDrawable();

    if (bg instanceof DrawableContainer) {
      // If we have a Drawable container, we can try and set it's constant state via
      // reflection from the new Drawable
      mHasReconstructedEditTextBackground =
          com.commonsware.cwac.crossport.design.widget.DrawableUtils.setContainerConstantState(
              (DrawableContainer) bg, newBg.getConstantState());
    }

    if (!mHasReconstructedEditTextBackground) {
      // If we reach here then we just need to set a brand new instance of the Drawable
      // as the background. This has the unfortunate side-effect of wiping out any
      // user set padding, but I'd hope that use of custom padding on an EditText
      // is limited.
      ViewCompat.setBackground(mEditText, newBg);
      mHasReconstructedEditTextBackground = true;
    }
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:37,代码来源:TextInputLayout.java

示例11: isCompatTintEnabled

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
protected boolean isCompatTintEnabled() {
    if (VERSION.SDK_INT != 21) {
        return false;
    }
    Drawable drawable = this.mDrawable;
    if ((drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable)) {
        return true;
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:DrawableWrapperLollipop.java

示例12: ensureBackgroundDrawableStateWorkaround

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
private void ensureBackgroundDrawableStateWorkaround() {
    Drawable bg = this.mEditText.getBackground();
    if (bg != null && !this.mHasReconstructedEditTextBackground) {
        Drawable newBg = bg.getConstantState().newDrawable();
        if (bg instanceof DrawableContainer) {
            this.mHasReconstructedEditTextBackground = DrawableUtils.setContainerConstantState((DrawableContainer) bg, newBg.getConstantState());
        }
        if (!this.mHasReconstructedEditTextBackground) {
            this.mEditText.setBackgroundDrawable(newBg);
            this.mHasReconstructedEditTextBackground = true;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:TextInputLayout.java

示例13: canSafelyMutateDrawable

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
        return false;
    }  else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return false;
    } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
        return false;
    }

    if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (final Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof ScaleDrawable) {
        return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
    }

    return true;
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:42,代码来源:SkinCompatDrawableUtils.java

示例14: m2634b

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
public static boolean m2634b(Drawable drawable) {
    if (drawable instanceof LayerDrawable) {
        return VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return VERSION.SDK_INT >= 14;
    } else {
        if (drawable instanceof StateListDrawable) {
            return VERSION.SDK_INT >= 8;
        } else {
            if (drawable instanceof GradientDrawable) {
                return VERSION.SDK_INT >= 14;
            } else {
                if (!(drawable instanceof DrawableContainer)) {
                    return drawable instanceof C0063q ? m2634b(((C0063q) drawable).m469a()) : drawable instanceof C0244a ? m2634b(((C0244a) drawable).m1984a()) : drawable instanceof ScaleDrawable ? m2634b(((ScaleDrawable) drawable).getDrawable()) : true;
                } else {
                    ConstantState constantState = drawable.getConstantState();
                    if (!(constantState instanceof DrawableContainerState)) {
                        return true;
                    }
                    for (Drawable b : ((DrawableContainerState) constantState).getChildren()) {
                        if (!m2634b(b)) {
                            return false;
                        }
                    }
                    return true;
                }
            }
        }
    }
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:31,代码来源:bt.java

示例15: m487c

import android.graphics.drawable.DrawableContainer; //导入依赖的package包/类
protected boolean m487c() {
    if (VERSION.SDK_INT != 21) {
        return false;
    }
    Drawable drawable = this.c;
    return (drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable);
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:8,代码来源:aa.java


注:本文中的android.graphics.drawable.DrawableContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。