• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DrawableContainerState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setContainerConstantStateV9

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的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


示例2: getExistingStates

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的package包/类
/**
 * Returns a {@link Map} that holds a mapping from the existing state-lists
 * in the background {@link Drawable}.
 * 
 * @param background A {@link Drawable} background (
 *            {@link StateListDrawable}).
 * @return A {@link Map}. An empty map in case the background
 *         <code>null</code>, or is not a {@link StateListDrawable}.
 */
public static Map<int[], Drawable> getExistingStates(Drawable background) {
    LinkedHashMap<int[], Drawable> map = new LinkedHashMap<int[], Drawable>();
    if (background instanceof StateListDrawable) {
        // Grab the existing states. Note that the API hides some of the
        // public functionality with the @hide tag, so we have to access
        // those through reflection...
        StateListDrawable stateList = (StateListDrawable) background;
        DrawableContainerState containerState = (DrawableContainerState) stateList
                .getConstantState();
        Drawable[] children = containerState.getChildren();
        try {
            // This method is public but hidden ("pending API council")
            Method method = stateList.getClass().getMethod("getStateSet", int.class);
            for (int i = 0; i < containerState.getChildCount(); i++) {
                Object state = method.invoke(stateList, i);
                if (state instanceof int[]) {
                    map.put((int[]) state, children[i]);
                }
            }
        } catch (Exception e) {
            PXLog.e(TAG, e, "Error getting the state set");
        }
    }
    return map;
}
 
开发者ID:Pixate,项目名称:pixate-freestyle-android,代码行数:35,代码来源:PXDrawableUtil.java


示例3: isEquals

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的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


示例4: setColors

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的package包/类
private void setColors(View view, int[] colors) {
    Drawable drawable = view.getBackground();
    if (drawable instanceof StateListDrawable) {
        StateListDrawable stateListDrawable = (StateListDrawable) drawable;
        DrawableContainerState drawableContainerState = (DrawableContainerState) stateListDrawable.getConstantState();
        if (drawableContainerState != null) {
            Drawable[] drawables = drawableContainerState.getChildren();
            for (int i = 0; i < colors.length; i++) if (drawables[i] instanceof GradientDrawable) ((GradientDrawable) drawables[i]).setColor(colors[i]);
        }
    } else Log.w(TAG, "Drawable of view must be StateListDrawable in WoWoStateListColorAnimation");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:WoWoStateListColorAnimation.java


示例5: m2634b

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的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


示例6: shouldMutateBackground

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的package包/类
private static boolean shouldMutateBackground(Drawable paramDrawable)
{
  if (Build.VERSION.SDK_INT >= 16) {}
  for (;;)
  {
    return true;
    if ((paramDrawable instanceof LayerDrawable))
    {
      if (Build.VERSION.SDK_INT < 16) {
        return false;
      }
    }
    else if ((paramDrawable instanceof InsetDrawable))
    {
      if (Build.VERSION.SDK_INT < 14) {
        return false;
      }
    }
    else if ((paramDrawable instanceof DrawableContainer))
    {
      Drawable.ConstantState localConstantState = paramDrawable.getConstantState();
      if ((localConstantState instanceof DrawableContainer.DrawableContainerState))
      {
        Drawable[] arrayOfDrawable = ((DrawableContainer.DrawableContainerState)localConstantState).getChildren();
        int i = arrayOfDrawable.length;
        for (int j = 0; j < i; j++) {
          if (!shouldMutateBackground(arrayOfDrawable[j])) {
            return false;
          }
        }
      }
    }
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:35,代码来源:TintManager.java


示例7: getBitmapFromStateListDrawable

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的package包/类
private Bitmap getBitmapFromStateListDrawable(){
    DrawableContainerState state = (DrawableContainerState) getDrawable().getConstantState();
    for(Drawable drawable : state.getChildren() ){
        if( drawable instanceof BitmapDrawable ){
            return ((BitmapDrawable) drawable).getBitmap();
        }
    }
    return null;
}
 
开发者ID:khreenberg,项目名称:android-segoway,代码行数:10,代码来源:ImageButtonIgnoreTransparency.java


示例8: canSafelyMutateDrawable

import android.graphics.drawable.DrawableContainer.DrawableContainerState; //导入依赖的package包/类
static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (drawable instanceof LayerDrawable) {
        if (VERSION.SDK_INT >= 16) {
            return true;
        }
        return false;
    } else if (drawable instanceof InsetDrawable) {
        if (VERSION.SDK_INT < 14) {
            return false;
        }
        return true;
    } else if (drawable instanceof StateListDrawable) {
        if (VERSION.SDK_INT < 8) {
            return false;
        }
        return true;
    } else if (drawable instanceof GradientDrawable) {
        if (VERSION.SDK_INT < 14) {
            return false;
        }
        return true;
    } else if (drawable instanceof DrawableContainer) {
        ConstantState state = drawable.getConstantState();
        if (!(state instanceof DrawableContainerState)) {
            return true;
        }
        for (Drawable child : ((DrawableContainerState) state).getChildren()) {
            if (!canSafelyMutateDrawable(child)) {
                return false;
            }
        }
        return true;
    } else if (drawable instanceof DrawableWrapper) {
        return canSafelyMutateDrawable(((DrawableWrapper) drawable).getWrappedDrawable());
    } else {
        if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
            return canSafelyMutateDrawable(((android.support.v7.graphics.drawable.DrawableWrapper) drawable).getWrappedDrawable());
        }
        return true;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:42,代码来源:DrawableUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SqlCountAggFunction类代码示例发布时间:2022-05-23
下一篇:
Java Priv3DES类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap