fix lag when click shortcut of script with dialog

This commit is contained in:
hyb1996
2017-07-09 10:08:47 +08:00
parent fd2b5e5206
commit a660a98539
3 changed files with 38 additions and 13 deletions

View File

@@ -36,8 +36,9 @@ public class BlockedMaterialDialog extends MaterialDialog {
private boolean isActivityContext(Context context) {
if (context == null)
return false;
if (context instanceof Activity)
return true;
if (context instanceof Activity) {
return !((Activity) context).isFinishing();
}
if (context instanceof ContextWrapper) {
return isActivityContext(((ContextWrapper) context).getBaseContext());
}

View File

@@ -1,5 +1,6 @@
package com.stardust.autojs.runtime.api.ui;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.text.TextUtils;
@@ -73,7 +74,7 @@ public class Dialogs {
private Context getContext() {
if (mThemeWrapper != null)
return mThemeWrapper;
mThemeWrapper = new ContextThemeWrapper(mUiHandler.getContext(), R.style.Theme_AppCompat_Light);
mThemeWrapper = new ContextThemeWrapper(mUiHandler.getContext().getApplicationContext(), R.style.Theme_AppCompat_Light);
return mThemeWrapper;
}
@@ -115,7 +116,7 @@ public class Dialogs {
private BlockedMaterialDialog.Builder dialogBuilder() {
Context context = mAppUtils.getCurrentActivity();
if (context == null) {
if (context == null || ((Activity) context).isFinishing()) {
context = getContext();
}
return (BlockedMaterialDialog.Builder) new BlockedMaterialDialog.Builder(context, mUiHandler)