|
@@ -30,6 +30,7 @@ import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewTreeObserver;
|
|
import android.view.ViewTreeObserver;
|
|
|
|
+import android.view.WindowManager;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebView;
|
|
import android.widget.AdapterView;
|
|
import android.widget.AdapterView;
|
|
import android.widget.ArrayAdapter;
|
|
import android.widget.ArrayAdapter;
|
|
@@ -616,6 +617,12 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static class DialogException extends WindowManager.BadTokenException {
|
|
|
|
+ public DialogException(String message) {
|
|
|
|
+ super(message);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Detects whether or not the content TextView can be scrolled.
|
|
* Detects whether or not the content TextView can be scrolled.
|
|
*/
|
|
*/
|
|
@@ -1482,7 +1489,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
public void show() {
|
|
public void show() {
|
|
if (Looper.myLooper() != Looper.getMainLooper())
|
|
if (Looper.myLooper() != Looper.getMainLooper())
|
|
throw new IllegalStateException("Dialogs can only be shown from the UI thread.");
|
|
throw new IllegalStateException("Dialogs can only be shown from the UI thread.");
|
|
- super.show();
|
|
|
|
|
|
+ try {
|
|
|
|
+ super.show();
|
|
|
|
+ } catch (WindowManager.BadTokenException e) {
|
|
|
|
+ throw new DialogException("Bad window token, you cannot show a dialog before an Activity is created or after it's hidden.");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private ColorStateList getActionTextStateList(int newPrimaryColor) {
|
|
private ColorStateList getActionTextStateList(int newPrimaryColor) {
|