Java Code Examples for android.app.Dialog#isShowing()

The following examples show how to use android.app.Dialog#isShowing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogUIUtils.java    From KUtils-master with Apache License 2.0 6 votes vote down vote up
/**
 * 关闭弹出框
 */
public static void dismiss(DialogInterface... dialogs) {
    if (dialogs != null && dialogs.length > 0) {
        for (DialogInterface dialog : dialogs) {
            if (dialog instanceof Dialog) {
                Dialog dialog1 = (Dialog) dialog;
                if (dialog1.isShowing()) {
                    dialog1.dismiss();
                }
            } else if (dialog instanceof AppCompatDialog) {
                AppCompatDialog dialog2 = (AppCompatDialog) dialog;
                if (dialog2.isShowing()) {
                    dialog2.dismiss();
                }
            }
        }

    }


}
 
Example 2
Source File: BaseRequest.java    From AndPermission with Apache License 2.0 6 votes vote down vote up
static boolean tryDisplayDialog(Context context) {
    Dialog dialog = new Dialog(context, R.style.Permission_Theme_Dialog_Transparent);
    Window window = dialog.getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        window.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
    } else {
        window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    }
    try {
        dialog.show();
    } catch (Exception e) {
        return false;
    } finally {
        if (dialog.isShowing()) dialog.dismiss();
    }
    return true;
}
 
Example 3
Source File: DialogsMaintainer.java    From DialogUtil with Apache License 2.0 6 votes vote down vote up
/**
 * 在这里移除已经dismiss的dialog引用
 *
 * @param activity
 */
public static void onPause(Activity activity) {
    if (!dialogsOfActivity.containsKey(activity)) {
        return;
    }
    Set<Dialog> dialogInterfaces = dialogsOfActivity.get(activity);
    if (dialogInterfaces == null || dialogInterfaces.isEmpty()) {
        dialogInterfaces.remove(activity);
        return;
    }
    Iterator<Dialog> iterator = dialogInterfaces.iterator();
    while (iterator.hasNext()) {
        Dialog dialog = iterator.next();
        if (!dialog.isShowing()) {
            iterator.remove();
        }
    }
    if (dialogInterfaces == null || dialogInterfaces.isEmpty()) {
        dialogInterfaces.remove(activity);
        return;
    }

}
 
Example 4
Source File: DialogUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 关闭 Dialog
 * @param dialog {@link Dialog}
 * @return {@code true} success, {@code false} fail
 */
public static boolean closeDialog(final Dialog dialog) {
    if (dialog != null && dialog.isShowing()) {
        try {
            dialog.dismiss();
            return true;
        } catch (Exception e) {
            LogPrintUtils.eTag(TAG, e, "closeDialog");
        }
    }
    return false;
}
 
Example 5
Source File: VolumeControllerDialogFragmentListener.java    From Kore with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    long timeSinceLastEvent = System.currentTimeMillis() - lastVolumeChangeInteractionEvent;
    if (timeSinceLastEvent >= AUTO_DISMISS_DELAY) {
        Dialog dialog = getDialog();
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}
 
Example 6
Source File: CustomInputStylePreference.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
@Override
protected Parcelable onSaveInstanceState() {
    final Parcelable superState = super.onSaveInstanceState();
    final Dialog dialog = getDialog();
    if (dialog == null || !dialog.isShowing()) {
        return superState;
    }

    final SavedState myState = new SavedState(superState);
    myState.mSubtype = mSubtype;
    return myState;
}
 
Example 7
Source File: CustomInputStylePreference.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
@Override
protected Parcelable onSaveInstanceState() {
    final Parcelable superState = super.onSaveInstanceState();
    final Dialog dialog = getDialog();
    if (dialog == null || !dialog.isShowing()) {
        return superState;
    }

    final SavedState myState = new SavedState(superState);
    myState.mSubtype = mSubtype;
    return myState;
}
 
