PaintView.java
4.85 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
package net.hockeyapp.android.views;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Join;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.net.Uri;
import android.os.AsyncTask;
import android.view.MotionEvent;
import android.widget.ImageView;
import java.io.IOException;
import java.util.Iterator;
import java.util.Stack;
import net.hockeyapp.android.utils.HockeyLog;
@SuppressLint({"ViewConstructor"})
public class PaintView
extends ImageView
{
private Path a = new Path();
private Stack<Path> b = new Stack();
private Paint c = new Paint();
private float d;
private float e;
public PaintView(Context paramContext, Uri paramUri, int paramInt1, int paramInt2)
{
super(paramContext);
this.c.setAntiAlias(true);
this.c.setDither(true);
this.c.setColor(-65536);
this.c.setStyle(Paint.Style.STROKE);
this.c.setStrokeJoin(Paint.Join.ROUND);
this.c.setStrokeCap(Paint.Cap.ROUND);
this.c.setStrokeWidth(12.0F);
new AsyncTask()
{
private static Bitmap a(Object... paramAnonymousVarArgs)
{
Context localContext = (Context)paramAnonymousVarArgs[0];
Uri localUri = (Uri)paramAnonymousVarArgs[1];
Integer localInteger = (Integer)paramAnonymousVarArgs[2];
paramAnonymousVarArgs = (Integer)paramAnonymousVarArgs[3];
try
{
paramAnonymousVarArgs = PaintView.a(localContext.getContentResolver(), localUri, localInteger.intValue(), paramAnonymousVarArgs.intValue());
return paramAnonymousVarArgs;
}
catch (IOException paramAnonymousVarArgs)
{
HockeyLog.error("Could not load image into ImageView.", paramAnonymousVarArgs);
}
return null;
}
protected final void onPreExecute()
{
PaintView.this.setAdjustViewBounds(true);
}
}.execute(new Object[] { paramContext, paramUri, Integer.valueOf(paramInt1), Integer.valueOf(paramInt2) });
}
private static int a(BitmapFactory.Options paramOptions, int paramInt1, int paramInt2)
{
int k = paramOptions.outHeight;
int m = paramOptions.outWidth;
int j = 1;
int i = 1;
if ((k > paramInt2) || (m > paramInt1))
{
k /= 2;
m /= 2;
for (;;)
{
j = i;
if (k / i <= paramInt2) {
break;
}
j = i;
if (m / i <= paramInt1) {
break;
}
i *= 2;
}
}
return j;
}
public static int determineOrientation(ContentResolver paramContentResolver, Uri paramUri)
{
int i = 1;
BitmapFactory.Options localOptions = new BitmapFactory.Options();
localOptions.inJustDecodeBounds = true;
try
{
BitmapFactory.decodeStream(paramContentResolver.openInputStream(paramUri), null, localOptions);
float f = localOptions.outWidth;
int j = localOptions.outHeight;
if (f / j > 1.0F) {
i = 0;
}
return i;
}
catch (IOException paramContentResolver)
{
HockeyLog.error("Unable to determine necessary screen orientation.", paramContentResolver);
}
return 1;
}
public void clearImage()
{
this.b.clear();
invalidate();
}
public boolean isClear()
{
return this.b.empty();
}
protected void onDraw(Canvas paramCanvas)
{
super.onDraw(paramCanvas);
Iterator localIterator = this.b.iterator();
while (localIterator.hasNext()) {
paramCanvas.drawPath((Path)localIterator.next(), this.c);
}
paramCanvas.drawPath(this.a, this.c);
}
public boolean onTouchEvent(MotionEvent paramMotionEvent)
{
float f1 = paramMotionEvent.getX();
float f2 = paramMotionEvent.getY();
switch (paramMotionEvent.getAction())
{
}
for (;;)
{
return true;
this.a.reset();
this.a.moveTo(f1, f2);
this.d = f1;
this.e = f2;
invalidate();
continue;
float f3 = Math.abs(f1 - this.d);
float f4 = Math.abs(f2 - this.e);
if ((f3 >= 4.0F) || (f4 >= 4.0F))
{
this.a.quadTo(this.d, this.e, (this.d + f1) / 2.0F, (this.e + f2) / 2.0F);
this.d = f1;
this.e = f2;
}
invalidate();
continue;
this.a.lineTo(this.d, this.e);
this.b.push(this.a);
this.a = new Path();
invalidate();
}
}
public void undo()
{
if (!this.b.empty())
{
this.b.pop();
invalidate();
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/net/hockeyapp/android/views/PaintView.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/