Commit 757f8a973d7a3fc34fdf789fab0be6bdfbd5ca9d
1 parent
46a9e528
1 优化QmuiDialogUtil
Showing
12 changed files
with
137 additions
and
67 deletions
app/strike/src/main/java/com/cnlive/strike/LoginSuccessActivity.java
| ... | ... | @@ -9,8 +9,6 @@ import com.alibaba.android.arouter.facade.annotation.Autowired; |
| 9 | 9 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 10 | 10 | import com.alibaba.android.arouter.launcher.ARouter; |
| 11 | 11 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 12 | -import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 13 | -import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; | |
| 14 | 12 | import com.cnlive.strike.user.auth.UserService; |
| 15 | 13 | import com.cnlive.strike.user.model.LoginSuccessInfo; |
| 16 | 14 | import com.cnlive.strike.user.ui.activity.FirstLoginActivity; |
| ... | ... | @@ -48,8 +46,6 @@ public class LoginSuccessActivity extends BaseActivity { |
| 48 | 46 | private void initAction() { |
| 49 | 47 | switch (eventType) { |
| 50 | 48 | case UserRouterHelper.SHOW_MAIN_VIEW://显示主界面 |
| 51 | -// CommonInfo.setUserInfo(this, UserService.getUid(this), UserService.getInstance(this).getAppAccount().getNickName(), UserService.getInstance(this).getAppAccount().getFaceUrl(), UserService.getInstance(this).getAppAccount().getMobile()); | |
| 52 | -// RunLineActivity.newInstance(this, null, null, null, null); | |
| 53 | 49 | startActivity(new Intent(me, PersonalDataActivity.class)); |
| 54 | 50 | finish(); |
| 55 | 51 | break; | ... | ... |
app/strike/src/main/java/com/cnlive/strike/demo/activity/DemoFragment.java deleted
100644 → 0
| 1 | -package com.cnlive.strike.demo.activity; | |
| 2 | - | |
| 3 | -import android.os.Handler; | |
| 4 | - | |
| 5 | -import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | |
| 6 | -import com.cnlive.core.libs.base.util.QMUITipDialogUtil; | |
| 7 | - | |
| 8 | -import java.util.Observable; | |
| 9 | - | |
| 10 | -public class DemoFragment extends BaseFragment { | |
| 11 | - | |
| 12 | - @Override | |
| 13 | - protected void initView() { | |
| 14 | - super.initView(); | |
| 15 | - addObservable(MyOb.getInstance()); | |
| 16 | - Handler handler = getMyFragHandler(); | |
| 17 | - handler.postDelayed(new Runnable() { | |
| 18 | - @Override | |
| 19 | - public void run() { | |
| 20 | - MyOb.getInstance().noti("我是你"); | |
| 21 | - } | |
| 22 | - }, 3000); | |
| 23 | - } | |
| 24 | - @Override | |
| 25 | - public void update(Observable o, Object data) { | |
| 26 | - super.update(o, data); | |
| 27 | - if (data instanceof String) { | |
| 28 | - QMUITipDialogUtil.successDialog(me, (String) data, 3); | |
| 29 | - } | |
| 30 | - } | |
| 31 | -} |
app/strike/src/main/java/com/cnlive/strike/demo/activity/DemoMvpActivity.java
| ... | ... | @@ -11,6 +11,7 @@ import androidx.annotation.NonNull; |
| 11 | 11 | |
| 12 | 12 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 13 | 13 | import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; |
| 14 | +import com.cnlive.core.libs.base.util.AlertUtil; | |
| 14 | 15 | import com.cnlive.core.libs.base.util.QMUITipDialogUtil; |
| 15 | 16 | import com.cnlive.moudle.collectionTrace.ui.activity.RaceListActivity; |
| 16 | 17 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| ... | ... | @@ -148,7 +149,7 @@ public class DemoMvpActivity extends BaseActivity<DemoActivityView, DemoActivity |
| 148 | 149 | binding.btnObser.setOnClickListener(new View.OnClickListener() { |
| 149 | 150 | @Override |
| 150 | 151 | public void onClick(View v) { |
| 151 | - addObservable(MyOb.getInstance(),MyOb.getInstance(),MyOb.getInstance()); | |
| 152 | + addObservable(MyOb.getInstance(), MyOb.getInstance(), MyOb.getInstance()); | |
| 152 | 153 | MyOb.getInstance().noti("观察者信息"); |
| 153 | 154 | } |
| 154 | 155 | }); |
| ... | ... | @@ -297,8 +298,10 @@ public class DemoMvpActivity extends BaseActivity<DemoActivityView, DemoActivity |
| 297 | 298 | @Override |
| 298 | 299 | public void update(Observable o, Object data) { |
| 299 | 300 | super.update(o, data); |
| 300 | - if (o instanceof MyOb){ | |
| 301 | - QMUITipDialogUtil.textDialog(me, (String) data, 2); | |
| 301 | + if (o instanceof MyOb) { | |
| 302 | +// AlertUtil.showDeftToast(getBaseContext(),(String) data); | |
| 303 | + QMUITipDialogUtil.loadingDialog(me, (String) data); | |
| 304 | +// QMUITipDialogUtil.textDialog(me, (String) data, 2); | |
| 302 | 305 | } |
| 303 | 306 | } |
| 304 | 307 | } | ... | ... |
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
| ... | ... | @@ -224,7 +224,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 224 | 224 | |
| 225 | 225 | @Override |
| 226 | 226 | public void update(Observable o, Object data) { |
| 227 | - | |
| 227 | + if (null == getMvpView()) { | |
| 228 | + return; | |
| 229 | + } | |
| 228 | 230 | } |
| 229 | 231 | |
| 230 | 232 | /** |
| ... | ... | @@ -492,9 +494,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 492 | 494 | @Override |
| 493 | 495 | protected void onDestroy() { |
| 494 | 496 | super.onDestroy(); |
| 495 | - mDelegate.onDestroy(); | |
| 496 | 497 | //删除观察者 |
| 497 | 498 | deleteObservable(); |
| 499 | + mDelegate.onDestroy(); | |
| 498 | 500 | if (null != baseBinding) { |
| 499 | 501 | baseBinding.unbind(); |
| 500 | 502 | } |
| ... | ... | @@ -673,7 +675,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 673 | 675 | public void requestPermission(String[] permissions, OnPermissionResponseListener |
| 674 | 676 | onPermissionResponseListener) { |
| 675 | 677 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 676 | - this.userSetPermission=permissions; | |
| 678 | + this.userSetPermission = permissions; | |
| 677 | 679 | if (checkPermissions(permissions)) { |
| 678 | 680 | if (onPermissionResponseListener != null) { |
| 679 | 681 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -688,7 +690,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 688 | 690 | onPermissionResponseListener) { |
| 689 | 691 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 690 | 692 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 691 | - this.userSetPermission=permissions; | |
| 693 | + this.userSetPermission = permissions; | |
| 692 | 694 | if (checkPermissions(permissions)) { |
| 693 | 695 | if (onPermissionResponseListener != null) { |
| 694 | 696 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -713,7 +715,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 713 | 715 | onPermissionResponseListener) { |
| 714 | 716 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 715 | 717 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 716 | - this.userSetPermission=permissions; | |
| 718 | + this.userSetPermission = permissions; | |
| 717 | 719 | if (checkPermissions(permissions)) { |
| 718 | 720 | if (onPermissionResponseListener != null) { |
| 719 | 721 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -729,7 +731,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 729 | 731 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 730 | 732 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 731 | 733 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 732 | - this.userSetPermission=permissions; | |
| 734 | + this.userSetPermission = permissions; | |
| 733 | 735 | if (checkPermissions(permissions)) { |
| 734 | 736 | if (onPermissionResponseListener != null) { |
| 735 | 737 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -796,7 +798,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 796 | 798 | onPermissionResponseListener) { |
| 797 | 799 | this.userSetDefinePermissionTip = defineTip; |
| 798 | 800 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 799 | - this.userSetPermission=permissions; | |
| 801 | + this.userSetPermission = permissions; | |
| 800 | 802 | if (checkPermissions(permissions)) { |
| 801 | 803 | if (onPermissionResponseListener != null) { |
| 802 | 804 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -812,7 +814,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 812 | 814 | this.userSetDefinePermissionTip = defineTip; |
| 813 | 815 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 814 | 816 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 815 | - this.userSetPermission=permissions; | |
| 817 | + this.userSetPermission = permissions; | |
| 816 | 818 | if (checkPermissions(permissions)) { |
| 817 | 819 | if (onPermissionResponseListener != null) { |
| 818 | 820 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -835,7 +837,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 835 | 837 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 836 | 838 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 837 | 839 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 838 | - this.userSetPermission=permissions; | |
| 840 | + this.userSetPermission = permissions; | |
| 839 | 841 | if (checkPermissions(permissions)) { |
| 840 | 842 | if (onPermissionResponseListener != null) { |
| 841 | 843 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -852,7 +854,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 852 | 854 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 853 | 855 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 854 | 856 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 855 | - this.userSetPermission=permissions; | |
| 857 | + this.userSetPermission = permissions; | |
| 856 | 858 | if (checkPermissions(permissions)) { |
| 857 | 859 | if (onPermissionResponseListener != null) { |
| 858 | 860 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -874,7 +876,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 874 | 876 | permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 875 | 877 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 876 | 878 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 877 | - this.userSetPermission=permissions; | |
| 879 | + this.userSetPermission = permissions; | |
| 878 | 880 | if (checkPermissions(permissions)) { |
| 879 | 881 | if (onPermissionResponseListener != null) { |
| 880 | 882 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -890,7 +892,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 890 | 892 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 891 | 893 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 892 | 894 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 893 | - this.userSetPermission=permissions; | |
| 895 | + this.userSetPermission = permissions; | |
| 894 | 896 | if (checkPermissions(permissions)) { |
| 895 | 897 | if (onPermissionResponseListener != null) { |
| 896 | 898 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -914,7 +916,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 914 | 916 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 915 | 917 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 916 | 918 | this.userSetDefinePermissionTip = defineTip; |
| 917 | - this.userSetPermission=permissions; | |
| 919 | + this.userSetPermission = permissions; | |
| 918 | 920 | if (checkPermissions(permissions)) { |
| 919 | 921 | if (onPermissionResponseListener != null) { |
| 920 | 922 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -932,7 +934,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 932 | 934 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 933 | 935 | this.userSetDefinePermissionTip = defineTip; |
| 934 | 936 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 935 | - this.userSetPermission=permissions; | |
| 937 | + this.userSetPermission = permissions; | |
| 936 | 938 | if (checkPermissions(permissions)) { |
| 937 | 939 | if (onPermissionResponseListener != null) { |
| 938 | 940 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -955,7 +957,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 955 | 957 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 956 | 958 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 957 | 959 | this.userSetDefinePermissionTip = defineTip; |
| 958 | - this.userSetPermission=permissions; | |
| 960 | + this.userSetPermission = permissions; | |
| 959 | 961 | if (checkPermissions(permissions)) { |
| 960 | 962 | if (onPermissionResponseListener != null) { |
| 961 | 963 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -972,7 +974,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 972 | 974 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 973 | 975 | this.userSetDefinePermissionTip = defineTip; |
| 974 | 976 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 975 | - this.userSetPermission=permissions; | |
| 977 | + this.userSetPermission = permissions; | |
| 976 | 978 | if (checkPermissions(permissions)) { |
| 977 | 979 | if (onPermissionResponseListener != null) { |
| 978 | 980 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -997,7 +999,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 997 | 999 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 998 | 1000 | this.userSetDefinePermissionTip = getResources().getString(defineTip); |
| 999 | 1001 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 1000 | - this.userSetPermission=permissions; | |
| 1002 | + this.userSetPermission = permissions; | |
| 1001 | 1003 | if (checkPermissions(permissions)) { |
| 1002 | 1004 | if (onPermissionResponseListener != null) { |
| 1003 | 1005 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -1015,7 +1017,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 1015 | 1017 | this.userSetDefinePermissionTip = getResources().getString(defineTip); |
| 1016 | 1018 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| 1017 | 1019 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 1018 | - this.userSetPermission=permissions; | |
| 1020 | + this.userSetPermission = permissions; | |
| 1019 | 1021 | if (checkPermissions(permissions)) { |
| 1020 | 1022 | if (onPermissionResponseListener != null) { |
| 1021 | 1023 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -1039,7 +1041,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 1039 | 1041 | this.onPermissionResponseListener = onPermissionResponseListener; |
| 1040 | 1042 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 1041 | 1043 | this.userSetDefinePermissionTip = getResources().getString(defineTip); |
| 1042 | - this.userSetPermission=permissions; | |
| 1044 | + this.userSetPermission = permissions; | |
| 1043 | 1045 | if (checkPermissions(permissions)) { |
| 1044 | 1046 | if (onPermissionResponseListener != null) { |
| 1045 | 1047 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -1056,7 +1058,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 1056 | 1058 | this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; |
| 1057 | 1059 | this.userSetDefinePermissionTip = getResources().getString(defineTip); |
| 1058 | 1060 | this.isShowRefuseDialog = isShowRefuseDialog; |
| 1059 | - this.userSetPermission=permissions; | |
| 1061 | + this.userSetPermission = permissions; | |
| 1060 | 1062 | if (checkPermissions(permissions)) { |
| 1061 | 1063 | if (onPermissionResponseListener != null) { |
| 1062 | 1064 | onPermissionResponseListener.onSuccess(permissions); |
| ... | ... | @@ -1214,6 +1216,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 1214 | 1216 | * 显示提示对话框 |
| 1215 | 1217 | */ |
| 1216 | 1218 | private void showTipsDialog() { |
| 1219 | + if (null == getMvpView()) { | |
| 1220 | + return; | |
| 1221 | + } | |
| 1217 | 1222 | String tip = ""; |
| 1218 | 1223 | if (TextUtils.isEmpty(userSetDefinePermissionTip)) { |
| 1219 | 1224 | tip = defaultDefinePermissionTip; |
| ... | ... | @@ -1571,6 +1576,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V |
| 1571 | 1576 | } |
| 1572 | 1577 | |
| 1573 | 1578 | |
| 1579 | + | |
| 1574 | 1580 | /** |
| 1575 | 1581 | * 显示fragment栈视图 |
| 1576 | 1582 | */ | ... | ... |
core/base/src/main/java/com/cnlive/core/libs/base/util/QMUITipDialogUtil.java
| 1 | 1 | package com.cnlive.core.libs.base.util; |
| 2 | 2 | |
| 3 | +import android.app.Activity; | |
| 3 | 4 | import android.content.Context; |
| 4 | 5 | import android.os.Handler; |
| 6 | +import android.util.Log; | |
| 5 | 7 | |
| 6 | 8 | import androidx.appcompat.app.AppCompatActivity; |
| 7 | 9 | |
| ... | ... | @@ -15,13 +17,47 @@ import java.lang.ref.WeakReference; |
| 15 | 17 | * 创建日期: 2018/10/22 18:51 |
| 16 | 18 | * 描 述: |
| 17 | 19 | * 修 改 人: |
| 18 | - * 修改时间: | |
| 20 | + * 修改时间:2019/12/4 | |
| 19 | 21 | * 修改备注: |
| 20 | 22 | */ |
| 21 | 23 | public class QMUITipDialogUtil { |
| 22 | 24 | private static QMUITipDialog tipDialog; |
| 23 | 25 | private static WeakReference<Context> currentContext; |
| 26 | + private static Handler handler = new Handler(); | |
| 27 | + /** | |
| 28 | + * Loading 类型提示框 | |
| 29 | + * | |
| 30 | + * @param context | |
| 31 | + * @param tipStr | |
| 32 | + */ | |
| 33 | + public static void loadingDialog(Context context, String tipStr) { | |
| 34 | + try { | |
| 35 | + if (context instanceof Activity) { | |
| 36 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 37 | + return; | |
| 38 | + } | |
| 39 | + } | |
| 40 | + currentContext = new WeakReference<>(context); | |
| 41 | + if (currentContext == null) { | |
| 42 | + return; | |
| 43 | + } | |
| 44 | + if (tipDialog != null && tipDialog.isShowing()) { | |
| 45 | + tipDialog.dismiss(); | |
| 46 | + } | |
| 47 | + tipDialog = new QMUITipDialog.Builder(currentContext.get()) | |
| 48 | + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) | |
| 49 | + .setTipWord(tipStr) | |
| 50 | + .create(); | |
| 51 | + tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键 | |
| 52 | + tipDialog.setCancelable(true); | |
| 53 | + if (!tipDialog.isShowing()) { | |
| 54 | + tipDialog.show(); | |
| 55 | + } | |
| 56 | + } catch (Exception e) { | |
| 57 | + | |
| 58 | + } | |
| 24 | 59 | |
| 60 | + } | |
| 25 | 61 | /** |
| 26 | 62 | * Loading 类型提示框 |
| 27 | 63 | * |
| ... | ... | @@ -30,6 +66,11 @@ public class QMUITipDialogUtil { |
| 30 | 66 | */ |
| 31 | 67 | public static void loadingDialog(Context context, String tipStr, boolean isCancel) { |
| 32 | 68 | try { |
| 69 | + if (context instanceof Activity) { | |
| 70 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 71 | + return; | |
| 72 | + } | |
| 73 | + } | |
| 33 | 74 | currentContext = new WeakReference<>(context); |
| 34 | 75 | if (currentContext == null) { |
| 35 | 76 | return; |
| ... | ... | @@ -59,6 +100,11 @@ public class QMUITipDialogUtil { |
| 59 | 100 | */ |
| 60 | 101 | public static void successDialog(Context context, String tipStr, int second) { |
| 61 | 102 | try { |
| 103 | + if (context instanceof Activity) { | |
| 104 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + } | |
| 62 | 108 | currentContext = new WeakReference<>(context); |
| 63 | 109 | if (currentContext == null) { |
| 64 | 110 | return; |
| ... | ... | @@ -73,12 +119,18 @@ public class QMUITipDialogUtil { |
| 73 | 119 | tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键 |
| 74 | 120 | if (!tipDialog.isShowing()) { |
| 75 | 121 | tipDialog.show(); |
| 76 | - new Handler().postDelayed(new Runnable() { | |
| 122 | + handler.removeCallbacksAndMessages(null); | |
| 123 | + handler.postDelayed(new Runnable() { | |
| 77 | 124 | @Override |
| 78 | 125 | public void run() { |
| 79 | 126 | if (currentContext == null) { |
| 80 | 127 | return; |
| 81 | 128 | } |
| 129 | + if (context instanceof Activity) { | |
| 130 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 131 | + return; | |
| 132 | + } | |
| 133 | + } | |
| 82 | 134 | /** |
| 83 | 135 | * 延时执行的代码 |
| 84 | 136 | */ |
| ... | ... | @@ -101,6 +153,11 @@ public class QMUITipDialogUtil { |
| 101 | 153 | */ |
| 102 | 154 | public static void failedDialog(Context context, String tipStr, int second) { |
| 103 | 155 | try { |
| 156 | + if (context instanceof Activity) { | |
| 157 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 158 | + return; | |
| 159 | + } | |
| 160 | + } | |
| 104 | 161 | currentContext = new WeakReference<>(context); |
| 105 | 162 | if (currentContext == null) { |
| 106 | 163 | return; |
| ... | ... | @@ -115,12 +172,18 @@ public class QMUITipDialogUtil { |
| 115 | 172 | tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键 |
| 116 | 173 | if (!tipDialog.isShowing()) { |
| 117 | 174 | tipDialog.show(); |
| 118 | - new Handler().postDelayed(new Runnable() { | |
| 175 | + handler.removeCallbacksAndMessages(null); | |
| 176 | + handler.postDelayed(new Runnable() { | |
| 119 | 177 | @Override |
| 120 | 178 | public void run() { |
| 121 | 179 | if (currentContext == null) { |
| 122 | 180 | return; |
| 123 | 181 | } |
| 182 | + if (context instanceof Activity) { | |
| 183 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 184 | + return; | |
| 185 | + } | |
| 186 | + } | |
| 124 | 187 | /** |
| 125 | 188 | * 延时执行的代码 |
| 126 | 189 | */ |
| ... | ... | @@ -147,6 +210,11 @@ public class QMUITipDialogUtil { |
| 147 | 210 | */ |
| 148 | 211 | public static void messageDialog(Context context, String tipStr, int second) { |
| 149 | 212 | try { |
| 213 | + if (context instanceof Activity) { | |
| 214 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 215 | + return; | |
| 216 | + } | |
| 217 | + } | |
| 150 | 218 | currentContext = new WeakReference<>(context); |
| 151 | 219 | if (currentContext == null) { |
| 152 | 220 | return; |
| ... | ... | @@ -161,12 +229,18 @@ public class QMUITipDialogUtil { |
| 161 | 229 | tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键 |
| 162 | 230 | if (!tipDialog.isShowing()) { |
| 163 | 231 | tipDialog.show(); |
| 164 | - new Handler().postDelayed(new Runnable() { | |
| 232 | + handler.removeCallbacksAndMessages(null); | |
| 233 | + handler.postDelayed(new Runnable() { | |
| 165 | 234 | @Override |
| 166 | 235 | public void run() { |
| 167 | 236 | if (currentContext == null) { |
| 168 | 237 | return; |
| 169 | 238 | } |
| 239 | + if (context instanceof Activity) { | |
| 240 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 241 | + return; | |
| 242 | + } | |
| 243 | + } | |
| 170 | 244 | /** |
| 171 | 245 | * 延时执行的代码 |
| 172 | 246 | */ |
| ... | ... | @@ -191,6 +265,11 @@ public class QMUITipDialogUtil { |
| 191 | 265 | */ |
| 192 | 266 | public static void textDialog(Context context, String tipStr, int second) { |
| 193 | 267 | try { |
| 268 | + if (context instanceof Activity) { | |
| 269 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 270 | + return; | |
| 271 | + } | |
| 272 | + } | |
| 194 | 273 | currentContext = new WeakReference<>(context); |
| 195 | 274 | if (currentContext == null) { |
| 196 | 275 | return; |
| ... | ... | @@ -204,12 +283,18 @@ public class QMUITipDialogUtil { |
| 204 | 283 | tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键 |
| 205 | 284 | if (!tipDialog.isShowing()) { |
| 206 | 285 | tipDialog.show(); |
| 207 | - new Handler().postDelayed(new Runnable() { | |
| 286 | + handler.removeCallbacksAndMessages(null); | |
| 287 | + handler.postDelayed(new Runnable() { | |
| 208 | 288 | @Override |
| 209 | 289 | public void run() { |
| 210 | 290 | if (currentContext == null) { |
| 211 | 291 | return; |
| 212 | 292 | } |
| 293 | + if (context instanceof Activity) { | |
| 294 | + if (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()) { | |
| 295 | + return; | |
| 296 | + } | |
| 297 | + } | |
| 213 | 298 | /** |
| 214 | 299 | * 延时执行的代码 |
| 215 | 300 | */ |
| ... | ... | @@ -228,6 +313,7 @@ public class QMUITipDialogUtil { |
| 228 | 313 | if (currentContext == null) { |
| 229 | 314 | return; |
| 230 | 315 | } |
| 316 | + handler.removeCallbacksAndMessages(null); | |
| 231 | 317 | if (tipDialog != null && tipDialog.isShowing()) { |
| 232 | 318 | tipDialog.dismiss(); |
| 233 | 319 | } | ... | ... |
core/base/src/main/res/drawable/selector_my_dialog_btn_left.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| 3 | 3 | <item android:drawable="@color/transparent" android:state_pressed="false" /> |
| 4 | - <item android:drawable="@drawable/shape_xiaojia_dialog_btn_left_press" android:state_pressed="true" /> | |
| 4 | + <item android:drawable="@drawable/shape_select_dialog_btn_left_press" android:state_pressed="true" /> | |
| 5 | 5 | |
| 6 | 6 | </selector> |
| 7 | 7 | \ No newline at end of file | ... | ... |
core/base/src/main/res/drawable/selector_my_dialog_btn_right.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| 3 | 3 | <item android:drawable="@color/transparent" android:state_pressed="false" /> |
| 4 | - <item android:drawable="@drawable/shape_xiaojia_dialog_btn_right_press" android:state_pressed="true" /> | |
| 4 | + <item android:drawable="@drawable/shape_select_dialog_btn_right_press" android:state_pressed="true" /> | |
| 5 | 5 | |
| 6 | 6 | </selector> |
| 7 | 7 | \ No newline at end of file | ... | ... |
core/base/src/main/res/drawable/selector_xiaojia_tip_dialog_btn_bottom.xml renamed to core/base/src/main/res/drawable/selector_tip_dialog_btn_bottom.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| 3 | 3 | <item android:drawable="@color/transparent" android:state_pressed="false" /> |
| 4 | - <item android:drawable="@drawable/shape_xiaojia_tip_dialog_btn_bottom_press" android:state_pressed="true" /> | |
| 4 | + <item android:drawable="@drawable/shape_tip_dialog_btn_bottom_press" android:state_pressed="true" /> | |
| 5 | 5 | |
| 6 | 6 | </selector> |
| 7 | 7 | \ No newline at end of file | ... | ... |
core/base/src/main/res/drawable/shape_select_dialog_btn_left_press.xml
0 → 100644
core/base/src/main/res/drawable/shape_select_dialog_btn_right_press.xml
0 → 100644
core/base/src/main/res/drawable/shape_xiaojia_tip_dialog_btn_bottom_press.xml renamed to core/base/src/main/res/drawable/shape_tip_dialog_btn_bottom_press.xml
core/base/src/main/res/layout/dialog_tip.xml
| ... | ... | @@ -52,7 +52,7 @@ |
| 52 | 52 | android:layout_width="match_parent" |
| 53 | 53 | android:layout_height="match_parent" |
| 54 | 54 | android:layout_gravity="center" |
| 55 | - android:background="@drawable/selector_xiaojia_tip_dialog_btn_bottom" | |
| 55 | + android:background="@drawable/selector_tip_dialog_btn_bottom" | |
| 56 | 56 | android:text="好的" |
| 57 | 57 | android:textColor="@color/my_dialog_btn_text_color" |
| 58 | 58 | android:textSize="15sp" /> | ... | ... |