CrackMe.apk
Download file
package androidx.swiperefreshlayout.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Transformation;
import android.widget.AbsListView;
import android.widget.ListView;
import androidx.core.content.ContextCompat;
import androidx.core.view.NestedScrollingChild;
import androidx.core.view.NestedScrollingChildHelper;
import androidx.core.view.NestedScrollingParent;
import androidx.core.view.NestedScrollingParentHelper;
import androidx.core.view.ViewCompat;
import androidx.core.widget.ListViewCompat;
public class SwipeRefreshLayout extends ViewGroup implements NestedScrollingParent, NestedScrollingChild {
private static final int ALPHA_ANIMATION_DURATION = 300;
private static final int ANIMATE_TO_START_DURATION = 200;
private static final int ANIMATE_TO_TRIGGER_DURATION = 200;
private static final int CIRCLE_BG_LIGHT = -328966;
static final int CIRCLE_DIAMETER = 40;
static final int CIRCLE_DIAMETER_LARGE = 56;
private static final float DECELERATE_INTERPOLATION_FACTOR = 2.0f;
public static final int DEFAULT = 1;
private static final int DEFAULT_CIRCLE_TARGET = 64;
public static final int DEFAULT_SLINGSHOT_DISTANCE = -1;
private static final float DRAG_RATE = 0.5f;
private static final int INVALID_POINTER = -1;
public static final int LARGE = 0;
private static final int[] LAYOUT_ATTRS = {16842766};
private static final String LOG_TAG = "SwipeRefreshLayout";
private static final int MAX_ALPHA = 255;
private static final float MAX_PROGRESS_ANGLE = 0.8f;
private static final int SCALE_DOWN_DURATION = 150;
private static final int STARTING_PROGRESS_ALPHA = 76;
private int mActivePointerId;
private Animation mAlphaMaxAnimation;
private Animation mAlphaStartAnimation;
private final Animation mAnimateToCorrectPosition;
private final Animation mAnimateToStartPosition;
private OnChildScrollUpCallback mChildScrollUpCallback;
private int mCircleDiameter;
CircleImageView mCircleView;
private int mCircleViewIndex;
int mCurrentTargetOffsetTop;
int mCustomSlingshotDistance;
private final DecelerateInterpolator mDecelerateInterpolator;
protected int mFrom;
private float mInitialDownY;
private float mInitialMotionY;
private boolean mIsBeingDragged;
OnRefreshListener mListener;
private int mMediumAnimationDuration;
private boolean mNestedScrollInProgress;
private final NestedScrollingChildHelper mNestedScrollingChildHelper;
private final NestedScrollingParentHelper mNestedScrollingParentHelper;
boolean mNotify;
protected int mOriginalOffsetTop;
private final int[] mParentOffsetInWindow;
private final int[] mParentScrollConsumed;
CircularProgressDrawable mProgress;
private Animation.AnimationListener mRefreshListener;
boolean mRefreshing;
private boolean mReturningToStart;
boolean mScale;
private Animation mScaleAnimation;
private Animation mScaleDownAnimation;
private Animation mScaleDownToStartAnimation;
int mSpinnerOffsetEnd;
float mStartingScale;
private View mTarget;
private float mTotalDragDistance;
private float mTotalUnconsumed;
private int mTouchSlop;
boolean mUsingCustomStart;
public interface OnChildScrollUpCallback {
boolean canChildScrollUp(SwipeRefreshLayout swipeRefreshLayout, View view);
}
public interface OnRefreshListener {
void onRefresh();
}
/* access modifiers changed from: package-private */
public void reset() {
this.mCircleView.clearAnimation();
this.mProgress.stop();
this.mCircleView.setVisibility(8);
setColorViewAlpha(255);
if (this.mScale) {
setAnimationProgress(0.0f);
} else {
setTargetOffsetTopAndBottom(this.mOriginalOffsetTop - this.mCurrentTargetOffsetTop);
}
this.mCurrentTargetOffsetTop = this.mCircleView.getTop();
}
public void setEnabled(boolean z) {
super.setEnabled(z);
if (!z) {
reset();
}
}
/* access modifiers changed from: protected */
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
reset();
}
private void setColorViewAlpha(int i) {
this.mCircleView.getBackground().setAlpha(i);
this.mProgress.setAlpha(i);
}
public void setProgressViewOffset(boolean z, int i, int i2) {
this.mScale = z;
this.mOriginalOffsetTop = i;
this.mSpinnerOffsetEnd = i2;
this.mUsingCustomStart = true;
reset();
this.mRefreshing = false;
}
public int getProgressViewStartOffset() {
return this.mOriginalOffsetTop;
}
public int getProgressViewEndOffset() {
return this.mSpinnerOffsetEnd;
}
public void setProgressViewEndTarget(boolean z, int i) {
this.mSpinnerOffsetEnd = i;
this.mScale = z;
this.mCircleView.invalidate();
}
public void setSlingshotDistance(int i) {
this.mCustomSlingshotDistance = i;
}
public void setSize(int i) {
if (i == 0 || i == 1) {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
if (i == 0) {
this.mCircleDiameter = (int) (displayMetrics.density * 56.0f);
} else {
this.mCircleDiameter = (int) (displayMetrics.density * 40.0f);
}
this.mCircleView.setImageDrawable((Drawable) null);
this.mProgress.setStyle(i);
this.mCircleView.setImageDrawable(this.mProgress);
}
}
public SwipeRefreshLayout(Context context) {
this(context, (AttributeSet) null);
}
public SwipeRefreshLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mRefreshing = false;
this.mTotalDragDistance = -1.0f;
this.mParentScrollConsumed = new int[2];
this.mParentOffsetInWindow = new int[2];
this.mActivePointerId = -1;
this.mCircleViewIndex = -1;
this.mRefreshListener = new Animation.AnimationListener() {
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
if (SwipeRefreshLayout.this.mRefreshing) {
SwipeRefreshLayout.this.mProgress.setAlpha(255);
SwipeRefreshLayout.this.mProgress.start();
if (SwipeRefreshLayout.this.mNotify && SwipeRefreshLayout.this.mListener != null) {
SwipeRefreshLayout.this.mListener.onRefresh();
}
SwipeRefreshLayout swipeRefreshLayout = SwipeRefreshLayout.this;
swipeRefreshLayout.mCurrentTargetOffsetTop = swipeRefreshLayout.mCircleView.getTop();
return;
}
SwipeRefreshLayout.this.reset();
}
};
this.mAnimateToCorrectPosition = new Animation() {
public void applyTransformation(float f, Transformation transformation) {
int i;
if (!SwipeRefreshLayout.this.mUsingCustomStart) {
i = SwipeRefreshLayout.this.mSpinnerOffsetEnd - Math.abs(SwipeRefreshLayout.this.mOriginalOffsetTop);
} else {
i = SwipeRefreshLayout.this.mSpinnerOffsetEnd;
}
SwipeRefreshLayout.this.setTargetOffsetTopAndBottom((SwipeRefreshLayout.this.mFrom + ((int) (((float) (i - SwipeRefreshLayout.this.mFrom)) * f))) - SwipeRefreshLayout.this.mCircleView.getTop());
SwipeRefreshLayout.this.mProgress.setArrowScale(1.0f - f);
}
};
this.mAnimateToStartPosition = new Animation() {
public void applyTransformation(float f, Transformation transformation) {
SwipeRefreshLayout.this.moveToStart(f);
}
};
this.mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
this.mMediumAnimationDuration = getResources().getInteger(17694721);
setWillNotDraw(false);
this.mDecelerateInterpolator = new DecelerateInterpolator(2.0f);
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
this.mCircleDiameter = (int) (displayMetrics.density * 40.0f);
createProgressView();
setChildrenDrawingOrderEnabled(true);
int i = (int) (displayMetrics.density * 64.0f);
this.mSpinnerOffsetEnd = i;
this.mTotalDragDistance = (float) i;
this.mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
this.mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
setNestedScrollingEnabled(true);
int i2 = -this.mCircleDiameter;
this.mCurrentTargetOffsetTop = i2;
this.mOriginalOffsetTop = i2;
moveToStart(1.0f);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, LAYOUT_ATTRS);
setEnabled(obtainStyledAttributes.getBoolean(0, true));
obtainStyledAttributes.recycle();
}
/* access modifiers changed from: protected */
public int getChildDrawingOrder(int i, int i2) {
int i3 = this.mCircleViewIndex;
if (i3 < 0) {
return i2;
}
if (i2 == i - 1) {
return i3;
}
return i2 >= i3 ? i2 + 1 : i2;
}
private void createProgressView() {
this.mCircleView = new CircleImageView(getContext(), CIRCLE_BG_LIGHT);
CircularProgressDrawable circularProgressDrawable = new CircularProgressDrawable(getContext());
this.mProgress = circularProgressDrawable;
circularProgressDrawable.setStyle(1);
this.mCircleView.setImageDrawable(this.mProgress);
this.mCircleView.setVisibility(8);
addView(this.mCircleView);
}
public void setOnRefreshListener(OnRefreshListener onRefreshListener) {
this.mListener = onRefreshListener;
}
public void setRefreshing(boolean z) {
int i;
if (!z || this.mRefreshing == z) {
setRefreshing(z, false);
return;
}
this.mRefreshing = z;
if (!this.mUsingCustomStart) {
i = this.mSpinnerOffsetEnd + this.mOriginalOffsetTop;
} else {
i = this.mSpinnerOffsetEnd;
}
setTargetOffsetTopAndBottom(i - this.mCurrentTargetOffsetTop);
this.mNotify = false;
startScaleUpAnimation(this.mRefreshListener);
}
private void startScaleUpAnimation(Animation.AnimationListener animationListener) {
this.mCircleView.setVisibility(0);
this.mProgress.setAlpha(255);
AnonymousClass2 r0 = new Animation() {
public void applyTransformation(float f, Transformation transformation) {
SwipeRefreshLayout.this.setAnimationProgress(f);
}
};
this.mScaleAnimation = r0;
r0.setDuration((long) this.mMediumAnimationDuration);
if (animationListener != null) {
this.mCircleView.setAnimationListener(animationListener);
}
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(this.mScaleAnimation);
}
/* access modifiers changed from: package-private */
public void setAnimationProgress(float f) {
this.mCircleView.setScaleX(f);
this.mCircleView.setScaleY(f);
}
private void setRefreshing(boolean z, boolean z2) {
if (this.mRefreshing != z) {
this.mNotify = z2;
ensureTarget();
this.mRefreshing = z;
if (z) {
animateOffsetToCorrectPosition(this.mCurrentTargetOffsetTop, this.mRefreshListener);
} else {
startScaleDownAnimation(this.mRefreshListener);
}
}
}
/* access modifiers changed from: package-private */
public void startScaleDownAnimation(Animation.AnimationListener animationListener) {
AnonymousClass3 r0 = new Animation() {
public void applyTransformation(float f, Transformation transformation) {
SwipeRefreshLayout.this.setAnimationProgress(1.0f - f);
}
};
this.mScaleDownAnimation = r0;
r0.setDuration(150);
this.mCircleView.setAnimationListener(animationListener);
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(this.mScaleDownAnimation);
}
private void startProgressAlphaStartAnimation() {
this.mAlphaStartAnimation = startAlphaAnimation(this.mProgress.getAlpha(), 76);
}
private void startProgressAlphaMaxAnimation() {
this.mAlphaMaxAnimation = startAlphaAnimation(this.mProgress.getAlpha(), 255);
}
private Animation startAlphaAnimation(final int i, final int i2) {
AnonymousClass4 r0 = new Animation() {
public void applyTransformation(float f, Transformation transformation) {
CircularProgressDrawable circularProgressDrawable = SwipeRefreshLayout.this.mProgress;
int i = i;
circularProgressDrawable.setAlpha((int) (((float) i) + (((float) (i2 - i)) * f)));
}
};
r0.setDuration(300);
this.mCircleView.setAnimationListener((Animation.AnimationListener) null);
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(r0);
return r0;
}
@Deprecated
public void setProgressBackgroundColor(int i) {
setProgressBackgroundColorSchemeResource(i);
}
public void setProgressBackgroundColorSchemeResource(int i) {
setProgressBackgroundColorSchemeColor(ContextCompat.getColor(getContext(), i));
}
public void setProgressBackgroundColorSchemeColor(int i) {
this.mCircleView.setBackgroundColor(i);
}
@Deprecated
public void setColorScheme(int... iArr) {
setColorSchemeResources(iArr);
}
public void setColorSchemeResources(int... iArr) {
Context context = getContext();
int[] iArr2 = new int[iArr.length];
for (int i = 0; i < iArr.length; i++) {
iArr2[i] = ContextCompat.getColor(context, iArr[i]);
}
setColorSchemeColors(iArr2);
}
public void setColorSchemeColors(int... iArr) {
ensureTarget();
this.mProgress.setColorSchemeColors(iArr);
}
public boolean isRefreshing() {
return this.mRefreshing;
}
private void ensureTarget() {
if (this.mTarget == null) {
for (int i = 0; i < getChildCount(); i++) {
View childAt = getChildAt(i);
if (!childAt.equals(this.mCircleView)) {
this.mTarget = childAt;
return;
}
}
}
}
public void setDistanceToTriggerSync(int i) {
this.mTotalDragDistance = (float) i;
}
/* access modifiers changed from: protected */
public void onLayout(boolean z, int i, int i2, int i3, int i4) {
int measuredWidth = getMeasuredWidth();
int measuredHeight = getMeasuredHeight();
if (getChildCount() != 0) {
if (this.mTarget == null) {
ensureTarget();
}
View view = this.mTarget;
if (view != null) {
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
view.layout(paddingLeft, paddingTop, ((measuredWidth - getPaddingLeft()) - getPaddingRight()) + paddingLeft, ((measuredHeight - getPaddingTop()) - getPaddingBottom()) + paddingTop);
int measuredWidth2 = this.mCircleView.getMeasuredWidth();
int measuredHeight2 = this.mCircleView.getMeasuredHeight();
int i5 = measuredWidth / 2;
int i6 = measuredWidth2 / 2;
int i7 = this.mCurrentTargetOffsetTop;
this.mCircleView.layout(i5 - i6, i7, i5 + i6, measuredHeight2 + i7);
}
}
}
public void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
if (this.mTarget == null) {
ensureTarget();
}
View view = this.mTarget;
if (view != null) {
view.measure(View.MeasureSpec.makeMeasureSpec((getMeasuredWidth() - getPaddingLeft()) - getPaddingRight(), 1073741824), View.MeasureSpec.makeMeasureSpec((getMeasuredHeight() - getPaddingTop()) - getPaddingBottom(), 1073741824));
this.mCircleView.measure(View.MeasureSpec.makeMeasureSpec(this.mCircleDiameter, 1073741824), View.MeasureSpec.makeMeasureSpec(this.mCircleDiameter, 1073741824));
this.mCircleViewIndex = -1;
for (int i3 = 0; i3 < getChildCount(); i3++) {
if (getChildAt(i3) == this.mCircleView) {
this.mCircleViewIndex = i3;
return;
}
}
}
}
public int getProgressCircleDiameter() {
return this.mCircleDiameter;
}
public boolean canChildScrollUp() {
OnChildScrollUpCallback onChildScrollUpCallback = this.mChildScrollUpCallback;
if (onChildScrollUpCallback != null) {
return onChildScrollUpCallback.canChildScrollUp(this, this.mTarget);
}
View view = this.mTarget;
if (view instanceof ListView) {
return ListViewCompat.canScrollList((ListView) view, -1);
}
return view.canScrollVertically(-1);
}
public void setOnChildScrollUpCallback(OnChildScrollUpCallback onChildScrollUpCallback) {
this.mChildScrollUpCallback = onChildScrollUpCallback;
}
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
ensureTarget();
int actionMasked = motionEvent.getActionMasked();
if (this.mReturningToStart && actionMasked == 0) {
this.mReturningToStart = false;
}
if (!isEnabled() || this.mReturningToStart || canChildScrollUp() || this.mRefreshing || this.mNestedScrollInProgress) {
return false;
}
if (actionMasked != 0) {
if (actionMasked != 1) {
if (actionMasked == 2) {
int i = this.mActivePointerId;
if (i == -1) {
Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
int findPointerIndex = motionEvent.findPointerIndex(i);
if (findPointerIndex < 0) {
return false;
}
startDragging(motionEvent.getY(findPointerIndex));
} else if (actionMasked != 3) {
if (actionMasked == 6) {
onSecondaryPointerUp(motionEvent);
}
}
}
this.mIsBeingDragged = false;
this.mActivePointerId = -1;
} else {
setTargetOffsetTopAndBottom(this.mOriginalOffsetTop - this.mCircleView.getTop());
int pointerId = motionEvent.getPointerId(0);
this.mActivePointerId = pointerId;
this.mIsBeingDragged = false;
int findPointerIndex2 = motionEvent.findPointerIndex(pointerId);
if (findPointerIndex2 < 0) {
return false;
}
this.mInitialDownY = motionEvent.getY(findPointerIndex2);
}
return this.mIsBeingDragged;
}
public void requestDisallowInterceptTouchEvent(boolean z) {
if (Build.VERSION.SDK_INT >= 21 || !(this.mTarget instanceof AbsListView)) {
View view = this.mTarget;
if (view == null || ViewCompat.isNestedScrollingEnabled(view)) {
super.requestDisallowInterceptTouchEvent(z);
}
}
}
public boolean onStartNestedScroll(View view, View view2, int i) {
return isEnabled() && !this.mReturningToStart && !this.mRefreshing && (i & 2) != 0;
}
public void onNestedScrollAccepted(View view, View view2, int i) {
this.mNestedScrollingParentHelper.onNestedScrollAccepted(view, view2, i);
startNestedScroll(i & 2);
this.mTotalUnconsumed = 0.0f;
this.mNestedScrollInProgress = true;
}
public void onNestedPreScroll(View view, int i, int i2, int[] iArr) {
if (i2 > 0) {
float f = this.mTotalUnconsumed;
if (f > 0.0f) {
float f2 = (float) i2;
if (f2 > f) {
iArr[1] = i2 - ((int) f);
this.mTotalUnconsumed = 0.0f;
} else {
this.mTotalUnconsumed = f - f2;
iArr[1] = i2;
}
moveSpinner(this.mTotalUnconsumed);
}
}
if (this.mUsingCustomStart && i2 > 0 && this.mTotalUnconsumed == 0.0f && Math.abs(i2 - iArr[1]) > 0) {
this.mCircleView.setVisibility(8);
}
int[] iArr2 = this.mParentScrollConsumed;
if (dispatchNestedPreScroll(i - iArr[0], i2 - iArr[1], iArr2, (int[]) null)) {
iArr[0] = iArr[0] + iArr2[0];
iArr[1] = iArr[1] + iArr2[1];
}
}
public int getNestedScrollAxes() {
return this.mNestedScrollingParentHelper.getNestedScrollAxes();
}
public void onStopNestedScroll(View view) {
this.mNestedScrollingParentHelper.onStopNestedScroll(view);
this.mNestedScrollInProgress = false;
float f = this.mTotalUnconsumed;
if (f > 0.0f) {
finishSpinner(f);
this.mTotalUnconsumed = 0.0f;
}
stopNestedScroll();
}
public void onNestedScroll(View view, int i, int i2, int i3, int i4) {
dispatchNestedScroll(i, i2, i3, i4, this.mParentOffsetInWindow);
int i5 = i4 + this.mParentOffsetInWindow[1];
if (i5 < 0 && !canChildScrollUp()) {
float abs = this.mTotalUnconsumed + ((float) Math.abs(i5));
this.mTotalUnconsumed = abs;
moveSpinner(abs);
}
}
public void setNestedScrollingEnabled(boolean z) {
this.mNestedScrollingChildHelper.setNestedScrollingEnabled(z);
}
public boolean isNestedScrollingEnabled() {
return this.mNestedScrollingChildHelper.isNestedScrollingEnabled();
}
public boolean startNestedScroll(int i) {
return this.mNestedScrollingChildHelper.startNestedScroll(i);
}
public void stopNestedScroll() {
this.mNestedScrollingChildHelper.stopNestedScroll();
}
public boolean hasNestedScrollingParent() {
return this.mNestedScrollingChildHelper.hasNestedScrollingParent();
}
public boolean dispatchNestedScroll(int i, int i2, int i3, int i4, int[] iArr) {
return this.mNestedScrollingChildHelper.dispatchNestedScroll(i, i2, i3, i4, iArr);
}
public boolean dispatchNestedPreScroll(int i, int i2, int[] iArr, int[] iArr2) {
return this.mNestedScrollingChildHelper.dispatchNestedPreScroll(i, i2, iArr, iArr2);
}
public boolean onNestedPreFling(View view, float f, float f2) {
return dispatchNestedPreFling(f, f2);
}
public boolean onNestedFling(View view, float f, float f2, boolean z) {
return dispatchNestedFling(f, f2, z);
}
public boolean dispatchNestedFling(float f, float f2, boolean z) {
return this.mNestedScrollingChildHelper.dispatchNestedFling(f, f2, z);
}
public boolean dispatchNestedPreFling(float f, float f2) {
return this.mNestedScrollingChildHelper.dispatchNestedPreFling(f, f2);
}
private boolean isAnimationRunning(Animation animation) {
return animation != null && animation.hasStarted() && !animation.hasEnded();
}
private void moveSpinner(float f) {
this.mProgress.setArrowEnabled(true);
float min = Math.min(1.0f, Math.abs(f / this.mTotalDragDistance));
float max = (((float) Math.max(((double) min) - 0.4d, 0.0d)) * 5.0f) / 3.0f;
float abs = Math.abs(f) - this.mTotalDragDistance;
int i = this.mCustomSlingshotDistance;
if (i <= 0) {
i = this.mUsingCustomStart ? this.mSpinnerOffsetEnd - this.mOriginalOffsetTop : this.mSpinnerOffsetEnd;
}
float f2 = (float) i;
double max2 = (double) (Math.max(0.0f, Math.min(abs, f2 * 2.0f) / f2) / 4.0f);
float pow = ((float) (max2 - Math.pow(max2, 2.0d))) * 2.0f;
int i2 = this.mOriginalOffsetTop + ((int) ((f2 * min) + (f2 * pow * 2.0f)));
if (this.mCircleView.getVisibility() != 0) {
this.mCircleView.setVisibility(0);
}
if (!this.mScale) {
this.mCircleView.setScaleX(1.0f);
this.mCircleView.setScaleY(1.0f);
}
if (this.mScale) {
setAnimationProgress(Math.min(1.0f, f / this.mTotalDragDistance));
}
if (f < this.mTotalDragDistance) {
if (this.mProgress.getAlpha() > 76 && !isAnimationRunning(this.mAlphaStartAnimation)) {
startProgressAlphaStartAnimation();
}
} else if (this.mProgress.getAlpha() < 255 && !isAnimationRunning(this.mAlphaMaxAnimation)) {
startProgressAlphaMaxAnimation();
}
this.mProgress.setStartEndTrim(0.0f, Math.min(MAX_PROGRESS_ANGLE, max * MAX_PROGRESS_ANGLE));
this.mProgress.setArrowScale(Math.min(1.0f, max));
this.mProgress.setProgressRotation((((max * 0.4f) - 16.0f) + (pow * 2.0f)) * DRAG_RATE);
setTargetOffsetTopAndBottom(i2 - this.mCurrentTargetOffsetTop);
}
private void finishSpinner(float f) {
if (f > this.mTotalDragDistance) {
setRefreshing(true, true);
return;
}
this.mRefreshing = false;
this.mProgress.setStartEndTrim(0.0f, 0.0f);
AnonymousClass5 r0 = null;
if (!this.mScale) {
r0 = new Animation.AnimationListener() {
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
if (!SwipeRefreshLayout.this.mScale) {
SwipeRefreshLayout.this.startScaleDownAnimation((Animation.AnimationListener) null);
}
}
};
}
animateOffsetToStartPosition(this.mCurrentTargetOffsetTop, r0);
this.mProgress.setArrowEnabled(false);
}
public boolean onTouchEvent(MotionEvent motionEvent) {
int actionMasked = motionEvent.getActionMasked();
if (this.mReturningToStart && actionMasked == 0) {
this.mReturningToStart = false;
}
if (!isEnabled() || this.mReturningToStart || canChildScrollUp() || this.mRefreshing || this.mNestedScrollInProgress) {
return false;
}
if (actionMasked == 0) {
this.mActivePointerId = motionEvent.getPointerId(0);
this.mIsBeingDragged = false;
} else if (actionMasked == 1) {
int findPointerIndex = motionEvent.findPointerIndex(this.mActivePointerId);
if (findPointerIndex < 0) {
Log.e(LOG_TAG, "Got ACTION_UP event but don't have an active pointer id.");
return false;
}
if (this.mIsBeingDragged) {
float y = (motionEvent.getY(findPointerIndex) - this.mInitialMotionY) * DRAG_RATE;
this.mIsBeingDragged = false;
finishSpinner(y);
}
this.mActivePointerId = -1;
return false;
} else if (actionMasked == 2) {
int findPointerIndex2 = motionEvent.findPointerIndex(this.mActivePointerId);
if (findPointerIndex2 < 0) {
Log.e(LOG_TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
return false;
}
float y2 = motionEvent.getY(findPointerIndex2);
startDragging(y2);
if (this.mIsBeingDragged) {
float f = (y2 - this.mInitialMotionY) * DRAG_RATE;
if (f <= 0.0f) {
return false;
}
moveSpinner(f);
}
} else if (actionMasked == 3) {
return false;
} else {
if (actionMasked == 5) {
int actionIndex = motionEvent.getActionIndex();
if (actionIndex < 0) {
Log.e(LOG_TAG, "Got ACTION_POINTER_DOWN event but have an invalid action index.");
return false;
}
this.mActivePointerId = motionEvent.getPointerId(actionIndex);
} else if (actionMasked == 6) {
onSecondaryPointerUp(motionEvent);
}
}
return true;
}
private void startDragging(float f) {
float f2 = this.mInitialDownY;
int i = this.mTouchSlop;
if (f - f2 > ((float) i) && !this.mIsBeingDragged) {
this.mInitialMotionY = f2 + ((float) i);
this.mIsBeingDragged = true;
this.mProgress.setAlpha(76);
}
}
private void animateOffsetToCorrectPosition(int i, Animation.AnimationListener animationListener) {
this.mFrom = i;
this.mAnimateToCorrectPosition.reset();
this.mAnimateToCorrectPosition.setDuration(200);
this.mAnimateToCorrectPosition.setInterpolator(this.mDecelerateInterpolator);
if (animationListener != null) {
this.mCircleView.setAnimationListener(animationListener);
}
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(this.mAnimateToCorrectPosition);
}
private void animateOffsetToStartPosition(int i, Animation.AnimationListener animationListener) {
if (this.mScale) {
startScaleDownReturnToStartAnimation(i, animationListener);
return;
}
this.mFrom = i;
this.mAnimateToStartPosition.reset();
this.mAnimateToStartPosition.setDuration(200);
this.mAnimateToStartPosition.setInterpolator(this.mDecelerateInterpolator);
if (animationListener != null) {
this.mCircleView.setAnimationListener(animationListener);
}
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(this.mAnimateToStartPosition);
}
/* access modifiers changed from: package-private */
public void moveToStart(float f) {
int i = this.mFrom;
setTargetOffsetTopAndBottom((i + ((int) (((float) (this.mOriginalOffsetTop - i)) * f))) - this.mCircleView.getTop());
}
private void startScaleDownReturnToStartAnimation(int i, Animation.AnimationListener animationListener) {
this.mFrom = i;
this.mStartingScale = this.mCircleView.getScaleX();
AnonymousClass8 r3 = new Animation() {
public void applyTransformation(float f, Transformation transformation) {
SwipeRefreshLayout.this.setAnimationProgress(SwipeRefreshLayout.this.mStartingScale + ((-SwipeRefreshLayout.this.mStartingScale) * f));
SwipeRefreshLayout.this.moveToStart(f);
}
};
this.mScaleDownToStartAnimation = r3;
r3.setDuration(150);
if (animationListener != null) {
this.mCircleView.setAnimationListener(animationListener);
}
this.mCircleView.clearAnimation();
this.mCircleView.startAnimation(this.mScaleDownToStartAnimation);
}
/* access modifiers changed from: package-private */
public void setTargetOffsetTopAndBottom(int i) {
this.mCircleView.bringToFront();
ViewCompat.offsetTopAndBottom(this.mCircleView, i);
this.mCurrentTargetOffsetTop = this.mCircleView.getTop();
}
private void onSecondaryPointerUp(MotionEvent motionEvent) {
int actionIndex = motionEvent.getActionIndex();
if (motionEvent.getPointerId(actionIndex) == this.mActivePointerId) {
this.mActivePointerId = motionEvent.getPointerId(actionIndex == 0 ? 1 : 0);
}
}
}
Download file