Example usage for android.app Dialog onRestoreInstanceState

List of usage examples for android.app Dialog onRestoreInstanceState

Introduction

In this page you can find the example usage for android.app Dialog onRestoreInstanceState.

Prototype

public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) 

Source Link

Document

Restore the state of the dialog from a previously saved bundle.

Usage

From source file:com.zogamonline.laisiangthou.MaterialPreferenceLib.custom_preferences.DialogPreference.java

protected void showDialog(Bundle state) {
    Context context = getContext();

    mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
    mBuilder = new AlertDialog.Builder(context).setTitle(mDialogTitle).setIcon(mDialogIcon)
            .setPositiveButton(mPositiveButtonText, this).setNegativeButton(mNegativeButtonText, this);
    View contentView = onCreateDialogView();
    if (contentView != null) {
        onBindDialogView(contentView);/*  w w w.  j a va2  s  .  c  o  m*/
        mBuilder.setView(contentView);
    } else {
        mBuilder.setMessage(mDialogMessage);
    }

    onPrepareDialogBuilder(mBuilder);
    PreferenceManagerEx.getInstance().registerOnActivityDestroyListener(getPreferenceManager(), this);

    // Create the dialog
    final Dialog dialog = mDialog = mBuilder.create();
    if (state != null) {
        dialog.onRestoreInstanceState(state);
    }
    if (needInputMethod()) {
        requestInputMethod(dialog);
    }
    dialog.setOnDismissListener(this);
    dialog.show();
}

From source file:com.ahao.preferencelibrary.preference.DialogPreference.java

/**
 * Shows the dialog associated with this Preference. This is normally initiated
 * automatically on clicking on the preference. Call this method if you need to
 * show the dialog on some other event.//from w  ww  .j ava 2  s . co m
 *
 * @param state Optional instance state to restore on the dialog
 */
protected void showDialog(Bundle state) {
    Context context = getContext();

    mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
    mBuilder = new AlertDialog.Builder(context).setTitle(mDialogTitle).setIcon(mDialogIcon)
            .setPositiveButton(mPositiveButtonText, this).setNegativeButton(mNegativeButtonText, this);
    View contentView = onCreateDialogView();
    if (contentView != null) {
        onBindDialogView(contentView);
        mBuilder.setView(contentView);
    } else {
        mBuilder.setMessage(mDialogMessage);
    }

    onPrepareDialogBuilder(mBuilder);
    PreferenceManagerEx.getInstance().registerOnActivityDestroyListener(getPreferenceManager(), this);

    // Create the dialog
    final Dialog dialog = mDialog = mBuilder.create();
    if (state != null) {
        dialog.onRestoreInstanceState(state);
    }
    if (needInputMethod()) {
        requestInputMethod(dialog);
    }
    dialog.setOnDismissListener(this);
    dialog.show();
}