216 lines
7.6 KiB
Java
216 lines
7.6 KiB
Java
|
package me.relex.circleindicator;
|
||
|
|
||
|
import android.animation.Animator;
|
||
|
import android.animation.AnimatorInflater;
|
||
|
import android.content.Context;
|
||
|
import android.content.res.ColorStateList;
|
||
|
import android.content.res.TypedArray;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.util.TypedValue;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import android.view.animation.Interpolator;
|
||
|
import android.widget.LinearLayout;
|
||
|
import o.C15106ghN;
|
||
|
import o.ghP;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class BaseCircleIndicator extends LinearLayout {
|
||
|
private Animator a;
|
||
|
private Animator b;
|
||
|
private Animator c;
|
||
|
private Animator d;
|
||
|
protected int e;
|
||
|
private int f;
|
||
|
private int g;
|
||
|
private ColorStateList h;
|
||
|
private int i;
|
||
|
private IeS j;
|
||
|
private ColorStateList k;
|
||
|
private int n;
|
||
|
|
||
|
/* renamed from: o, reason: collision with root package name */
|
||
|
private int f8095o;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public interface IeS {
|
||
|
}
|
||
|
|
||
|
public BaseCircleIndicator(Context context) {
|
||
|
super(context);
|
||
|
this.g = -1;
|
||
|
this.f8095o = -1;
|
||
|
this.i = -1;
|
||
|
this.e = -1;
|
||
|
a(aDd_(context, null));
|
||
|
if (isInEditMode()) {
|
||
|
a(3, 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public BaseCircleIndicator(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
this.g = -1;
|
||
|
this.f8095o = -1;
|
||
|
this.i = -1;
|
||
|
this.e = -1;
|
||
|
a(aDd_(context, attributeSet));
|
||
|
if (isInEditMode()) {
|
||
|
a(3, 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public BaseCircleIndicator(Context context, AttributeSet attributeSet, int i) {
|
||
|
super(context, attributeSet, i);
|
||
|
this.g = -1;
|
||
|
this.f8095o = -1;
|
||
|
this.i = -1;
|
||
|
this.e = -1;
|
||
|
a(aDd_(context, attributeSet));
|
||
|
if (isInEditMode()) {
|
||
|
a(3, 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static C15106ghN aDd_(Context context, AttributeSet attributeSet) {
|
||
|
C15106ghN c15106ghN = new C15106ghN();
|
||
|
if (attributeSet == null) {
|
||
|
return c15106ghN;
|
||
|
}
|
||
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ghP.HBt.BaseCircleIndicator);
|
||
|
c15106ghN.i = obtainStyledAttributes.getDimensionPixelSize(ghP.HBt.BaseCircleIndicator_ci_width, -1);
|
||
|
c15106ghN.a = obtainStyledAttributes.getDimensionPixelSize(ghP.HBt.BaseCircleIndicator_ci_height, -1);
|
||
|
c15106ghN.g = obtainStyledAttributes.getDimensionPixelSize(ghP.HBt.BaseCircleIndicator_ci_margin, -1);
|
||
|
c15106ghN.e = obtainStyledAttributes.getResourceId(ghP.HBt.BaseCircleIndicator_ci_animator, ghP.Sts.scale_with_alpha);
|
||
|
c15106ghN.b = obtainStyledAttributes.getResourceId(ghP.HBt.BaseCircleIndicator_ci_animator_reverse, 0);
|
||
|
c15106ghN.d = obtainStyledAttributes.getResourceId(ghP.HBt.BaseCircleIndicator_ci_drawable, ghP.RVV.white_radius);
|
||
|
c15106ghN.f = obtainStyledAttributes.getResourceId(ghP.HBt.BaseCircleIndicator_ci_drawable_unselected, c15106ghN.d);
|
||
|
c15106ghN.j = obtainStyledAttributes.getInt(ghP.HBt.BaseCircleIndicator_ci_orientation, -1);
|
||
|
c15106ghN.c = obtainStyledAttributes.getInt(ghP.HBt.BaseCircleIndicator_ci_gravity, -1);
|
||
|
obtainStyledAttributes.recycle();
|
||
|
return c15106ghN;
|
||
|
}
|
||
|
|
||
|
public void a(C15106ghN c15106ghN) {
|
||
|
int applyDimension = (int) (TypedValue.applyDimension(1, 5.0f, getResources().getDisplayMetrics()) + 0.5f);
|
||
|
this.f8095o = c15106ghN.i < 0 ? applyDimension : c15106ghN.i;
|
||
|
this.i = c15106ghN.a < 0 ? applyDimension : c15106ghN.a;
|
||
|
if (c15106ghN.g >= 0) {
|
||
|
applyDimension = c15106ghN.g;
|
||
|
}
|
||
|
this.g = applyDimension;
|
||
|
this.b = AnimatorInflater.loadAnimator(getContext(), c15106ghN.e);
|
||
|
Animator loadAnimator = AnimatorInflater.loadAnimator(getContext(), c15106ghN.e);
|
||
|
this.d = loadAnimator;
|
||
|
loadAnimator.setDuration(0L);
|
||
|
this.c = aDe_(c15106ghN);
|
||
|
Animator aDe_ = aDe_(c15106ghN);
|
||
|
this.a = aDe_;
|
||
|
aDe_.setDuration(0L);
|
||
|
this.f = c15106ghN.d == 0 ? ghP.RVV.white_radius : c15106ghN.d;
|
||
|
this.n = c15106ghN.f == 0 ? c15106ghN.d : c15106ghN.f;
|
||
|
setOrientation(c15106ghN.j != 1 ? 0 : 1);
|
||
|
setGravity(c15106ghN.c >= 0 ? c15106ghN.c : 17);
|
||
|
}
|
||
|
|
||
|
private Animator aDe_(C15106ghN c15106ghN) {
|
||
|
if (c15106ghN.b == 0) {
|
||
|
Animator loadAnimator = AnimatorInflater.loadAnimator(getContext(), c15106ghN.e);
|
||
|
loadAnimator.setInterpolator(new RVV());
|
||
|
return loadAnimator;
|
||
|
}
|
||
|
return AnimatorInflater.loadAnimator(getContext(), c15106ghN.b);
|
||
|
}
|
||
|
|
||
|
public void a(int i, int i2) {
|
||
|
if (this.d.isRunning()) {
|
||
|
this.d.end();
|
||
|
this.d.cancel();
|
||
|
}
|
||
|
if (this.a.isRunning()) {
|
||
|
this.a.end();
|
||
|
this.a.cancel();
|
||
|
}
|
||
|
int childCount = getChildCount();
|
||
|
if (i < childCount) {
|
||
|
removeViews(i, childCount - i);
|
||
|
} else if (i > childCount) {
|
||
|
int orientation = getOrientation();
|
||
|
for (int i3 = 0; i3 < i - childCount; i3++) {
|
||
|
View view = new View(getContext());
|
||
|
LinearLayout.LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams();
|
||
|
((ViewGroup.LayoutParams) generateDefaultLayoutParams).width = this.f8095o;
|
||
|
((ViewGroup.LayoutParams) generateDefaultLayoutParams).height = this.i;
|
||
|
if (orientation == 0) {
|
||
|
((ViewGroup.MarginLayoutParams) generateDefaultLayoutParams).leftMargin = this.g;
|
||
|
((ViewGroup.MarginLayoutParams) generateDefaultLayoutParams).rightMargin = this.g;
|
||
|
} else {
|
||
|
((ViewGroup.MarginLayoutParams) generateDefaultLayoutParams).topMargin = this.g;
|
||
|
((ViewGroup.MarginLayoutParams) generateDefaultLayoutParams).bottomMargin = this.g;
|
||
|
}
|
||
|
addView(view, generateDefaultLayoutParams);
|
||
|
}
|
||
|
}
|
||
|
for (int i4 = 0; i4 < i; i4++) {
|
||
|
View childAt = getChildAt(i4);
|
||
|
if (i2 == i4) {
|
||
|
childAt.setBackgroundResource(this.f);
|
||
|
this.d.setTarget(childAt);
|
||
|
this.d.start();
|
||
|
this.d.end();
|
||
|
} else {
|
||
|
childAt.setBackgroundResource(this.n);
|
||
|
this.a.setTarget(childAt);
|
||
|
this.a.start();
|
||
|
this.a.end();
|
||
|
}
|
||
|
}
|
||
|
this.e = i2;
|
||
|
}
|
||
|
|
||
|
public void b(int i) {
|
||
|
View childAt;
|
||
|
if (this.e == i) {
|
||
|
return;
|
||
|
}
|
||
|
if (this.c.isRunning()) {
|
||
|
this.c.end();
|
||
|
this.c.cancel();
|
||
|
}
|
||
|
if (this.b.isRunning()) {
|
||
|
this.b.end();
|
||
|
this.b.cancel();
|
||
|
}
|
||
|
int i2 = this.e;
|
||
|
if (i2 >= 0 && (childAt = getChildAt(i2)) != null) {
|
||
|
childAt.setBackgroundResource(this.n);
|
||
|
this.c.setTarget(childAt);
|
||
|
this.c.start();
|
||
|
}
|
||
|
View childAt2 = getChildAt(i);
|
||
|
if (childAt2 != null) {
|
||
|
childAt2.setBackgroundResource(this.f);
|
||
|
this.b.setTarget(childAt2);
|
||
|
this.b.start();
|
||
|
}
|
||
|
this.e = i;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static class RVV implements Interpolator {
|
||
|
protected RVV() {
|
||
|
}
|
||
|
|
||
|
@Override // android.animation.TimeInterpolator
|
||
|
public final float getInterpolation(float f) {
|
||
|
return Math.abs(1.0f - f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setIndicatorCreatedListener(IeS ieS) {
|
||
|
this.j = ieS;
|
||
|
}
|
||
|
}
|