package com.ubt.jimu.widgets; import android.animation.Animator; import android.animation.ObjectAnimator; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import com.ubt.jimu.R; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; import java.util.concurrent.TimeUnit; /* loaded from: classes2.dex */ public class LoadStateView extends RelativeLayout { private Context a; private View b; private ImageView c; private ImageView d; private TextView e; private RelativeLayout f; private RetryListener g; /* renamed from: com.ubt.jimu.widgets.LoadStateView$6, reason: invalid class name */ static /* synthetic */ class AnonymousClass6 { static final /* synthetic */ int[] a = new int[LoadState.values().length]; static { try { a[LoadState.LOADING.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { a[LoadState.SUCCEED.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { a[LoadState.FAILURE.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { a[LoadState.EMPTY.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } public enum LoadState { LOADING, SUCCEED, FAILURE, EMPTY } public interface RetryListener { void p0(); } public LoadStateView(Context context) { super(context); this.a = context; d(); b(); c(); } private void b() { } private void e() { this.b.setVisibility(0); Observable.timer(500L, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer() { // from class: com.ubt.jimu.widgets.LoadStateView.3 @Override // io.reactivex.functions.Consumer /* renamed from: a, reason: merged with bridge method [inline-methods] */ public void accept(Long l) throws Exception { LoadStateView.this.e.setText(R.string.loading_error); LoadStateView.this.c.setVisibility(8); LoadStateView.this.c.clearAnimation(); LoadStateView.this.d.setVisibility(0); LoadStateView.this.d.setBackgroundResource(R.drawable.ic_network_error); } }); } private void f() { if (this.c.getVisibility() == 8) { this.b.setVisibility(0); this.c.setVisibility(0); this.d.setVisibility(4); this.e.setText(R.string.loading_text); a(this.c); } } public void setLoadViewBackColor(int i) { this.b.setBackgroundColor(this.a.getResources().getColor(i)); } public void setRetryListener(RetryListener retryListener) { this.g = retryListener; } public void setTextColor(int i) { this.e.setTextColor(this.a.getResources().getColor(i)); } /* JADX INFO: Access modifiers changed from: private */ public void b(final View view) { ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.0f); ofFloat.setDuration(500L); ofFloat.addListener(new Animator.AnimatorListener() { // from class: com.ubt.jimu.widgets.LoadStateView.5 @Override // android.animation.Animator.AnimatorListener public void onAnimationCancel(Animator animator) { } @Override // android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { LoadStateView.this.c.clearAnimation(); LoadStateView.this.c.setVisibility(8); view.setVisibility(8); } @Override // android.animation.Animator.AnimatorListener public void onAnimationRepeat(Animator animator) { } @Override // android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { } }); ofFloat.start(); } private void c() { this.f.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.widgets.LoadStateView.1 @Override // android.view.View.OnClickListener public void onClick(View view) { if (LoadStateView.this.g != null) { LoadStateView.this.g.p0(); } } }); } private void d() { this.b = View.inflate(this.a, R.layout.layout_loading_view, this); this.b.setVisibility(8); this.c = (ImageView) this.b.findViewById(R.id.im_loading); this.c.setVisibility(8); this.d = (ImageView) this.b.findViewById(R.id.im_load_state); this.e = (TextView) this.b.findViewById(R.id.tv_load_state_des); this.f = (RelativeLayout) this.b.findViewById(R.id.rl_re); } public void a(LoadState loadState) { int i = AnonymousClass6.a[loadState.ordinal()]; if (i == 1) { f(); return; } if (i == 2) { a(this.b); } else if (i == 3) { e(); } else { if (i != 4) { return; } a(); } } public LoadStateView(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.a = context; d(); b(); c(); } private void a() { this.b.setVisibility(0); Observable.timer(500L, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer() { // from class: com.ubt.jimu.widgets.LoadStateView.2 @Override // io.reactivex.functions.Consumer /* renamed from: a, reason: merged with bridge method [inline-methods] */ public void accept(Long l) throws Exception { LoadStateView.this.e.setText(R.string.loading_service_error); LoadStateView.this.c.setVisibility(8); LoadStateView.this.c.clearAnimation(); LoadStateView.this.d.setVisibility(0); LoadStateView.this.d.setBackgroundResource(R.drawable.ic_try_reload); } }); } private void a(final View view) { Observable.timer(500L, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer() { // from class: com.ubt.jimu.widgets.LoadStateView.4 @Override // io.reactivex.functions.Consumer /* renamed from: a, reason: merged with bridge method [inline-methods] */ public void accept(Long l) throws Exception { LoadStateView.this.b(view); } }); } private void a(ImageView imageView) { Animation loadAnimation = AnimationUtils.loadAnimation(this.a, R.anim.rotate_anim); loadAnimation.setInterpolator(new LinearInterpolator()); if (loadAnimation != null) { imageView.startAnimation(loadAnimation); } } }