|
@@ -50,7 +50,7 @@ import java.lang.ref.WeakReference;
|
|
|
* @createTime: 2020/9/27 14:50
|
|
|
*/
|
|
|
public class WaitDialog extends BaseDialog {
|
|
|
-
|
|
|
+
|
|
|
public static int overrideEnterDuration = -1;
|
|
|
public static int overrideExitDuration = -1;
|
|
|
public static int overrideEnterAnimRes = 0;
|
|
@@ -63,13 +63,13 @@ public class WaitDialog extends BaseDialog {
|
|
|
protected float backgroundRadius = -1;
|
|
|
protected DialogXAnimInterface<WaitDialog> dialogXAnimImpl;
|
|
|
protected OnBackPressedListener<WaitDialog> onBackPressedListener;
|
|
|
-
|
|
|
+
|
|
|
public enum TYPE {
|
|
|
/**
|
|
|
* @deprecated NONE 和 PROGRESSING 不建议使用,禁止使用此方法。
|
|
|
* 此类型等同于直接使用 WaitDialog,因此请勿使用 TipDialog 并指定使用 TYPE.NONE,
|
|
|
* 如有需要,请直接使用: WaitDialog.show(...)
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 要是用进度,请直接使用 WaitDialog.show(float)
|
|
|
*/
|
|
|
@Deprecated
|
|
@@ -80,7 +80,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
@Deprecated
|
|
|
PROGRESSING
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static WeakReference<WaitDialog> me;
|
|
|
protected CharSequence message;
|
|
|
protected long tipShowDuration = 1500;
|
|
@@ -89,24 +89,24 @@ public class WaitDialog extends BaseDialog {
|
|
|
protected TextInfo messageTextInfo;
|
|
|
protected int maskColor = -1;
|
|
|
protected BOOLEAN privateCancelable;
|
|
|
-
|
|
|
+
|
|
|
protected DialogLifecycleCallback<WaitDialog> dialogLifecycleCallback;
|
|
|
protected OnBackgroundMaskClickListener<WaitDialog> onBackgroundMaskClickListener;
|
|
|
-
|
|
|
+
|
|
|
protected WaitDialog() {
|
|
|
super();
|
|
|
cancelable = DialogX.cancelableTipDialog;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static WaitDialog instanceBuild() {
|
|
|
me = new WeakReference<>(new WaitDialog());
|
|
|
return me.get();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog build() {
|
|
|
return new WaitDialog();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(CharSequence message) {
|
|
|
boolean noInstance = noInstance();
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -114,7 +114,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
showWithInstance(noInstance);
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(Activity activity, CharSequence message) {
|
|
|
boolean noInstance = noInstance(activity);
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -123,7 +123,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
if (noInstance) showWithInstance(instance, activity);
|
|
|
return instance;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(int messageResId) {
|
|
|
boolean noInstance = noInstance();
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -131,7 +131,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
showWithInstance(noInstance);
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(Activity activity, int messageResId) {
|
|
|
boolean noInstance = noInstance(activity);
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -140,7 +140,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
if (noInstance) showWithInstance(instance, activity);
|
|
|
return instance;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(CharSequence message, float progress) {
|
|
|
boolean noInstance = noInstance();
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -149,7 +149,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
showWithInstance(noInstance);
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(Activity activity, CharSequence message, float progress) {
|
|
|
boolean noInstance = noInstance(activity);
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -159,7 +159,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
if (noInstance) showWithInstance(instance, activity);
|
|
|
return instance;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(int messageResId, float progress) {
|
|
|
boolean noInstance = noInstance();
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -168,7 +168,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
showWithInstance(noInstance);
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(Activity activity, int messageResId, float progress) {
|
|
|
boolean noInstance = noInstance(activity);
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -178,7 +178,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
if (noInstance) showWithInstance(instance, activity);
|
|
|
return instance;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(Activity activity, float progress) {
|
|
|
boolean noInstance = noInstance(activity);
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -188,7 +188,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
if (noInstance) showWithInstance(instance, activity);
|
|
|
return instance;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog show(float progress) {
|
|
|
boolean noInstance = noInstance();
|
|
|
if (noInstance) instanceBuild();
|
|
@@ -197,28 +197,28 @@ public class WaitDialog extends BaseDialog {
|
|
|
showWithInstance(noInstance);
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public float getProgress() {
|
|
|
return waitProgress;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setProgress(float waitProgress) {
|
|
|
this.waitProgress = waitProgress;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private WeakReference<View> dialogView;
|
|
|
-
|
|
|
+
|
|
|
protected View getWaitDialogView() {
|
|
|
if (dialogView == null) return null;
|
|
|
return dialogView.get();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void setWaitDialogView(View v) {
|
|
|
dialogView = new WeakReference<>(v);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog show() {
|
|
|
super.beforeShow();
|
|
|
runOnMain(new Runnable() {
|
|
@@ -240,7 +240,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
});
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog show(final Activity activity) {
|
|
|
super.beforeShow();
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
@@ -262,9 +262,9 @@ public class WaitDialog extends BaseDialog {
|
|
|
});
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected WeakReference<DialogImpl> dialogImpl;
|
|
|
-
|
|
|
+
|
|
|
public class DialogImpl implements DialogConvertViewInterface {
|
|
|
public DialogXBaseRelativeLayout boxRoot;
|
|
|
public MaxRelativeLayout bkg;
|
|
@@ -273,13 +273,13 @@ public class WaitDialog extends BaseDialog {
|
|
|
public ProgressViewInterface progressView;
|
|
|
public RelativeLayout boxCustomView;
|
|
|
public TextView txtInfo;
|
|
|
-
|
|
|
+
|
|
|
private int layoutResId;
|
|
|
-
|
|
|
+
|
|
|
public DialogImpl(int layoutResId) {
|
|
|
this.layoutResId = layoutResId;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void lazyCreate() {
|
|
|
View dialogView = createView(layoutResId);
|
|
|
if (dialogView == null) return;
|
|
@@ -300,7 +300,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
setDialogImpl(this);
|
|
|
refreshView();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public DialogImpl(View convertView) {
|
|
|
if (convertView == null) return;
|
|
|
boxRoot = convertView.findViewById(R.id.box_root);
|
|
@@ -319,18 +319,18 @@ public class WaitDialog extends BaseDialog {
|
|
|
setDialogImpl(this);
|
|
|
refreshView();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void init() {
|
|
|
if (messageTextInfo == null) messageTextInfo = DialogX.tipTextInfo;
|
|
|
if (backgroundColor == -1) backgroundColor = DialogX.tipBackgroundColor;
|
|
|
-
|
|
|
+
|
|
|
if (style.overrideWaitTipRes() == null) {
|
|
|
blurView.setRadiusPx(dip2px(15));
|
|
|
} else {
|
|
|
blurView.setRadiusPx(style.overrideWaitTipRes().overrideRadiusPx() < 0 ? dip2px(15) : style.overrideWaitTipRes().overrideRadiusPx());
|
|
|
}
|
|
|
boxRoot.setClickable(true);
|
|
|
-
|
|
|
+
|
|
|
boxRoot.setParentDialog(me());
|
|
|
boxRoot.setOnLifecycleCallBack(new DialogXBaseRelativeLayout.OnLifecycleCallBack() {
|
|
|
@Override
|
|
@@ -343,22 +343,22 @@ public class WaitDialog extends BaseDialog {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
if (getTopActivity() == null) return;
|
|
|
-
|
|
|
+
|
|
|
getDialogXAnimImpl().doShowAnim(WaitDialog.this, new ObjectRunnable<Float>() {
|
|
|
@Override
|
|
|
public void run(Float value) {
|
|
|
boxRoot.setBkgAlpha(value);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
onDialogShow();
|
|
|
getDialogLifecycleCallback().onShow(me());
|
|
|
-
|
|
|
+
|
|
|
lifecycle.setCurrentState(Lifecycle.State.RESUMED);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void onDismiss() {
|
|
|
isShow = false;
|
|
@@ -374,7 +374,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
System.gc();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
if (readyTipType != null) {
|
|
|
progressView.noLoading();
|
|
|
((View) progressView).postDelayed(new Runnable() {
|
|
@@ -384,7 +384,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
}, 100);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
boxRoot.setOnBackPressedListener(new DialogXBaseRelativeLayout.PrivateBackPressedListener() {
|
|
|
@Override
|
|
|
public boolean onBackPressed() {
|
|
@@ -402,20 +402,20 @@ public class WaitDialog extends BaseDialog {
|
|
|
});
|
|
|
onDialogInit();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private float oldProgress;
|
|
|
-
|
|
|
+
|
|
|
public void refreshView() {
|
|
|
if (boxRoot == null || getTopActivity() == null) {
|
|
|
return;
|
|
|
}
|
|
|
boxRoot.setRootPadding(screenPaddings[0], screenPaddings[1], screenPaddings[2], screenPaddings[3]);
|
|
|
-
|
|
|
+
|
|
|
bkg.setMaxWidth(getMaxWidth());
|
|
|
bkg.setMaxHeight(getMaxHeight());
|
|
|
bkg.setMinimumWidth(getMinWidth());
|
|
|
bkg.setMinimumHeight(getMinHeight());
|
|
|
-
|
|
|
+
|
|
|
if (style.overrideWaitTipRes() != null) {
|
|
|
int overrideBackgroundColorRes = style.overrideWaitTipRes().overrideBackgroundColorRes(isLightTheme());
|
|
|
if (overrideBackgroundColorRes == 0) {
|
|
@@ -445,7 +445,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
}
|
|
|
if (DialogX.tipProgressColor != -1) progressView.setColor(DialogX.tipProgressColor);
|
|
|
-
|
|
|
+
|
|
|
if (waitProgress >= 0 && waitProgress <= 1 && oldProgress != waitProgress) {
|
|
|
progressView.progress(waitProgress);
|
|
|
oldProgress = waitProgress;
|
|
@@ -464,14 +464,14 @@ public class WaitDialog extends BaseDialog {
|
|
|
bkg.setClipToOutline(true);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
showText(txtInfo, message);
|
|
|
useTextInfo(txtInfo, messageTextInfo);
|
|
|
-
|
|
|
+
|
|
|
if (maskColor != -1) {
|
|
|
boxRoot.setBackgroundColor(maskColor);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (onBindView != null && onBindView.getCustomView() != null) {
|
|
|
onBindView.bindParent(boxCustomView, WaitDialog.this);
|
|
|
boxCustomView.setVisibility(View.VISIBLE);
|
|
@@ -480,7 +480,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
boxCustomView.setVisibility(View.GONE);
|
|
|
boxProgress.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (bkgInterceptTouch) {
|
|
|
if (isCancelable()) {
|
|
|
boxRoot.setOnClickListener(new View.OnClickListener() {
|
|
@@ -499,11 +499,11 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
onDialogRefreshUI();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doDismiss(final View v) {
|
|
|
if (boxRoot == null) return;
|
|
|
if (getTopActivity() == null) return;
|
|
|
-
|
|
|
+
|
|
|
if (!dismissAnimFlag) {
|
|
|
dismissAnimFlag = true;
|
|
|
boxRoot.post(new Runnable() {
|
|
@@ -528,7 +528,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected DialogXAnimInterface<WaitDialog> getDialogXAnimImpl() {
|
|
|
if (dialogXAnimImpl == null) {
|
|
|
dialogXAnimImpl = new DialogXAnimInterface<WaitDialog>() {
|
|
@@ -552,7 +552,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
enterAnim.setDuration(enterAnimDurationTemp);
|
|
|
bkg.startAnimation(enterAnim);
|
|
|
-
|
|
|
+
|
|
|
ValueAnimator bkgAlpha = ValueAnimator.ofFloat(0f, 1f);
|
|
|
bkgAlpha.setDuration(enterAnimDurationTemp);
|
|
|
bkgAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
|
@@ -562,20 +562,20 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
});
|
|
|
bkgAlpha.start();
|
|
|
-
|
|
|
+
|
|
|
boxRoot.animate()
|
|
|
.setDuration(enterAnimDurationTemp)
|
|
|
.alpha(1f)
|
|
|
.setInterpolator(new DecelerateInterpolator())
|
|
|
.setListener(null);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void doExitAnim(WaitDialog dialog, ObjectRunnable<Float> animProgress) {
|
|
|
Context context = getTopActivity();
|
|
|
if (context == null) context = boxRoot.getContext();
|
|
|
if (context == null) return;
|
|
|
-
|
|
|
+
|
|
|
int exitAnimResId = R.anim.anim_dialogx_default_exit;
|
|
|
if (overrideExitAnimRes != 0) {
|
|
|
exitAnimResId = overrideExitAnimRes;
|
|
@@ -594,12 +594,12 @@ public class WaitDialog extends BaseDialog {
|
|
|
exitAnim.setDuration(exitAnimDurationTemp);
|
|
|
exitAnim.setInterpolator(new AccelerateInterpolator());
|
|
|
bkg.startAnimation(exitAnim);
|
|
|
-
|
|
|
+
|
|
|
boxRoot.animate()
|
|
|
.alpha(0f)
|
|
|
.setInterpolator(new AccelerateInterpolator())
|
|
|
.setDuration(exitAnimDurationTemp);
|
|
|
-
|
|
|
+
|
|
|
ValueAnimator bkgAlpha = ValueAnimator.ofFloat(1f, 0f);
|
|
|
bkgAlpha.setDuration(exitAnimDurationTemp);
|
|
|
bkgAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
|
@@ -614,7 +614,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
return dialogXAnimImpl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void showTip(final TYPE tip) {
|
|
|
runOnMain(new Runnable() {
|
|
|
@Override
|
|
@@ -635,7 +635,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
progressView.error();
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (boxProgress != null && boxProgress.getVisibility() == View.VISIBLE) {
|
|
|
//此事件是在完成衔接动画绘制后执行的逻辑
|
|
|
progressView.whenShowTick(new Runnable() {
|
|
@@ -673,16 +673,16 @@ public class WaitDialog extends BaseDialog {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void setDialogImpl(DialogImpl d) {
|
|
|
if (dialogImpl != null && dialogImpl.get() != d) dialogImpl = new WeakReference<>(d);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public String dialogKey() {
|
|
|
return getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean isLightTheme() {
|
|
|
if (DialogX.tipTheme == null) {
|
|
@@ -691,7 +691,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
return DialogX.tipTheme == DialogX.THEME.LIGHT;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void refreshUI() {
|
|
|
if (getDialogImpl() == null) return;
|
|
|
runOnMain(new Runnable() {
|
|
@@ -701,8 +701,9 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doDismiss() {
|
|
|
+ isShow = false;
|
|
|
runOnMain(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -712,16 +713,16 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void dismiss() {
|
|
|
me().doDismiss();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void dismiss(Activity activity) {
|
|
|
WaitDialog instance = getInstance(activity);
|
|
|
if (instance != null) instance.doDismiss();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static WaitDialog me() {
|
|
|
for (BaseDialog baseDialog : getRunningDialogList()) {
|
|
|
if (baseDialog instanceof WaitDialog) {
|
|
@@ -735,37 +736,37 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
return me.get();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected TYPE readyTipType;
|
|
|
-
|
|
|
+
|
|
|
protected void showTip(CharSequence message, TYPE type) {
|
|
|
showType = type.ordinal();
|
|
|
this.message = message;
|
|
|
readyTipType = type;
|
|
|
show();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void showTip(Activity activity, CharSequence message, TYPE type) {
|
|
|
showType = type.ordinal();
|
|
|
this.message = message;
|
|
|
readyTipType = type;
|
|
|
show(activity);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void showTip(int messageResId, TYPE type) {
|
|
|
showType = type.ordinal();
|
|
|
this.message = getString(messageResId);
|
|
|
readyTipType = type;
|
|
|
show();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void showTip(Activity activity, int messageResId, TYPE type) {
|
|
|
showType = type.ordinal();
|
|
|
this.message = getString(messageResId);
|
|
|
readyTipType = type;
|
|
|
show(activity);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void showTip(TYPE type) {
|
|
|
if (readyTipType == type) {
|
|
|
return;
|
|
@@ -776,44 +777,44 @@ public class WaitDialog extends BaseDialog {
|
|
|
getDialogImpl().showTip(type);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void setTip(TYPE type) {
|
|
|
showTip(type);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void setTip(CharSequence message, TYPE type) {
|
|
|
this.message = message;
|
|
|
showTip(type);
|
|
|
refreshUI();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void setTip(int messageResId, TYPE type) {
|
|
|
this.message = getString(messageResId);
|
|
|
showTip(type);
|
|
|
refreshUI();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected void setTipShowDuration(long tipShowDuration) {
|
|
|
this.tipShowDuration = tipShowDuration;
|
|
|
showTip(readyTipType);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static CharSequence getMessage() {
|
|
|
return me().message;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog setMessage(CharSequence message) {
|
|
|
me().preMessage(message);
|
|
|
me().refreshUI();
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog setMessage(int messageResId) {
|
|
|
me().preMessage(messageResId);
|
|
|
me().refreshUI();
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean isCancelable() {
|
|
|
if (privateCancelable != null) {
|
|
|
return privateCancelable == BOOLEAN.TRUE;
|
|
@@ -823,13 +824,13 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
return DialogX.cancelableTipDialog;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setCancelable(boolean cancelable) {
|
|
|
privateCancelable = cancelable ? BOOLEAN.TRUE : BOOLEAN.FALSE;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 用于从 WaitDialog 到 TipDialog 的消息设置
|
|
|
* 此方法不会立即执行,而是等到动画衔接完成后由事件设置
|
|
@@ -841,100 +842,100 @@ public class WaitDialog extends BaseDialog {
|
|
|
this.message = message;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected WaitDialog preMessage(int messageResId) {
|
|
|
this.message = getString(messageResId);
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public DialogLifecycleCallback<WaitDialog> getDialogLifecycleCallback() {
|
|
|
return dialogLifecycleCallback == null ? new DialogLifecycleCallback<WaitDialog>() {
|
|
|
} : dialogLifecycleCallback;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setDialogLifecycleCallback(DialogLifecycleCallback<WaitDialog> dialogLifecycleCallback) {
|
|
|
this.dialogLifecycleCallback = dialogLifecycleCallback;
|
|
|
if (isShow) dialogLifecycleCallback.onShow(me());
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public DialogImpl getDialogImpl() {
|
|
|
if (dialogImpl == null) return null;
|
|
|
return dialogImpl.get();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setCustomView(OnBindView<WaitDialog> onBindView) {
|
|
|
this.onBindView = onBindView;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public View getCustomView() {
|
|
|
if (onBindView == null) return null;
|
|
|
return onBindView.getCustomView();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog removeCustomView() {
|
|
|
this.onBindView.clean();
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public OnBackPressedListener<WaitDialog> getOnBackPressedListener() {
|
|
|
return (OnBackPressedListener<WaitDialog>) onBackPressedListener;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setOnBackPressedListener(OnBackPressedListener<WaitDialog> onBackPressedListener) {
|
|
|
this.onBackPressedListener = onBackPressedListener;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public int getBackgroundColor() {
|
|
|
return backgroundColor;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setBackgroundColor(@ColorInt int backgroundColor) {
|
|
|
this.backgroundColor = backgroundColor;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setBackgroundColorRes(@ColorRes int backgroundColorResId) {
|
|
|
this.backgroundColor = getColor(backgroundColorResId);
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMaskColor(@ColorInt int maskColor) {
|
|
|
this.maskColor = maskColor;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setEnterAnimDuration(long enterAnimDuration) {
|
|
|
this.enterAnimDuration = enterAnimDuration;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public long getExitAnimDuration() {
|
|
|
return exitAnimDuration;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setExitAnimDuration(long exitAnimDuration) {
|
|
|
this.exitAnimDuration = exitAnimDuration;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void restartDialog() {
|
|
|
refreshUI();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog getInstance() {
|
|
|
return me();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前 WaitDialog 显示状态
|
|
|
* <p>
|
|
@@ -950,37 +951,37 @@ public class WaitDialog extends BaseDialog {
|
|
|
public static int getType() {
|
|
|
return me().showType;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setAnimResId(int enterResId, int exitResId) {
|
|
|
customEnterAnimResId = enterResId;
|
|
|
customExitAnimResId = exitResId;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setEnterAnimResId(int enterResId) {
|
|
|
customEnterAnimResId = enterResId;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setExitAnimResId(int exitResId) {
|
|
|
customExitAnimResId = exitResId;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static boolean noInstance() {
|
|
|
- if (getTopActivity() != null && getTopActivity() instanceof Activity && getInstance((Activity) getTopActivity()) != null) {
|
|
|
+ if (getTopActivity() != null && getInstance((Activity) getTopActivity()) != null) {
|
|
|
return false;
|
|
|
}
|
|
|
- return me == null || me.get() == null || me.get().getOwnActivity() == null || me.get().getOwnActivity() != getTopActivity();
|
|
|
+ return me == null || me.get() == null || me.get().getOwnActivity() == null || me.get().getOwnActivity() != getTopActivity() || !me.get().isShow;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static boolean noInstance(Activity activity) {
|
|
|
if (getTopActivity() != null && getInstance(activity) != null) {
|
|
|
return false;
|
|
|
}
|
|
|
- return me == null || me.get() == null || me.get().getOwnActivity() == null || me.get().getOwnActivity() != activity;
|
|
|
+ return me == null || me.get() == null || me.get().getOwnActivity() == null || me.get().getOwnActivity() != activity || !me.get().isShow;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog getInstanceNotNull(Activity activity) {
|
|
|
for (BaseDialog baseDialog : getRunningDialogList()) {
|
|
|
if (baseDialog instanceof WaitDialog) {
|
|
@@ -991,7 +992,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
return instanceBuild();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static WaitDialog getInstance(Activity activity) {
|
|
|
for (BaseDialog baseDialog : getRunningDialogList()) {
|
|
|
if (baseDialog instanceof WaitDialog) {
|
|
@@ -1002,7 +1003,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static void showWithInstance(boolean noInstance) {
|
|
|
if (noInstance) {
|
|
|
me().show();
|
|
@@ -1010,7 +1011,7 @@ public class WaitDialog extends BaseDialog {
|
|
|
me().refreshUI();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected static void showWithInstance(WaitDialog instance, Activity activity) {
|
|
|
if (activity == null) {
|
|
|
instance.show();
|
|
@@ -1018,125 +1019,125 @@ public class WaitDialog extends BaseDialog {
|
|
|
instance.show(activity);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
protected void shutdown() {
|
|
|
dismiss();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMaxWidth(int maxWidth) {
|
|
|
this.maxWidth = maxWidth;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMaxHeight(int maxHeight) {
|
|
|
this.maxHeight = maxHeight;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMinHeight(int minHeight) {
|
|
|
this.minHeight = minHeight;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMinWidth(int minWidth) {
|
|
|
this.minWidth = minWidth;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setDialogImplMode(DialogX.IMPL_MODE dialogImplMode) {
|
|
|
this.dialogImplMode = dialogImplMode;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean isBkgInterceptTouch() {
|
|
|
return bkgInterceptTouch;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setBkgInterceptTouch(boolean bkgInterceptTouch) {
|
|
|
this.bkgInterceptTouch = bkgInterceptTouch;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public OnBackgroundMaskClickListener<WaitDialog> getOnBackgroundMaskClickListener() {
|
|
|
return onBackgroundMaskClickListener;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<WaitDialog> onBackgroundMaskClickListener) {
|
|
|
this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setStyle(DialogXStyle style) {
|
|
|
this.style = style;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setTheme(DialogX.THEME theme) {
|
|
|
this.theme = theme;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public TextInfo getMessageTextInfo() {
|
|
|
return messageTextInfo;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMessageTextInfo(TextInfo messageTextInfo) {
|
|
|
this.messageTextInfo = messageTextInfo;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMessageContent(CharSequence message) {
|
|
|
this.message = message;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setMessageContent(int messageResId) {
|
|
|
this.message = getString(messageResId);
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public CharSequence getMessageContent() {
|
|
|
return message;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setTipType(TYPE type) {
|
|
|
showTip(type);
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setRadius(float radiusPx) {
|
|
|
backgroundRadius = radiusPx;
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public float getRadius() {
|
|
|
return backgroundRadius;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public DialogXAnimInterface<WaitDialog> getDialogXAnimImpl() {
|
|
|
return dialogXAnimImpl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setDialogXAnimImpl(DialogXAnimInterface<WaitDialog> dialogXAnimImpl) {
|
|
|
this.dialogXAnimImpl = dialogXAnimImpl;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setRootPadding(int padding) {
|
|
|
this.screenPaddings = new int[]{padding, padding, padding, padding};
|
|
|
refreshUI();
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public WaitDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
|
|
|
this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
|
|
|
refreshUI();
|