List of usage examples for android.app Dialog isShowing
public boolean isShowing()
From source file:Main.java
public static void showDialog(Dialog dialog) { if (!dialog.isShowing()) { dialog.show(); } }
From source file:Main.java
public static void dismissDialog(Dialog dialog) { if (dialog != null && dialog.isShowing()) { dialog.dismiss();//from w w w .java 2 s . co m } }
From source file:Main.java
public static void dismissDialog(Dialog dialog) { if (dialog.isShowing()) { //check if dialog is showing. //get the Context object that was used to great the dialog Context context = ((ContextWrapper) dialog.getContext()).getBaseContext(); //if the Context used here was an activity AND it hasn't been finished //then dismiss it if (context instanceof Activity) { if (!((Activity) context).isFinishing()) { dialog.dismiss();//from w w w. j a va 2s . c o m } } else { //if the Context used wasnt an Activity, then dismiss it too dialog.dismiss(); } } }
From source file:Main.java
public static Dialog waitForCurrentDialogShowing(final Activity activity, final long timeout) throws InterruptedException { long start = System.currentTimeMillis(); try {/*w w w.j av a2 s . co m*/ Field currentDialogField = activity.getClass().getDeclaredField("currentDialog"); currentDialogField.setAccessible(true); Dialog dialog = null; while (dialog == null || !dialog.isShowing()) { dialog = (Dialog) currentDialogField.get(activity); Thread.sleep(50); long now = System.currentTimeMillis(); if (now - start > timeout) { throw new InterruptedException( String.format("Timeout exceeded while waiting for dialog showing")); } } return dialog; } catch (Exception e) { throw new InterruptedException(String.format("Exception while waiting for dialog showing")); } }
From source file:Main.java
public static Dialog waitForDialogNotShowing(final Dialog dialog, final long timeout) throws InterruptedException { long start = System.currentTimeMillis(); while (dialog.isShowing()) { Thread.sleep(50);//from w w w . j av a2 s . c o m long now = System.currentTimeMillis(); if (now - start > timeout) { throw new InterruptedException( String.format("Timeout exceeded while waiting for dialog not showing")); } } return dialog; }
From source file:shared.dialog.fixedorderdialog.BaseDialogFragment.java
public boolean isShowing() { final Dialog dialog = getDialog(); return dialog != null && dialog.isShowing(); }
From source file:com.experiments.core.application.activities.BaseActivity.java
public void showDialog(Dialog dialog) { if (dialog == null || dialog.isShowing()) return; dialog.show(); }
From source file:com.experiments.core.application.activities.BaseActivity.java
public void dismissDialogs(Dialog... dialogs) { for (Dialog dialog : dialogs) { if (dialog == null || !dialog.isShowing()) continue; dialog.dismiss();/*from www . j av a 2s . c om*/ } }
From source file:am.roadpolice.roadpolice.DecisionDialogFragment.java
@Override public void onDestroy() { Dialog dialog = getDialog(); if (dialog != null && dialog.isShowing()) dialog.dismiss();//from www . j a v a 2s . c om super.onDestroy(); }
From source file:com.nks.nksmod.otaupdater.DownloadsActivity.java
@Override protected void onPause() { for (Dialog dlg : dlgs) { if (dlg.isShowing()) dlg.dismiss();//from w w w . j a va2 s . c om } dlgs.clear(); super.onPause(); }