package com.ubt.jimu.base.dialog; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.text.TextUtils; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; import android.widget.ImageView; import android.widget.TextView; import com.ubt.jimu.R; /* loaded from: classes.dex */ public class LoadingDialog extends Dialog { private ImageView imgLoading; private Activity mActivity; private RotateAnimation rotateAnimation; private TextView tvProgress; public LoadingDialog(Context context) { this(context, 0); } private void initView() { this.tvProgress = (TextView) findViewById(R.id.tvProgress); this.imgLoading = (ImageView) findViewById(R.id.imgLoading); } private void startAnimation() { RotateAnimation rotateAnimation = this.rotateAnimation; if (rotateAnimation != null) { rotateAnimation.cancel(); this.imgLoading.clearAnimation(); } this.rotateAnimation = new RotateAnimation(0.0f, 359.0f, 1, 0.5f, 1, 0.5f); this.rotateAnimation.setRepeatCount(-1); this.rotateAnimation.setDuration(800L); this.rotateAnimation.setInterpolator(new LinearInterpolator()); this.rotateAnimation.setRepeatMode(1); this.imgLoading.startAnimation(this.rotateAnimation); } @Override // android.app.Dialog, android.content.DialogInterface public void dismiss() { RotateAnimation rotateAnimation = this.rotateAnimation; if (rotateAnimation != null) { rotateAnimation.cancel(); } this.rotateAnimation = null; this.imgLoading.clearAnimation(); Activity activity = this.mActivity; if (activity == null || activity.isFinishing() || this.mActivity.isDestroyed()) { return; } super.dismiss(); } @Override // android.app.Dialog protected void onCreate(Bundle bundle) { super.onCreate(bundle); getWindow().requestFeature(1); setContentView(R.layout.dialog_loading); getWindow().setBackgroundDrawable(new ColorDrawable(0)); getWindow().setLayout(-1, -1); setCanceledOnTouchOutside(false); initView(); } @Override // android.app.Dialog public void show() { super.show(); startAnimation(); } public void updateProgress(String str) { TextView textView; if (TextUtils.isEmpty(str) || (textView = this.tvProgress) == null) { return; } textView.setText(str); } public LoadingDialog(Context context, boolean z, DialogInterface.OnCancelListener onCancelListener) { super(context, z, onCancelListener); this.mActivity = (Activity) context; } public LoadingDialog(Context context, int i) { super(context, i); this.mActivity = (Activity) context; } }