Commit 244fba607cf47e05a3b49a88366c589b50274815
1 parent
e43b6fa3
权限判断工具,增加当前是否显示弹窗判断方法
Showing
2 changed files
with
13 additions
and
2 deletions
config.gradle
lib_media/src/main/java/com/cnlive/media/utils/PermissionChecker.java
| ... | ... | @@ -21,7 +21,11 @@ import java.util.List; |
| 21 | 21 | /** |
| 22 | 22 | */ |
| 23 | 23 | public class PermissionChecker { |
| 24 | + private static boolean hasAlertWindow = false; | |
| 24 | 25 | |
| 26 | + public static boolean isHasAlertWindow(){ | |
| 27 | + return hasAlertWindow; | |
| 28 | + } | |
| 25 | 29 | /** |
| 26 | 30 | * 检查权限的方法 |
| 27 | 31 | * |
| ... | ... | @@ -78,6 +82,8 @@ public class PermissionChecker { |
| 78 | 82 | |
| 79 | 83 | if (needList.size() != 0) { |
| 80 | 84 | if (needShowRationale) { |
| 85 | + hasAlertWindow = true; | |
| 86 | + | |
| 81 | 87 | AlertDialogUtils.showTwoButtonDialog( |
| 82 | 88 | activity, |
| 83 | 89 | activity.getResources().getString(leftButton), |
| ... | ... | @@ -86,8 +92,8 @@ public class PermissionChecker { |
| 86 | 92 | R.color.color_dialog_btn, R.color.color_ffa300, new AlertDialogUtils.DialogTwoListener() { |
| 87 | 93 | @Override |
| 88 | 94 | public void onClickLeft(Dialog dialog) { |
| 95 | + hasAlertWindow = false; | |
| 89 | 96 | dialog.dismiss(); |
| 90 | - | |
| 91 | 97 | if (activityFinish) { |
| 92 | 98 | activity.finish(); |
| 93 | 99 | } |
| ... | ... | @@ -95,6 +101,7 @@ public class PermissionChecker { |
| 95 | 101 | |
| 96 | 102 | @Override |
| 97 | 103 | public void onClickRight(Dialog dialog) { |
| 104 | + hasAlertWindow = false; | |
| 98 | 105 | dialog.dismiss(); |
| 99 | 106 | ActivityCompat.requestPermissions(activity, needList.toArray(new String[needList.size()]), requestCode); |
| 100 | 107 | } |
| ... | ... | @@ -144,6 +151,8 @@ public class PermissionChecker { |
| 144 | 151 | if (!result) { |
| 145 | 152 | // Toast.makeText(activity, R.string.toast_imagepicker_permission_denied, Toast.LENGTH_SHORT).show(); |
| 146 | 153 | if (isNerverAsk) { |
| 154 | + hasAlertWindow = true; | |
| 155 | + | |
| 147 | 156 | AlertDialogUtils.showTwoButtonDialog( |
| 148 | 157 | activity, |
| 149 | 158 | activity.getResources().getString(R.string.dialog_imagepicker_permission_nerver_ask_cancel), |
| ... | ... | @@ -152,12 +161,14 @@ public class PermissionChecker { |
| 152 | 161 | R.color.color_dialog_btn, R.color.color_ffa300, new AlertDialogUtils.DialogTwoListener() { |
| 153 | 162 | @Override |
| 154 | 163 | public void onClickLeft(Dialog dialog) { |
| 164 | + hasAlertWindow = false; | |
| 155 | 165 | dialog.dismiss(); |
| 156 | 166 | if (cencelFinish) activity.finish(); |
| 157 | 167 | } |
| 158 | 168 | |
| 159 | 169 | @Override |
| 160 | 170 | public void onClickRight(Dialog dialog) { |
| 171 | + hasAlertWindow = false; | |
| 161 | 172 | dialog.dismiss(); |
| 162 | 173 | settingPermissionActivity(activity, 1007); |
| 163 | 174 | if (confirmFinish) activity.finish(); | ... | ... |