RoundedBitmapDrawable.java
6.27 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
package android.support.v4.graphics.drawable;
import android.annotation.TargetApi;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import android.support.annotation.RequiresApi;
import android.util.DisplayMetrics;
@TargetApi(9)
@RequiresApi(9)
public abstract class RoundedBitmapDrawable
extends Drawable
{
protected final Bitmap a;
protected final Rect b = new Rect();
private int c = 160;
private int d = 119;
private final Paint e = new Paint(3);
private final BitmapShader f;
private final Matrix g = new Matrix();
private float h;
private final RectF i = new RectF();
private boolean j = true;
private boolean k;
private int l;
private int m;
protected RoundedBitmapDrawable(Resources paramResources, Bitmap paramBitmap)
{
if (paramResources != null) {
this.c = paramResources.getDisplayMetrics().densityDpi;
}
this.a = paramBitmap;
if (this.a != null)
{
b();
this.f = new BitmapShader(this.a, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
return;
}
this.m = -1;
this.l = -1;
this.f = null;
}
private static boolean a(float paramFloat)
{
return paramFloat > 0.05F;
}
private void b()
{
this.l = this.a.getScaledWidth(this.c);
this.m = this.a.getScaledHeight(this.c);
}
private void c()
{
this.h = (Math.min(this.m, this.l) / 2);
}
protected final void a()
{
if (this.j)
{
if (!this.k) {
break label220;
}
int n = Math.min(this.l, this.m);
a(this.d, n, n, getBounds(), this.b);
n = Math.min(this.b.width(), this.b.height());
int i1 = Math.max(0, (this.b.width() - n) / 2);
int i2 = Math.max(0, (this.b.height() - n) / 2);
this.b.inset(i1, i2);
this.h = (n * 0.5F);
}
for (;;)
{
this.i.set(this.b);
if (this.f != null)
{
this.g.setTranslate(this.i.left, this.i.top);
this.g.preScale(this.i.width() / this.a.getWidth(), this.i.height() / this.a.getHeight());
this.f.setLocalMatrix(this.g);
this.e.setShader(this.f);
}
this.j = false;
return;
label220:
a(this.d, this.l, this.m, getBounds(), this.b);
}
}
public void a(int paramInt1, int paramInt2, int paramInt3, Rect paramRect1, Rect paramRect2)
{
throw new UnsupportedOperationException();
}
public void draw(Canvas paramCanvas)
{
Bitmap localBitmap = this.a;
if (localBitmap == null) {
return;
}
a();
if (this.e.getShader() == null)
{
paramCanvas.drawBitmap(localBitmap, null, this.b, this.e);
return;
}
paramCanvas.drawRoundRect(this.i, this.h, this.h, this.e);
}
public int getAlpha()
{
return this.e.getAlpha();
}
public final Bitmap getBitmap()
{
return this.a;
}
public ColorFilter getColorFilter()
{
return this.e.getColorFilter();
}
public float getCornerRadius()
{
return this.h;
}
public int getGravity()
{
return this.d;
}
public int getIntrinsicHeight()
{
return this.m;
}
public int getIntrinsicWidth()
{
return this.l;
}
public int getOpacity()
{
if ((this.d != 119) || (this.k)) {}
Bitmap localBitmap;
do
{
return -3;
localBitmap = this.a;
} while ((localBitmap == null) || (localBitmap.hasAlpha()) || (this.e.getAlpha() < 255) || (a(this.h)));
return -1;
}
public final Paint getPaint()
{
return this.e;
}
public boolean hasAntiAlias()
{
return this.e.isAntiAlias();
}
public boolean hasMipMap()
{
throw new UnsupportedOperationException();
}
public boolean isCircular()
{
return this.k;
}
protected void onBoundsChange(Rect paramRect)
{
super.onBoundsChange(paramRect);
if (this.k) {
c();
}
this.j = true;
}
public void setAlpha(int paramInt)
{
if (paramInt != this.e.getAlpha())
{
this.e.setAlpha(paramInt);
invalidateSelf();
}
}
public void setAntiAlias(boolean paramBoolean)
{
this.e.setAntiAlias(paramBoolean);
invalidateSelf();
}
public void setCircular(boolean paramBoolean)
{
this.k = paramBoolean;
this.j = true;
if (paramBoolean)
{
c();
this.e.setShader(this.f);
invalidateSelf();
return;
}
setCornerRadius(0.0F);
}
public void setColorFilter(ColorFilter paramColorFilter)
{
this.e.setColorFilter(paramColorFilter);
invalidateSelf();
}
public void setCornerRadius(float paramFloat)
{
if (this.h == paramFloat) {
return;
}
this.k = false;
if (a(paramFloat)) {
this.e.setShader(this.f);
}
for (;;)
{
this.h = paramFloat;
invalidateSelf();
return;
this.e.setShader(null);
}
}
public void setDither(boolean paramBoolean)
{
this.e.setDither(paramBoolean);
invalidateSelf();
}
public void setFilterBitmap(boolean paramBoolean)
{
this.e.setFilterBitmap(paramBoolean);
invalidateSelf();
}
public void setGravity(int paramInt)
{
if (this.d != paramInt)
{
this.d = paramInt;
this.j = true;
invalidateSelf();
}
}
public void setMipMap(boolean paramBoolean)
{
throw new UnsupportedOperationException();
}
public void setTargetDensity(int paramInt)
{
if (this.c != paramInt)
{
int n = paramInt;
if (paramInt == 0) {
n = 160;
}
this.c = n;
if (this.a != null) {
b();
}
invalidateSelf();
}
}
public void setTargetDensity(Canvas paramCanvas)
{
setTargetDensity(paramCanvas.getDensity());
}
public void setTargetDensity(DisplayMetrics paramDisplayMetrics)
{
setTargetDensity(paramDisplayMetrics.densityDpi);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/graphics/drawable/RoundedBitmapDrawable.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/