package xyz.stream.view.refresh.footer;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import xyz.stream.view.R;
import xyz.stream.view.refresh.drawable.ProgressDrawable;
import xyz.stream.view.refresh.layout.api.RefreshFooter;
import xyz.stream.view.refresh.layout.api.RefreshLayout;
import xyz.stream.view.refresh.layout.constant.RefreshState;
import xyz.stream.view.refresh.layout.constant.SpinnerStyle;
import xyz.stream.view.refresh.layout.util.AutoUtil;

/* JADX INFO: loaded from: classes3.dex */
public class ClassicsFooter extends ClassicsAbstract<ClassicsFooter> implements RefreshFooter {
    public static String REFRESH_FOOTER_FAILED;
    public static String REFRESH_FOOTER_FINISH;
    public static String REFRESH_FOOTER_LOADING;
    public static String REFRESH_FOOTER_NOTHING;
    public static String REFRESH_FOOTER_PULLING;
    public static String REFRESH_FOOTER_REFRESHING;
    public static String REFRESH_FOOTER_RELEASE;
    protected boolean mNoMoreData;
    protected String mTextFailed;
    protected String mTextFinish;
    protected String mTextLoading;
    protected String mTextNothing;
    protected String mTextPulling;
    protected String mTextRefreshing;
    protected String mTextRelease;

    /* JADX INFO: renamed from: xyz.stream.view.refresh.footer.ClassicsFooter$1, reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final /* synthetic */ int[] f36560a;

