Try fix MaterialDialog exception

Exception com.afollestad.materialdialogs.MaterialDialog$DialogException:
Bad window token, you cannot show a dialog before an Activity is created
or after it's hidden.

com.afollestad.materialdialogs.MaterialDialog.show (MaterialDialog.java)
org.emunix.unipatcher.ui.activity.FilePickerActivity.onItemClick
(FilePickerActivity.java)
org.emunix.unipatcher.ui.activity.FilePickerActivity.onItemLongClick
(FilePickerActivity.java)
org.emunix.unipatcher.ui.adapter.FilePickerAdapter$ViewHolder$2.onLongClick
(FilePickerAdapter.java)
android.view.View.performLongClick (View.java:4511)
android.view.View$CheckForLongPress.run (View.java:18758)
android.os.Handler.handleCallback (Handler.java:730)
android.os.Handler.dispatchMessage (Handler.java:92)
android.os.Looper.loop (Looper.java:176)
android.app.ActivityThread.main (ActivityThread.java:5419)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:525)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:1046)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:862)
dalvik.system.NativeStart.main (NativeStart.java)
This commit is contained in:
Boris Timofeev 2016-10-27 22:49:23 +03:00
parent c1dbf5547a
commit 2a62dc3e16

View file

@ -347,7 +347,8 @@ public class FilePickerActivity extends AppCompatActivity implements FilePickerA
sha1 = (TextView) dialog.getCustomView().findViewById(R.id.sha1_value);
new FileChecksumsTask().execute(file);
dialog.show();
if (this.hasWindowFocus())
dialog.show();
}
static public class FileEntry {