diff --git a/app/src/contemporary/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java b/app/src/contemporary/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java index 8d2a474c..6b279172 100644 --- a/app/src/contemporary/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java +++ b/app/src/contemporary/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java @@ -26,6 +26,8 @@ import android.view.View; import android.widget.ListAdapter; +import com.github.yeriomin.yalpstore.ContextUtil; + public class DialogWrapper extends DialogWrapperAbstract { protected AlertDialog.Builder builder; @@ -120,7 +122,12 @@ public DialogWrapperAbstract setCancelable(boolean cancelable) { @Override public DialogWrapperAbstract create() { - dialog = builder.create(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog = builder.create(); + } + }); return this; } @@ -129,21 +136,36 @@ public DialogWrapperAbstract show() { if (null == dialog) { create(); } - dialog.show(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog.show(); + } + }); return this; } @Override public void cancel() { if (null != dialog) { - dialog.cancel(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog.cancel(); + } + }); } } @Override public void dismiss() { if (null != dialog) { - dialog.dismiss(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog.dismiss(); + } + }); } } } diff --git a/app/src/legacy/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java b/app/src/legacy/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java index 94a65dba..3bfd7123 100644 --- a/app/src/legacy/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java +++ b/app/src/legacy/java/com/github/yeriomin/yalpstore/view/DialogWrapper.java @@ -26,6 +26,8 @@ import android.view.View; import android.widget.ListAdapter; +import com.github.yeriomin.yalpstore.ContextUtil; + public class DialogWrapper extends DialogWrapperAbstract { protected AlertDialog.Builder builder; @@ -120,7 +122,12 @@ public DialogWrapperAbstract setCancelable(boolean cancelable) { @Override public DialogWrapperAbstract create() { - dialog = builder.create(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog = builder.create(); + } + }); return this; } @@ -129,21 +136,36 @@ public DialogWrapperAbstract show() { if (null == dialog) { create(); } - dialog.show(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog.show(); + } + }); return this; } @Override public void cancel() { if (null != dialog) { - dialog.cancel(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog.cancel(); + } + }); } } @Override public void dismiss() { if (null != dialog) { - dialog.dismiss(); + ContextUtil.runOnUiThread(new Runnable() { + @Override + public void run() { + dialog.dismiss(); + } + }); } } }