package androidx.recyclerview.widget; import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; import androidx.recyclerview.widget.RecyclerView; /* loaded from: classes.dex */ public abstract class OrientationHelper { protected final RecyclerView.LayoutManager a; private int b; final Rect c; public static OrientationHelper a(RecyclerView.LayoutManager layoutManager, int i) { if (i == 0) { return a(layoutManager); } if (i == 1) { return b(layoutManager); } throw new IllegalArgumentException("invalid orientation"); } public static OrientationHelper b(RecyclerView.LayoutManager layoutManager) { return new OrientationHelper(layoutManager) { // from class: androidx.recyclerview.widget.OrientationHelper.2 @Override // androidx.recyclerview.widget.OrientationHelper public int a() { return this.a.h(); } @Override // androidx.recyclerview.widget.OrientationHelper public int b() { return this.a.h() - this.a.n(); } @Override // androidx.recyclerview.widget.OrientationHelper public int c(View view) { RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams(); return this.a.h(view) + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int d(View view) { return this.a.j(view) - ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).topMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int e(View view) { this.a.a(view, true, this.c); return this.c.bottom; } @Override // androidx.recyclerview.widget.OrientationHelper public int f() { return this.a.q(); } @Override // androidx.recyclerview.widget.OrientationHelper public int g() { return (this.a.h() - this.a.q()) - this.a.n(); } @Override // androidx.recyclerview.widget.OrientationHelper public void a(int i) { this.a.f(i); } @Override // androidx.recyclerview.widget.OrientationHelper public int b(View view) { RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams(); return this.a.g(view) + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int f(View view) { this.a.a(view, true, this.c); return this.c.top; } @Override // androidx.recyclerview.widget.OrientationHelper public int a(View view) { return this.a.e(view) + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).bottomMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int c() { return this.a.n(); } @Override // androidx.recyclerview.widget.OrientationHelper public int d() { return this.a.i(); } @Override // androidx.recyclerview.widget.OrientationHelper public int e() { return this.a.s(); } }; } public abstract int a(); public abstract int a(View view); public abstract void a(int i); public abstract int b(); public abstract int b(View view); public abstract int c(); public abstract int c(View view); public abstract int d(); public abstract int d(View view); public abstract int e(); public abstract int e(View view); public abstract int f(); public abstract int f(View view); public abstract int g(); public int h() { if (Integer.MIN_VALUE == this.b) { return 0; } return g() - this.b; } public void i() { this.b = g(); } private OrientationHelper(RecyclerView.LayoutManager layoutManager) { this.b = Integer.MIN_VALUE; this.c = new Rect(); this.a = layoutManager; } public static OrientationHelper a(RecyclerView.LayoutManager layoutManager) { return new OrientationHelper(layoutManager) { // from class: androidx.recyclerview.widget.OrientationHelper.1 @Override // androidx.recyclerview.widget.OrientationHelper public int a() { return this.a.r(); } @Override // androidx.recyclerview.widget.OrientationHelper public int b() { return this.a.r() - this.a.p(); } @Override // androidx.recyclerview.widget.OrientationHelper public int c(View view) { RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams(); return this.a.g(view) + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int d(View view) { return this.a.f(view) - ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).leftMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int e(View view) { this.a.a(view, true, this.c); return this.c.right; } @Override // androidx.recyclerview.widget.OrientationHelper public int f() { return this.a.o(); } @Override // androidx.recyclerview.widget.OrientationHelper public int g() { return (this.a.r() - this.a.o()) - this.a.p(); } @Override // androidx.recyclerview.widget.OrientationHelper public void a(int i) { this.a.e(i); } @Override // androidx.recyclerview.widget.OrientationHelper public int b(View view) { RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams(); return this.a.h(view) + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int f(View view) { this.a.a(view, true, this.c); return this.c.left; } @Override // androidx.recyclerview.widget.OrientationHelper public int a(View view) { return this.a.i(view) + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).rightMargin; } @Override // androidx.recyclerview.widget.OrientationHelper public int c() { return this.a.p(); } @Override // androidx.recyclerview.widget.OrientationHelper public int d() { return this.a.s(); } @Override // androidx.recyclerview.widget.OrientationHelper public int e() { return this.a.i(); } }; } }