/**
* 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);
}
PXDrawableUtil.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:pixate-freestyle-android
作者:
评论列表
文章目录