Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.view.View;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class AnimationUtils {
|
||||
public static ViewPropertyAnimator a(View view, int i) {
|
||||
if (view.getVisibility() != 0) {
|
||||
view.setAlpha(0.0f);
|
||||
view.setVisibility(0);
|
||||
}
|
||||
view.clearAnimation();
|
||||
ViewPropertyAnimator animate = view.animate();
|
||||
animate.alpha(1.0f).setDuration(i).setListener(null);
|
||||
return animate;
|
||||
}
|
||||
|
||||
public static ViewPropertyAnimator b(final View view, int i) {
|
||||
if (view.getVisibility() != 0) {
|
||||
return null;
|
||||
}
|
||||
view.clearAnimation();
|
||||
ViewPropertyAnimator animate = view.animate();
|
||||
animate.alpha(0.0f).setDuration(i).setListener(new AnimatorListenerAdapter() { // from class: com.twitter.sdk.android.tweetui.internal.AnimationUtils.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
view.setVisibility(4);
|
||||
view.setAlpha(1.0f);
|
||||
}
|
||||
});
|
||||
return animate;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import com.twitter.sdk.android.tweetui.R$styleable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AspectRatioFrameLayout extends FrameLayout {
|
||||
protected double a;
|
||||
private int b;
|
||||
|
||||
public AspectRatioFrameLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void a(int i) {
|
||||
TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(i, R$styleable.AspectRatioFrameLayout);
|
||||
try {
|
||||
this.a = obtainStyledAttributes.getFloat(R$styleable.AspectRatioFrameLayout_tw__frame_layout_aspect_ratio, 1.0f);
|
||||
this.b = obtainStyledAttributes.getInt(R$styleable.AspectRatioFrameLayout_tw__frame_layout_dimension_to_adjust, 0);
|
||||
} finally {
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int measuredHeight;
|
||||
int i3;
|
||||
int i4;
|
||||
int measuredWidth;
|
||||
int paddingLeft = getPaddingLeft() + getPaddingRight();
|
||||
int paddingBottom = getPaddingBottom() + getPaddingTop();
|
||||
if (this.b == 0) {
|
||||
if (View.MeasureSpec.getMode(i) == 1073741824) {
|
||||
measuredWidth = View.MeasureSpec.getSize(i);
|
||||
} else {
|
||||
super.onMeasure(i, i2);
|
||||
measuredWidth = getMeasuredWidth();
|
||||
}
|
||||
i4 = measuredWidth - paddingLeft;
|
||||
i3 = (int) (i4 / this.a);
|
||||
} else {
|
||||
if (View.MeasureSpec.getMode(i2) == 1073741824) {
|
||||
measuredHeight = View.MeasureSpec.getSize(i2);
|
||||
} else {
|
||||
super.onMeasure(i, i2);
|
||||
measuredHeight = getMeasuredHeight();
|
||||
}
|
||||
i3 = measuredHeight - paddingBottom;
|
||||
i4 = (int) (i3 * this.a);
|
||||
}
|
||||
super.onMeasure(View.MeasureSpec.makeMeasureSpec(i4 + paddingLeft, 1073741824), View.MeasureSpec.makeMeasureSpec(i3 + paddingBottom, 1073741824));
|
||||
}
|
||||
|
||||
public void setAspectRatio(double d) {
|
||||
this.a = d;
|
||||
}
|
||||
|
||||
public AspectRatioFrameLayout(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public AspectRatioFrameLayout(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
a(i);
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Target;
|
||||
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class GalleryImageView extends FrameLayout implements Target {
|
||||
final MultiTouchImageView a;
|
||||
final ProgressBar b;
|
||||
|
||||
public GalleryImageView(Context context) {
|
||||
this(context, new MultiTouchImageView(context), new ProgressBar(context));
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Target
|
||||
public void a(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
|
||||
this.a.setImageBitmap(bitmap);
|
||||
this.b.setVisibility(8);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Target
|
||||
public void a(Drawable drawable) {
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Target
|
||||
public void b(Drawable drawable) {
|
||||
this.a.setImageResource(R.color.transparent);
|
||||
this.b.setVisibility(0);
|
||||
}
|
||||
|
||||
public void setSwipeToDismissCallback(SwipeToDismissTouchListener.Callback callback) {
|
||||
this.a.setOnTouchListener(SwipeToDismissTouchListener.a(this.a, callback));
|
||||
}
|
||||
|
||||
GalleryImageView(Context context, MultiTouchImageView multiTouchImageView, ProgressBar progressBar) {
|
||||
super(context);
|
||||
this.a = multiTouchImageView;
|
||||
this.b = progressBar;
|
||||
progressBar.setLayoutParams(new FrameLayout.LayoutParams(-2, -2, 17));
|
||||
addView(progressBar);
|
||||
multiTouchImageView.setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
|
||||
addView(multiTouchImageView);
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.twitter.sdk.android.core.internal.VineCardUtils;
|
||||
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
|
||||
import com.twitter.sdk.android.core.models.Card;
|
||||
import com.twitter.sdk.android.core.models.MediaEntity;
|
||||
import com.twitter.sdk.android.core.models.VideoInfo;
|
||||
import com.twitter.sdk.android.tweetui.R$drawable;
|
||||
import com.twitter.sdk.android.tweetui.R$id;
|
||||
import com.twitter.sdk.android.tweetui.R$layout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MediaBadgeView extends FrameLayout {
|
||||
TextView a;
|
||||
ImageView b;
|
||||
|
||||
public MediaBadgeView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
void a(Context context) {
|
||||
View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R$layout.tw__media_badge, (ViewGroup) this, true);
|
||||
this.a = (TextView) inflate.findViewById(R$id.tw__video_duration);
|
||||
this.b = (ImageView) inflate.findViewById(R$id.tw__gif_badge);
|
||||
}
|
||||
|
||||
void setBadge(Drawable drawable) {
|
||||
this.b.setVisibility(0);
|
||||
this.a.setVisibility(8);
|
||||
this.b.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setCard(Card card) {
|
||||
if (VineCardUtils.d(card)) {
|
||||
setBadge(getResources().getDrawable(R$drawable.tw__vine_badge));
|
||||
} else {
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMediaEntity(MediaEntity mediaEntity) {
|
||||
if (ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type)) {
|
||||
setBadge(getResources().getDrawable(R$drawable.tw__gif_badge));
|
||||
} else if (!"video".equals(mediaEntity.type)) {
|
||||
a();
|
||||
} else {
|
||||
VideoInfo videoInfo = mediaEntity.videoInfo;
|
||||
setText(videoInfo == null ? 0L : videoInfo.durationMillis);
|
||||
}
|
||||
}
|
||||
|
||||
void setText(long j) {
|
||||
this.a.setVisibility(0);
|
||||
this.b.setVisibility(8);
|
||||
this.a.setText(MediaTimeUtils.a(j));
|
||||
}
|
||||
|
||||
public MediaBadgeView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public MediaBadgeView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
a(context);
|
||||
}
|
||||
|
||||
void a() {
|
||||
this.a.setVisibility(8);
|
||||
this.b.setVisibility(8);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class MediaTimeUtils {
|
||||
static String a(long j) {
|
||||
int i = (int) (j / 1000);
|
||||
int i2 = i % 60;
|
||||
int i3 = (i / 60) % 60;
|
||||
int i4 = i / 3600;
|
||||
return i4 > 0 ? String.format(Locale.getDefault(), "%1$d:%2$02d:%3$02d", Integer.valueOf(i4), Integer.valueOf(i3), Integer.valueOf(i2)) : String.format(Locale.getDefault(), "%1$d:%2$02d", Integer.valueOf(i3), Integer.valueOf(i2));
|
||||
}
|
||||
}
|
@@ -0,0 +1,275 @@
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class OverlayImageView extends ImageView {
|
||||
Overlay a;
|
||||
|
||||
public OverlayImageView(Context context) {
|
||||
super(context);
|
||||
this.a = new Overlay(null);
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void drawableStateChanged() {
|
||||
super.drawableStateChanged();
|
||||
this.a.a(getDrawableState());
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View, android.graphics.drawable.Drawable.Callback
|
||||
public void invalidateDrawable(Drawable drawable) {
|
||||
if (drawable == this.a.a) {
|
||||
invalidate();
|
||||
} else {
|
||||
super.invalidateDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
this.a.a(canvas);
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
super.onMeasure(i, i2);
|
||||
this.a.a(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
||||
super.onSizeChanged(i, i2, i3, i4);
|
||||
this.a.a(i, i2);
|
||||
}
|
||||
|
||||
public void setOverlayDrawable(Drawable drawable) {
|
||||
Overlay overlay = this.a;
|
||||
if (drawable != overlay.a) {
|
||||
overlay.a(this);
|
||||
if (drawable != null) {
|
||||
drawable.setCallback(this);
|
||||
}
|
||||
this.a = new Overlay(drawable);
|
||||
this.a.a(getDrawableState());
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected static class Overlay {
|
||||
final Drawable a;
|
||||
|
||||
Overlay(Drawable drawable) {
|
||||
this.a = drawable;
|
||||
}
|
||||
|
||||
protected void a(ImageView imageView) {
|
||||
Drawable drawable = this.a;
|
||||
if (drawable != null) {
|
||||
drawable.setCallback(null);
|
||||
imageView.unscheduleDrawable(this.a);
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(int i, int i2) {
|
||||
Drawable drawable = this.a;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(0, 0, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(int[] iArr) {
|
||||
Drawable drawable = this.a;
|
||||
if (drawable == null || !drawable.isStateful()) {
|
||||
return;
|
||||
}
|
||||
this.a.setState(iArr);
|
||||
}
|
||||
|
||||
protected void a(Canvas canvas) {
|
||||
Drawable drawable = this.a;
|
||||
if (drawable != null) {
|
||||
drawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,161 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.util.Property;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SwipeToDismissTouchListener implements View.OnTouchListener {
|
||||
private int a;
|
||||
private float b;
|
||||
private final float c;
|
||||
private final float d;
|
||||
private Callback e;
|
||||
private float f;
|
||||
private float g;
|
||||
private int h;
|
||||
private boolean i;
|
||||
|
||||
public interface Callback {
|
||||
void a(float f);
|
||||
|
||||
void onDismiss();
|
||||
}
|
||||
|
||||
public interface SwipeableViewProvider {
|
||||
boolean a();
|
||||
}
|
||||
|
||||
SwipeToDismissTouchListener(Callback callback, int i, float f) {
|
||||
this(callback, i, f, 0.2f * f);
|
||||
}
|
||||
|
||||
void b(View view) {
|
||||
if (view.getTranslationY() != 0.0f) {
|
||||
ObjectAnimator duration = ObjectAnimator.ofFloat(view, (Property<View, Float>) View.TRANSLATION_Y, 0.0f).setDuration(100L);
|
||||
duration.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.1
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
|
||||
if (SwipeToDismissTouchListener.this.e != null) {
|
||||
SwipeToDismissTouchListener.this.e.a(floatValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
duration.start();
|
||||
}
|
||||
}
|
||||
|
||||
boolean c(float f) {
|
||||
return Math.abs(f) > ((float) this.a);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // android.view.View.OnTouchListener
|
||||
@SuppressLint({"ClickableViewAccessibility"})
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return ((!(view instanceof SwipeableViewProvider) || ((SwipeableViewProvider) view).a() || a()) ? a(view, motionEvent) : false) || view.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
SwipeToDismissTouchListener(Callback callback, int i, float f, float f2) {
|
||||
a(callback);
|
||||
this.a = i;
|
||||
this.c = f;
|
||||
this.d = f2;
|
||||
}
|
||||
|
||||
public static SwipeToDismissTouchListener a(View view, Callback callback) {
|
||||
return new SwipeToDismissTouchListener(callback, ViewConfiguration.get(view.getContext()).getScaledTouchSlop(), view.getContext().getResources().getDisplayMetrics().heightPixels * 0.5f);
|
||||
}
|
||||
|
||||
boolean a(View view, MotionEvent motionEvent) {
|
||||
int actionMasked = motionEvent.getActionMasked();
|
||||
if (actionMasked != 0) {
|
||||
if (actionMasked != 1) {
|
||||
if (actionMasked == 2) {
|
||||
float rawX = motionEvent.getRawX();
|
||||
float rawY = motionEvent.getRawY();
|
||||
float f = rawY - this.b;
|
||||
float f2 = rawX - this.f;
|
||||
float f3 = rawY - this.g;
|
||||
this.f = rawX;
|
||||
this.g = rawY;
|
||||
if (a(motionEvent) && (this.i || (c(f) && a(f2, f3)))) {
|
||||
this.i = true;
|
||||
a(view, f3);
|
||||
}
|
||||
} else if (actionMasked != 3) {
|
||||
if (actionMasked == 5) {
|
||||
b(view);
|
||||
this.i = false;
|
||||
this.h = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean a = (a(motionEvent) && this.i) ? a(view) : false;
|
||||
this.i = false;
|
||||
return a;
|
||||
}
|
||||
this.f = motionEvent.getRawX();
|
||||
float rawY2 = motionEvent.getRawY();
|
||||
this.g = rawY2;
|
||||
this.b = rawY2;
|
||||
this.i = false;
|
||||
this.h = motionEvent.getPointerId(motionEvent.getPointerCount() - 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
double b(float f) {
|
||||
return 1.0d - (Math.pow(Math.abs(f), 2.0d) / Math.pow(this.d * 2.0f, 2.0d));
|
||||
}
|
||||
|
||||
boolean a(float f, float f2) {
|
||||
return Math.abs(f2) > Math.abs(f);
|
||||
}
|
||||
|
||||
boolean a() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
boolean a(MotionEvent motionEvent) {
|
||||
return this.h >= 0 && motionEvent.getPointerCount() == 1;
|
||||
}
|
||||
|
||||
boolean a(View view) {
|
||||
float translationY = view.getTranslationY();
|
||||
float f = this.d;
|
||||
if (translationY <= f && translationY >= (-f)) {
|
||||
b(view);
|
||||
return false;
|
||||
}
|
||||
Callback callback = this.e;
|
||||
if (callback == null) {
|
||||
return true;
|
||||
}
|
||||
callback.onDismiss();
|
||||
return true;
|
||||
}
|
||||
|
||||
void a(View view, float f) {
|
||||
float translationY = view.getTranslationY();
|
||||
float a = a(translationY + ((float) (f * b(translationY))));
|
||||
view.setTranslationY(a);
|
||||
Callback callback = this.e;
|
||||
if (callback != null) {
|
||||
callback.a(a);
|
||||
}
|
||||
}
|
||||
|
||||
float a(float f) {
|
||||
float f2 = this.c;
|
||||
return f < (-f2) ? -f2 : f > f2 ? f2 : f;
|
||||
}
|
||||
|
||||
public void a(Callback callback) {
|
||||
this.e = callback;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.os.Build;
|
||||
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
|
||||
import com.twitter.sdk.android.core.models.MediaEntity;
|
||||
import com.twitter.sdk.android.core.models.VideoInfo;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TweetMediaUtils {
|
||||
public static VideoInfo.Variant a(MediaEntity mediaEntity) {
|
||||
for (VideoInfo.Variant variant : mediaEntity.videoInfo.variants) {
|
||||
if (a(variant)) {
|
||||
return variant;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean b(MediaEntity mediaEntity) {
|
||||
return ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type) || ("video".endsWith(mediaEntity.type) && mediaEntity.videoInfo.durationMillis < 6500);
|
||||
}
|
||||
|
||||
static boolean c(MediaEntity mediaEntity) {
|
||||
return "photo".equals(mediaEntity.type);
|
||||
}
|
||||
|
||||
static boolean d(MediaEntity mediaEntity) {
|
||||
return "video".equals(mediaEntity.type) || ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type);
|
||||
}
|
||||
|
||||
public static boolean e(MediaEntity mediaEntity) {
|
||||
return !ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type);
|
||||
}
|
||||
|
||||
static boolean a(VideoInfo.Variant variant) {
|
||||
return (Build.VERSION.SDK_INT >= 21 && "application/x-mpegURL".equals(variant.contentType)) || "video/mp4".equals(variant.contentType);
|
||||
}
|
||||
}
|
@@ -0,0 +1,357 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestCreator;
|
||||
import com.twitter.sdk.android.core.IntentUtils;
|
||||
import com.twitter.sdk.android.core.internal.VineCardUtils;
|
||||
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
|
||||
import com.twitter.sdk.android.core.models.Card;
|
||||
import com.twitter.sdk.android.core.models.ImageValue;
|
||||
import com.twitter.sdk.android.core.models.MediaEntity;
|
||||
import com.twitter.sdk.android.core.models.Tweet;
|
||||
import com.twitter.sdk.android.tweetui.GalleryActivity;
|
||||
import com.twitter.sdk.android.tweetui.PlayerActivity;
|
||||
import com.twitter.sdk.android.tweetui.R$dimen;
|
||||
import com.twitter.sdk.android.tweetui.R$drawable;
|
||||
import com.twitter.sdk.android.tweetui.R$id;
|
||||
import com.twitter.sdk.android.tweetui.R$string;
|
||||
import com.twitter.sdk.android.tweetui.TweetMediaClickListener;
|
||||
import com.twitter.sdk.android.tweetui.TweetUi;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TweetMediaView extends ViewGroup implements View.OnClickListener {
|
||||
private final OverlayImageView[] a;
|
||||
private List<MediaEntity> b;
|
||||
private final Path c;
|
||||
private final RectF d;
|
||||
private final int e;
|
||||
private int f;
|
||||
final float[] g;
|
||||
int h;
|
||||
int i;
|
||||
final DependencyProvider j;
|
||||
boolean k;
|
||||
TweetMediaClickListener l;
|
||||
Tweet m;
|
||||
|
||||
static class DependencyProvider {
|
||||
DependencyProvider() {
|
||||
}
|
||||
|
||||
Picasso a() {
|
||||
return TweetUi.s().p();
|
||||
}
|
||||
}
|
||||
|
||||
static class PicassoCallback implements Callback {
|
||||
final WeakReference<ImageView> a;
|
||||
|
||||
PicassoCallback(ImageView imageView) {
|
||||
this.a = new WeakReference<>(imageView);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Callback
|
||||
public void onError() {
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Callback
|
||||
public void onSuccess() {
|
||||
ImageView imageView = this.a.get();
|
||||
if (imageView != null) {
|
||||
imageView.setBackgroundResource(R.color.transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Size {
|
||||
static final Size c = new Size();
|
||||
final int a;
|
||||
final int b;
|
||||
|
||||
private Size() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
static Size a(int i, int i2) {
|
||||
int max = Math.max(i, 0);
|
||||
int max2 = Math.max(i2, 0);
|
||||
return (max == 0 && max2 == 0) ? c : new Size(max, max2);
|
||||
}
|
||||
|
||||
private Size(int i, int i2) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
}
|
||||
}
|
||||
|
||||
public TweetMediaView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public void a(MediaEntity mediaEntity) {
|
||||
if (TweetMediaUtils.a(mediaEntity) != null) {
|
||||
Intent intent = new Intent(getContext(), (Class<?>) PlayerActivity.class);
|
||||
intent.putExtra("PLAYER_ITEM", new PlayerActivity.PlayerItem(TweetMediaUtils.a(mediaEntity).url, TweetMediaUtils.b(mediaEntity), TweetMediaUtils.e(mediaEntity), null, null));
|
||||
IntentUtils.b(getContext(), intent);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
Intent intent = new Intent(getContext(), (Class<?>) GalleryActivity.class);
|
||||
intent.putExtra("GALLERY_ITEM", new GalleryActivity.GalleryItem(this.m.i, i, this.b));
|
||||
IntentUtils.b(getContext(), intent);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (!this.k || Build.VERSION.SDK_INT < 18) {
|
||||
super.dispatchDraw(canvas);
|
||||
return;
|
||||
}
|
||||
int save = canvas.save();
|
||||
canvas.clipPath(this.c);
|
||||
super.dispatchDraw(canvas);
|
||||
canvas.restoreToCount(save);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
Integer num = (Integer) view.getTag(R$id.tw__entity_index);
|
||||
if (this.l != null) {
|
||||
this.l.a(this.m, !this.b.isEmpty() ? this.b.get(num.intValue()) : null);
|
||||
return;
|
||||
}
|
||||
if (this.b.isEmpty()) {
|
||||
a(this.m);
|
||||
return;
|
||||
}
|
||||
MediaEntity mediaEntity = this.b.get(num.intValue());
|
||||
if (TweetMediaUtils.d(mediaEntity)) {
|
||||
a(mediaEntity);
|
||||
} else if (TweetMediaUtils.c(mediaEntity)) {
|
||||
b(num.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||||
if (this.f > 0) {
|
||||
b();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
Size a = this.f > 0 ? a(i, i2) : Size.c;
|
||||
setMeasuredDimension(a.a, a.b);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
||||
super.onSizeChanged(i, i2, i3, i4);
|
||||
this.c.reset();
|
||||
this.d.set(0.0f, 0.0f, i, i2);
|
||||
this.c.addRoundRect(this.d, this.g, Path.Direction.CW);
|
||||
this.c.close();
|
||||
}
|
||||
|
||||
public void setMediaBgColor(int i) {
|
||||
this.h = i;
|
||||
}
|
||||
|
||||
public void setPhotoErrorResId(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public void setTweetMediaClickListener(TweetMediaClickListener tweetMediaClickListener) {
|
||||
this.l = tweetMediaClickListener;
|
||||
}
|
||||
|
||||
public void setVineCard(Tweet tweet) {
|
||||
Card card;
|
||||
if (tweet == null || (card = tweet.H) == null || !VineCardUtils.d(card)) {
|
||||
return;
|
||||
}
|
||||
this.m = tweet;
|
||||
this.b = Collections.emptyList();
|
||||
a();
|
||||
a(tweet.H);
|
||||
this.k = false;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public TweetMediaView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, new DependencyProvider());
|
||||
}
|
||||
|
||||
TweetMediaView(Context context, AttributeSet attributeSet, DependencyProvider dependencyProvider) {
|
||||
super(context, attributeSet);
|
||||
this.a = new OverlayImageView[4];
|
||||
this.b = Collections.emptyList();
|
||||
this.c = new Path();
|
||||
this.d = new RectF();
|
||||
this.g = new float[8];
|
||||
this.h = -16777216;
|
||||
this.j = dependencyProvider;
|
||||
this.e = getResources().getDimensionPixelSize(R$dimen.tw__media_view_divider_size);
|
||||
this.i = R$drawable.tw__ic_tweet_photo_error_dark;
|
||||
}
|
||||
|
||||
void b() {
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int measuredHeight = getMeasuredHeight();
|
||||
int i = this.e;
|
||||
int i2 = (measuredWidth - i) / 2;
|
||||
int i3 = (measuredHeight - i) / 2;
|
||||
int i4 = i2 + i;
|
||||
int i5 = this.f;
|
||||
if (i5 == 1) {
|
||||
a(0, 0, 0, measuredWidth, measuredHeight);
|
||||
return;
|
||||
}
|
||||
if (i5 == 2) {
|
||||
a(0, 0, 0, i2, measuredHeight);
|
||||
a(1, i2 + this.e, 0, measuredWidth, measuredHeight);
|
||||
return;
|
||||
}
|
||||
if (i5 == 3) {
|
||||
a(0, 0, 0, i2, measuredHeight);
|
||||
a(1, i4, 0, measuredWidth, i3);
|
||||
a(2, i4, i3 + this.e, measuredWidth, measuredHeight);
|
||||
} else {
|
||||
if (i5 != 4) {
|
||||
return;
|
||||
}
|
||||
a(0, 0, 0, i2, i3);
|
||||
a(2, 0, i3 + this.e, i2, measuredHeight);
|
||||
a(1, i4, 0, measuredWidth, i3);
|
||||
a(3, i4, i3 + this.e, measuredWidth, measuredHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Tweet tweet) {
|
||||
Card card = tweet.H;
|
||||
Intent intent = new Intent(getContext(), (Class<?>) PlayerActivity.class);
|
||||
intent.putExtra("PLAYER_ITEM", new PlayerActivity.PlayerItem(VineCardUtils.c(card), true, false, null, null));
|
||||
intent.putExtra("SCRIBE_ITEM", ScribeItem.fromTweetCard(tweet.i, card));
|
||||
IntentUtils.b(getContext(), intent);
|
||||
}
|
||||
|
||||
Size a(int i, int i2) {
|
||||
int size = View.MeasureSpec.getSize(i);
|
||||
int size2 = View.MeasureSpec.getSize(i2);
|
||||
int i3 = this.e;
|
||||
int i4 = (size - i3) / 2;
|
||||
int i5 = (size2 - i3) / 2;
|
||||
int i6 = this.f;
|
||||
if (i6 == 1) {
|
||||
a(0, size, size2);
|
||||
} else if (i6 == 2) {
|
||||
a(0, i4, size2);
|
||||
a(1, i4, size2);
|
||||
} else if (i6 == 3) {
|
||||
a(0, i4, size2);
|
||||
a(1, i4, i5);
|
||||
a(2, i4, i5);
|
||||
} else if (i6 == 4) {
|
||||
a(0, i4, i5);
|
||||
a(1, i4, i5);
|
||||
a(2, i4, i5);
|
||||
a(3, i4, i5);
|
||||
}
|
||||
return Size.a(size, size2);
|
||||
}
|
||||
|
||||
void b(ImageView imageView, String str) {
|
||||
Picasso a = this.j.a();
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
RequestCreator a2 = a.a(str);
|
||||
a2.b();
|
||||
a2.a();
|
||||
a2.a(this.i);
|
||||
a2.a(imageView, new PicassoCallback(imageView));
|
||||
}
|
||||
|
||||
void a(int i, int i2, int i3) {
|
||||
this.a[i].measure(View.MeasureSpec.makeMeasureSpec(i2, 1073741824), View.MeasureSpec.makeMeasureSpec(i3, 1073741824));
|
||||
}
|
||||
|
||||
void a(int i, int i2, int i3, int i4, int i5) {
|
||||
OverlayImageView overlayImageView = this.a[i];
|
||||
if (overlayImageView.getLeft() == i2 && overlayImageView.getTop() == i3 && overlayImageView.getRight() == i4 && overlayImageView.getBottom() == i5) {
|
||||
return;
|
||||
}
|
||||
overlayImageView.layout(i2, i3, i4, i5);
|
||||
}
|
||||
|
||||
void a() {
|
||||
for (int i = 0; i < this.f; i++) {
|
||||
OverlayImageView overlayImageView = this.a[i];
|
||||
if (overlayImageView != null) {
|
||||
overlayImageView.setVisibility(8);
|
||||
}
|
||||
}
|
||||
this.f = 0;
|
||||
}
|
||||
|
||||
void a(Card card) {
|
||||
this.f = 1;
|
||||
OverlayImageView a = a(0);
|
||||
ImageValue a2 = VineCardUtils.a(card);
|
||||
a(a, a2.b);
|
||||
b(a, a2.a);
|
||||
a(a, true);
|
||||
}
|
||||
|
||||
OverlayImageView a(int i) {
|
||||
OverlayImageView overlayImageView = this.a[i];
|
||||
if (overlayImageView == null) {
|
||||
overlayImageView = new OverlayImageView(getContext());
|
||||
overlayImageView.setLayoutParams(generateDefaultLayoutParams());
|
||||
overlayImageView.setOnClickListener(this);
|
||||
this.a[i] = overlayImageView;
|
||||
addView(overlayImageView, i);
|
||||
} else {
|
||||
a(i, 0, 0);
|
||||
a(i, 0, 0, 0, 0);
|
||||
}
|
||||
overlayImageView.setVisibility(0);
|
||||
overlayImageView.setBackgroundColor(this.h);
|
||||
overlayImageView.setTag(R$id.tw__entity_index, Integer.valueOf(i));
|
||||
return overlayImageView;
|
||||
}
|
||||
|
||||
void a(ImageView imageView, String str) {
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
imageView.setContentDescription(str);
|
||||
} else {
|
||||
imageView.setContentDescription(getResources().getString(R$string.tw__tweet_media));
|
||||
}
|
||||
}
|
||||
|
||||
void a(OverlayImageView overlayImageView, boolean z) {
|
||||
if (z) {
|
||||
overlayImageView.setOverlayDrawable(getContext().getResources().getDrawable(R$drawable.tw__player_overlay));
|
||||
} else {
|
||||
overlayImageView.setOverlayDrawable(null);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,231 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import com.twitter.sdk.android.tweetui.R$drawable;
|
||||
import com.twitter.sdk.android.tweetui.R$id;
|
||||
import com.twitter.sdk.android.tweetui.R$layout;
|
||||
import com.twitter.sdk.android.tweetui.R$string;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VideoControlView extends FrameLayout {
|
||||
MediaPlayerControl a;
|
||||
ImageButton b;
|
||||
TextView c;
|
||||
TextView d;
|
||||
SeekBar e;
|
||||
|
||||
@SuppressLint({"HandlerLeak"})
|
||||
private final Handler f;
|
||||
|
||||
public interface MediaPlayerControl {
|
||||
int getBufferPercentage();
|
||||
|
||||
int getCurrentPosition();
|
||||
|
||||
int getDuration();
|
||||
|
||||
boolean isPlaying();
|
||||
|
||||
void pause();
|
||||
|
||||
void seekTo(int i);
|
||||
|
||||
void start();
|
||||
}
|
||||
|
||||
public VideoControlView(Context context) {
|
||||
super(context);
|
||||
this.f = new Handler() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
if (message.what == 1001) {
|
||||
VideoControlView videoControlView = VideoControlView.this;
|
||||
if (videoControlView.a == null) {
|
||||
return;
|
||||
}
|
||||
videoControlView.k();
|
||||
VideoControlView.this.l();
|
||||
if (VideoControlView.this.e() && VideoControlView.this.a.isPlaying()) {
|
||||
sendMessageDelayed(obtainMessage(1001), 500L);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
View.OnClickListener b() {
|
||||
return new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (VideoControlView.this.a.isPlaying()) {
|
||||
VideoControlView.this.a.pause();
|
||||
} else {
|
||||
VideoControlView.this.a.start();
|
||||
}
|
||||
VideoControlView.this.i();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void c() {
|
||||
this.f.removeMessages(1001);
|
||||
AnimationUtils.b(this, 150);
|
||||
}
|
||||
|
||||
void d() {
|
||||
((LayoutInflater) getContext().getSystemService("layout_inflater")).inflate(R$layout.tw__video_control, this);
|
||||
this.b = (ImageButton) findViewById(R$id.tw__state_control);
|
||||
this.c = (TextView) findViewById(R$id.tw__current_time);
|
||||
this.d = (TextView) findViewById(R$id.tw__duration);
|
||||
this.e = (SeekBar) findViewById(R$id.tw__progress);
|
||||
this.e.setMax(1000);
|
||||
this.e.setOnSeekBarChangeListener(a());
|
||||
this.b.setOnClickListener(b());
|
||||
setDuration(0);
|
||||
setCurrentTime(0);
|
||||
a(0, 0, 0);
|
||||
}
|
||||
|
||||
public boolean e() {
|
||||
return getVisibility() == 0;
|
||||
}
|
||||
|
||||
void f() {
|
||||
this.b.setImageResource(R$drawable.tw__video_pause_btn);
|
||||
this.b.setContentDescription(getContext().getString(R$string.tw__pause));
|
||||
}
|
||||
|
||||
void g() {
|
||||
this.b.setImageResource(R$drawable.tw__video_play_btn);
|
||||
this.b.setContentDescription(getContext().getString(R$string.tw__play));
|
||||
}
|
||||
|
||||
void h() {
|
||||
this.b.setImageResource(R$drawable.tw__video_replay_btn);
|
||||
this.b.setContentDescription(getContext().getString(R$string.tw__replay));
|
||||
}
|
||||
|
||||
void i() {
|
||||
this.f.sendEmptyMessage(1001);
|
||||
AnimationUtils.a(this, 150);
|
||||
}
|
||||
|
||||
public void j() {
|
||||
this.f.sendEmptyMessage(1001);
|
||||
}
|
||||
|
||||
void k() {
|
||||
int duration = this.a.getDuration();
|
||||
int currentPosition = this.a.getCurrentPosition();
|
||||
int bufferPercentage = this.a.getBufferPercentage();
|
||||
setDuration(duration);
|
||||
setCurrentTime(currentPosition);
|
||||
a(currentPosition, duration, bufferPercentage);
|
||||
}
|
||||
|
||||
void l() {
|
||||
if (this.a.isPlaying()) {
|
||||
f();
|
||||
} else if (this.a.getCurrentPosition() > Math.max(this.a.getDuration() - 500, 0)) {
|
||||
h();
|
||||
} else {
|
||||
g();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
d();
|
||||
}
|
||||
|
||||
void setCurrentTime(int i) {
|
||||
this.c.setText(MediaTimeUtils.a(i));
|
||||
}
|
||||
|
||||
void setDuration(int i) {
|
||||
this.d.setText(MediaTimeUtils.a(i));
|
||||
}
|
||||
|
||||
public void setMediaPlayer(MediaPlayerControl mediaPlayerControl) {
|
||||
this.a = mediaPlayerControl;
|
||||
}
|
||||
|
||||
SeekBar.OnSeekBarChangeListener a() {
|
||||
return new SeekBar.OnSeekBarChangeListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.3
|
||||
@Override // android.widget.SeekBar.OnSeekBarChangeListener
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
|
||||
if (z) {
|
||||
int duration = (int) ((VideoControlView.this.a.getDuration() * i) / 1000);
|
||||
VideoControlView.this.a.seekTo(duration);
|
||||
VideoControlView.this.setCurrentTime(duration);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.SeekBar.OnSeekBarChangeListener
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
VideoControlView.this.f.removeMessages(1001);
|
||||
}
|
||||
|
||||
@Override // android.widget.SeekBar.OnSeekBarChangeListener
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
VideoControlView.this.f.sendEmptyMessage(1001);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public VideoControlView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.f = new Handler() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
if (message.what == 1001) {
|
||||
VideoControlView videoControlView = VideoControlView.this;
|
||||
if (videoControlView.a == null) {
|
||||
return;
|
||||
}
|
||||
videoControlView.k();
|
||||
VideoControlView.this.l();
|
||||
if (VideoControlView.this.e() && VideoControlView.this.a.isPlaying()) {
|
||||
sendMessageDelayed(obtainMessage(1001), 500L);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void a(int i, int i2, int i3) {
|
||||
this.e.setProgress((int) (i2 > 0 ? (i * 1000) / i2 : 0L));
|
||||
this.e.setSecondaryProgress(i3 * 10);
|
||||
}
|
||||
|
||||
public VideoControlView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.f = new Handler() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
if (message.what == 1001) {
|
||||
VideoControlView videoControlView = VideoControlView.this;
|
||||
if (videoControlView.a == null) {
|
||||
return;
|
||||
}
|
||||
videoControlView.k();
|
||||
VideoControlView.this.l();
|
||||
if (VideoControlView.this.e() && VideoControlView.this.a.isPlaying()) {
|
||||
sendMessageDelayed(obtainMessage(1001), 500L);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
628
sources/com/twitter/sdk/android/tweetui/internal/VideoView.java
Normal file
628
sources/com/twitter/sdk/android/tweetui/internal/VideoView.java
Normal file
@@ -0,0 +1,628 @@
|
||||
package com.twitter.sdk.android.tweetui.internal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import com.twitter.sdk.android.tweetui.internal.VideoControlView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VideoView extends SurfaceView implements VideoControlView.MediaPlayerControl {
|
||||
private GestureDetector A;
|
||||
SurfaceHolder.Callback B;
|
||||
private String a;
|
||||
private Uri b;
|
||||
private int c;
|
||||
private int d;
|
||||
private SurfaceHolder e;
|
||||
private MediaPlayer f;
|
||||
private int g;
|
||||
private int h;
|
||||
private int i;
|
||||
private int j;
|
||||
private int k;
|
||||
private VideoControlView l;
|
||||
private MediaPlayer.OnCompletionListener m;
|
||||
private MediaPlayer.OnPreparedListener n;
|
||||
private int o;
|
||||
private MediaPlayer.OnErrorListener p;
|
||||
private MediaPlayer.OnInfoListener q;
|
||||
private int r;
|
||||
private boolean s;
|
||||
MediaPlayer.OnVideoSizeChangedListener t;
|
||||
MediaPlayer.OnPreparedListener u;
|
||||
private MediaPlayer.OnCompletionListener v;
|
||||
private MediaPlayer.OnInfoListener x;
|
||||
private MediaPlayer.OnErrorListener y;
|
||||
private MediaPlayer.OnBufferingUpdateListener z;
|
||||
|
||||
public VideoView(Context context) {
|
||||
super(context);
|
||||
this.a = "VideoView";
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
this.e = null;
|
||||
this.f = null;
|
||||
this.t = new MediaPlayer.OnVideoSizeChangedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.1
|
||||
@Override // android.media.MediaPlayer.OnVideoSizeChangedListener
|
||||
public void onVideoSizeChanged(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
VideoView.this.h = mediaPlayer.getVideoWidth();
|
||||
VideoView.this.i = mediaPlayer.getVideoHeight();
|
||||
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
|
||||
return;
|
||||
}
|
||||
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
|
||||
VideoView.this.requestLayout();
|
||||
}
|
||||
};
|
||||
this.u = new MediaPlayer.OnPreparedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.2
|
||||
@Override // android.media.MediaPlayer.OnPreparedListener
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
VideoView.this.c = 2;
|
||||
if (VideoView.this.n != null) {
|
||||
VideoView.this.n.onPrepared(VideoView.this.f);
|
||||
}
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.setEnabled(true);
|
||||
}
|
||||
VideoView.this.h = mediaPlayer.getVideoWidth();
|
||||
VideoView.this.i = mediaPlayer.getVideoHeight();
|
||||
int i = VideoView.this.r;
|
||||
if (i != 0) {
|
||||
VideoView.this.seekTo(i);
|
||||
}
|
||||
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
|
||||
if (VideoView.this.d == 3) {
|
||||
VideoView.this.start();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
|
||||
if (VideoView.this.j == VideoView.this.h && VideoView.this.k == VideoView.this.i) {
|
||||
if (VideoView.this.d == 3) {
|
||||
VideoView.this.start();
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.i();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (VideoView.this.isPlaying()) {
|
||||
return;
|
||||
}
|
||||
if ((i != 0 || VideoView.this.getCurrentPosition() > 0) && VideoView.this.l != null) {
|
||||
VideoView.this.l.i();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.v = new MediaPlayer.OnCompletionListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.3
|
||||
@Override // android.media.MediaPlayer.OnCompletionListener
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
VideoView.this.c = 5;
|
||||
VideoView.this.d = 5;
|
||||
if (VideoView.this.m != null) {
|
||||
VideoView.this.m.onCompletion(VideoView.this.f);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.x = new MediaPlayer.OnInfoListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.4
|
||||
@Override // android.media.MediaPlayer.OnInfoListener
|
||||
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
if (VideoView.this.q == null) {
|
||||
return true;
|
||||
}
|
||||
VideoView.this.q.onInfo(mediaPlayer, i, i2);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
this.y = new MediaPlayer.OnErrorListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.5
|
||||
@Override // android.media.MediaPlayer.OnErrorListener
|
||||
public boolean onError(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
Log.d(VideoView.this.a, "Error: " + i + "," + i2);
|
||||
VideoView.this.c = -1;
|
||||
VideoView.this.d = -1;
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.c();
|
||||
}
|
||||
if (VideoView.this.p == null || VideoView.this.p.onError(VideoView.this.f, i, i2)) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
this.z = new MediaPlayer.OnBufferingUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.6
|
||||
@Override // android.media.MediaPlayer.OnBufferingUpdateListener
|
||||
public void onBufferingUpdate(MediaPlayer mediaPlayer, int i) {
|
||||
VideoView.this.o = i;
|
||||
}
|
||||
};
|
||||
this.A = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.7
|
||||
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
||||
public boolean onSingleTapUp(MotionEvent motionEvent) {
|
||||
if (!VideoView.this.d() || VideoView.this.l == null) {
|
||||
return false;
|
||||
}
|
||||
VideoView.this.f();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.B = new SurfaceHolder.Callback() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.8
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
|
||||
VideoView.this.j = i2;
|
||||
VideoView.this.k = i3;
|
||||
boolean z = VideoView.this.d == 3;
|
||||
boolean z2 = VideoView.this.h == i2 && VideoView.this.i == i3;
|
||||
if (VideoView.this.f != null && z && z2) {
|
||||
if (VideoView.this.r != 0) {
|
||||
VideoView videoView = VideoView.this;
|
||||
videoView.seekTo(videoView.r);
|
||||
}
|
||||
VideoView.this.start();
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.i();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
||||
VideoView.this.e = surfaceHolder;
|
||||
VideoView.this.e();
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
||||
VideoView.this.e = null;
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.c();
|
||||
}
|
||||
VideoView.this.a(true);
|
||||
}
|
||||
};
|
||||
c();
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public int getBufferPercentage() {
|
||||
if (this.f != null) {
|
||||
return this.o;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public int getCurrentPosition() {
|
||||
if (d()) {
|
||||
return this.f.getCurrentPosition();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public int getDuration() {
|
||||
if (d()) {
|
||||
return this.f.getDuration();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public boolean isPlaying() {
|
||||
return d() && this.f.isPlaying();
|
||||
}
|
||||
|
||||
@Override // android.view.View, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
boolean z = (i == 4 || i == 24 || i == 25 || i == 82 || i == 5 || i == 6) ? false : true;
|
||||
if (d() && z && this.l != null) {
|
||||
if (i == 79 || i == 85) {
|
||||
if (this.f.isPlaying()) {
|
||||
pause();
|
||||
this.l.i();
|
||||
} else {
|
||||
start();
|
||||
this.l.c();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (i == 126) {
|
||||
if (!this.f.isPlaying()) {
|
||||
start();
|
||||
this.l.c();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (i == 86 || i == 127) {
|
||||
if (this.f.isPlaying()) {
|
||||
pause();
|
||||
this.l.i();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
f();
|
||||
}
|
||||
return super.onKeyDown(i, keyEvent);
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int i3;
|
||||
int defaultSize = SurfaceView.getDefaultSize(this.h, i);
|
||||
int defaultSize2 = SurfaceView.getDefaultSize(this.i, i2);
|
||||
if (this.h > 0 && this.i > 0) {
|
||||
int mode = View.MeasureSpec.getMode(i);
|
||||
i3 = View.MeasureSpec.getSize(i);
|
||||
int mode2 = View.MeasureSpec.getMode(i2);
|
||||
int size = View.MeasureSpec.getSize(i2);
|
||||
if (mode == 1073741824 && mode2 == 1073741824) {
|
||||
int i4 = this.h;
|
||||
int i5 = i4 * size;
|
||||
int i6 = this.i;
|
||||
if (i5 < i3 * i6) {
|
||||
defaultSize = (i4 * size) / i6;
|
||||
defaultSize2 = size;
|
||||
} else {
|
||||
if (i4 * size > i3 * i6) {
|
||||
defaultSize2 = (i6 * i3) / i4;
|
||||
}
|
||||
defaultSize2 = size;
|
||||
}
|
||||
} else if (mode == 1073741824) {
|
||||
int i7 = (this.i * i3) / this.h;
|
||||
if (mode2 != Integer.MIN_VALUE || i7 <= size) {
|
||||
defaultSize2 = i7;
|
||||
}
|
||||
defaultSize2 = size;
|
||||
} else if (mode2 == 1073741824) {
|
||||
int i8 = (this.h * size) / this.i;
|
||||
if (mode != Integer.MIN_VALUE || i8 <= i3) {
|
||||
i3 = i8;
|
||||
}
|
||||
defaultSize2 = size;
|
||||
} else {
|
||||
int i9 = this.h;
|
||||
int i10 = this.i;
|
||||
if (mode2 != Integer.MIN_VALUE || i10 <= size) {
|
||||
defaultSize2 = i10;
|
||||
} else {
|
||||
i9 = (i9 * size) / i10;
|
||||
defaultSize2 = size;
|
||||
}
|
||||
if (mode != Integer.MIN_VALUE || i9 <= i3) {
|
||||
i3 = i9;
|
||||
} else {
|
||||
defaultSize2 = (this.i * i3) / this.h;
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(i3, defaultSize2);
|
||||
}
|
||||
i3 = defaultSize;
|
||||
setMeasuredDimension(i3, defaultSize2);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
return this.A.onTouchEvent(motionEvent) || super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public void pause() {
|
||||
if (d() && this.f.isPlaying()) {
|
||||
this.f.pause();
|
||||
this.c = 4;
|
||||
}
|
||||
this.d = 4;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public void seekTo(int i) {
|
||||
if (!d()) {
|
||||
this.r = i;
|
||||
} else {
|
||||
this.f.seekTo(i);
|
||||
this.r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMediaController(VideoControlView videoControlView) {
|
||||
VideoControlView videoControlView2 = this.l;
|
||||
if (videoControlView2 != null) {
|
||||
videoControlView2.c();
|
||||
}
|
||||
this.l = videoControlView;
|
||||
b();
|
||||
}
|
||||
|
||||
public void setOnCompletionListener(MediaPlayer.OnCompletionListener onCompletionListener) {
|
||||
this.m = onCompletionListener;
|
||||
}
|
||||
|
||||
public void setOnErrorListener(MediaPlayer.OnErrorListener onErrorListener) {
|
||||
this.p = onErrorListener;
|
||||
}
|
||||
|
||||
public void setOnInfoListener(MediaPlayer.OnInfoListener onInfoListener) {
|
||||
this.q = onInfoListener;
|
||||
}
|
||||
|
||||
public void setOnPreparedListener(MediaPlayer.OnPreparedListener onPreparedListener) {
|
||||
this.n = onPreparedListener;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
|
||||
public void start() {
|
||||
if (d()) {
|
||||
this.f.start();
|
||||
this.c = 3;
|
||||
}
|
||||
this.d = 3;
|
||||
}
|
||||
|
||||
private void b() {
|
||||
VideoControlView videoControlView;
|
||||
if (this.f == null || (videoControlView = this.l) == null) {
|
||||
return;
|
||||
}
|
||||
videoControlView.setMediaPlayer(this);
|
||||
this.l.setEnabled(d());
|
||||
}
|
||||
|
||||
private void c() {
|
||||
this.h = 0;
|
||||
this.i = 0;
|
||||
getHolder().addCallback(this.B);
|
||||
getHolder().setType(3);
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
setClickable(true);
|
||||
requestFocus();
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean d() {
|
||||
int i;
|
||||
return (this.f == null || (i = this.c) == -1 || i == 0 || i == 1) ? false : true;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void e() {
|
||||
if (this.b == null || this.e == null) {
|
||||
return;
|
||||
}
|
||||
a(false);
|
||||
try {
|
||||
this.f = new MediaPlayer();
|
||||
if (this.g != 0) {
|
||||
this.f.setAudioSessionId(this.g);
|
||||
} else {
|
||||
this.g = this.f.getAudioSessionId();
|
||||
}
|
||||
this.f.setOnPreparedListener(this.u);
|
||||
this.f.setOnVideoSizeChangedListener(this.t);
|
||||
this.f.setOnCompletionListener(this.v);
|
||||
this.f.setOnErrorListener(this.y);
|
||||
this.f.setOnInfoListener(this.x);
|
||||
this.f.setOnBufferingUpdateListener(this.z);
|
||||
this.o = 0;
|
||||
this.f.setLooping(this.s);
|
||||
this.f.setDataSource(getContext(), this.b);
|
||||
this.f.setDisplay(this.e);
|
||||
this.f.setAudioStreamType(3);
|
||||
this.f.setScreenOnWhilePlaying(true);
|
||||
this.f.prepareAsync();
|
||||
this.c = 1;
|
||||
b();
|
||||
} catch (Exception e) {
|
||||
Log.w(this.a, "Unable to open content: " + this.b, e);
|
||||
this.c = -1;
|
||||
this.d = -1;
|
||||
this.y.onError(this.f, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void f() {
|
||||
if (this.l.e()) {
|
||||
this.l.c();
|
||||
} else {
|
||||
this.l.i();
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Uri uri, boolean z) {
|
||||
this.b = uri;
|
||||
this.s = z;
|
||||
this.r = 0;
|
||||
e();
|
||||
requestLayout();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
MediaPlayer mediaPlayer = this.f;
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.stop();
|
||||
this.f.release();
|
||||
this.f = null;
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public VideoView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public VideoView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.a = "VideoView";
|
||||
this.c = 0;
|
||||
this.d = 0;
|
||||
this.e = null;
|
||||
this.f = null;
|
||||
this.t = new MediaPlayer.OnVideoSizeChangedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.1
|
||||
@Override // android.media.MediaPlayer.OnVideoSizeChangedListener
|
||||
public void onVideoSizeChanged(MediaPlayer mediaPlayer, int i2, int i22) {
|
||||
VideoView.this.h = mediaPlayer.getVideoWidth();
|
||||
VideoView.this.i = mediaPlayer.getVideoHeight();
|
||||
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
|
||||
return;
|
||||
}
|
||||
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
|
||||
VideoView.this.requestLayout();
|
||||
}
|
||||
};
|
||||
this.u = new MediaPlayer.OnPreparedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.2
|
||||
@Override // android.media.MediaPlayer.OnPreparedListener
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
VideoView.this.c = 2;
|
||||
if (VideoView.this.n != null) {
|
||||
VideoView.this.n.onPrepared(VideoView.this.f);
|
||||
}
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.setEnabled(true);
|
||||
}
|
||||
VideoView.this.h = mediaPlayer.getVideoWidth();
|
||||
VideoView.this.i = mediaPlayer.getVideoHeight();
|
||||
int i2 = VideoView.this.r;
|
||||
if (i2 != 0) {
|
||||
VideoView.this.seekTo(i2);
|
||||
}
|
||||
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
|
||||
if (VideoView.this.d == 3) {
|
||||
VideoView.this.start();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
|
||||
if (VideoView.this.j == VideoView.this.h && VideoView.this.k == VideoView.this.i) {
|
||||
if (VideoView.this.d == 3) {
|
||||
VideoView.this.start();
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.i();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (VideoView.this.isPlaying()) {
|
||||
return;
|
||||
}
|
||||
if ((i2 != 0 || VideoView.this.getCurrentPosition() > 0) && VideoView.this.l != null) {
|
||||
VideoView.this.l.i();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.v = new MediaPlayer.OnCompletionListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.3
|
||||
@Override // android.media.MediaPlayer.OnCompletionListener
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
VideoView.this.c = 5;
|
||||
VideoView.this.d = 5;
|
||||
if (VideoView.this.m != null) {
|
||||
VideoView.this.m.onCompletion(VideoView.this.f);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.x = new MediaPlayer.OnInfoListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.4
|
||||
@Override // android.media.MediaPlayer.OnInfoListener
|
||||
public boolean onInfo(MediaPlayer mediaPlayer, int i2, int i22) {
|
||||
if (VideoView.this.q == null) {
|
||||
return true;
|
||||
}
|
||||
VideoView.this.q.onInfo(mediaPlayer, i2, i22);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
this.y = new MediaPlayer.OnErrorListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.5
|
||||
@Override // android.media.MediaPlayer.OnErrorListener
|
||||
public boolean onError(MediaPlayer mediaPlayer, int i2, int i22) {
|
||||
Log.d(VideoView.this.a, "Error: " + i2 + "," + i22);
|
||||
VideoView.this.c = -1;
|
||||
VideoView.this.d = -1;
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.c();
|
||||
}
|
||||
if (VideoView.this.p == null || VideoView.this.p.onError(VideoView.this.f, i2, i22)) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
this.z = new MediaPlayer.OnBufferingUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.6
|
||||
@Override // android.media.MediaPlayer.OnBufferingUpdateListener
|
||||
public void onBufferingUpdate(MediaPlayer mediaPlayer, int i2) {
|
||||
VideoView.this.o = i2;
|
||||
}
|
||||
};
|
||||
this.A = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.7
|
||||
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
||||
public boolean onSingleTapUp(MotionEvent motionEvent) {
|
||||
if (!VideoView.this.d() || VideoView.this.l == null) {
|
||||
return false;
|
||||
}
|
||||
VideoView.this.f();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.B = new SurfaceHolder.Callback() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.8
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceChanged(SurfaceHolder surfaceHolder, int i2, int i22, int i3) {
|
||||
VideoView.this.j = i22;
|
||||
VideoView.this.k = i3;
|
||||
boolean z = VideoView.this.d == 3;
|
||||
boolean z2 = VideoView.this.h == i22 && VideoView.this.i == i3;
|
||||
if (VideoView.this.f != null && z && z2) {
|
||||
if (VideoView.this.r != 0) {
|
||||
VideoView videoView = VideoView.this;
|
||||
videoView.seekTo(videoView.r);
|
||||
}
|
||||
VideoView.this.start();
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.i();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
||||
VideoView.this.e = surfaceHolder;
|
||||
VideoView.this.e();
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
||||
VideoView.this.e = null;
|
||||
if (VideoView.this.l != null) {
|
||||
VideoView.this.l.c();
|
||||
}
|
||||
VideoView.this.a(true);
|
||||
}
|
||||
};
|
||||
c();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(boolean z) {
|
||||
MediaPlayer mediaPlayer = this.f;
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.reset();
|
||||
this.f.release();
|
||||
this.f = null;
|
||||
this.c = 0;
|
||||
if (z) {
|
||||
this.d = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user