package com.ubt.jimu.widgets; import android.app.Activity; import android.graphics.drawable.AnimationDrawable; import android.view.View; import android.view.WindowManager; import android.widget.CheckBox; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView; import com.ubt.jimu.JimuApplication; import com.ubt.jimu.R; import com.ubt.jimu.base.entities.Constant; import com.ubt.jimu.utils.LogUtils; import com.ubt.jimu.utils.SPUtils; import com.ubtech.utils.XLog; 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 UploadPopupWindow implements View.OnClickListener { private PopupWindow a; private OnClickListener b; private final RelativeLayout c; private final RelativeLayout d; private final LinearLayout e; private final TextView f; private final RelativeLayout g; private final SweepGradientCircleProgressBar h; private final CheckBox i; private final TextView j; private final TextView k; private final TextView l; private ImageView m; private ImageView n; private ImageView o; private UploadState p; private Activity q; /* renamed from: com.ubt.jimu.widgets.UploadPopupWindow$5, reason: invalid class name */ static /* synthetic */ class AnonymousClass5 { static final /* synthetic */ int[] a = new int[UploadState.values().length]; static { try { a[UploadState.UPLOAD_FAILURE.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { a[UploadState.UPLOAD_SUCCEED.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { a[UploadState.UPLOADING_PROGRESS.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { a[UploadState.SAVE_DRAFT.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } public interface OnClickListener { void G(); void O(); void R(); void e0(); } public enum UploadState { UPLOAD_SUCCEED, UPLOAD_FAILURE, UPLOADING_PROGRESS, STORAGE_SUCCEED, STORAGE_PROGRESS, SAVE_DRAFT } public UploadPopupWindow(Activity activity) { this.q = activity; View inflate = View.inflate(activity, R.layout.upload_popup_layout, null); this.a = new PopupWindow(inflate, -1, -1); this.a.setOutsideTouchable(false); this.a.setTouchable(true); this.a.setAnimationStyle(R.style.popupWindow_anim_shop); ((TextView) inflate.findViewById(R.id.tv_upload_back)).setOnClickListener(this); ((TextView) inflate.findViewById(R.id.tv_upload_continue)).setOnClickListener(this); ((TextView) inflate.findViewById(R.id.tv_upload_got)).setOnClickListener(this); this.c = (RelativeLayout) inflate.findViewById(R.id.ll_upload_failure); this.o = (ImageView) inflate.findViewById(R.id.im_publish_failure); this.d = (RelativeLayout) inflate.findViewById(R.id.ll_upload_succeed_hint); this.m = (ImageView) inflate.findViewById(R.id.im_upload_succeed); this.n = (ImageView) inflate.findViewById(R.id.im_upload_succeed_2); this.j = (TextView) inflate.findViewById(R.id.tv_upload_succeed); this.k = (TextView) inflate.findViewById(R.id.tv_succeed_title); this.i = (CheckBox) inflate.findViewById(R.id.cb_upload_hint); this.e = (LinearLayout) inflate.findViewById(R.id.ll_upload_succeed); this.f = (TextView) inflate.findViewById(R.id.tv_upload_cancel); this.f.setOnClickListener(this); this.g = (RelativeLayout) inflate.findViewById(R.id.ll_upload_progress); this.h = (SweepGradientCircleProgressBar) inflate.findViewById(R.id.pro_upload_view); this.l = (TextView) inflate.findViewById(R.id.tv_update_des); a(activity); WindowManager.LayoutParams attributes = activity.getWindow().getAttributes(); attributes.alpha = 0.3f; activity.getWindow().addFlags(2); activity.getWindow().setAttributes(attributes); } @Override // android.view.View.OnClickListener public void onClick(View view) { switch (view.getId()) { case R.id.tv_upload_back /* 2131297829 */: a(); break; case R.id.tv_upload_cancel /* 2131297830 */: a(); OnClickListener onClickListener = this.b; if (onClickListener != null) { onClickListener.O(); break; } break; case R.id.tv_upload_continue /* 2131297831 */: OnClickListener onClickListener2 = this.b; if (onClickListener2 != null) { onClickListener2.e0(); break; } break; case R.id.tv_upload_got /* 2131297833 */: a(); if (this.p == UploadState.SAVE_DRAFT) { SPUtils.a(Constant.Publish.SAVE_DRAFT_SUCCEED_DHINT_KEY, this.i.isChecked()); } else { SPUtils.a(Constant.Publish.SUCCEED_HINT_KEY, this.i.isChecked()); } LogUtils.c("I got it"); OnClickListener onClickListener3 = this.b; if (onClickListener3 != null) { if (this.p != UploadState.SAVE_DRAFT) { onClickListener3.G(); break; } else { onClickListener3.R(); break; } } break; } } private void b(String str) { this.j.setText(str); } private void d() { this.q.runOnUiThread(new Runnable() { // from class: com.ubt.jimu.widgets.UploadPopupWindow.2 @Override // java.lang.Runnable public void run() { UploadPopupWindow.this.c.setVisibility(0); UploadPopupWindow.this.d.setVisibility(8); UploadPopupWindow.this.e.setVisibility(8); UploadPopupWindow.this.g.setVisibility(8); ((AnimationDrawable) UploadPopupWindow.this.o.getBackground()).start(); } }); } private void e() { this.c.setVisibility(8); this.d.setVisibility(8); this.e.setVisibility(8); this.g.setVisibility(0); } public void a(String str) { this.l.setText(str); } public boolean c() { return this.a.isShowing(); } private void a(final Activity activity) { this.a.setOnDismissListener(new PopupWindow.OnDismissListener(this) { // from class: com.ubt.jimu.widgets.UploadPopupWindow.1 @Override // android.widget.PopupWindow.OnDismissListener public void onDismiss() { WindowManager.LayoutParams attributes = activity.getWindow().getAttributes(); attributes.alpha = 1.0f; activity.getWindow().clearFlags(2); activity.getWindow().setAttributes(attributes); } }); } public int b() { return this.h.getMax(); } public void a(View view, UploadState uploadState) { int i = AnonymousClass5.a[uploadState.ordinal()]; if (i == 1) { d(); } else if (i == 2) { a(uploadState); } else if (i == 3) { e(); } else if (i != 4) { XLog.b("upload", "unknown upload state : %d", uploadState); } else { a(uploadState); } if (this.a.isShowing()) { return; } this.a.showAtLocation(view, 80, 0, 0); } public void b(int i) { this.h.setProgress(i); } private void a(UploadState uploadState) { boolean a = SPUtils.a(Constant.Publish.SUCCEED_HINT_KEY); boolean a2 = SPUtils.a(Constant.Publish.SAVE_DRAFT_SUCCEED_DHINT_KEY); if (a && uploadState == UploadState.UPLOAD_SUCCEED) { this.c.setVisibility(8); this.d.setVisibility(8); this.e.setVisibility(0); this.g.setVisibility(8); ((AnimationDrawable) this.n.getBackground()).start(); Observable.timer(1500L, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer() { // from class: com.ubt.jimu.widgets.UploadPopupWindow.3 @Override // io.reactivex.functions.Consumer /* renamed from: a, reason: merged with bridge method [inline-methods] */ public void accept(Long l) throws Exception { UploadPopupWindow.this.a(); if (UploadPopupWindow.this.b != null) { UploadPopupWindow.this.b.G(); UploadPopupWindow.this.n.clearAnimation(); } } }); return; } if (!a && uploadState == UploadState.UPLOAD_SUCCEED) { this.c.setVisibility(8); this.d.setVisibility(0); b(JimuApplication.l().getResources().getString(R.string.upload_completed) + ". " + JimuApplication.l().getResources().getString(R.string.upload_completed_des)); this.e.setVisibility(8); this.g.setVisibility(8); ((AnimationDrawable) this.m.getBackground()).start(); return; } if (a2 && uploadState == UploadState.SAVE_DRAFT) { this.k.setText(JimuApplication.l().getResources().getString(R.string.save_draft)); this.p = UploadState.SAVE_DRAFT; this.c.setVisibility(8); this.d.setVisibility(8); this.e.setVisibility(0); this.g.setVisibility(8); ((AnimationDrawable) this.n.getBackground()).start(); Observable.timer(1500L, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer() { // from class: com.ubt.jimu.widgets.UploadPopupWindow.4 @Override // io.reactivex.functions.Consumer /* renamed from: a, reason: merged with bridge method [inline-methods] */ public void accept(Long l) throws Exception { UploadPopupWindow.this.a(); if (UploadPopupWindow.this.b == null || UploadPopupWindow.this.p != UploadState.SAVE_DRAFT) { return; } UploadPopupWindow.this.b.R(); } }); return; } b(JimuApplication.l().getResources().getString(R.string.save_draft) + ". " + JimuApplication.l().getResources().getString(R.string.save_succeed)); this.p = UploadState.SAVE_DRAFT; this.c.setVisibility(8); this.d.setVisibility(0); this.e.setVisibility(8); this.g.setVisibility(8); ((AnimationDrawable) this.m.getBackground()).start(); } public void a() { this.a.dismiss(); } public void a(int i) { this.h.setMax(i); } public void a(OnClickListener onClickListener) { this.b = onClickListener; } }