ScaleImageView.java
6.71 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
package com.instabug.library.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
public class ScaleImageView
extends ImageView
implements View.OnTouchListener
{
String a = "ScaleImageView";
private Context b;
private float c = 5.0F;
private Matrix d;
private final float[] e = new float[9];
private int f;
private int g;
private int h;
private int i;
private float j;
private float k;
private float l;
private boolean m;
private int n;
private int o;
private GestureDetector p;
public ScaleImageView(Context paramContext)
{
super(paramContext);
this.b = paramContext;
b();
}
public ScaleImageView(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, paramAttributeSet);
this.b = paramContext;
b();
}
private static float a(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
{
paramFloat1 -= paramFloat2;
paramFloat2 = paramFloat3 - paramFloat4;
return (float)Math.sqrt(paramFloat1 * paramFloat1 + paramFloat2 * paramFloat2);
}
private void b()
{
setScaleType(ImageView.ScaleType.MATRIX);
this.d = new Matrix();
Drawable localDrawable = getDrawable();
if (localDrawable != null)
{
this.h = localDrawable.getIntrinsicWidth();
this.i = localDrawable.getIntrinsicHeight();
setOnTouchListener(this);
}
this.p = new GestureDetector(this.b, new GestureDetector.SimpleOnGestureListener()
{
public final boolean onDoubleTap(MotionEvent paramAnonymousMotionEvent)
{
ScaleImageView.this.a((int)paramAnonymousMotionEvent.getX(), (int)paramAnonymousMotionEvent.getY());
ScaleImageView.this.a();
return super.onDoubleTap(paramAnonymousMotionEvent);
}
});
}
protected float a(Matrix paramMatrix, int paramInt)
{
paramMatrix.getValues(this.e);
return this.e[paramInt];
}
public void a()
{
int i1 = (int)(this.h * getScale());
int i2 = (int)(this.i * getScale());
if (getTranslateX() < -(i1 - this.f)) {
this.d.postTranslate(-(getTranslateX() + i1 - this.f), 0.0F);
}
if (getTranslateX() > 0.0F) {
this.d.postTranslate(-getTranslateX(), 0.0F);
}
if (getTranslateY() < -(i2 - this.g)) {
this.d.postTranslate(0.0F, -(getTranslateY() + i2 - this.g));
}
if (getTranslateY() > 0.0F) {
this.d.postTranslate(0.0F, -getTranslateY());
}
if (i1 < this.f) {
this.d.postTranslate((this.f - i1) / 2, 0.0F);
}
if (i2 < this.g) {
this.d.postTranslate(0.0F, (this.g - i2) / 2);
}
setImageMatrix(this.d);
}
public void a(float paramFloat, int paramInt1, int paramInt2)
{
if (getScale() * paramFloat < this.k) {}
while ((paramFloat >= 1.0F) && (getScale() * paramFloat > this.c)) {
return;
}
this.d.postScale(paramFloat, paramFloat);
this.d.postTranslate(-(this.f * paramFloat - this.f) / 2.0F, -(this.g * paramFloat - this.g) / 2.0F);
this.d.postTranslate(-(paramInt1 - this.f / 2) * paramFloat, 0.0F);
this.d.postTranslate(0.0F, -(paramInt2 - this.g / 2) * paramFloat);
setImageMatrix(this.d);
}
protected void a(int paramInt1, int paramInt2)
{
if ((this.k != getScale()) && (getScale() - this.k > 0.1F))
{
a(this.k / getScale(), paramInt1, paramInt2);
return;
}
a(this.c / getScale(), paramInt1, paramInt2);
}
protected float getScale()
{
return a(this.d, 0);
}
public float getTranslateX()
{
return a(this.d, 2);
}
protected float getTranslateY()
{
return a(this.d, 5);
}
public boolean onTouch(View paramView, MotionEvent paramMotionEvent)
{
return super.onTouchEvent(paramMotionEvent);
}
public boolean onTouchEvent(MotionEvent paramMotionEvent)
{
if (this.p.onTouchEvent(paramMotionEvent)) {}
do
{
do
{
return true;
i1 = paramMotionEvent.getPointerCount();
switch (paramMotionEvent.getAction())
{
default:
return true;
case 0:
case 5:
case 261:
if (i1 >= 2)
{
this.l = a(paramMotionEvent.getX(0), paramMotionEvent.getX(1), paramMotionEvent.getY(0), paramMotionEvent.getY(1));
this.m = true;
}
case 2:
while ((i1 >= 2) && (this.m))
{
float f1 = a(paramMotionEvent.getX(0), paramMotionEvent.getX(1), paramMotionEvent.getY(0), paramMotionEvent.getY(1));
float f2 = (f1 - this.l) / (float)Math.sqrt(this.f * this.f + this.g * this.g);
this.l = f1;
f1 = 1.0F + f2;
a(f1 * f1, this.f / 2, this.g / 2);
a();
return true;
this.n = ((int)paramMotionEvent.getX());
this.o = ((int)paramMotionEvent.getY());
}
}
} while (this.m);
int i1 = this.n;
int i2 = (int)paramMotionEvent.getX();
int i3 = this.o;
int i4 = (int)paramMotionEvent.getY();
this.n = ((int)paramMotionEvent.getX());
this.o = ((int)paramMotionEvent.getY());
this.d.postTranslate(-(i1 - i2), -(i3 - i4));
a();
return true;
} while (paramMotionEvent.getPointerCount() > 1);
this.m = false;
return true;
}
protected boolean setFrame(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
int i2 = 0;
this.f = (paramInt3 - paramInt1);
this.g = (paramInt4 - paramInt2);
this.d.reset();
this.j = ((paramInt3 - paramInt1) / this.h);
if (this.j * this.i > this.g)
{
this.j = (this.g / this.i);
this.d.postScale(this.j, this.j);
}
for (int i1 = (paramInt3 - this.f) / 2;; i1 = 0)
{
this.d.postTranslate(i1, i2);
setImageMatrix(this.d);
this.k = this.j;
a(this.j, this.f / 2, this.g / 2);
a();
return super.setFrame(paramInt1, paramInt2, paramInt3, paramInt4);
this.d.postScale(this.j, this.j);
i2 = (paramInt4 - this.g) / 2;
}
}
public void setImageBitmap(Bitmap paramBitmap)
{
super.setImageBitmap(paramBitmap);
b();
}
public void setImageResource(int paramInt)
{
super.setImageResource(paramInt);
b();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/instabug/library/view/ScaleImageView.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/