DrawableUtils.java
5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package android.support.v7.widget;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.graphics.drawable.DrawableContainer.DrawableContainerState;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ScaleDrawable;
import android.os.Build.VERSION;
import android.support.annotation.NonNull;
import android.support.annotation.RestrictTo;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.Log;
import gz;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class DrawableUtils
{
public static final Rect INSETS_NONE = new Rect();
private static Class<?> a;
static
{
if (Build.VERSION.SDK_INT >= 18) {}
try
{
a = Class.forName("android.graphics.Insets");
return;
}
catch (ClassNotFoundException localClassNotFoundException) {}
}
public static PorterDuff.Mode a(int paramInt, PorterDuff.Mode paramMode)
{
switch (paramInt)
{
}
do
{
return paramMode;
return PorterDuff.Mode.SRC_OVER;
return PorterDuff.Mode.SRC_IN;
return PorterDuff.Mode.SRC_ATOP;
return PorterDuff.Mode.MULTIPLY;
return PorterDuff.Mode.SCREEN;
} while (Build.VERSION.SDK_INT < 11);
return PorterDuff.Mode.valueOf("ADD");
}
static void a(@NonNull Drawable paramDrawable)
{
int[] arrayOfInt;
if ((Build.VERSION.SDK_INT == 21) && ("android.graphics.drawable.VectorDrawable".equals(paramDrawable.getClass().getName())))
{
arrayOfInt = paramDrawable.getState();
if ((arrayOfInt != null) && (arrayOfInt.length != 0)) {
break label52;
}
paramDrawable.setState(gz.e);
}
for (;;)
{
paramDrawable.setState(arrayOfInt);
return;
label52:
paramDrawable.setState(gz.h);
}
}
public static boolean canSafelyMutateDrawable(@NonNull Drawable paramDrawable)
{
for (;;)
{
if ((Build.VERSION.SDK_INT < 15) && ((paramDrawable instanceof InsetDrawable))) {
return false;
}
if ((Build.VERSION.SDK_INT < 15) && ((paramDrawable instanceof GradientDrawable))) {
return false;
}
if ((Build.VERSION.SDK_INT < 17) && ((paramDrawable instanceof LayerDrawable))) {
return false;
}
if ((paramDrawable instanceof DrawableContainer))
{
paramDrawable = paramDrawable.getConstantState();
if (!(paramDrawable instanceof DrawableContainer.DrawableContainerState)) {
break;
}
paramDrawable = ((DrawableContainer.DrawableContainerState)paramDrawable).getChildren();
int j = paramDrawable.length;
int i = 0;
while (i < j)
{
if (!canSafelyMutateDrawable(paramDrawable[i])) {
return false;
}
i += 1;
}
}
if ((paramDrawable instanceof android.support.v4.graphics.drawable.DrawableWrapper))
{
paramDrawable = ((android.support.v4.graphics.drawable.DrawableWrapper)paramDrawable).getWrappedDrawable();
}
else if ((paramDrawable instanceof android.support.v7.graphics.drawable.DrawableWrapper))
{
paramDrawable = ((android.support.v7.graphics.drawable.DrawableWrapper)paramDrawable).getWrappedDrawable();
}
else
{
if (!(paramDrawable instanceof ScaleDrawable)) {
break;
}
paramDrawable = ((ScaleDrawable)paramDrawable).getDrawable();
}
}
return true;
}
public static Rect getOpticalBounds(Drawable paramDrawable)
{
if (a != null) {}
for (;;)
{
Object localObject;
Rect localRect;
int j;
int i;
try
{
paramDrawable = DrawableCompat.unwrap(paramDrawable);
localObject = paramDrawable.getClass().getMethod("getOpticalInsets", new Class[0]).invoke(paramDrawable, new Object[0]);
if (localObject == null) {
break label215;
}
localRect = new Rect();
Field[] arrayOfField = a.getFields();
int k = arrayOfField.length;
j = 0;
paramDrawable = localRect;
if (j >= k) {
break label219;
}
paramDrawable = arrayOfField[j];
str = paramDrawable.getName();
i = -1;
switch (str.hashCode())
{
case 3317767:
if (!str.equals("left")) {
break label263;
}
i = 0;
}
}
catch (Exception paramDrawable)
{
String str;
Log.e("DrawableUtils", "Couldn't obtain the optical insets. Ignoring.");
}
if (str.equals("top"))
{
i = 1;
break label263;
if (str.equals("right"))
{
i = 2;
break label263;
if (str.equals("bottom"))
{
i = 3;
break label263;
localRect.left = paramDrawable.getInt(localObject);
break label296;
label215:
paramDrawable = INSETS_NONE;
label219:
return paramDrawable;
localRect.top = paramDrawable.getInt(localObject);
break label296;
localRect.right = paramDrawable.getInt(localObject);
break label296;
localRect.bottom = paramDrawable.getInt(localObject);
break label296;
}
}
}
label263:
switch (i)
{
}
label296:
j += 1;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/DrawableUtils.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/