2075 lines
68 KiB
Java
2075 lines
68 KiB
Java
package androidx.viewpager.widget;
|
|
|
|
import android.R;
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.database.DataSetObserver;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Bundle;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.view.FocusFinder;
|
|
import android.view.KeyEvent;
|
|
import android.view.MotionEvent;
|
|
import android.view.SoundEffectConstants;
|
|
import android.view.VelocityTracker;
|
|
import android.view.View;
|
|
import android.view.ViewConfiguration;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewParent;
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
import android.view.animation.Interpolator;
|
|
import android.widget.EdgeEffect;
|
|
import android.widget.Scroller;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.core.view.AccessibilityDelegateCompat;
|
|
import androidx.core.view.OnApplyWindowInsetsListener;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.WindowInsetsCompat;
|
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
|
import androidx.customview.view.AbsSavedState;
|
|
import com.ubt.jimu.base.util.FileUtil;
|
|
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
|
import java.lang.annotation.ElementType;
|
|
import java.lang.annotation.Inherited;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
import java.lang.annotation.Target;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ViewPager extends ViewGroup {
|
|
static final int[] g0 = {R.attr.layout_gravity};
|
|
private static final Comparator<ItemInfo> h0 = new Comparator<ItemInfo>() { // from class: androidx.viewpager.widget.ViewPager.1
|
|
@Override // java.util.Comparator
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public int compare(ItemInfo itemInfo, ItemInfo itemInfo2) {
|
|
return itemInfo.b - itemInfo2.b;
|
|
}
|
|
};
|
|
private static final Interpolator i0 = new Interpolator() { // from class: androidx.viewpager.widget.ViewPager.2
|
|
@Override // android.animation.TimeInterpolator
|
|
public float getInterpolation(float f) {
|
|
float f2 = f - 1.0f;
|
|
return (f2 * f2 * f2 * f2 * f2) + 1.0f;
|
|
}
|
|
};
|
|
private static final ViewPositionComparator j0 = new ViewPositionComparator();
|
|
private int A;
|
|
private int B;
|
|
private int C;
|
|
private float D;
|
|
private float E;
|
|
private float F;
|
|
private float G;
|
|
private int H;
|
|
private VelocityTracker I;
|
|
private int J;
|
|
private int K;
|
|
private int L;
|
|
private int M;
|
|
private boolean N;
|
|
private EdgeEffect O;
|
|
private EdgeEffect P;
|
|
private boolean Q;
|
|
private boolean R;
|
|
private int S;
|
|
private List<OnPageChangeListener> T;
|
|
private OnPageChangeListener U;
|
|
private OnPageChangeListener V;
|
|
private List<OnAdapterChangeListener> W;
|
|
private int a;
|
|
private PageTransformer a0;
|
|
private final ArrayList<ItemInfo> b;
|
|
private int b0;
|
|
private final ItemInfo c;
|
|
private int c0;
|
|
private final Rect d;
|
|
private ArrayList<View> d0;
|
|
PagerAdapter e;
|
|
private final Runnable e0;
|
|
int f;
|
|
private int f0;
|
|
private int g;
|
|
private Parcelable h;
|
|
private ClassLoader i;
|
|
private Scroller j;
|
|
private boolean k;
|
|
private PagerObserver l;
|
|
private int m;
|
|
private Drawable n;
|
|
private int o;
|
|
private int p;
|
|
private float q;
|
|
private float r;
|
|
private int s;
|
|
private boolean t;
|
|
private boolean u;
|
|
private boolean v;
|
|
private int x;
|
|
private boolean y;
|
|
private boolean z;
|
|
|
|
@Target({ElementType.TYPE})
|
|
@Inherited
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
public @interface DecorView {
|
|
}
|
|
|
|
static class ItemInfo {
|
|
Object a;
|
|
int b;
|
|
boolean c;
|
|
float d;
|
|
float e;
|
|
|
|
ItemInfo() {
|
|
}
|
|
}
|
|
|
|
public interface OnAdapterChangeListener {
|
|
void a(ViewPager viewPager, PagerAdapter pagerAdapter, PagerAdapter pagerAdapter2);
|
|
}
|
|
|
|
public interface OnPageChangeListener {
|
|
void onPageScrollStateChanged(int i);
|
|
|
|
void onPageScrolled(int i, float f, int i2);
|
|
|
|
void onPageSelected(int i);
|
|
}
|
|
|
|
public interface PageTransformer {
|
|
void a(View view, float f);
|
|
}
|
|
|
|
private class PagerObserver extends DataSetObserver {
|
|
PagerObserver() {
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onChanged() {
|
|
ViewPager.this.a();
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onInvalidated() {
|
|
ViewPager.this.a();
|
|
}
|
|
}
|
|
|
|
public static class SavedState extends AbsSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: androidx.viewpager.widget.ViewPager.SavedState.1
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.ClassLoaderCreator
|
|
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
|
|
return new SavedState(parcel, classLoader);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel, null);
|
|
}
|
|
};
|
|
Parcelable adapterState;
|
|
ClassLoader loader;
|
|
int position;
|
|
|
|
public SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
|
|
public String toString() {
|
|
return "FragmentPager.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " position=" + this.position + "}";
|
|
}
|
|
|
|
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
super.writeToParcel(parcel, i);
|
|
parcel.writeInt(this.position);
|
|
parcel.writeParcelable(this.adapterState, i);
|
|
}
|
|
|
|
SavedState(Parcel parcel, ClassLoader classLoader) {
|
|
super(parcel, classLoader);
|
|
classLoader = classLoader == null ? SavedState.class.getClassLoader() : classLoader;
|
|
this.position = parcel.readInt();
|
|
this.adapterState = parcel.readParcelable(classLoader);
|
|
this.loader = classLoader;
|
|
}
|
|
}
|
|
|
|
static class ViewPositionComparator implements Comparator<View> {
|
|
ViewPositionComparator() {
|
|
}
|
|
|
|
@Override // java.util.Comparator
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public int compare(View view, View view2) {
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
LayoutParams layoutParams2 = (LayoutParams) view2.getLayoutParams();
|
|
boolean z = layoutParams.a;
|
|
return z != layoutParams2.a ? z ? 1 : -1 : layoutParams.e - layoutParams2.e;
|
|
}
|
|
}
|
|
|
|
public ViewPager(Context context) {
|
|
super(context);
|
|
this.b = new ArrayList<>();
|
|
this.c = new ItemInfo();
|
|
this.d = new Rect();
|
|
this.g = -1;
|
|
this.h = null;
|
|
this.i = null;
|
|
this.q = -3.4028235E38f;
|
|
this.r = Float.MAX_VALUE;
|
|
this.x = 1;
|
|
this.H = -1;
|
|
this.Q = true;
|
|
this.e0 = new Runnable() { // from class: androidx.viewpager.widget.ViewPager.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ViewPager.this.setScrollState(0);
|
|
ViewPager.this.e();
|
|
}
|
|
};
|
|
this.f0 = 0;
|
|
b();
|
|
}
|
|
|
|
private void d(int i) {
|
|
OnPageChangeListener onPageChangeListener = this.U;
|
|
if (onPageChangeListener != null) {
|
|
onPageChangeListener.onPageSelected(i);
|
|
}
|
|
List<OnPageChangeListener> list = this.T;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
OnPageChangeListener onPageChangeListener2 = this.T.get(i2);
|
|
if (onPageChangeListener2 != null) {
|
|
onPageChangeListener2.onPageSelected(i);
|
|
}
|
|
}
|
|
}
|
|
OnPageChangeListener onPageChangeListener3 = this.V;
|
|
if (onPageChangeListener3 != null) {
|
|
onPageChangeListener3.onPageSelected(i);
|
|
}
|
|
}
|
|
|
|
private boolean f(int i) {
|
|
if (this.b.size() == 0) {
|
|
if (this.Q) {
|
|
return false;
|
|
}
|
|
this.R = false;
|
|
a(0, 0.0f, 0);
|
|
if (this.R) {
|
|
return false;
|
|
}
|
|
throw new IllegalStateException("onPageScrolled did not call superclass implementation");
|
|
}
|
|
ItemInfo g = g();
|
|
int clientWidth = getClientWidth();
|
|
int i2 = this.m;
|
|
int i3 = clientWidth + i2;
|
|
float f = clientWidth;
|
|
int i4 = g.b;
|
|
float f2 = ((i / f) - g.e) / (g.d + (i2 / f));
|
|
this.R = false;
|
|
a(i4, f2, (int) (i3 * f2));
|
|
if (this.R) {
|
|
return true;
|
|
}
|
|
throw new IllegalStateException("onPageScrolled did not call superclass implementation");
|
|
}
|
|
|
|
private ItemInfo g() {
|
|
int i;
|
|
int clientWidth = getClientWidth();
|
|
float scrollX = clientWidth > 0 ? getScrollX() / clientWidth : 0.0f;
|
|
float f = clientWidth > 0 ? this.m / clientWidth : 0.0f;
|
|
ItemInfo itemInfo = null;
|
|
int i2 = 0;
|
|
boolean z = true;
|
|
int i3 = -1;
|
|
float f2 = 0.0f;
|
|
float f3 = 0.0f;
|
|
while (i2 < this.b.size()) {
|
|
ItemInfo itemInfo2 = this.b.get(i2);
|
|
if (!z && itemInfo2.b != (i = i3 + 1)) {
|
|
itemInfo2 = this.c;
|
|
itemInfo2.e = f2 + f3 + f;
|
|
itemInfo2.b = i;
|
|
itemInfo2.d = this.e.getPageWidth(itemInfo2.b);
|
|
i2--;
|
|
}
|
|
f2 = itemInfo2.e;
|
|
float f4 = itemInfo2.d + f2 + f;
|
|
if (!z && scrollX < f2) {
|
|
return itemInfo;
|
|
}
|
|
if (scrollX < f4 || i2 == this.b.size() - 1) {
|
|
return itemInfo2;
|
|
}
|
|
i3 = itemInfo2.b;
|
|
f3 = itemInfo2.d;
|
|
i2++;
|
|
itemInfo = itemInfo2;
|
|
z = false;
|
|
}
|
|
return itemInfo;
|
|
}
|
|
|
|
private int getClientWidth() {
|
|
return (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
|
|
}
|
|
|
|
private void h() {
|
|
int i = 0;
|
|
while (i < getChildCount()) {
|
|
if (!((LayoutParams) getChildAt(i).getLayoutParams()).a) {
|
|
removeViewAt(i);
|
|
i--;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private boolean i() {
|
|
this.H = -1;
|
|
f();
|
|
this.O.onRelease();
|
|
this.P.onRelease();
|
|
return this.O.isFinished() || this.P.isFinished();
|
|
}
|
|
|
|
private void j() {
|
|
if (this.c0 != 0) {
|
|
ArrayList<View> arrayList = this.d0;
|
|
if (arrayList == null) {
|
|
this.d0 = new ArrayList<>();
|
|
} else {
|
|
arrayList.clear();
|
|
}
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
this.d0.add(getChildAt(i));
|
|
}
|
|
Collections.sort(this.d0, j0);
|
|
}
|
|
}
|
|
|
|
private void setScrollingCacheEnabled(boolean z) {
|
|
if (this.u != z) {
|
|
this.u = z;
|
|
}
|
|
}
|
|
|
|
public void a(OnAdapterChangeListener onAdapterChangeListener) {
|
|
if (this.W == null) {
|
|
this.W = new ArrayList();
|
|
}
|
|
this.W.add(onAdapterChangeListener);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void addFocusables(ArrayList<View> arrayList, int i, int i2) {
|
|
ItemInfo b;
|
|
int size = arrayList.size();
|
|
int descendantFocusability = getDescendantFocusability();
|
|
if (descendantFocusability != 393216) {
|
|
for (int i3 = 0; i3 < getChildCount(); i3++) {
|
|
View childAt = getChildAt(i3);
|
|
if (childAt.getVisibility() == 0 && (b = b(childAt)) != null && b.b == this.f) {
|
|
childAt.addFocusables(arrayList, i, i2);
|
|
}
|
|
}
|
|
}
|
|
if ((descendantFocusability != 262144 || size == arrayList.size()) && isFocusable()) {
|
|
if (((i2 & 1) == 1 && isInTouchMode() && !isFocusableInTouchMode()) || arrayList == null) {
|
|
return;
|
|
}
|
|
arrayList.add(this);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void addTouchables(ArrayList<View> arrayList) {
|
|
ItemInfo b;
|
|
for (int i = 0; i < getChildCount(); i++) {
|
|
View childAt = getChildAt(i);
|
|
if (childAt.getVisibility() == 0 && (b = b(childAt)) != null && b.b == this.f) {
|
|
childAt.addTouchables(arrayList);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
|
if (!checkLayoutParams(layoutParams)) {
|
|
layoutParams = generateLayoutParams(layoutParams);
|
|
}
|
|
LayoutParams layoutParams2 = (LayoutParams) layoutParams;
|
|
layoutParams2.a |= c(view);
|
|
if (!this.t) {
|
|
super.addView(view, i, layoutParams);
|
|
} else {
|
|
if (layoutParams2 != null && layoutParams2.a) {
|
|
throw new IllegalStateException("Cannot add pager decor view during layout");
|
|
}
|
|
layoutParams2.d = true;
|
|
addViewInLayout(view, i, layoutParams);
|
|
}
|
|
}
|
|
|
|
void b() {
|
|
setWillNotDraw(false);
|
|
setDescendantFocusability(262144);
|
|
setFocusable(true);
|
|
Context context = getContext();
|
|
this.j = new Scroller(context, i0);
|
|
ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
|
|
float f = context.getResources().getDisplayMetrics().density;
|
|
this.C = viewConfiguration.getScaledPagingTouchSlop();
|
|
this.J = (int) (400.0f * f);
|
|
this.K = viewConfiguration.getScaledMaximumFlingVelocity();
|
|
this.O = new EdgeEffect(context);
|
|
this.P = new EdgeEffect(context);
|
|
this.L = (int) (25.0f * f);
|
|
this.M = (int) (2.0f * f);
|
|
this.A = (int) (f * 16.0f);
|
|
ViewCompat.a(this, new MyAccessibilityDelegate());
|
|
if (ViewCompat.i(this) == 0) {
|
|
ViewCompat.f((View) this, 1);
|
|
}
|
|
ViewCompat.a(this, new OnApplyWindowInsetsListener() { // from class: androidx.viewpager.widget.ViewPager.4
|
|
private final Rect a = new Rect();
|
|
|
|
@Override // androidx.core.view.OnApplyWindowInsetsListener
|
|
public WindowInsetsCompat a(View view, WindowInsetsCompat windowInsetsCompat) {
|
|
WindowInsetsCompat b = ViewCompat.b(view, windowInsetsCompat);
|
|
if (b.f()) {
|
|
return b;
|
|
}
|
|
Rect rect = this.a;
|
|
rect.left = b.c();
|
|
rect.top = b.e();
|
|
rect.right = b.d();
|
|
rect.bottom = b.b();
|
|
int childCount = ViewPager.this.getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
WindowInsetsCompat a = ViewCompat.a(ViewPager.this.getChildAt(i), b);
|
|
rect.left = Math.min(a.c(), rect.left);
|
|
rect.top = Math.min(a.e(), rect.top);
|
|
rect.right = Math.min(a.d(), rect.right);
|
|
rect.bottom = Math.min(a.b(), rect.bottom);
|
|
}
|
|
return b.a(rect.left, rect.top, rect.right, rect.bottom);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:25:0x0060, code lost:
|
|
|
|
if (r9 == r10) goto L28;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:26:0x0066, code lost:
|
|
|
|
r8 = null;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
void c(int r18) {
|
|
/*
|
|
Method dump skipped, instructions count: 617
|
|
To view this dump change 'Code comments level' option to 'DEBUG'
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.c(int):void");
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean canScrollHorizontally(int i) {
|
|
if (this.e == null) {
|
|
return false;
|
|
}
|
|
int clientWidth = getClientWidth();
|
|
int scrollX = getScrollX();
|
|
return i < 0 ? scrollX > ((int) (((float) clientWidth) * this.q)) : i > 0 && scrollX < ((int) (((float) clientWidth) * this.r));
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return (layoutParams instanceof LayoutParams) && super.checkLayoutParams(layoutParams);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void computeScroll() {
|
|
this.k = true;
|
|
if (this.j.isFinished() || !this.j.computeScrollOffset()) {
|
|
a(true);
|
|
return;
|
|
}
|
|
int scrollX = getScrollX();
|
|
int scrollY = getScrollY();
|
|
int currX = this.j.getCurrX();
|
|
int currY = this.j.getCurrY();
|
|
if (scrollX != currX || scrollY != currY) {
|
|
scrollTo(currX, currY);
|
|
if (!f(currX)) {
|
|
this.j.abortAnimation();
|
|
scrollTo(0, currY);
|
|
}
|
|
}
|
|
ViewCompat.A(this);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
|
|
return super.dispatchKeyEvent(keyEvent) || a(keyEvent);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
|
ItemInfo b;
|
|
if (accessibilityEvent.getEventType() == 4096) {
|
|
return super.dispatchPopulateAccessibilityEvent(accessibilityEvent);
|
|
}
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
if (childAt.getVisibility() == 0 && (b = b(childAt)) != null && b.b == this.f && childAt.dispatchPopulateAccessibilityEvent(accessibilityEvent)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void draw(Canvas canvas) {
|
|
PagerAdapter pagerAdapter;
|
|
super.draw(canvas);
|
|
int overScrollMode = getOverScrollMode();
|
|
boolean z = false;
|
|
if (overScrollMode == 0 || (overScrollMode == 1 && (pagerAdapter = this.e) != null && pagerAdapter.getCount() > 1)) {
|
|
if (!this.O.isFinished()) {
|
|
int save = canvas.save();
|
|
int height = (getHeight() - getPaddingTop()) - getPaddingBottom();
|
|
int width = getWidth();
|
|
canvas.rotate(270.0f);
|
|
canvas.translate((-height) + getPaddingTop(), this.q * width);
|
|
this.O.setSize(height, width);
|
|
z = false | this.O.draw(canvas);
|
|
canvas.restoreToCount(save);
|
|
}
|
|
if (!this.P.isFinished()) {
|
|
int save2 = canvas.save();
|
|
int width2 = getWidth();
|
|
int height2 = (getHeight() - getPaddingTop()) - getPaddingBottom();
|
|
canvas.rotate(90.0f);
|
|
canvas.translate(-getPaddingTop(), (-(this.r + 1.0f)) * width2);
|
|
this.P.setSize(height2, width2);
|
|
z |= this.P.draw(canvas);
|
|
canvas.restoreToCount(save2);
|
|
}
|
|
} else {
|
|
this.O.finish();
|
|
this.P.finish();
|
|
}
|
|
if (z) {
|
|
ViewCompat.A(this);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void drawableStateChanged() {
|
|
super.drawableStateChanged();
|
|
Drawable drawable = this.n;
|
|
if (drawable == null || !drawable.isStateful()) {
|
|
return;
|
|
}
|
|
drawable.setState(getDrawableState());
|
|
}
|
|
|
|
void e() {
|
|
c(this.f);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
|
return new LayoutParams();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return generateDefaultLayoutParams();
|
|
}
|
|
|
|
public PagerAdapter getAdapter() {
|
|
return this.e;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected int getChildDrawingOrder(int i, int i2) {
|
|
if (this.c0 == 2) {
|
|
i2 = (i - 1) - i2;
|
|
}
|
|
return ((LayoutParams) this.d0.get(i2).getLayoutParams()).f;
|
|
}
|
|
|
|
public int getCurrentItem() {
|
|
return this.f;
|
|
}
|
|
|
|
public int getOffscreenPageLimit() {
|
|
return this.x;
|
|
}
|
|
|
|
public int getPageMargin() {
|
|
return this.m;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
this.Q = true;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onDetachedFromWindow() {
|
|
removeCallbacks(this.e0);
|
|
Scroller scroller = this.j;
|
|
if (scroller != null && !scroller.isFinished()) {
|
|
this.j.abortAnimation();
|
|
}
|
|
super.onDetachedFromWindow();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onDraw(Canvas canvas) {
|
|
float f;
|
|
float f2;
|
|
super.onDraw(canvas);
|
|
if (this.m <= 0 || this.n == null || this.b.size() <= 0 || this.e == null) {
|
|
return;
|
|
}
|
|
int scrollX = getScrollX();
|
|
float width = getWidth();
|
|
float f3 = this.m / width;
|
|
int i = 0;
|
|
ItemInfo itemInfo = this.b.get(0);
|
|
float f4 = itemInfo.e;
|
|
int size = this.b.size();
|
|
int i2 = itemInfo.b;
|
|
int i3 = this.b.get(size - 1).b;
|
|
while (i2 < i3) {
|
|
while (i2 > itemInfo.b && i < size) {
|
|
i++;
|
|
itemInfo = this.b.get(i);
|
|
}
|
|
if (i2 == itemInfo.b) {
|
|
float f5 = itemInfo.e;
|
|
float f6 = itemInfo.d;
|
|
f = (f5 + f6) * width;
|
|
f4 = f5 + f6 + f3;
|
|
} else {
|
|
float pageWidth = this.e.getPageWidth(i2);
|
|
f = (f4 + pageWidth) * width;
|
|
f4 += pageWidth + f3;
|
|
}
|
|
if (this.m + f > scrollX) {
|
|
f2 = f3;
|
|
this.n.setBounds(Math.round(f), this.o, Math.round(this.m + f), this.p);
|
|
this.n.draw(canvas);
|
|
} else {
|
|
f2 = f3;
|
|
}
|
|
if (f > scrollX + r2) {
|
|
return;
|
|
}
|
|
i2++;
|
|
f3 = f2;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
|
int action = motionEvent.getAction() & 255;
|
|
if (action == 3 || action == 1) {
|
|
i();
|
|
return false;
|
|
}
|
|
if (action != 0) {
|
|
if (this.y) {
|
|
return true;
|
|
}
|
|
if (this.z) {
|
|
return false;
|
|
}
|
|
}
|
|
if (action == 0) {
|
|
float x = motionEvent.getX();
|
|
this.F = x;
|
|
this.D = x;
|
|
float y = motionEvent.getY();
|
|
this.G = y;
|
|
this.E = y;
|
|
this.H = motionEvent.getPointerId(0);
|
|
this.z = false;
|
|
this.k = true;
|
|
this.j.computeScrollOffset();
|
|
if (this.f0 != 2 || Math.abs(this.j.getFinalX() - this.j.getCurrX()) <= this.M) {
|
|
a(false);
|
|
this.y = false;
|
|
} else {
|
|
this.j.abortAnimation();
|
|
this.v = false;
|
|
e();
|
|
this.y = true;
|
|
c(true);
|
|
setScrollState(1);
|
|
}
|
|
} else if (action == 2) {
|
|
int i = this.H;
|
|
if (i != -1) {
|
|
int findPointerIndex = motionEvent.findPointerIndex(i);
|
|
float x2 = motionEvent.getX(findPointerIndex);
|
|
float f = x2 - this.D;
|
|
float abs = Math.abs(f);
|
|
float y2 = motionEvent.getY(findPointerIndex);
|
|
float abs2 = Math.abs(y2 - this.G);
|
|
if (f != 0.0f && !a(this.D, f) && a(this, false, (int) f, (int) x2, (int) y2)) {
|
|
this.D = x2;
|
|
this.E = y2;
|
|
this.z = true;
|
|
return false;
|
|
}
|
|
if (abs > this.C && abs * 0.5f > abs2) {
|
|
this.y = true;
|
|
c(true);
|
|
setScrollState(1);
|
|
float f2 = this.F;
|
|
float f3 = this.C;
|
|
this.D = f > 0.0f ? f2 + f3 : f2 - f3;
|
|
this.E = y2;
|
|
setScrollingCacheEnabled(true);
|
|
} else if (abs2 > this.C) {
|
|
this.z = true;
|
|
}
|
|
if (this.y && b(x2)) {
|
|
ViewCompat.A(this);
|
|
}
|
|
}
|
|
} else if (action == 6) {
|
|
a(motionEvent);
|
|
}
|
|
if (this.I == null) {
|
|
this.I = VelocityTracker.obtain();
|
|
}
|
|
this.I.addMovement(motionEvent);
|
|
return this.y;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
|
boolean z2;
|
|
ItemInfo b;
|
|
int max;
|
|
int max2;
|
|
int childCount = getChildCount();
|
|
int i5 = i3 - i;
|
|
int i6 = i4 - i2;
|
|
int paddingLeft = getPaddingLeft();
|
|
int paddingTop = getPaddingTop();
|
|
int paddingRight = getPaddingRight();
|
|
int paddingBottom = getPaddingBottom();
|
|
int scrollX = getScrollX();
|
|
int i7 = paddingBottom;
|
|
int i8 = 0;
|
|
int i9 = paddingTop;
|
|
int i10 = paddingLeft;
|
|
for (int i11 = 0; i11 < childCount; i11++) {
|
|
View childAt = getChildAt(i11);
|
|
if (childAt.getVisibility() != 8) {
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
if (layoutParams.a) {
|
|
int i12 = layoutParams.b;
|
|
int i13 = i12 & 7;
|
|
int i14 = i12 & 112;
|
|
if (i13 == 1) {
|
|
max = Math.max((i5 - childAt.getMeasuredWidth()) / 2, i10);
|
|
} else if (i13 == 3) {
|
|
max = i10;
|
|
i10 = childAt.getMeasuredWidth() + i10;
|
|
} else if (i13 != 5) {
|
|
max = i10;
|
|
} else {
|
|
max = (i5 - paddingRight) - childAt.getMeasuredWidth();
|
|
paddingRight += childAt.getMeasuredWidth();
|
|
}
|
|
if (i14 == 16) {
|
|
max2 = Math.max((i6 - childAt.getMeasuredHeight()) / 2, i9);
|
|
} else if (i14 == 48) {
|
|
max2 = i9;
|
|
i9 = childAt.getMeasuredHeight() + i9;
|
|
} else if (i14 != 80) {
|
|
max2 = i9;
|
|
} else {
|
|
max2 = (i6 - i7) - childAt.getMeasuredHeight();
|
|
i7 += childAt.getMeasuredHeight();
|
|
}
|
|
int i15 = max + scrollX;
|
|
childAt.layout(i15, max2, childAt.getMeasuredWidth() + i15, max2 + childAt.getMeasuredHeight());
|
|
i8++;
|
|
}
|
|
}
|
|
}
|
|
int i16 = (i5 - i10) - paddingRight;
|
|
for (int i17 = 0; i17 < childCount; i17++) {
|
|
View childAt2 = getChildAt(i17);
|
|
if (childAt2.getVisibility() != 8) {
|
|
LayoutParams layoutParams2 = (LayoutParams) childAt2.getLayoutParams();
|
|
if (!layoutParams2.a && (b = b(childAt2)) != null) {
|
|
float f = i16;
|
|
int i18 = ((int) (b.e * f)) + i10;
|
|
if (layoutParams2.d) {
|
|
layoutParams2.d = false;
|
|
childAt2.measure(View.MeasureSpec.makeMeasureSpec((int) (f * layoutParams2.c), 1073741824), View.MeasureSpec.makeMeasureSpec((i6 - i9) - i7, 1073741824));
|
|
}
|
|
childAt2.layout(i18, i9, childAt2.getMeasuredWidth() + i18, childAt2.getMeasuredHeight() + i9);
|
|
}
|
|
}
|
|
}
|
|
this.o = i9;
|
|
this.p = i6 - i7;
|
|
this.S = i8;
|
|
if (this.Q) {
|
|
z2 = false;
|
|
a(this.f, false, 0, false);
|
|
} else {
|
|
z2 = false;
|
|
}
|
|
this.Q = z2;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:26:0x0084 */
|
|
/* JADX WARN: Removed duplicated region for block: B:31:0x0090 */
|
|
/* JADX WARN: Removed duplicated region for block: B:35:0x00a4 */
|
|
/* JADX WARN: Removed duplicated region for block: B:38:0x00aa */
|
|
/* JADX WARN: Removed duplicated region for block: B:42:0x0095 */
|
|
/* JADX WARN: Removed duplicated region for block: B:43:0x008b */
|
|
@Override // android.view.View
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
protected void onMeasure(int r14, int r15) {
|
|
/*
|
|
Method dump skipped, instructions count: 243
|
|
To view this dump change 'Code comments level' option to 'DEBUG'
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.onMeasure(int, int):void");
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
protected boolean onRequestFocusInDescendants(int i, Rect rect) {
|
|
int i2;
|
|
int i3;
|
|
ItemInfo b;
|
|
int childCount = getChildCount();
|
|
int i4 = -1;
|
|
if ((i & 2) != 0) {
|
|
i4 = childCount;
|
|
i2 = 0;
|
|
i3 = 1;
|
|
} else {
|
|
i2 = childCount - 1;
|
|
i3 = -1;
|
|
}
|
|
while (i2 != i4) {
|
|
View childAt = getChildAt(i2);
|
|
if (childAt.getVisibility() == 0 && (b = b(childAt)) != null && b.b == this.f && childAt.requestFocus(i, rect)) {
|
|
return true;
|
|
}
|
|
i2 += i3;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onRestoreInstanceState(Parcelable parcelable) {
|
|
if (!(parcelable instanceof SavedState)) {
|
|
super.onRestoreInstanceState(parcelable);
|
|
return;
|
|
}
|
|
SavedState savedState = (SavedState) parcelable;
|
|
super.onRestoreInstanceState(savedState.getSuperState());
|
|
PagerAdapter pagerAdapter = this.e;
|
|
if (pagerAdapter != null) {
|
|
pagerAdapter.restoreState(savedState.adapterState, savedState.loader);
|
|
a(savedState.position, false, true);
|
|
} else {
|
|
this.g = savedState.position;
|
|
this.h = savedState.adapterState;
|
|
this.i = savedState.loader;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public Parcelable onSaveInstanceState() {
|
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
|
savedState.position = this.f;
|
|
PagerAdapter pagerAdapter = this.e;
|
|
if (pagerAdapter != null) {
|
|
savedState.adapterState = pagerAdapter.saveState();
|
|
}
|
|
return savedState;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
if (i != i3) {
|
|
int i5 = this.m;
|
|
a(i, i3, i5, i5);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
PagerAdapter pagerAdapter;
|
|
if (this.N) {
|
|
return true;
|
|
}
|
|
boolean z = false;
|
|
if ((motionEvent.getAction() == 0 && motionEvent.getEdgeFlags() != 0) || (pagerAdapter = this.e) == null || pagerAdapter.getCount() == 0) {
|
|
return false;
|
|
}
|
|
if (this.I == null) {
|
|
this.I = VelocityTracker.obtain();
|
|
}
|
|
this.I.addMovement(motionEvent);
|
|
int action = motionEvent.getAction() & 255;
|
|
if (action == 0) {
|
|
this.j.abortAnimation();
|
|
this.v = false;
|
|
e();
|
|
float x = motionEvent.getX();
|
|
this.F = x;
|
|
this.D = x;
|
|
float y = motionEvent.getY();
|
|
this.G = y;
|
|
this.E = y;
|
|
this.H = motionEvent.getPointerId(0);
|
|
} else if (action != 1) {
|
|
if (action == 2) {
|
|
if (!this.y) {
|
|
int findPointerIndex = motionEvent.findPointerIndex(this.H);
|
|
if (findPointerIndex == -1) {
|
|
z = i();
|
|
} else {
|
|
float x2 = motionEvent.getX(findPointerIndex);
|
|
float abs = Math.abs(x2 - this.D);
|
|
float y2 = motionEvent.getY(findPointerIndex);
|
|
float abs2 = Math.abs(y2 - this.E);
|
|
if (abs > this.C && abs > abs2) {
|
|
this.y = true;
|
|
c(true);
|
|
float f = this.F;
|
|
this.D = x2 - f > 0.0f ? f + this.C : f - this.C;
|
|
this.E = y2;
|
|
setScrollState(1);
|
|
setScrollingCacheEnabled(true);
|
|
ViewParent parent = getParent();
|
|
if (parent != null) {
|
|
parent.requestDisallowInterceptTouchEvent(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.y) {
|
|
z = false | b(motionEvent.getX(motionEvent.findPointerIndex(this.H)));
|
|
}
|
|
} else if (action != 3) {
|
|
if (action == 5) {
|
|
int actionIndex = motionEvent.getActionIndex();
|
|
this.D = motionEvent.getX(actionIndex);
|
|
this.H = motionEvent.getPointerId(actionIndex);
|
|
} else if (action == 6) {
|
|
a(motionEvent);
|
|
this.D = motionEvent.getX(motionEvent.findPointerIndex(this.H));
|
|
}
|
|
} else if (this.y) {
|
|
a(this.f, true, 0, false);
|
|
z = i();
|
|
}
|
|
} else if (this.y) {
|
|
VelocityTracker velocityTracker = this.I;
|
|
velocityTracker.computeCurrentVelocity(1000, this.K);
|
|
int xVelocity = (int) velocityTracker.getXVelocity(this.H);
|
|
this.v = true;
|
|
int clientWidth = getClientWidth();
|
|
int scrollX = getScrollX();
|
|
ItemInfo g = g();
|
|
float f2 = clientWidth;
|
|
a(a(g.b, ((scrollX / f2) - g.e) / (g.d + (this.m / f2)), xVelocity, (int) (motionEvent.getX(motionEvent.findPointerIndex(this.H)) - this.F)), true, true, xVelocity);
|
|
z = i();
|
|
}
|
|
if (z) {
|
|
ViewCompat.A(this);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewManager
|
|
public void removeView(View view) {
|
|
if (this.t) {
|
|
removeViewInLayout(view);
|
|
} else {
|
|
super.removeView(view);
|
|
}
|
|
}
|
|
|
|
public void setAdapter(PagerAdapter pagerAdapter) {
|
|
PagerAdapter pagerAdapter2 = this.e;
|
|
if (pagerAdapter2 != null) {
|
|
pagerAdapter2.setViewPagerObserver(null);
|
|
this.e.startUpdate((ViewGroup) this);
|
|
for (int i = 0; i < this.b.size(); i++) {
|
|
ItemInfo itemInfo = this.b.get(i);
|
|
this.e.destroyItem((ViewGroup) this, itemInfo.b, itemInfo.a);
|
|
}
|
|
this.e.finishUpdate((ViewGroup) this);
|
|
this.b.clear();
|
|
h();
|
|
this.f = 0;
|
|
scrollTo(0, 0);
|
|
}
|
|
PagerAdapter pagerAdapter3 = this.e;
|
|
this.e = pagerAdapter;
|
|
this.a = 0;
|
|
if (this.e != null) {
|
|
if (this.l == null) {
|
|
this.l = new PagerObserver();
|
|
}
|
|
this.e.setViewPagerObserver(this.l);
|
|
this.v = false;
|
|
boolean z = this.Q;
|
|
this.Q = true;
|
|
this.a = this.e.getCount();
|
|
if (this.g >= 0) {
|
|
this.e.restoreState(this.h, this.i);
|
|
a(this.g, false, true);
|
|
this.g = -1;
|
|
this.h = null;
|
|
this.i = null;
|
|
} else if (z) {
|
|
requestLayout();
|
|
} else {
|
|
e();
|
|
}
|
|
}
|
|
List<OnAdapterChangeListener> list = this.W;
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
int size = this.W.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
this.W.get(i2).a(this, pagerAdapter3, pagerAdapter);
|
|
}
|
|
}
|
|
|
|
public void setCurrentItem(int i) {
|
|
this.v = false;
|
|
a(i, !this.Q, false);
|
|
}
|
|
|
|
public void setOffscreenPageLimit(int i) {
|
|
if (i < 1) {
|
|
Log.w("ViewPager", "Requested offscreen page limit " + i + " too small; defaulting to 1");
|
|
i = 1;
|
|
}
|
|
if (i != this.x) {
|
|
this.x = i;
|
|
e();
|
|
}
|
|
}
|
|
|
|
@Deprecated
|
|
public void setOnPageChangeListener(OnPageChangeListener onPageChangeListener) {
|
|
this.U = onPageChangeListener;
|
|
}
|
|
|
|
public void setPageMargin(int i) {
|
|
int i2 = this.m;
|
|
this.m = i;
|
|
int width = getWidth();
|
|
a(width, width, i, i2);
|
|
requestLayout();
|
|
}
|
|
|
|
public void setPageMarginDrawable(Drawable drawable) {
|
|
this.n = drawable;
|
|
if (drawable != null) {
|
|
refreshDrawableState();
|
|
}
|
|
setWillNotDraw(drawable == null);
|
|
invalidate();
|
|
}
|
|
|
|
void setScrollState(int i) {
|
|
if (this.f0 == i) {
|
|
return;
|
|
}
|
|
this.f0 = i;
|
|
if (this.a0 != null) {
|
|
b(i != 0);
|
|
}
|
|
e(i);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected boolean verifyDrawable(Drawable drawable) {
|
|
return super.verifyDrawable(drawable) || drawable == this.n;
|
|
}
|
|
|
|
public static class LayoutParams extends ViewGroup.LayoutParams {
|
|
public boolean a;
|
|
public int b;
|
|
float c;
|
|
boolean d;
|
|
int e;
|
|
int f;
|
|
|
|
public LayoutParams() {
|
|
super(-1, -1);
|
|
this.c = 0.0f;
|
|
}
|
|
|
|
public LayoutParams(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.c = 0.0f;
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ViewPager.g0);
|
|
this.b = obtainStyledAttributes.getInteger(0, 48);
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
}
|
|
|
|
private void e(int i) {
|
|
OnPageChangeListener onPageChangeListener = this.U;
|
|
if (onPageChangeListener != null) {
|
|
onPageChangeListener.onPageScrollStateChanged(i);
|
|
}
|
|
List<OnPageChangeListener> list = this.T;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
OnPageChangeListener onPageChangeListener2 = this.T.get(i2);
|
|
if (onPageChangeListener2 != null) {
|
|
onPageChangeListener2.onPageScrollStateChanged(i);
|
|
}
|
|
}
|
|
}
|
|
OnPageChangeListener onPageChangeListener3 = this.V;
|
|
if (onPageChangeListener3 != null) {
|
|
onPageChangeListener3.onPageScrollStateChanged(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
|
return new LayoutParams(getContext(), attributeSet);
|
|
}
|
|
|
|
public void a(int i, boolean z) {
|
|
this.v = false;
|
|
a(i, z, false);
|
|
}
|
|
|
|
public void setPageMarginDrawable(int i) {
|
|
setPageMarginDrawable(ContextCompat.c(getContext(), i));
|
|
}
|
|
|
|
void a(int i, boolean z, boolean z2) {
|
|
a(i, z, z2, 0);
|
|
}
|
|
|
|
class MyAccessibilityDelegate extends AccessibilityDelegateCompat {
|
|
MyAccessibilityDelegate() {
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public void a(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
|
super.a(view, accessibilityNodeInfoCompat);
|
|
accessibilityNodeInfoCompat.a((CharSequence) ViewPager.class.getName());
|
|
accessibilityNodeInfoCompat.d(b());
|
|
if (ViewPager.this.canScrollHorizontally(1)) {
|
|
accessibilityNodeInfoCompat.a(FileUtil.ZIP_BUFFER_SIZE);
|
|
}
|
|
if (ViewPager.this.canScrollHorizontally(-1)) {
|
|
accessibilityNodeInfoCompat.a(UnityActivity.BLOCKLY_TYPE_NONE);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public void b(View view, AccessibilityEvent accessibilityEvent) {
|
|
PagerAdapter pagerAdapter;
|
|
super.b(view, accessibilityEvent);
|
|
accessibilityEvent.setClassName(ViewPager.class.getName());
|
|
accessibilityEvent.setScrollable(b());
|
|
if (accessibilityEvent.getEventType() != 4096 || (pagerAdapter = ViewPager.this.e) == null) {
|
|
return;
|
|
}
|
|
accessibilityEvent.setItemCount(pagerAdapter.getCount());
|
|
accessibilityEvent.setFromIndex(ViewPager.this.f);
|
|
accessibilityEvent.setToIndex(ViewPager.this.f);
|
|
}
|
|
|
|
private boolean b() {
|
|
PagerAdapter pagerAdapter = ViewPager.this.e;
|
|
return pagerAdapter != null && pagerAdapter.getCount() > 1;
|
|
}
|
|
|
|
@Override // androidx.core.view.AccessibilityDelegateCompat
|
|
public boolean a(View view, int i, Bundle bundle) {
|
|
if (super.a(view, i, bundle)) {
|
|
return true;
|
|
}
|
|
if (i != 4096) {
|
|
if (i != 8192 || !ViewPager.this.canScrollHorizontally(-1)) {
|
|
return false;
|
|
}
|
|
ViewPager viewPager = ViewPager.this;
|
|
viewPager.setCurrentItem(viewPager.f - 1);
|
|
return true;
|
|
}
|
|
if (!ViewPager.this.canScrollHorizontally(1)) {
|
|
return false;
|
|
}
|
|
ViewPager viewPager2 = ViewPager.this;
|
|
viewPager2.setCurrentItem(viewPager2.f + 1);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
void a(int i, boolean z, boolean z2, int i2) {
|
|
PagerAdapter pagerAdapter = this.e;
|
|
if (pagerAdapter != null && pagerAdapter.getCount() > 0) {
|
|
if (!z2 && this.f == i && this.b.size() != 0) {
|
|
setScrollingCacheEnabled(false);
|
|
return;
|
|
}
|
|
if (i < 0) {
|
|
i = 0;
|
|
} else if (i >= this.e.getCount()) {
|
|
i = this.e.getCount() - 1;
|
|
}
|
|
int i3 = this.x;
|
|
int i4 = this.f;
|
|
if (i > i4 + i3 || i < i4 - i3) {
|
|
for (int i5 = 0; i5 < this.b.size(); i5++) {
|
|
this.b.get(i5).c = true;
|
|
}
|
|
}
|
|
boolean z3 = this.f != i;
|
|
if (this.Q) {
|
|
this.f = i;
|
|
if (z3) {
|
|
d(i);
|
|
}
|
|
requestLayout();
|
|
return;
|
|
}
|
|
c(i);
|
|
a(i, z, i2, z3);
|
|
return;
|
|
}
|
|
setScrollingCacheEnabled(false);
|
|
}
|
|
|
|
boolean d() {
|
|
PagerAdapter pagerAdapter = this.e;
|
|
if (pagerAdapter == null || this.f >= pagerAdapter.getCount() - 1) {
|
|
return false;
|
|
}
|
|
a(this.f + 1, true);
|
|
return true;
|
|
}
|
|
|
|
public ViewPager(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.b = new ArrayList<>();
|
|
this.c = new ItemInfo();
|
|
this.d = new Rect();
|
|
this.g = -1;
|
|
this.h = null;
|
|
this.i = null;
|
|
this.q = -3.4028235E38f;
|
|
this.r = Float.MAX_VALUE;
|
|
this.x = 1;
|
|
this.H = -1;
|
|
this.Q = true;
|
|
this.e0 = new Runnable() { // from class: androidx.viewpager.widget.ViewPager.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ViewPager.this.setScrollState(0);
|
|
ViewPager.this.e();
|
|
}
|
|
};
|
|
this.f0 = 0;
|
|
b();
|
|
}
|
|
|
|
private void f() {
|
|
this.y = false;
|
|
this.z = false;
|
|
VelocityTracker velocityTracker = this.I;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.recycle();
|
|
this.I = null;
|
|
}
|
|
}
|
|
|
|
public void b(OnAdapterChangeListener onAdapterChangeListener) {
|
|
List<OnAdapterChangeListener> list = this.W;
|
|
if (list != null) {
|
|
list.remove(onAdapterChangeListener);
|
|
}
|
|
}
|
|
|
|
public void b(OnPageChangeListener onPageChangeListener) {
|
|
List<OnPageChangeListener> list = this.T;
|
|
if (list != null) {
|
|
list.remove(onPageChangeListener);
|
|
}
|
|
}
|
|
|
|
private void a(int i, boolean z, int i2, boolean z2) {
|
|
ItemInfo b = b(i);
|
|
int clientWidth = b != null ? (int) (getClientWidth() * Math.max(this.q, Math.min(b.e, this.r))) : 0;
|
|
if (z) {
|
|
a(clientWidth, 0, i2);
|
|
if (z2) {
|
|
d(i);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (z2) {
|
|
d(i);
|
|
}
|
|
a(false);
|
|
scrollTo(clientWidth, 0);
|
|
f(clientWidth);
|
|
}
|
|
|
|
ItemInfo b(View view) {
|
|
for (int i = 0; i < this.b.size(); i++) {
|
|
ItemInfo itemInfo = this.b.get(i);
|
|
if (this.e.isViewFromObject(view, itemInfo.a)) {
|
|
return itemInfo;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
ItemInfo b(int i) {
|
|
for (int i2 = 0; i2 < this.b.size(); i2++) {
|
|
ItemInfo itemInfo = this.b.get(i2);
|
|
if (itemInfo.b == i) {
|
|
return itemInfo;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void b(int i, float f, int i2) {
|
|
OnPageChangeListener onPageChangeListener = this.U;
|
|
if (onPageChangeListener != null) {
|
|
onPageChangeListener.onPageScrolled(i, f, i2);
|
|
}
|
|
List<OnPageChangeListener> list = this.T;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
OnPageChangeListener onPageChangeListener2 = this.T.get(i3);
|
|
if (onPageChangeListener2 != null) {
|
|
onPageChangeListener2.onPageScrolled(i, f, i2);
|
|
}
|
|
}
|
|
}
|
|
OnPageChangeListener onPageChangeListener3 = this.V;
|
|
if (onPageChangeListener3 != null) {
|
|
onPageChangeListener3.onPageScrolled(i, f, i2);
|
|
}
|
|
}
|
|
|
|
public void a(OnPageChangeListener onPageChangeListener) {
|
|
if (this.T == null) {
|
|
this.T = new ArrayList();
|
|
}
|
|
this.T.add(onPageChangeListener);
|
|
}
|
|
|
|
private void b(boolean z) {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
getChildAt(i).setLayerType(z ? this.b0 : 0, null);
|
|
}
|
|
}
|
|
|
|
public void a(boolean z, PageTransformer pageTransformer) {
|
|
a(z, pageTransformer, 2);
|
|
}
|
|
|
|
public void a(boolean z, PageTransformer pageTransformer, int i) {
|
|
boolean z2 = pageTransformer != null;
|
|
boolean z3 = z2 != (this.a0 != null);
|
|
this.a0 = pageTransformer;
|
|
setChildrenDrawingOrderEnabled(z2);
|
|
if (z2) {
|
|
this.c0 = z ? 2 : 1;
|
|
this.b0 = i;
|
|
} else {
|
|
this.c0 = 0;
|
|
}
|
|
if (z3) {
|
|
e();
|
|
}
|
|
}
|
|
|
|
private boolean b(float f) {
|
|
boolean z;
|
|
boolean z2;
|
|
float f2 = this.D - f;
|
|
this.D = f;
|
|
float scrollX = getScrollX() + f2;
|
|
float clientWidth = getClientWidth();
|
|
float f3 = this.q * clientWidth;
|
|
float f4 = this.r * clientWidth;
|
|
boolean z3 = false;
|
|
ItemInfo itemInfo = this.b.get(0);
|
|
ArrayList<ItemInfo> arrayList = this.b;
|
|
ItemInfo itemInfo2 = arrayList.get(arrayList.size() - 1);
|
|
if (itemInfo.b != 0) {
|
|
f3 = itemInfo.e * clientWidth;
|
|
z = false;
|
|
} else {
|
|
z = true;
|
|
}
|
|
if (itemInfo2.b != this.e.getCount() - 1) {
|
|
f4 = itemInfo2.e * clientWidth;
|
|
z2 = false;
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
if (scrollX < f3) {
|
|
if (z) {
|
|
this.O.onPull(Math.abs(f3 - scrollX) / clientWidth);
|
|
z3 = true;
|
|
}
|
|
scrollX = f3;
|
|
} else if (scrollX > f4) {
|
|
if (z2) {
|
|
this.P.onPull(Math.abs(scrollX - f4) / clientWidth);
|
|
z3 = true;
|
|
}
|
|
scrollX = f4;
|
|
}
|
|
int i = (int) scrollX;
|
|
this.D += scrollX - i;
|
|
scrollTo(i, getScrollY());
|
|
f(i);
|
|
return z3;
|
|
}
|
|
|
|
float a(float f) {
|
|
return (float) Math.sin((f - 0.5f) * 0.47123894f);
|
|
}
|
|
|
|
void a(int i, int i2, int i3) {
|
|
int scrollX;
|
|
int abs;
|
|
if (getChildCount() == 0) {
|
|
setScrollingCacheEnabled(false);
|
|
return;
|
|
}
|
|
Scroller scroller = this.j;
|
|
if ((scroller == null || scroller.isFinished()) ? false : true) {
|
|
scrollX = this.k ? this.j.getCurrX() : this.j.getStartX();
|
|
this.j.abortAnimation();
|
|
setScrollingCacheEnabled(false);
|
|
} else {
|
|
scrollX = getScrollX();
|
|
}
|
|
int i4 = scrollX;
|
|
int scrollY = getScrollY();
|
|
int i5 = i - i4;
|
|
int i6 = i2 - scrollY;
|
|
if (i5 == 0 && i6 == 0) {
|
|
a(false);
|
|
e();
|
|
setScrollState(0);
|
|
return;
|
|
}
|
|
setScrollingCacheEnabled(true);
|
|
setScrollState(2);
|
|
int clientWidth = getClientWidth();
|
|
int i7 = clientWidth / 2;
|
|
float f = clientWidth;
|
|
float f2 = i7;
|
|
float a = f2 + (a(Math.min(1.0f, (Math.abs(i5) * 1.0f) / f)) * f2);
|
|
int abs2 = Math.abs(i3);
|
|
if (abs2 > 0) {
|
|
abs = Math.round(Math.abs(a / abs2) * 1000.0f) * 4;
|
|
} else {
|
|
abs = (int) (((Math.abs(i5) / ((f * this.e.getPageWidth(this.f)) + this.m)) + 1.0f) * 100.0f);
|
|
}
|
|
int min = Math.min(abs, 600);
|
|
this.k = false;
|
|
this.j.startScroll(i4, scrollY, i5, i6, min);
|
|
ViewCompat.A(this);
|
|
}
|
|
|
|
ItemInfo a(int i, int i2) {
|
|
ItemInfo itemInfo = new ItemInfo();
|
|
itemInfo.b = i;
|
|
itemInfo.a = this.e.instantiateItem((ViewGroup) this, i);
|
|
itemInfo.d = this.e.getPageWidth(i);
|
|
if (i2 >= 0 && i2 < this.b.size()) {
|
|
this.b.add(i2, itemInfo);
|
|
} else {
|
|
this.b.add(itemInfo);
|
|
}
|
|
return itemInfo;
|
|
}
|
|
|
|
private static boolean c(View view) {
|
|
return view.getClass().getAnnotation(DecorView.class) != null;
|
|
}
|
|
|
|
private void c(boolean z) {
|
|
ViewParent parent = getParent();
|
|
if (parent != null) {
|
|
parent.requestDisallowInterceptTouchEvent(z);
|
|
}
|
|
}
|
|
|
|
boolean c() {
|
|
int i = this.f;
|
|
if (i <= 0) {
|
|
return false;
|
|
}
|
|
a(i - 1, true);
|
|
return true;
|
|
}
|
|
|
|
void a() {
|
|
int count = this.e.getCount();
|
|
this.a = count;
|
|
boolean z = this.b.size() < (this.x * 2) + 1 && this.b.size() < count;
|
|
int i = this.f;
|
|
int i2 = 0;
|
|
boolean z2 = false;
|
|
while (i2 < this.b.size()) {
|
|
ItemInfo itemInfo = this.b.get(i2);
|
|
int itemPosition = this.e.getItemPosition(itemInfo.a);
|
|
if (itemPosition != -1) {
|
|
if (itemPosition == -2) {
|
|
this.b.remove(i2);
|
|
i2--;
|
|
if (!z2) {
|
|
this.e.startUpdate((ViewGroup) this);
|
|
z2 = true;
|
|
}
|
|
this.e.destroyItem((ViewGroup) this, itemInfo.b, itemInfo.a);
|
|
int i3 = this.f;
|
|
if (i3 == itemInfo.b) {
|
|
i = Math.max(0, Math.min(i3, count - 1));
|
|
}
|
|
} else {
|
|
int i4 = itemInfo.b;
|
|
if (i4 != itemPosition) {
|
|
if (i4 == this.f) {
|
|
i = itemPosition;
|
|
}
|
|
itemInfo.b = itemPosition;
|
|
}
|
|
}
|
|
z = true;
|
|
}
|
|
i2++;
|
|
}
|
|
if (z2) {
|
|
this.e.finishUpdate((ViewGroup) this);
|
|
}
|
|
Collections.sort(this.b, h0);
|
|
if (z) {
|
|
int childCount = getChildCount();
|
|
for (int i5 = 0; i5 < childCount; i5++) {
|
|
LayoutParams layoutParams = (LayoutParams) getChildAt(i5).getLayoutParams();
|
|
if (!layoutParams.a) {
|
|
layoutParams.c = 0.0f;
|
|
}
|
|
}
|
|
a(i, false, true);
|
|
requestLayout();
|
|
}
|
|
}
|
|
|
|
private void a(ItemInfo itemInfo, int i, ItemInfo itemInfo2) {
|
|
int i2;
|
|
int i3;
|
|
ItemInfo itemInfo3;
|
|
ItemInfo itemInfo4;
|
|
int count = this.e.getCount();
|
|
int clientWidth = getClientWidth();
|
|
float f = clientWidth > 0 ? this.m / clientWidth : 0.0f;
|
|
if (itemInfo2 != null) {
|
|
int i4 = itemInfo2.b;
|
|
int i5 = itemInfo.b;
|
|
if (i4 < i5) {
|
|
int i6 = 0;
|
|
float f2 = itemInfo2.e + itemInfo2.d + f;
|
|
while (true) {
|
|
i4++;
|
|
if (i4 > itemInfo.b || i6 >= this.b.size()) {
|
|
break;
|
|
}
|
|
ItemInfo itemInfo5 = this.b.get(i6);
|
|
while (true) {
|
|
itemInfo4 = itemInfo5;
|
|
if (i4 <= itemInfo4.b || i6 >= this.b.size() - 1) {
|
|
break;
|
|
}
|
|
i6++;
|
|
itemInfo5 = this.b.get(i6);
|
|
}
|
|
while (i4 < itemInfo4.b) {
|
|
f2 += this.e.getPageWidth(i4) + f;
|
|
i4++;
|
|
}
|
|
itemInfo4.e = f2;
|
|
f2 += itemInfo4.d + f;
|
|
}
|
|
} else if (i4 > i5) {
|
|
int size = this.b.size() - 1;
|
|
float f3 = itemInfo2.e;
|
|
while (true) {
|
|
i4--;
|
|
if (i4 < itemInfo.b || size < 0) {
|
|
break;
|
|
}
|
|
ItemInfo itemInfo6 = this.b.get(size);
|
|
while (true) {
|
|
itemInfo3 = itemInfo6;
|
|
if (i4 >= itemInfo3.b || size <= 0) {
|
|
break;
|
|
}
|
|
size--;
|
|
itemInfo6 = this.b.get(size);
|
|
}
|
|
while (i4 > itemInfo3.b) {
|
|
f3 -= this.e.getPageWidth(i4) + f;
|
|
i4--;
|
|
}
|
|
f3 -= itemInfo3.d + f;
|
|
itemInfo3.e = f3;
|
|
}
|
|
}
|
|
}
|
|
int size2 = this.b.size();
|
|
float f4 = itemInfo.e;
|
|
int i7 = itemInfo.b;
|
|
int i8 = i7 - 1;
|
|
this.q = i7 == 0 ? f4 : -3.4028235E38f;
|
|
int i9 = count - 1;
|
|
this.r = itemInfo.b == i9 ? (itemInfo.e + itemInfo.d) - 1.0f : Float.MAX_VALUE;
|
|
int i10 = i - 1;
|
|
while (i10 >= 0) {
|
|
ItemInfo itemInfo7 = this.b.get(i10);
|
|
while (true) {
|
|
i3 = itemInfo7.b;
|
|
if (i8 <= i3) {
|
|
break;
|
|
}
|
|
f4 -= this.e.getPageWidth(i8) + f;
|
|
i8--;
|
|
}
|
|
f4 -= itemInfo7.d + f;
|
|
itemInfo7.e = f4;
|
|
if (i3 == 0) {
|
|
this.q = f4;
|
|
}
|
|
i10--;
|
|
i8--;
|
|
}
|
|
float f5 = itemInfo.e + itemInfo.d + f;
|
|
int i11 = itemInfo.b + 1;
|
|
int i12 = i + 1;
|
|
while (i12 < size2) {
|
|
ItemInfo itemInfo8 = this.b.get(i12);
|
|
while (true) {
|
|
i2 = itemInfo8.b;
|
|
if (i11 >= i2) {
|
|
break;
|
|
}
|
|
f5 += this.e.getPageWidth(i11) + f;
|
|
i11++;
|
|
}
|
|
if (i2 == i9) {
|
|
this.r = (itemInfo8.d + f5) - 1.0f;
|
|
}
|
|
itemInfo8.e = f5;
|
|
f5 += itemInfo8.d + f;
|
|
i12++;
|
|
i11++;
|
|
}
|
|
}
|
|
|
|
ItemInfo a(View view) {
|
|
while (true) {
|
|
Object parent = view.getParent();
|
|
if (parent != this) {
|
|
if (parent == null || !(parent instanceof View)) {
|
|
return null;
|
|
}
|
|
view = (View) parent;
|
|
} else {
|
|
return b(view);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(int i, int i2, int i3, int i4) {
|
|
if (i2 > 0 && !this.b.isEmpty()) {
|
|
if (!this.j.isFinished()) {
|
|
this.j.setFinalX(getCurrentItem() * getClientWidth());
|
|
return;
|
|
} else {
|
|
scrollTo((int) ((getScrollX() / (((i2 - getPaddingLeft()) - getPaddingRight()) + i4)) * (((i - getPaddingLeft()) - getPaddingRight()) + i3)), getScrollY());
|
|
return;
|
|
}
|
|
}
|
|
ItemInfo b = b(this.f);
|
|
int min = (int) ((b != null ? Math.min(b.e, this.r) : 0.0f) * ((i - getPaddingLeft()) - getPaddingRight()));
|
|
if (min != getScrollX()) {
|
|
a(false);
|
|
scrollTo(min, getScrollY());
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:16:0x0066 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
protected void a(int r13, float r14, int r15) {
|
|
/*
|
|
r12 = this;
|
|
int r0 = r12.S
|
|
r1 = 0
|
|
r2 = 1
|
|
if (r0 <= 0) goto L6d
|
|
int r0 = r12.getScrollX()
|
|
int r3 = r12.getPaddingLeft()
|
|
int r4 = r12.getPaddingRight()
|
|
int r5 = r12.getWidth()
|
|
int r6 = r12.getChildCount()
|
|
r7 = r4
|
|
r4 = r3
|
|
r3 = 0
|
|
L1d:
|
|
if (r3 >= r6) goto L6d
|
|
android.view.View r8 = r12.getChildAt(r3)
|
|
android.view.ViewGroup$LayoutParams r9 = r8.getLayoutParams()
|
|
androidx.viewpager.widget.ViewPager$LayoutParams r9 = (androidx.viewpager.widget.ViewPager.LayoutParams) r9
|
|
boolean r10 = r9.a
|
|
if (r10 != 0) goto L2e
|
|
goto L6a
|
|
L2e:
|
|
int r9 = r9.b
|
|
r9 = r9 & 7
|
|
if (r9 == r2) goto L4f
|
|
r10 = 3
|
|
if (r9 == r10) goto L49
|
|
r10 = 5
|
|
if (r9 == r10) goto L3c
|
|
r9 = r4
|
|
goto L5e
|
|
L3c:
|
|
int r9 = r5 - r7
|
|
int r10 = r8.getMeasuredWidth()
|
|
int r9 = r9 - r10
|
|
int r10 = r8.getMeasuredWidth()
|
|
int r7 = r7 + r10
|
|
goto L5b
|
|
L49:
|
|
int r9 = r8.getWidth()
|
|
int r9 = r9 + r4
|
|
goto L5e
|
|
L4f:
|
|
int r9 = r8.getMeasuredWidth()
|
|
int r9 = r5 - r9
|
|
int r9 = r9 / 2
|
|
int r9 = java.lang.Math.max(r9, r4)
|
|
L5b:
|
|
r11 = r9
|
|
r9 = r4
|
|
r4 = r11
|
|
L5e:
|
|
int r4 = r4 + r0
|
|
int r10 = r8.getLeft()
|
|
int r4 = r4 - r10
|
|
if (r4 == 0) goto L69
|
|
r8.offsetLeftAndRight(r4)
|
|
L69:
|
|
r4 = r9
|
|
L6a:
|
|
int r3 = r3 + 1
|
|
goto L1d
|
|
L6d:
|
|
r12.b(r13, r14, r15)
|
|
androidx.viewpager.widget.ViewPager$PageTransformer r13 = r12.a0
|
|
if (r13 == 0) goto La1
|
|
int r13 = r12.getScrollX()
|
|
int r14 = r12.getChildCount()
|
|
L7c:
|
|
if (r1 >= r14) goto La1
|
|
android.view.View r15 = r12.getChildAt(r1)
|
|
android.view.ViewGroup$LayoutParams r0 = r15.getLayoutParams()
|
|
androidx.viewpager.widget.ViewPager$LayoutParams r0 = (androidx.viewpager.widget.ViewPager.LayoutParams) r0
|
|
boolean r0 = r0.a
|
|
if (r0 == 0) goto L8d
|
|
goto L9e
|
|
L8d:
|
|
int r0 = r15.getLeft()
|
|
int r0 = r0 - r13
|
|
float r0 = (float) r0
|
|
int r3 = r12.getClientWidth()
|
|
float r3 = (float) r3
|
|
float r0 = r0 / r3
|
|
androidx.viewpager.widget.ViewPager$PageTransformer r3 = r12.a0
|
|
r3.a(r15, r0)
|
|
L9e:
|
|
int r1 = r1 + 1
|
|
goto L7c
|
|
La1:
|
|
r12.R = r2
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.viewpager.widget.ViewPager.a(int, float, int):void");
|
|
}
|
|
|
|
private void a(boolean z) {
|
|
boolean z2 = this.f0 == 2;
|
|
if (z2) {
|
|
setScrollingCacheEnabled(false);
|
|
if (!this.j.isFinished()) {
|
|
this.j.abortAnimation();
|
|
int scrollX = getScrollX();
|
|
int scrollY = getScrollY();
|
|
int currX = this.j.getCurrX();
|
|
int currY = this.j.getCurrY();
|
|
if (scrollX != currX || scrollY != currY) {
|
|
scrollTo(currX, currY);
|
|
if (currX != scrollX) {
|
|
f(currX);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.v = false;
|
|
boolean z3 = z2;
|
|
for (int i = 0; i < this.b.size(); i++) {
|
|
ItemInfo itemInfo = this.b.get(i);
|
|
if (itemInfo.c) {
|
|
itemInfo.c = false;
|
|
z3 = true;
|
|
}
|
|
}
|
|
if (z3) {
|
|
if (z) {
|
|
ViewCompat.a(this, this.e0);
|
|
} else {
|
|
this.e0.run();
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean a(float f, float f2) {
|
|
return (f < ((float) this.B) && f2 > 0.0f) || (f > ((float) (getWidth() - this.B)) && f2 < 0.0f);
|
|
}
|
|
|
|
private int a(int i, float f, int i2, int i3) {
|
|
if (Math.abs(i3) <= this.L || Math.abs(i2) <= this.J) {
|
|
i += (int) (f + (i >= this.f ? 0.4f : 0.6f));
|
|
} else if (i2 <= 0) {
|
|
i++;
|
|
}
|
|
if (this.b.size() <= 0) {
|
|
return i;
|
|
}
|
|
return Math.max(this.b.get(0).b, Math.min(i, this.b.get(r4.size() - 1).b));
|
|
}
|
|
|
|
private void a(MotionEvent motionEvent) {
|
|
int actionIndex = motionEvent.getActionIndex();
|
|
if (motionEvent.getPointerId(actionIndex) == this.H) {
|
|
int i = actionIndex == 0 ? 1 : 0;
|
|
this.D = motionEvent.getX(i);
|
|
this.H = motionEvent.getPointerId(i);
|
|
VelocityTracker velocityTracker = this.I;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected boolean a(View view, boolean z, int i, int i2, int i3) {
|
|
int i4;
|
|
if (view instanceof ViewGroup) {
|
|
ViewGroup viewGroup = (ViewGroup) view;
|
|
int scrollX = view.getScrollX();
|
|
int scrollY = view.getScrollY();
|
|
for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) {
|
|
View childAt = viewGroup.getChildAt(childCount);
|
|
int i5 = i2 + scrollX;
|
|
if (i5 >= childAt.getLeft() && i5 < childAt.getRight() && (i4 = i3 + scrollY) >= childAt.getTop() && i4 < childAt.getBottom() && a(childAt, true, i, i5 - childAt.getLeft(), i4 - childAt.getTop())) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return z && view.canScrollHorizontally(-i);
|
|
}
|
|
|
|
public boolean a(KeyEvent keyEvent) {
|
|
if (keyEvent.getAction() == 0) {
|
|
int keyCode = keyEvent.getKeyCode();
|
|
if (keyCode == 21) {
|
|
if (keyEvent.hasModifiers(2)) {
|
|
return c();
|
|
}
|
|
return a(17);
|
|
}
|
|
if (keyCode == 22) {
|
|
if (keyEvent.hasModifiers(2)) {
|
|
return d();
|
|
}
|
|
return a(66);
|
|
}
|
|
if (keyCode == 61) {
|
|
if (keyEvent.hasNoModifiers()) {
|
|
return a(2);
|
|
}
|
|
if (keyEvent.hasModifiers(1)) {
|
|
return a(1);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean a(int i) {
|
|
boolean requestFocus;
|
|
boolean z;
|
|
View findFocus = findFocus();
|
|
boolean z2 = false;
|
|
View view = null;
|
|
if (findFocus != this) {
|
|
if (findFocus != null) {
|
|
ViewParent parent = findFocus.getParent();
|
|
while (true) {
|
|
if (!(parent instanceof ViewGroup)) {
|
|
z = false;
|
|
break;
|
|
}
|
|
if (parent == this) {
|
|
z = true;
|
|
break;
|
|
}
|
|
parent = parent.getParent();
|
|
}
|
|
if (!z) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(findFocus.getClass().getSimpleName());
|
|
for (ViewParent parent2 = findFocus.getParent(); parent2 instanceof ViewGroup; parent2 = parent2.getParent()) {
|
|
sb.append(" => ");
|
|
sb.append(parent2.getClass().getSimpleName());
|
|
}
|
|
Log.e("ViewPager", "arrowScroll tried to find focus based on non-child current focused view " + sb.toString());
|
|
}
|
|
}
|
|
view = findFocus;
|
|
}
|
|
View findNextFocus = FocusFinder.getInstance().findNextFocus(this, view, i);
|
|
if (findNextFocus != null && findNextFocus != view) {
|
|
if (i == 17) {
|
|
int i2 = a(this.d, findNextFocus).left;
|
|
int i3 = a(this.d, view).left;
|
|
if (view != null && i2 >= i3) {
|
|
requestFocus = c();
|
|
} else {
|
|
requestFocus = findNextFocus.requestFocus();
|
|
}
|
|
} else if (i == 66) {
|
|
int i4 = a(this.d, findNextFocus).left;
|
|
int i5 = a(this.d, view).left;
|
|
if (view != null && i4 <= i5) {
|
|
requestFocus = d();
|
|
} else {
|
|
requestFocus = findNextFocus.requestFocus();
|
|
}
|
|
}
|
|
z2 = requestFocus;
|
|
} else if (i == 17 || i == 1) {
|
|
z2 = c();
|
|
} else if (i == 66 || i == 2) {
|
|
z2 = d();
|
|
}
|
|
if (z2) {
|
|
playSoundEffect(SoundEffectConstants.getContantForFocusDirection(i));
|
|
}
|
|
return z2;
|
|
}
|
|
|
|
private Rect a(Rect rect, View view) {
|
|
if (rect == null) {
|
|
rect = new Rect();
|
|
}
|
|
if (view == null) {
|
|
rect.set(0, 0, 0, 0);
|
|
return rect;
|
|
}
|
|
rect.left = view.getLeft();
|
|
rect.right = view.getRight();
|
|
rect.top = view.getTop();
|
|
rect.bottom = view.getBottom();
|
|
ViewParent parent = view.getParent();
|
|
while ((parent instanceof ViewGroup) && parent != this) {
|
|
ViewGroup viewGroup = (ViewGroup) parent;
|
|
rect.left += viewGroup.getLeft();
|
|
rect.right += viewGroup.getRight();
|
|
rect.top += viewGroup.getTop();
|
|
rect.bottom += viewGroup.getBottom();
|
|
parent = viewGroup.getParent();
|
|
}
|
|
return rect;
|
|
}
|
|
}
|