Example 8
Source File: CCPActivityBase.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 */
private void releaseDialogList() {
    if(mAppDialogCache == null) {
        return;
    }

    for(Dialog dialog : mAppDialogCache) {
        if(dialog == null || !dialog.isShowing()) {
            continue;
        }
        dialog.dismiss();
    }
    mAppDialogCache.clear();
    mAppDialogCache = null;
}
 
Example 9
Source File: AppCompatDialog.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
public final boolean isShowing() {
    if (isAdded()) {
        return true;
    }
    final Dialog dialog = getDialog();
    return dialog != null && dialog.isShowing();
}
 
Example 10
Source File: CustomInputStylePreference.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
protected Parcelable onSaveInstanceState() {
    final Parcelable superState = super.onSaveInstanceState();
    final Dialog dialog = getDialog();
    if (dialog == null || !dialog.isShowing()) {
        return superState;
    }

    final SavedState myState = new SavedState(superState);
    myState.mSubtype = mSubtype;
    return myState;
}
 
Example 11
Source File: MaterialDialogPreference.java    From talk-android with MIT License 5 votes vote down vote up
@Override
protected Parcelable onSaveInstanceState() {
    final Parcelable superState = super.onSaveInstanceState();
    Dialog dialog = getDialog();
    if (dialog == null || !dialog.isShowing()) {
        return superState;
    }

    final SavedState myState = new SavedState(superState);
    myState.isDialogShowing = true;
    myState.dialogBundle = dialog.onSaveInstanceState();
    return myState;
}
 
Example 12
Source File: Utils.java    From KUAS-AP-Material with MIT License 5 votes vote down vote up
public static void dismissDialog(Dialog dialog) {
	try {
		if (dialog != null && dialog.isShowing()) {
			dialog.dismiss();
		}
	} catch (IllegalArgumentException e) {
		// ignore
	}
}
 
Example 13
Source File: AppDialog.java    From BleSensorTag with MIT License 4 votes vote down vote up
public boolean isShowing() {
    final Dialog dialog = getDialog();
    return dialog != null && dialog.isShowing();
}
 
Example 14
Source File: DialogHelper.java    From android-common-utils with Apache License 2.0 4 votes vote down vote up
public static void dismissDialog(Dialog d){
    if(d!=null && d.isShowing()){
        d.dismiss();
    }
}
 
Example 15
Source File: ContextUtils.java    From WayHoo with Apache License 2.0 4 votes vote down vote up
/**
 * close progress dialog
 * 
 * @param progressDialog
 */
public static void closeProgressDialog(Dialog progressDialog) {
	if (progressDialog != null && progressDialog.isShowing()) {
		progressDialog.cancel();
	}
}
 
Example 16
Source File: AbsAgentWebUIController.java    From AgentWeb with Apache License 2.0 4 votes vote down vote up
protected void toShowDialog(Dialog dialog) {
	if (dialog != null && !dialog.isShowing()) {
		dialog.show();
	}
}
 
Example 17
Source File: DialogUIUtils.java    From KUtils-master with Apache License 2.0 4 votes vote down vote up
/**
 * 关闭弹出框
 */
public static void dismiss(Dialog dialog) {
    if (dialog != null && dialog.isShowing()) {
        dialog.dismiss();
    }
}
 
Example 18
Source File: StytledDialog.java    From DialogUtils with Apache License 2.0 4 votes vote down vote up
public static void dismiss(Dialog dialog){
    if (dialog != null && dialog.isShowing()){
        dialog.dismiss();
    }
}
 
Example 19
Source File: NfcPage.java    From nfcard with GNU General Public License v3.0 4 votes vote down vote up
private void hideProgressBar() {
	final Dialog d = progressBar;
	if (d != null && d.isShowing())
		d.cancel();
}
 
Example 20
Source File: DialogUtils.java    From DevUtils with Apache License 2.0 2 votes vote down vote up
/**
 * 获取 Dialog 是否显示
 * @param dialog {@link Dialog}
 * @return {@code true} yes, {@code false} no
 */
public static boolean isShowing(final Dialog dialog) {
    return (dialog != null && dialog.isShowing());
}