        static {
            int[] iArr = new int[RefreshState.values().length];
            f36560a = iArr;
            try {
                iArr[RefreshState.None.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f36560a[RefreshState.PullUpToLoad.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f36560a[RefreshState.Loading.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f36560a[RefreshState.LoadReleased.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f36560a[RefreshState.ReleaseToLoad.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f36560a[RefreshState.Refreshing.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    public ClassicsFooter(Context context) {
        this(context, null);
    }

    @Override // xyz.stream.view.refresh.footer.ClassicsAbstract, xyz.stream.view.refresh.layout.simple.SimpleComponent, xyz.stream.view.refresh.layout.api.RefreshComponent
    public int onFinish(@NonNull RefreshLayout refreshLayout, boolean z10) {
        super.onFinish(refreshLayout, z10);
        if (this.mNoMoreData) {
            return 0;
        }
        if (z10) {
            TextView textView = this.mTitleText;
            String str = this.mTextFinish;
            textView.setText(str != null ? str : "");
        } else {
            TextView textView2 = this.mTitleText;
            String str2 = this.mTextFailed;
            textView2.setText(str2 != null ? str2 : "");
        }
        return this.mFinishDuration;
    }

    @Override // xyz.stream.view.refresh.layout.simple.SimpleComponent, xyz.stream.view.refresh.layout.listener.OnStateChangedListener
    public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState refreshState, @NonNull RefreshState refreshState2) {
        ImageView imageView = this.mArrowView;
        if (this.mNoMoreData) {
            return;
        }
        switch (AnonymousClass1.f36560a[refreshState2.ordinal()]) {
            case 1:
                imageView.setVisibility(0);
                break;
            case 2:
                break;
            case 3:
            case 4:
                imageView.setVisibility(8);
                TextView textView = this.mTitleText;
                String str = this.mTextLoading;
                textView.setText(str != null ? str : "");
                return;
            case 5:
                TextView textView2 = this.mTitleText;
                String str2 = this.mTextRelease;
                textView2.setText(str2 != null ? str2 : "");
                imageView.animate().rotation(0.0f);
                return;
            case 6:
                TextView textView3 = this.mTitleText;
                String str3 = this.mTextRefreshing;
                textView3.setText(str3 != null ? str3 : "");
                imageView.setVisibility(8);
                return;
            default:
                return;
        }
        TextView textView4 = this.mTitleText;
        String str4 = this.mTextPulling;
        textView4.setText(str4 != null ? str4 : "");
        imageView.animate().rotation(180.0f);
    }

    @Override // xyz.stream.view.refresh.layout.simple.SimpleComponent, xyz.stream.view.refresh.layout.api.RefreshFooter
    public boolean setNoMoreData(boolean z10) {
        if (this.mNoMoreData == z10) {
            return true;
        }
        this.mNoMoreData = z10;
        ImageView imageView = this.mArrowView;
        if (z10) {
            TextView textView = this.mTitleText;
            String str = this.mTextNothing;
            textView.setText(str != null ? str : "");
            imageView.setVisibility(8);
            return true;
        }
        TextView textView2 = this.mTitleText;
        String str2 = this.mTextPulling;
        textView2.setText(str2 != null ? str2 : "");
        imageView.setVisibility(0);
        return true;
    }

    public void setNoMoreText(String str) {
        this.mTextNothing = str;
    }

    @Override // xyz.stream.view.refresh.footer.ClassicsAbstract, xyz.stream.view.refresh.layout.simple.SimpleComponent, xyz.stream.view.refresh.layout.api.RefreshComponent
    @Deprecated
    public void setPrimaryColors(@ColorInt int... iArr) {
        if (this.mSpinnerStyle == SpinnerStyle.FixedBehind) {
            super.setPrimaryColors(iArr);
        }
    }

    public ClassicsFooter(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, 0);
        this.mNoMoreData = false;
        View.inflate(context, R.layout.srl_classics_footer, this);
        ImageView imageView = (ImageView) findViewById(R.id.srl_classics_arrow);
        this.mArrowView = imageView;
        ImageView imageView2 = (ImageView) findViewById(R.id.srl_classics_progress);
        this.mProgressView = imageView2;
        this.mTitleText = (TextView) findViewById(R.id.srl_classics_title);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ClassicsFooter);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) imageView2.getLayoutParams();
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(R.styleable.ClassicsFooter_srlDrawableMarginRight, AutoUtil.dp2px(20.0f));
        layoutParams2.rightMargin = dimensionPixelSize;
        layoutParams.rightMargin = dimensionPixelSize;
        int i10 = R.styleable.ClassicsFooter_srlDrawableArrowSize;
        layoutParams.width = typedArrayObtainStyledAttributes.getLayoutDimension(i10, layoutParams.width);
        layoutParams.height = typedArrayObtainStyledAttributes.getLayoutDimension(i10, layoutParams.height);
        int i11 = R.styleable.ClassicsFooter_srlDrawableProgressSize;
        layoutParams2.width = typedArrayObtainStyledAttributes.getLayoutDimension(i11, layoutParams2.width);
        layoutParams2.height = typedArrayObtainStyledAttributes.getLayoutDimension(i11, layoutParams2.height);
        int i12 = R.styleable.ClassicsFooter_srlDrawableSize;
        layoutParams.width = typedArrayObtainStyledAttributes.getLayoutDimension(i12, layoutParams.width);
        layoutParams.height = typedArrayObtainStyledAttributes.getLayoutDimension(i12, layoutParams.height);
        layoutParams2.width = typedArrayObtainStyledAttributes.getLayoutDimension(i12, layoutParams2.width);
        layoutParams2.height = typedArrayObtainStyledAttributes.getLayoutDimension(i12, layoutParams2.height);
        this.mFinishDuration = typedArrayObtainStyledAttributes.getInt(R.styleable.ClassicsFooter_srlFinishDuration, this.mFinishDuration);
        this.mSpinnerStyle = SpinnerStyle.values[typedArrayObtainStyledAttributes.getInt(R.styleable.ClassicsFooter_srlClassicsSpinnerStyle, this.mSpinnerStyle.ordinal)];
        int i13 = R.styleable.ClassicsFooter_srlDrawableArrow;
        if (typedArrayObtainStyledAttributes.hasValue(i13)) {
            this.mArrowView.setImageDrawable(typedArrayObtainStyledAttributes.getDrawable(i13));
        } else {
            this.mArrowView.getDrawable();
        }
        int i14 = R.styleable.ClassicsFooter_srlDrawableProgress;
        if (typedArrayObtainStyledAttributes.hasValue(i14)) {
            this.mProgressView.setImageDrawable(typedArrayObtainStyledAttributes.getDrawable(i14));
        } else if (this.mProgressView.getDrawable() == null) {
            ProgressDrawable progressDrawable = new ProgressDrawable();
            this.mProgressDrawable = progressDrawable;
            progressDrawable.setColor(-10066330);
            this.mProgressView.setImageDrawable(this.mProgressDrawable);
        }
        if (typedArrayObtainStyledAttributes.hasValue(R.styleable.ClassicsFooter_srlTextSizeTitle)) {
            this.mTitleText.setTextSize(0, typedArrayObtainStyledAttributes.getDimensionPixelSize(r8, AutoUtil.dp2px(16.0f)));
        }
        int i15 = R.styleable.ClassicsFooter_srlAccentColor;
        if (typedArrayObtainStyledAttributes.hasValue(i15)) {
            super.setAccentColor(typedArrayObtainStyledAttributes.getColor(i15, 0));
        }
        int i16 = R.styleable.ClassicsFooter_srlTextPulling;
        if (typedArrayObtainStyledAttributes.hasValue(i16)) {
            this.mTextPulling = typedArrayObtainStyledAttributes.getString(i16);
        } else {
            String str = REFRESH_FOOTER_PULLING;
            if (str != null) {
                this.mTextPulling = str;
            } else {
                this.mTextPulling = null;
            }
        }
        int i17 = R.styleable.ClassicsFooter_srlTextRelease;
        if (typedArrayObtainStyledAttributes.hasValue(i17)) {
            this.mTextRelease = typedArrayObtainStyledAttributes.getString(i17);
        } else {
            String str2 = REFRESH_FOOTER_RELEASE;
            if (str2 != null) {
                this.mTextRelease = str2;
            } else {
                this.mTextRelease = null;
            }
        }
        int i18 = R.styleable.ClassicsFooter_srlTextLoading;
        if (typedArrayObtainStyledAttributes.hasValue(i18)) {
            this.mTextLoading = typedArrayObtainStyledAttributes.getString(i18);
        } else {
            String str3 = REFRESH_FOOTER_LOADING;
            if (str3 != null) {
                this.mTextLoading = str3;
            } else {
                this.mTextLoading = null;
            }
        }
        int i19 = R.styleable.ClassicsFooter_srlTextRefreshing;
        if (typedArrayObtainStyledAttributes.hasValue(i19)) {
            this.mTextRefreshing = typedArrayObtainStyledAttributes.getString(i19);
        } else {
            String str4 = REFRESH_FOOTER_REFRESHING;
            if (str4 != null) {
                this.mTextRefreshing = str4;
            } else {
                this.mTextRefreshing = null;
            }
        }
        int i20 = R.styleable.ClassicsFooter_srlTextFinish;
        if (typedArrayObtainStyledAttributes.hasValue(i20)) {
            this.mTextFinish = typedArrayObtainStyledAttributes.getString(i20);
        } else {
            String str5 = REFRESH_FOOTER_FINISH;
            if (str5 != null) {
                this.mTextFinish = str5;
            } else {
                this.mTextFinish = null;
            }
        }
        int i21 = R.styleable.ClassicsFooter_srlTextFailed;
        if (typedArrayObtainStyledAttributes.hasValue(i21)) {
            this.mTextFailed = typedArrayObtainStyledAttributes.getString(i21);
        } else {
            String str6 = REFRESH_FOOTER_FAILED;
            if (str6 != null) {
                this.mTextFailed = str6;
            } else {
                this.mTextFailed = null;
            }
        }
        int i22 = R.styleable.ClassicsFooter_srlTextNothing;
        if (typedArrayObtainStyledAttributes.hasValue(i22)) {
            this.mTextNothing = typedArrayObtainStyledAttributes.getString(i22);
        } else {
            String str7 = REFRESH_FOOTER_NOTHING;
            if (str7 != null) {
                this.mTextNothing = str7;
            } else {
                this.mTextNothing = null;
            }
        }
        typedArrayObtainStyledAttributes.recycle();
        if (isInEditMode()) {
            TextView textView = this.mTitleText;
            String str8 = this.mTextLoading;
            textView.setText(str8 != null ? str8 : "");
        } else {
            TextView textView2 = this.mTitleText;
            String str9 = this.mTextPulling;
            textView2.setText(str9 != null ? str9 : "");
        }
        if (isInEditMode()) {
            imageView.setVisibility(8);
        } else {
            imageView2.setVisibility(8);
        }
    }
}
