276 lines
9.9 KiB
Java
276 lines
9.9 KiB
Java
package com.twitter.sdk.android.tweetui.internal;
|
|
|
|
import android.animation.ValueAnimator;
|
|
import android.content.Context;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.RectF;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.view.GestureDetector;
|
|
import android.view.MotionEvent;
|
|
import android.view.ScaleGestureDetector;
|
|
import android.view.ViewParent;
|
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
|
import android.widget.ImageView;
|
|
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class MultiTouchImageView extends ImageView implements SwipeToDismissTouchListener.SwipeableViewProvider {
|
|
final ScaleGestureDetector a;
|
|
final GestureDetector b;
|
|
final Matrix c;
|
|
final Matrix d;
|
|
final Matrix e;
|
|
final RectF f;
|
|
final RectF g;
|
|
final float[] h;
|
|
boolean i;
|
|
|
|
public MultiTouchImageView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
void a(Drawable drawable) {
|
|
RectF rectF = new RectF(0.0f, 0.0f, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
this.d.reset();
|
|
this.d.setRectToRect(rectF, this.f, Matrix.ScaleToFit.CENTER);
|
|
}
|
|
|
|
void b() {
|
|
this.f.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom());
|
|
}
|
|
|
|
boolean c() {
|
|
Drawable drawable = getDrawable();
|
|
return drawable != null && drawable.getIntrinsicWidth() > 0;
|
|
}
|
|
|
|
void d() {
|
|
this.e.reset();
|
|
}
|
|
|
|
void e() {
|
|
f();
|
|
setScaleType(ImageView.ScaleType.MATRIX);
|
|
setImageMatrix(getDrawMatrix());
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:12:0x0069 */
|
|
/* JADX WARN: Removed duplicated region for block: B:7:0x0056 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
void f() {
|
|
/*
|
|
r7 = this;
|
|
android.graphics.Matrix r0 = r7.getDrawMatrix()
|
|
android.graphics.RectF r0 = r7.a(r0)
|
|
float r1 = r0.height()
|
|
android.graphics.RectF r2 = r7.f
|
|
float r2 = r2.height()
|
|
r3 = 1073741824(0x40000000, float:2.0)
|
|
r4 = 0
|
|
int r1 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1))
|
|
if (r1 > 0) goto L29
|
|
android.graphics.RectF r1 = r7.f
|
|
float r1 = r1.height()
|
|
float r2 = r0.height()
|
|
float r1 = r1 - r2
|
|
float r1 = r1 / r3
|
|
float r2 = r0.top
|
|
L27:
|
|
float r1 = r1 - r2
|
|
goto L47
|
|
L29:
|
|
float r1 = r0.top
|
|
int r2 = (r1 > r4 ? 1 : (r1 == r4 ? 0 : -1))
|
|
if (r2 <= 0) goto L31
|
|
float r1 = -r1
|
|
goto L47
|
|
L31:
|
|
float r1 = r0.bottom
|
|
android.graphics.RectF r2 = r7.f
|
|
float r2 = r2.height()
|
|
int r1 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1))
|
|
if (r1 >= 0) goto L46
|
|
android.graphics.RectF r1 = r7.f
|
|
float r1 = r1.height()
|
|
float r2 = r0.bottom
|
|
goto L27
|
|
L46:
|
|
r1 = 0
|
|
L47:
|
|
float r2 = r0.width()
|
|
android.graphics.RectF r5 = r7.f
|
|
float r5 = r5.width()
|
|
r6 = 1
|
|
int r2 = (r2 > r5 ? 1 : (r2 == r5 ? 0 : -1))
|
|
if (r2 > 0) goto L69
|
|
r7.i = r6
|
|
android.graphics.RectF r2 = r7.f
|
|
float r2 = r2.width()
|
|
float r4 = r0.width()
|
|
float r2 = r2 - r4
|
|
float r2 = r2 / r3
|
|
float r0 = r0.left
|
|
L66:
|
|
float r4 = r2 - r0
|
|
goto L8d
|
|
L69:
|
|
float r2 = r0.left
|
|
int r3 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
|
|
if (r3 <= 0) goto L73
|
|
r7.i = r6
|
|
float r4 = -r2
|
|
goto L8d
|
|
L73:
|
|
float r2 = r0.right
|
|
android.graphics.RectF r3 = r7.f
|
|
float r3 = r3.width()
|
|
int r2 = (r2 > r3 ? 1 : (r2 == r3 ? 0 : -1))
|
|
if (r2 >= 0) goto L8a
|
|
r7.i = r6
|
|
android.graphics.RectF r2 = r7.f
|
|
float r2 = r2.width()
|
|
float r0 = r0.right
|
|
goto L66
|
|
L8a:
|
|
r0 = 0
|
|
r7.i = r0
|
|
L8d:
|
|
r7.a(r4, r1)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.f():void");
|
|
}
|
|
|
|
Matrix getDrawMatrix() {
|
|
this.c.set(this.d);
|
|
this.c.postConcat(this.e);
|
|
return this.c;
|
|
}
|
|
|
|
float getScale() {
|
|
this.e.getValues(this.h);
|
|
return this.h[0];
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
|
super.onLayout(z, i, i2, i3, i4);
|
|
if (c()) {
|
|
b();
|
|
a(getDrawable());
|
|
e();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
if (!c()) {
|
|
return false;
|
|
}
|
|
a(true);
|
|
return (this.b.onTouchEvent(motionEvent) || this.a.onTouchEvent(motionEvent)) || super.onTouchEvent(motionEvent);
|
|
}
|
|
|
|
public MultiTouchImageView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public MultiTouchImageView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.c = new Matrix();
|
|
this.d = new Matrix();
|
|
this.e = new Matrix();
|
|
this.f = new RectF();
|
|
this.g = new RectF();
|
|
this.h = new float[9];
|
|
this.i = false;
|
|
this.a = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.1
|
|
@Override // android.view.ScaleGestureDetector.SimpleOnScaleGestureListener, android.view.ScaleGestureDetector.OnScaleGestureListener
|
|
public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
|
|
MultiTouchImageView.this.a(scaleGestureDetector.getScaleFactor(), scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY());
|
|
MultiTouchImageView.this.e();
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.ScaleGestureDetector.SimpleOnScaleGestureListener, android.view.ScaleGestureDetector.OnScaleGestureListener
|
|
public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) {
|
|
if (MultiTouchImageView.this.getScale() < 1.0f) {
|
|
MultiTouchImageView.this.d();
|
|
MultiTouchImageView.this.e();
|
|
}
|
|
}
|
|
});
|
|
this.b = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.2
|
|
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
|
|
public boolean onDoubleTap(MotionEvent motionEvent) {
|
|
if (MultiTouchImageView.this.getScale() > 1.0f) {
|
|
MultiTouchImageView multiTouchImageView = MultiTouchImageView.this;
|
|
multiTouchImageView.a(multiTouchImageView.getScale(), 1.0f, motionEvent.getX(), motionEvent.getY());
|
|
return true;
|
|
}
|
|
MultiTouchImageView multiTouchImageView2 = MultiTouchImageView.this;
|
|
multiTouchImageView2.a(multiTouchImageView2.getScale(), 2.0f, motionEvent.getX(), motionEvent.getY());
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
|
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
|
|
MultiTouchImageView.this.a(-f, -f2);
|
|
MultiTouchImageView.this.e();
|
|
MultiTouchImageView multiTouchImageView = MultiTouchImageView.this;
|
|
if (!multiTouchImageView.i || multiTouchImageView.a.isInProgress()) {
|
|
return true;
|
|
}
|
|
MultiTouchImageView.this.a(false);
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
|
|
void a(boolean z) {
|
|
ViewParent parent = getParent();
|
|
if (parent != null) {
|
|
parent.requestDisallowInterceptTouchEvent(z);
|
|
}
|
|
}
|
|
|
|
void a(float f, float f2, float f3) {
|
|
this.e.postScale(f, f, f2, f3);
|
|
}
|
|
|
|
void a(float f, float f2) {
|
|
this.e.postTranslate(f, f2);
|
|
}
|
|
|
|
RectF a(Matrix matrix) {
|
|
if (getDrawable() != null) {
|
|
this.g.set(0.0f, 0.0f, r0.getIntrinsicWidth(), r0.getIntrinsicHeight());
|
|
matrix.mapRect(this.g);
|
|
}
|
|
return this.g;
|
|
}
|
|
|
|
void a(float f, float f2, final float f3, final float f4) {
|
|
ValueAnimator ofFloat = ValueAnimator.ofFloat(f, f2);
|
|
ofFloat.setDuration(300L);
|
|
ofFloat.setInterpolator(new AccelerateDecelerateInterpolator());
|
|
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.3
|
|
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
|
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
|
MultiTouchImageView.this.a(((Float) valueAnimator.getAnimatedValue()).floatValue() / MultiTouchImageView.this.getScale(), f3, f4);
|
|
MultiTouchImageView.this.e();
|
|
}
|
|
});
|
|
ofFloat.start();
|
|
}
|
|
|
|
@Override // com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.SwipeableViewProvider
|
|
public boolean a() {
|
|
return getScale() == 1.0f;
|
|
}
|
|
}
|