android.app.Dialog

Here are the examples of the java api class android.app.Dialog taken from open source projects.

1. ActivityMain#optionTutorial()

Project: XPrivacy
File: ActivityMain.java
private void optionTutorial() {
    ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
    ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
    int userId = Util.getUserId(Process.myUid());
    PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.FALSE.toString());
    Dialog dlgUsage = new Dialog(this);
    dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dlgUsage.setTitle(R.string.title_usage_header);
    dlgUsage.setContentView(R.layout.usage);
    dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
    dlgUsage.setCancelable(true);
    dlgUsage.show();
}

2. ActivityMain#optionLegend()

Project: XPrivacy
File: ActivityMain.java
private void optionLegend() {
    // Show help
    Dialog dialog = new Dialog(ActivityMain.this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.menu_legend);
    dialog.setContentView(R.layout.legend);
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
    ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
    ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());
    for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "details")) child.setVisibility(View.GONE);
    ((LinearLayout) dialog.findViewById(R.id.llUnsafe)).setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE);
    dialog.setCancelable(true);
    dialog.show();
}

3. ActivityApp#optionLegend()

Project: XPrivacy
File: ActivityApp.java
private void optionLegend() {
    // Show help
    Dialog dialog = new Dialog(ActivityApp.this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.menu_legend);
    dialog.setContentView(R.layout.legend);
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
    ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
    ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());
    for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "main")) child.setVisibility(View.GONE);
    ((LinearLayout) dialog.findViewById(R.id.llUnsafe)).setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE);
    dialog.setCancelable(true);
    dialog.show();
}

4. PopupPlayer#newInstance()

Project: Pr0
File: PopupPlayer.java
public static Dialog newInstance(Activity activity, FeedItem item) {
    MediaUri uri = MediaUri.of(activity, item);
    MediaView mediaView = MediaViews.newInstance(ImmutableConfig.of(activity, uri).withAudio(item.audio()).withPreviewInfo(PreviewInfo.of(activity, item)));
    Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(mediaView);
    dialog.setOnShowListener( di -> {
        mediaView.onResume();
        mediaView.playMedia();
    });
    dialog.setOnDismissListener( di -> {
        mediaView.stopMedia();
        mediaView.onPause();
    });
    dialog.show();
    return dialog;
}

5. WaniKaniImprove#showDialog()

Project: WaniKani-for-Android
File: WaniKaniImprove.java
/**
     * Shows the dialog. Must be run on the main UI thread
     * @param state the state to be published
     */
private void showDialog(State state) {
    Resources res;
    WebView webview;
    Dialog dialog;
    String title;
    if (!activity.visible)
        return;
    res = activity.getResources();
    dialog = new Dialog(activity);
    dialog.setTitle(res.getString(R.string.fmt_last_item_wait));
    dialog.setContentView(R.layout.lastitem);
    webview = (WebView) dialog.findViewById(R.id.wv_lastitem);
    webview.getSettings().setJavaScriptEnabled(true);
    title = res.getString(R.string.fmt_last_item, state.type);
    webview.setWebViewClient(new WebViewClientImpl(dialog, title));
    webview.loadUrl(state.getURL());
    dialog.show();
}

6. OverviewFragment#showA1cDialog()

Project: glucosio-android
File: OverviewFragment.java
private void showA1cDialog() {
    final Dialog a1CDialog = new Dialog(getActivity(), R.style.GlucosioTheme);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(a1CDialog.getWindow().getAttributes());
    a1CDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    a1CDialog.setContentView(R.layout.dialog_a1c);
    a1CDialog.getWindow().setAttributes(lp);
    a1CDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    a1CDialog.getWindow().setDimAmount(0.5f);
    a1CDialog.setCanceledOnTouchOutside(true);
    a1CDialog.show();
    ListView a1cListView = (ListView) a1CDialog.findViewById(R.id.dialog_a1c_listview);
    A1cEstimateAdapter customAdapter = new A1cEstimateAdapter(getActivity(), R.layout.dialog_a1c_item, presenter.getA1cEstimateList());
    a1cListView.setAdapter(customAdapter);
}

7. MainActivity#onCoachMark()

Project: FaceSlim
File: MainActivity.java
// first run dialog with introduction
private void onCoachMark() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.setContentView(R.layout.coach_mark);
    dialog.setCanceledOnTouchOutside(true);
    //for dismissing anywhere you touch
    View masterView = dialog.findViewById(R.id.coach_mark_master_view);
    masterView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dialog.dismiss();
            // notifications setup notice
            Toast.makeText(getApplicationContext(), getString(R.string.setup_notifications), Toast.LENGTH_SHORT).show();
        }
    });
    dialog.show();
}

8. ActionWaitForAccuracy2#showSkipPositionDetectionDialog()

Project: droidar
File: ActionWaitForAccuracy2.java
/**
	 * call this if the user should be able to skip this procedure
	 */
public void showSkipPositionDetectionDialog() {
    final Dialog dialog = new Dialog(myActivity);
    Button b = new Button(myActivity);
    b.setText(TEXT_SKIP_ACCURACY_DETECTION);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            callFirstTimeAccReachedIfNotYetCalled(GeoUtils.getCurrentLocation(myActivity));
            dialog.dismiss();
        }
    });
    dialog.setContentView(b);
    dialog.setTitle(TEXT_DIALOG_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

9. ActionWaitForAccuracy#showSkipPositionDetectionDialog()

Project: droidar
File: ActionWaitForAccuracy.java
private void showSkipPositionDetectionDialog() {
    final Dialog dialog = new Dialog(myActivity);
    Button b = new Button(myActivity);
    b.setText(TEXT_SKIP_ACCURACY_DETECTION);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.d(LOG_TAG, "Trying to skip accuracy detection");
            callFirstTimeAccReachedIfNotYetCalled(GeoUtils.getCurrentLocation(myActivity));
            hideUI();
            dialog.dismiss();
        }
    });
    dialog.setContentView(b);
    dialog.setTitle(TEXT_DIALOG_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

10. ClientActivity#search()

Project: BluetoothProfile
File: ClientActivity.java
private void search() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(new DialogView(this).onSelectedDevice(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    }));
    dialog.setTitle(R.string.remote_device_connect_title);
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            mBluetoothAdapter.cancelDiscovery();
        }
    });
    dialog.show();
}

11. ProfileActivity#addNewProfile()

Project: afwall
File: ProfileActivity.java
// Handle user click
public void addNewProfile() {
    final Dialog d = new Dialog(this);
    d.setContentView(R.layout.profile_adddialog);
    d.setTitle(getString(R.string.profile_add));
    d.setCancelable(true);
    final EditText edit = (EditText) d.findViewById(R.id.editTextProfile);
    Button b = (Button) d.findViewById(R.id.button1);
    b.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            String profileName = edit.getText().toString();
            ProfileActivity.this.profilesList.add(new Profile(profileName));
            G.addAdditionalProfile(profileName);
            // We notify the data model is changed
            ProfileActivity.this.profileAdapter.notifyDataSetChanged();
            d.dismiss();
        }
    });
    d.show();
}

12. SystemUtils#getCustomeDialog()

Project: WayHoo
File: SystemUtils.java
public static Dialog getCustomeDialog(Activity activity, int style, int customView) {
    Dialog dialog = new Dialog(activity, style);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(customView);
    Window window = dialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    lp.x = 0;
    lp.y = 0;
    window.setAttributes(lp);
    return dialog;
}

13. SystemUtils#getCustomeDialog()

Project: WayHoo
File: SystemUtils.java
/**
	 * ??????????Dialog
	 * 
	 * @param activity
	 *            ?????
	 * @param style
	 *            ??
	 * @param customView
	 *            ???view
	 * @return dialog
	 */
public static Dialog getCustomeDialog(Activity activity, int style, View customView) {
    Dialog dialog = new Dialog(activity, style);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(customView);
    Window window = dialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    lp.x = 0;
    lp.y = 0;
    window.setAttributes(lp);
    return dialog;
}

14. PluginFullScreenPauseAD#creatSelectDownloadDialog()

Project: SimplifyReader
File: PluginFullScreenPauseAD.java
// ??2G/3G?????????????
private void creatSelectDownloadDialog(Activity activity) {
    Dialog alertDialog = new AlertDialog.Builder(activity).setMessage("??????WiFi???????????????").setPositiveButton("??", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            new AdvClickProcessor().processAdvClick(mActivity, mADClickURL, mAdForward);
        }
    }).setNegativeButton("??", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    }).create();
    alertDialog.setCancelable(false);
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
}

15. DialogTest#shouldOnlyCallOnCreateOnce()

Project: robolectric
File: DialogTest.java
@Test
public void shouldOnlyCallOnCreateOnce() {
    final Transcript transcript = new Transcript();
    Dialog dialog = new Dialog(Robolectric.application) {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            transcript.add("onCreate called");
        }
    };
    dialog.show();
    transcript.assertEventsSoFar("onCreate called");
    dialog.dismiss();
    dialog.show();
    transcript.assertNoEventsSoFar();
}

16. TerminalKeyListener#urlScan()

Project: connectbot
File: TerminalKeyListener.java
public void urlScan(View v) {
    //final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
    List<String> urls = bridge.scanForURLs();
    Dialog urlDialog = new Dialog(v.getContext());
    urlDialog.setTitle(R.string.console_menu_urlscan);
    ListView urlListView = new ListView(v.getContext());
    URLItemListener urlListener = new URLItemListener(v.getContext());
    urlListView.setOnItemClickListener(urlListener);
    urlListView.setAdapter(new ArrayAdapter<String>(v.getContext(), android.R.layout.simple_list_item_1, urls));
    urlDialog.setContentView(urlListView);
    urlDialog.show();
}

17. SortingDialogFragment#onCreateDialog()

Project: CineBuff
File: SortingDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogView = inflater.inflate(R.layout.sorting_options, null);
    initViews(dialogView);
    Dialog dialog = new Dialog(getActivity());
    dialog.setContentView(dialogView);
    dialog.setTitle(R.string.sort_by);
    dialog.show();
    return dialog;
}

18. DateChangedAlerts#showRepeatChangedDialog()

Project: astrid
File: DateChangedAlerts.java
public static void showRepeatChangedDialog(final AstridActivity activity, Task task) {
    if (!Preferences.getBoolean(PREF_SHOW_HELPERS, true))
        return;
    final Dialog d = new Dialog(activity, R.style.ReminderDialog);
    d.setContentView(R.layout.astrid_reminder_view);
    Button okButton = (Button) d.findViewById(R.id.reminder_complete);
    okButton.setText(R.string.DLG_ok);
    d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE);
    d.findViewById(R.id.reminder_edit).setVisibility(View.GONE);
    ((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.TLA_repeat_scheduled_title, task.getValue(Task.TITLE)));
    String speechBubbleText = constructSpeechBubbleTextForRepeat(activity, task);
    ((TextView) d.findViewById(R.id.reminder_message)).setText(speechBubbleText);
    setupOkAndDismissButtons(d);
    setupHideCheckbox(d);
    setupDialogLayoutParams(activity, d);
    d.setOwnerActivity(activity);
    d.show();
}

19. PromoDialog#onCreateDialog()

Project: WordPress-Android
File: PromoDialog.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    mDrawableId = getArguments().getInt("drawableId");
    mTitleId = getArguments().getInt("titleId");
    mDescriptionId = getArguments().getInt("descriptionId");
    mButtonLabelId = getArguments().getInt("buttonLabelId");
    // request a window without the title
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
    return dialog;
}

20. UVCDialog#onCreateDialog()

Project: Tower
File: UVCDialog.java
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(initView());
    builder.setTitle(R.string.uvc_device_select);
    builder.setPositiveButton(android.R.string.ok, mOnDialogClickListener);
    builder.setNegativeButton(android.R.string.cancel, mOnDialogClickListener);
    builder.setNeutralButton(R.string.uvc_device_refresh, mOnDialogClickListener);
    final Dialog dialog = builder.create();
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
}

21. DialogTest#shouldCallOnDismissListener()

Project: robolectric
File: DialogTest.java
@Test
public void shouldCallOnDismissListener() throws Exception {
    final Transcript transcript = new Transcript();
    final Dialog dialog = new Dialog(null);
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInListener) {
            assertThat((Dialog) dialogInListener, sameInstance(dialog));
            transcript.add("onDismiss called!");
        }
    });
    dialog.dismiss();
    transcript.assertEventsSoFar("onDismiss called!");
}

22. SignInActivity#showNoPlayServicesError()

Project: ribot-app-android
File: SignInActivity.java
private void showNoPlayServicesError() {
    Dialog playServicesDialog = DialogFactory.createSimpleOkErrorDialog(SignInActivity.this, R.string.dialog_error_title, R.string.error_message_play_services);
    playServicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            finish();
        }
    });
    playServicesDialog.show();
}

23. UnitUtilWrapper#test()

Project: bither-android
File: UnitUtilWrapper.java
public static void test(Context context) {
    Dialog d = new Dialog(context);
    TextView tv = new TextView(context);
    ImageView iv = new ImageView(context);
    tv.setTextSize(20);
    tv.setText("100.00");
    iv.setImageBitmap(getBtcSymbol(Color.RED, tv.getTextSize(), unit()));
    LinearLayout ll = new LinearLayout(context);
    ll.setOrientation(LinearLayout.HORIZONTAL);
    ll.addView(iv);
    ll.addView(tv);
    LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) iv.getLayoutParams();
    lp.gravity = Gravity.CENTER_VERTICAL;
    lp = (LinearLayout.LayoutParams) tv.getLayoutParams();
    lp.gravity = Gravity.CENTER_VERTICAL;
    d.setContentView(ll, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    d.show();
}

24. AbsFullDialogFragment#onCreateDialog()

Project: ZhihuDailyFluxRRD
File: AbsFullDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // the content
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    return dialog;
}

25. BaseDialogFragment#onCreateDialog()

Project: android-styled-dialogs
File: BaseDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int theme = resolveTheme();
    Dialog dialog = new Dialog(getActivity(), theme);
    Bundle args = getArguments();
    if (args != null) {
        dialog.setCanceledOnTouchOutside(args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE));
    }
    dialog.setOnShowListener(this);
    return dialog;
}

26. ConfirmDialog#getDialog()

Project: android-obd-reader
File: ConfirmDialog.java
public static Dialog getDialog(final int id, String title, String message, Context context, final Listener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setCancelable(true);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            listener.onConfirmationDialogResponse(id, true);
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            listener.onConfirmationDialogResponse(id, false);
        }
    });
    Dialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}

27. ChangelogDialog#onCreateDialog()

Project: android
File: ChangelogDialog.java
/**
     * {@inheritDoc}
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    /// load the custom view to insert in the dialog, between title and 
    WebView webview = new WebView(getActivity());
    webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
    /// build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Dialog dialog = builder.setView(webview).setIcon(DisplayUtils.getSeasonalIconId()).setPositiveButton(//.setTitle(R.string.whats_new)
    R.string.common_ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).create();
    dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
    return dialog;
}

28. AlertUtils#showAlert()

Project: WordPress-Android
File: AlertUtils.java
/**
     * Show Alert Dialog
     * @param context
     * @param titleId
     * @param messageId
     * @param positiveButtontxt
     * @param positiveListener
     * @param negativeButtontxt
     * @param negativeListener
     */
public static void showAlert(Context context, int titleId, int messageId, CharSequence positiveButtontxt, DialogInterface.OnClickListener positiveListener, CharSequence negativeButtontxt, DialogInterface.OnClickListener negativeListener) {
    Dialog dlg = new AlertDialog.Builder(context).setTitle(titleId).setPositiveButton(positiveButtontxt, positiveListener).setNegativeButton(negativeButtontxt, negativeListener).setMessage(messageId).setCancelable(false).create();
    dlg.show();
}

29. ActivityTest#showDialog_shouldReuseDialogs()

Project: robolectric
File: ActivityTest.java
@Test
public void showDialog_shouldReuseDialogs() {
    final DialogCreatingActivity activity = new DialogCreatingActivity();
    activity.showDialog(1);
    Dialog firstDialog = ShadowDialog.getLatestDialog();
    activity.showDialog(1);
    final Dialog secondDialog = ShadowDialog.getLatestDialog();
    assertSame("dialogs should be the same instance", firstDialog, secondDialog);
}

30. EpisodeDialogFragment#onCreateDialog()

Project: popcorn-android-legacy
File: EpisodeDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                smoothDismiss();
            }
            return true;
        }
    });
    return dialog;
}

31. DiscountDialogFragment#onCreateDialog()

Project: openshop.io-android
File: DiscountDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity(), getTheme()) {

        @Override
        public void dismiss() {
            // Remove soft keyboard
            if (getActivity() != null && getView() != null) {
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
            }
            requestListener = null;
            super.dismiss();
        }
    };
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.getWindow().setWindowAnimations(R.style.dialogFragmentAnimation);
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}

32. ChangelogDialog#onCreateDialog()

Project: MyRepository-master
File: ChangelogDialog.java
/**
     * {@inheritDoc}
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    /// load the custom view to insert in the dialog, between title and 
    WebView webview = new WebView(getActivity());
    webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
    /// build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Dialog dialog = builder.setView(webview).setIcon(DisplayUtils.getSeasonalIconId()).setPositiveButton(//.setTitle(R.string.whats_new)
    R.string.common_ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).create();
    dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
    return dialog;
}

33. EditTextPreference#onShowDialog()

Project: MDPreference
File: EditTextPreference.java
@Override
protected void onShowDialog(Bundle state) {
    com.rey.material.dialog.Dialog.Builder mBuilder = new SimpleDialog.Builder().title(mDialogTitle).contentView(R.layout.mp_edittext).positiveAction(mPositiveButtonText, new com.rey.material.dialog.Dialog.Action1() {

        @Override
        public void onAction(com.rey.material.dialog.Dialog dialog) {
            String value = ((com.rey.material.widget.EditText) dialog.findViewById(R.id.custom_et)).getText().toString();
            if (callChangeListener(value)) {
                setText(value);
            }
        }
    }).negativeAction(mNegativeButtonText, null);
    final Dialog dialog = mDialog = mBuilder.build(getContext());
    EditText editText = (com.rey.material.widget.EditText) dialog.findViewById(R.id.custom_et);
    editText.setText(getSummary());
    editText.setSelection(getSummary() == null ? 0 : getSummary().length());
    if (state != null) {
        dialog.onRestoreInstanceState(state);
    }
    dialog.show();
}

34. FavAdapter#showDialogForSipData()

Project: CSipSimple
File: FavAdapter.java
private void showDialogForSipData(final Context context, final Long profileId, final String groupName, final String domain) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.set_android_group);
    builder.setCancelable(true);
    builder.setItems(R.array.sip_data_sources, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            applyNumbersToCSip(groupName, 1 << which, domain, profileId);
        }
    });
    final Dialog dialog = builder.create();
    dialog.show();
}

35. DirectMessagesItemClickListener#destroyConversation()

Project: YiBo
File: DirectMessagesItemClickListener.java
private void destroyConversation(final CacheAdapter<DirectMessage> cacheAdapter) {
    Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.title_dialog_alert).setMessage(R.string.msg_message_destroy_conversation_confirm).setPositiveButton(R.string.btn_confirm, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            DestroyDirectMessageTask destroyTask = new DestroyDirectMessageTask(cacheAdapter, message);
            destroyTask.execute();
        }
    }).setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    }).create();
    dialog.show();
}

36. DirectMessagesItemClickListener#onItemClick()

Project: YiBo
File: DirectMessagesItemClickListener.java
@SuppressWarnings("unchecked")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Adapter adapter = parent.getAdapter();
    message = (DirectMessage) adapter.getItem(position);
    if (message == null || (message instanceof LocalDirectMessage && ((LocalDirectMessage) message).isDivider())) {
        return;
    }
    if (adapter instanceof HeaderViewListAdapter) {
        adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
    }
    CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>) adapter;
    Dialog dialog = onCreateDialog(cacheAdapter, position);
    if (dialog != null) {
        dialog.show();
    }
}

37. ConversationItemClickListener#onItemClick()

Project: YiBo
File: ConversationItemClickListener.java
@SuppressWarnings("unchecked")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Adapter adapter = parent.getAdapter();
    message = (DirectMessage) adapter.getItem(position);
    if (message == null || (message instanceof LocalDirectMessage && ((LocalDirectMessage) message).isDivider())) {
        return;
    }
    if (adapter instanceof HeaderViewListAdapter) {
        adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
    }
    CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>) adapter;
    Dialog dialog = onCreateDialog(cacheAdapter, position);
    if (dialog != null) {
        dialog.show();
    }
}

38. CommentsItemClickListener#onItemClick()

Project: YiBo
File: CommentsItemClickListener.java
@SuppressWarnings("unchecked")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Adapter adapter = parent.getAdapter();
    comment = (Comment) adapter.getItem(position);
    if (comment == null || (comment instanceof LocalComment && ((LocalComment) comment).isDivider())) {
        return;
    }
    if (adapter instanceof HeaderViewListAdapter) {
        adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
    }
    CacheAdapter<Comment> cacheAdapter = (CacheAdapter<Comment>) adapter;
    Dialog dialog = onCreateDialog(cacheAdapter, position);
    if (dialog != null) {
        dialog.show();
    }
}

39. EditMicroBlogActivity#onCreateDialog()

Project: YiBo
File: EditMicroBlogActivity.java
@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog = null;
    switch(id) {
        case DIALOG_AGREEMENT:
            dialog = new AlertDialog.Builder(this).setTitle(R.string.title_dialog_alert).setMessage(R.string.msg_agreement_edit).setPositiveButton(R.string.btn_confirm, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
            break;
        default:
            break;
    }
    return dialog;
}

40. LearnMorePreference#showDialog()

Project: WordPress-Android
File: LearnMorePreference.java
private void showDialog() {
    final WebView webView = loadSupportWebView();
    mDialog = new Dialog(getContext());
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            webView.stopLoading();
            mDialog = null;
        }
    });
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.learn_more_pref_screen);
    WindowManager.LayoutParams params = mDialog.getWindow().getAttributes();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.CENTER;
    params.x = 12;
    params.y = 12;
    mDialog.getWindow().setAttributes(params);
    mDialog.show();
}

41. WebReviewActivity#showHWAccelMessage()

Project: WaniKani-for-Android
File: WebReviewActivity.java
protected void showHWAccelMessage() {
    AlertDialog.Builder builder;
    Dialog dialog;
    if (prefMan.getHWAccelMessage()) {
        builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.hw_accel_message_title);
        builder.setMessage(R.string.hw_accel_message_text);
        builder.setPositiveButton(R.string.ok, new AccelOkListener());
        dialog = builder.create();
        new PrefManager(this).setHWAccelMessage(false);
        dialog.show();
    }
}

42. WebReviewActivity#showIgnoreButtonMessage()

Project: WaniKani-for-Android
File: WebReviewActivity.java
protected void showIgnoreButtonMessage() {
    AlertDialog.Builder builder;
    Dialog dialog;
    if (visible && prefMan.getIgnoreButtonMessage()) {
        builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.ignore_button_message_title);
        builder.setMessage(R.string.ignore_button_message_text);
        builder.setPositiveButton(R.string.ignore_button_message_ok, new OkListener());
        dialog = builder.create();
        new PrefManager(this).setIgnoreButtonMessage(false);
        dialog.show();
    }
}

43. DialogFragmentExample#onCreateDialog()

Project: UltimateSwipeTool
File: DialogFragmentExample.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new AlertDialog.Builder(getContext()).setTitle("swipe dialog fragment").setIcon(R.mipmap.ic_launcher).setItems(new String[] { "1 any dialog ", "2 init in onCreateDialog" }, null).create();
    return dialog;
}

44. OkDialog#onStart()

Project: Tower
File: OkDialog.java
@Override
public void onStart() {
    super.onStart();
    Dialog dialog = getDialog();
    if (dialog != null) {
        dialog.setCanceledOnTouchOutside(dismissDialogWithoutClicking);
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                if (listener != null) {
                    listener.onCancel();
                }
            }
        });
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                if (listener != null) {
                    listener.onDismiss();
                }
            }
        });
    }
}

45. LoadingDialog#onStart()

Project: Tower
File: LoadingDialog.java
@Override
public void onStart() {
    super.onStart();
    Dialog dialog = getDialog();
    if (dialog != null) {
        dialog.setCanceledOnTouchOutside(true);
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                if (listener != null) {
                    listener.onCancel();
                }
            }
        });
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                if (listener != null) {
                    listener.onDismiss();
                }
            }
        });
    }
}

46. VideoPlayerPrepareListenerTest#onPreparedResumeDialogIsSetToExpectedValue()

Project: serenity-android
File: VideoPlayerPrepareListenerTest.java
@Test
public void onPreparedResumeDialogIsSetToExpectedValue() {
    videoPlayerPrepareListener = new VideoPlayerPrepareListener(spyMediaController, surfaceView, 100, false, "1.77", mockHandler, mockRunnable);
    videoPlayerPrepareListener.onPrepared(mockMediaPlayer);
    Dialog resumeDialog = ShadowDialog.getLatestDialog();
    ShadowDialog shadowDialog = Robolectric.shadowOf(resumeDialog);
    assertThat(shadowDialog.getTitle()).isEqualTo(resources.getText(R.string.resume_video));
}

47. VideoPlayerPrepareListenerTest#onPreparedShowsResumeDialogWhenAutoResumeIsFalseAndResumeOffsetNotZero()

Project: serenity-android
File: VideoPlayerPrepareListenerTest.java
@Test
public void onPreparedShowsResumeDialogWhenAutoResumeIsFalseAndResumeOffsetNotZero() {
    videoPlayerPrepareListener = new VideoPlayerPrepareListener(spyMediaController, surfaceView, 100, false, "1.77", mockHandler, mockRunnable);
    videoPlayerPrepareListener.onPrepared(mockMediaPlayer);
    Dialog resumeDialog = ShadowDialog.getLatestDialog();
    assertThat(resumeDialog).isNotNull();
    ShadowDialog shadowDialog = Robolectric.shadowOf(resumeDialog);
    assertThat(shadowDialog.getTitle()).isEqualTo(resources.getText(R.string.resume_video));
}

48. GridVideoOnItemLongClickListener#performInfoDialog()

Project: serenity-android
File: GridVideoOnItemLongClickListener.java
protected void performInfoDialog() {
    dialog.dismiss();
    detailsDialog = new Dialog(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Dialog));
    detailsDialog.setContentView(R.layout.details_layout);
    detailsDialog.setTitle("Details");
    ImageView posterImage = (ImageView) detailsDialog.findViewById(R.id.video_poster);
    posterImage.setVisibility(View.VISIBLE);
    posterImage.setScaleType(ScaleType.FIT_XY);
    serenityImageLoader.displayImage(info.getImageURL(), posterImage);
    TextView summary = (TextView) detailsDialog.findViewById(R.id.movieSummary);
    summary.setText(info.getSummary());
    TextView title = (TextView) detailsDialog.findViewById(R.id.movieBrowserPosterTitle);
    title.setText(info.getTitle());
    detailsDialog.show();
}

49. SeasonOnItemLongClickListener#onItemLongClick()

Project: serenity-android
File: SeasonOnItemLongClickListener.java
/**
	 * @return
	 */
protected boolean onItemLongClick() {
    dialog = new Dialog(context);
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(context, android.R.style.Theme_Holo));
    builder.setTitle(context.getString(R.string.season_options));
    ListView modeList = new ListView(context);
    modeList.setSelector(R.drawable.menu_item_selector);
    ArrayList<String> options = new ArrayList<String>();
    options.add(context.getString(R.string.add_season_to_queue));
    ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(context, R.layout.simple_list_item, R.id.list_item_text, options);
    modeList.setAdapter(modeAdapter);
    modeList.setOnItemClickListener(new DialogOnItemSelected());
    builder.setView(modeList);
    dialog = builder.create();
    dialog.show();
    return true;
}

50. AbstractTVShowOnItemLongClick#createAndShowDialog()

Project: serenity-android
File: AbstractTVShowOnItemLongClick.java
/**
	 *
	 */
public void createAndShowDialog() {
    dialog = new Dialog(context);
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Dialog));
    builder.setTitle(context.getString(R.string.video_options));
    ListView modeList = new ListView(context);
    modeList.setSelector(R.drawable.menu_item_selector);
    ArrayList<String> options = new ArrayList<String>();
    options.add(context.getString(R.string.toggle_watched_status));
    ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(context, R.layout.simple_list_item, R.id.list_item_text, options);
    modeList.setAdapter(modeAdapter);
    modeList.setOnItemClickListener(new DialogOnItemSelected());
    builder.setView(modeList);
    dialog = builder.create();
    dialog.show();
}

51. PickSubredditActivity#onCreateDialog()

Project: reddit-is-fun
File: PickSubredditActivity.java
@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;
    ProgressDialog pdialog;
    switch(id) {
        // "Please wait"
        case Constants.DIALOG_LOADING_REDDITS_LIST:
            pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
            pdialog.setMessage("Loading your reddits...");
            pdialog.setIndeterminate(true);
            pdialog.setCancelable(true);
            dialog = pdialog;
            break;
        default:
            throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

52. BaseDialogFragment#onStart()

Project: Pr0
File: BaseDialogFragment.java
@Override
public void onStart() {
    super.onStart();
    lifecycleSubject.onNext(FragmentEvent.START);
    // bind dialog. It is only created in on start.
    Dialog dialog = getDialog();
    if (dialog != null) {
        unbinder = ButterKnife.bind(this, dialog);
        onDialogViewCreated();
    }
}

53. ShippingDialogFragment#onStart()

Project: openshop.io-android
File: ShippingDialogFragment.java
@Override
public void onStart() {
    super.onStart();
    Dialog d = getDialog();
    if (d != null) {
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        Window window = d.getWindow();
        window.setLayout(width, height);
        window.setWindowAnimations(R.style.alertDialogAnimation);
    }
}

54. ProductImagesDialogFragment#onStart()

Project: openshop.io-android
File: ProductImagesDialogFragment.java
@Override
public void onStart() {
    super.onStart();
    Dialog d = getDialog();
    if (d != null) {
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        Window window = d.getWindow();
        window.setLayout(width, height);
        window.setWindowAnimations(R.style.dialogFragmentAnimation);
    }
}

55. PaymentDialogFragment#onStart()

Project: openshop.io-android
File: PaymentDialogFragment.java
@Override
public void onStart() {
    super.onStart();
    Dialog d = getDialog();
    if (d != null) {
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        Window window = d.getWindow();
        window.setLayout(width, height);
        window.setWindowAnimations(R.style.alertDialogAnimation);
    }
}

56. LicensesDialogFragment#onStart()

Project: openshop.io-android
File: LicensesDialogFragment.java
@Override
public void onStart() {
    super.onStart();
    Dialog d = getDialog();
    if (d != null) {
        Window window = d.getWindow();
        if (window != null)
            window.setWindowAnimations(R.style.dialogFragmentAnimation);
        else
            Timber.e("Cannot set dialog animation");
    }
}

57. FilterDialogFragment#onStart()

Project: openshop.io-android
File: FilterDialogFragment.java
@Override
public void onStart() {
    super.onStart();
    Dialog d = getDialog();
    if (d != null) {
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        Window window = d.getWindow();
        window.setLayout(width, height);
        window.setWindowAnimations(R.style.alertDialogAnimation);
    }
}

58. SharePasswordDialogFragment#onCreateDialog()

Project: MyRepository-master
File: SharePasswordDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mFile = getArguments().getParcelable(ARG_FILE);
    mCreateShare = getArguments().getBoolean(ARG_CREATE_SHARE, false);
    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.password_dialog, null);
    // Setup layout
    EditText inputText = ((EditText) v.findViewById(R.id.share_password));
    inputText.setText("");
    inputText.requestFocus();
    // Build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog_NoButtonBarStyle);
    builder.setView(v).setPositiveButton(R.string.common_ok, this).setNegativeButton(R.string.common_cancel, this).setTitle(R.string.share_link_password_title);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

59. SamlWebViewDialog#onDestroyView()

Project: MyRepository-master
File: SamlWebViewDialog.java
@Override
public void onDestroyView() {
    Log_OC.v(TAG, "onDestroyView");
    if ((ViewGroup) mSsoWebView.getParent() != null) {
        ((ViewGroup) mSsoWebView.getParent()).removeView(mSsoWebView);
    }
    mSsoWebView.setWebViewClient(null);
    // Work around bug: http://code.google.com/p/android/issues/detail?id=17423
    Dialog dialog = getDialog();
    if ((dialog != null)) {
        dialog.setOnDismissListener(null);
    }
    super.onDestroyView();
}

60. CreateFolderDialogFragment#onCreateDialog()

Project: MyRepository-master
File: CreateFolderDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mParentFolder = getArguments().getParcelable(ARG_PARENT_FOLDER);
    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.edit_box_dialog, null);
    // Setup layout 
    EditText inputText = ((EditText) v.findViewById(R.id.user_input));
    inputText.setText("");
    inputText.requestFocus();
    // Build the dialog  
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(v).setPositiveButton(R.string.common_ok, this).setNegativeButton(R.string.common_cancel, this).setTitle(R.string.uploader_info_dirname);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

61. LoginActivity#initLoginingDlg()

Project: MaterialQQLite
File: LoginActivity.java
private void initLoginingDlg() {
    m_dlgLogining = new Dialog(this, R.style.dialog);
    m_dlgLogining.setContentView(R.layout.loginingdlg);
    //    CircularProgress cp= (CircularProgress) findViewById(R.id.progress_circular_login);
    //    cp.setColor(color_theme);
    Window win = m_dlgLogining.getWindow();
    WindowManager.LayoutParams params = win.getAttributes();
    int cxScreen = getScreenWidth(this);
    int cyScreen = getScreenHeight(this);
    int cy = (int) getResources().getDimension(R.dimen.cyloginingdlg);
    int lrMargin = (int) getResources().getDimension(R.dimen.loginingdlg_lr_margin);
    int tMargin = (int) getResources().getDimension(R.dimen.loginingdlg_t_margin);
    params.x = -(cxScreen - lrMargin * 2) / 2;
    params.y = (-(cyScreen - cy) / 2) + tMargin;
    params.width = cxScreen;
    params.height = cy;
    //????Dialog????????Dialog
    m_dlgLogining.setCanceledOnTouchOutside(true);
//m_dlgLogining.setCancelable(false);		// ???false?????????
}

62. MaterialMultiSelectListPreference#onSaveInstanceState()

Project: material-dialogs
File: MaterialMultiSelectListPreference.java
@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;
}

63. MaterialListPreference#onSaveInstanceState()

Project: material-dialogs
File: MaterialListPreference.java
@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;
}

64. MaterialEditTextPreference#onSaveInstanceState()

Project: material-dialogs
File: MaterialEditTextPreference.java
@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;
}

65. MaterialDialogPreference#onSaveInstanceState()

Project: material-dialogs
File: MaterialDialogPreference.java
@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;
}

66. AndroidOnscreenKeyboard#createDialog()

Project: libgdx
File: AndroidOnscreenKeyboard.java
Dialog createDialog() {
    textView = createView(context);
    textView.setOnKeyListener(this);
    FrameLayout.LayoutParams textBoxLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
    textView.setLayoutParams(textBoxLayoutParams);
    textView.setFocusable(true);
    textView.setFocusableInTouchMode(true);
    textView.setImeOptions(textView.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    final FrameLayout layout = new FrameLayout(context);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
    layout.setLayoutParams(layoutParams);
    layout.addView(textView);
    layout.setOnTouchListener(this);
    dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    dialog.setContentView(layout);
    return dialog;
}

67. GoogleApiFragment#showErrorDialog()

Project: financius-public
File: GoogleApiFragment.java
private void showErrorDialog(int errorCode) {
    final Activity activity = getActivity();
    if (activity == null) {
        return;
    }
    // Get the error dialog fromInt Google Play services
    Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, getActivity(), REQUEST_GOOGLE_PLAY_SERVICES);
    // If Google Play services can provide an error dialog
    if (errorDialog != null) {
        // Create a new DialogFragment in which to show the error dialog
        ErrorDialogFragment errorFragment = new ErrorDialogFragment();
        // Set the dialog in the DialogFragment
        errorFragment.setDialog(errorDialog);
        // Show the error dialog in the DialogFragment
        errorFragment.show(getFragmentManager(), FRAGMENT_ERROR_DIALOG);
    }
}

68. ProgressDialogTask#createDialog()

Project: DroidPHP
File: ProgressDialogTask.java
protected Dialog createDialog() {
    LayoutInflater inflater = LayoutInflater.from(context);
    progress = new Dialog(context, R.style.Theme_DroidPHP_Dialog);
    progress.setContentView(inflater.inflate(R.layout.dialog_progress_holo, null));
    title = title != null ? title : context.getString(R.string.core_apps);
    message = message != null ? message : context.getString(R.string.installing_core_apps);
    //Title View
    tv_title = (TextView) progress.findViewById(R.id.title);
    tv_title.setText(title);
    //Message View
    tv_message = (TextView) progress.findViewById(R.id.message);
    tv_message.setText(message);
    //progressBar = (ProgressBar) progress.findViewById(R.id.pb_progress);
    return progress;
}

69. SupportBlurDialogFragment#onStart()

Project: BlurDialogFragment
File: SupportBlurDialogFragment.java
@Override
public void onStart() {
    Dialog dialog = getDialog();
    if (dialog != null) {
        // enable or disable dimming effect.
        if (!mDimmingEffect) {
            dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        }
        // add default fade to the dialog if no window animation has been set.
        int currentAnimation = dialog.getWindow().getAttributes().windowAnimations;
        if (currentAnimation == 0) {
            dialog.getWindow().getAttributes().windowAnimations = R.style.BlurDialogFragment_Default_Animation;
        }
    }
    super.onStart();
}

70. BlurDialogFragment#onStart()

Project: BlurDialogFragment
File: BlurDialogFragment.java
@Override
public void onStart() {
    Dialog dialog = getDialog();
    if (dialog != null) {
        // enable or disable dimming effect.
        if (!mDimmingEffect) {
            dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        }
        // add default fade to the dialog if no window animation has been set.
        int currentAnimation = dialog.getWindow().getAttributes().windowAnimations;
        if (currentAnimation == 0) {
            dialog.getWindow().getAttributes().windowAnimations = R.style.BlurDialogFragment_Default_Animation;
        }
    }
    super.onStart();
}

71. AddressDetailActivity#optionClicked()

Project: bither-android
File: AddressDetailActivity.java
protected void optionClicked() {
    Dialog dialog = null;
    if (address.isHDAccount()) {
        return;
    }
    if (address.isHDM()) {
        new DialogHDMAddressOptions(AddressDetailActivity.this, (HDMAddress) address, true).show();
    } else if (address.hasPrivKey()) {
        dialog = new DialogAddressWithPrivateKeyOption(AddressDetailActivity.this, address);
    } else {
        dialog = new DialogAddressWatchOnlyOption(AddressDetailActivity.this, address, new Runnable() {

            @Override
            public void run() {
                finish();
            }
        });
    }
    if (dialog != null) {
        dialog.show();
    }
}

72. ThemeDownloadActivity#showDialog()

Project: BeeFramework_Android
File: ThemeDownloadActivity.java
private void showDialog() {
    LayoutInflater inflater = LayoutInflater.from(this);
    View view = inflater.inflate(R.layout.download_dialog, null);
    mDialog = new Dialog(this, R.style.dialog);
    mDialog.setContentView(view);
    mDialog.setCanceledOnTouchOutside(false);
    progressBar = (ProgressBar) view.findViewById(R.id.download_progress);
    cancel = (TextView) view.findViewById(R.id.download_cancel);
    mDialog.show();
    cancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDialog.dismiss();
            cancelDownload = true;
        }
    });
    initThread("http://www.bee-framework.com/download/theme.zip");
}

73. TaskEditFragment#constructWhenDialog()

Project: astrid
File: TaskEditFragment.java
private void constructWhenDialog(View whenDialogView) {
    int theme = ThemeService.getEditDialogTheme();
    whenDialog = new Dialog(getActivity(), theme);
    Button dismissDialogButton = (Button) whenDialogView.findViewById(R.id.when_dismiss);
    dismissDialogButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DialogUtilities.dismissDialog(getActivity(), whenDialog);
        }
    });
    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    whenDialog.setTitle(R.string.TEA_when_dialog_title);
    whenDialog.addContentView(whenDialogView, new LayoutParams(metrics.widthPixels - (int) (30 * metrics.density), LayoutParams.WRAP_CONTENT));
}

74. DonationFragment#donateGoogle()

Project: androidclient
File: DonationFragment.java
private void donateGoogle() {
    // progress dialog
    Dialog dialog = new MaterialDialog.Builder(getActivity()).content(R.string.msg_connecting_iab).cancelable(true).progress(true, 0).cancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            // FIXME this doesn't seem to work in some cases
            if (mBillingService != null) {
                mBillingService.dispose();
                mBillingService = null;
            }
        }
    }).show();
    setupGoogle(dialog);
}

75. HelloWebView#onCreateDialog()

Project: android-demos
File: HelloWebView.java
@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog = null;
    switch(id) {
        case DIALOG_CHOOSE_VIEW_ID:
            dialog = getChooseViewDialog();
            break;
        default:
            dialog = super.onCreateDialog(id);
    }
    return dialog;
}

76. SharePasswordDialogFragment#onCreateDialog()

Project: android
File: SharePasswordDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mFile = getArguments().getParcelable(ARG_FILE);
    mCreateShare = getArguments().getBoolean(ARG_CREATE_SHARE, false);
    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.password_dialog, null);
    // Setup layout
    EditText inputText = ((EditText) v.findViewById(R.id.share_password));
    inputText.setText("");
    inputText.requestFocus();
    // Build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog_NoButtonBarStyle);
    builder.setView(v).setPositiveButton(R.string.common_ok, this).setNegativeButton(R.string.common_cancel, this).setTitle(R.string.share_link_password_title);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

77. SamlWebViewDialog#onDestroyView()

Project: android
File: SamlWebViewDialog.java
@Override
public void onDestroyView() {
    Log_OC.v(TAG, "onDestroyView");
    if ((ViewGroup) mSsoWebView.getParent() != null) {
        ((ViewGroup) mSsoWebView.getParent()).removeView(mSsoWebView);
    }
    mSsoWebView.setWebViewClient(null);
    // Work around bug: http://code.google.com/p/android/issues/detail?id=17423
    Dialog dialog = getDialog();
    if ((dialog != null)) {
        dialog.setOnDismissListener(null);
    }
    super.onDestroyView();
}

78. CreateFolderDialogFragment#onCreateDialog()

Project: android
File: CreateFolderDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mParentFolder = getArguments().getParcelable(ARG_PARENT_FOLDER);
    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.edit_box_dialog, null);
    // Setup layout 
    EditText inputText = ((EditText) v.findViewById(R.id.user_input));
    inputText.setText("");
    inputText.requestFocus();
    // Build the dialog  
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(v).setPositiveButton(R.string.common_ok, this).setNegativeButton(R.string.common_cancel, this).setTitle(R.string.uploader_info_dirname);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

79. ActivityMain#optionAbout()

Project: XPrivacy
File: ActivityMain.java
@SuppressLint("DefaultLocale")
private void optionAbout() {
    // About
    Dialog dlgAbout = new Dialog(this);
    dlgAbout.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dlgAbout.setTitle(R.string.menu_about);
    dlgAbout.setContentView(R.layout.about);
    dlgAbout.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
    // Show version
    try {
        int userId = Util.getUserId(Process.myUid());
        Version currentVersion = new Version(Util.getSelfVersionName(this));
        Version storedVersion = new Version(PrivacyManager.getSetting(userId, PrivacyManager.cSettingVersion, "0.0"));
        boolean migrated = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingMigrated, false);
        String versionName = currentVersion.toString();
        if (currentVersion.compareTo(storedVersion) != 0)
            versionName += "/" + storedVersion.toString();
        if (!migrated)
            versionName += "!";
        int versionCode = Util.getSelfVersionCode(this);
        TextView tvVersion = (TextView) dlgAbout.findViewById(R.id.tvVersion);
        tvVersion.setText(String.format(getString(R.string.app_version), versionName, versionCode));
    } catch (Throwable ex) {
        Util.bug(null, ex);
    }
    if (!PrivacyManager.cVersion3 || Hook.isAOSP(19))
        ((TextView) dlgAbout.findViewById(R.id.tvCompatibility)).setVisibility(View.GONE);
    // Show license
    String licensed = Util.hasProLicense(this);
    TextView tvLicensed1 = (TextView) dlgAbout.findViewById(R.id.tvLicensed);
    TextView tvLicensed2 = (TextView) dlgAbout.findViewById(R.id.tvLicensedAlt);
    if (licensed == null) {
        tvLicensed1.setText(Environment.getExternalStorageDirectory().getAbsolutePath());
        tvLicensed2.setText(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
    } else {
        tvLicensed1.setText(String.format(getString(R.string.app_licensed), licensed));
        tvLicensed2.setVisibility(View.GONE);
    }
    // Show some build properties
    String android = String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT);
    ((TextView) dlgAbout.findViewById(R.id.tvAndroid)).setText(android);
    ((TextView) dlgAbout.findViewById(R.id.build_brand)).setText(Build.BRAND);
    ((TextView) dlgAbout.findViewById(R.id.build_manufacturer)).setText(Build.MANUFACTURER);
    ((TextView) dlgAbout.findViewById(R.id.build_model)).setText(Build.MODEL);
    ((TextView) dlgAbout.findViewById(R.id.build_product)).setText(Build.PRODUCT);
    ((TextView) dlgAbout.findViewById(R.id.build_device)).setText(Build.DEVICE);
    ((TextView) dlgAbout.findViewById(R.id.build_host)).setText(Build.HOST);
    ((TextView) dlgAbout.findViewById(R.id.build_display)).setText(Build.DISPLAY);
    ((TextView) dlgAbout.findViewById(R.id.build_id)).setText(Build.ID);
    dlgAbout.setCancelable(true);
    final int userId = Util.getUserId(Process.myUid());
    if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFirstRun, true))
        dlgAbout.setOnDismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                Dialog dlgUsage = new Dialog(ActivityMain.this);
                dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
                dlgUsage.setTitle(R.string.app_name);
                dlgUsage.setContentView(R.layout.usage);
                dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
                dlgUsage.setCancelable(true);
                dlgUsage.setOnDismissListener(new DialogInterface.OnDismissListener() {

                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        PrivacyManager.setSetting(userId, PrivacyManager.cSettingFirstRun, Boolean.FALSE.toString());
                        optionLegend();
                    }
                });
                dlgUsage.show();
            }
        });
    dlgAbout.show();
}

80. ActivityApp#showHelp()

Project: XPrivacy
File: ActivityApp.java
@SuppressLint("InflateParams")
public static void showHelp(ActivityBase context, View parent, Hook hook) {
    // Build dialog
    Dialog dlgHelp = new Dialog(context);
    dlgHelp.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dlgHelp.setTitle(R.string.app_name);
    dlgHelp.setContentView(R.layout.helpfunc);
    dlgHelp.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, context.getThemed(R.attr.icon_launcher));
    dlgHelp.setCancelable(true);
    // Set title
    TextView tvTitle = (TextView) dlgHelp.findViewById(R.id.tvTitle);
    tvTitle.setText(hook.getName());
    // Set info
    TextView tvInfo = (TextView) dlgHelp.findViewById(R.id.tvInfo);
    tvInfo.setText(Html.fromHtml(hook.getAnnotation()));
    tvInfo.setMovementMethod(LinkMovementMethod.getInstance());
    // Set permissions
    String[] permissions = hook.getPermissions();
    if (permissions != null && permissions.length > 0)
        if (!permissions[0].equals("")) {
            TextView tvPermissions = (TextView) dlgHelp.findViewById(R.id.tvPermissions);
            tvPermissions.setText(Html.fromHtml(TextUtils.join("<br />", permissions)));
        }
    dlgHelp.show();
}

81. Util#showDialog()

Project: VideoRecorder
File: Util.java
/**
	 * ????
	 * 
	 * @param context
	 *            :Context ??????????activity??
	 * @param msg
	 *            :String ????????
	 * @param type
	 *            :int ????1??????2??“??”?“??”????
	 * @param handler
	 *            :Handler ????????handler?????????????msg.what = 1?????????
	 */
public static void showDialog(Context context, String title, String content, int type, final Handler handler) {
    final Dialog dialog = new Dialog(context, R.style.Dialog_loading);
    dialog.setCancelable(true);
    // ????????
    LayoutInflater inflater = LayoutInflater.from(context);
    View view = inflater.inflate(R.layout.global_dialog_tpl, null);
    Button confirmButton = (Button) view.findViewById(// ??
    R.id.setting_account_bind_confirm);
    Button cancelButton = (Button) view.findViewById(// ??
    R.id.setting_account_bind_cancel);
    TextView dialogTitle = (TextView) view.findViewById(// ??
    R.id.global_dialog_title);
    View lineHoriCenter = // ???
    view.findViewById(// ???
    R.id.line_hori_center);
    // ????????
    confirmButton.setVisibility(View.GONE);
    lineHoriCenter.setVisibility(View.GONE);
    TextView textView = (TextView) view.findViewById(R.id.setting_account_bind_text);
    // ????????
    Window dialogWindow = dialog.getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.width = (int) (context.getResources().getDisplayMetrics().density * 288);
    dialogWindow.setAttributes(lp);
    // ??????
    if (type != 1 && type != 2) {
        type = 1;
    }
    // ????
    dialogTitle.setText(title);
    // ??????
    textView.setText(content);
    // ??????
    if (type == 1 || type == 2) {
        confirmButton.setVisibility(View.VISIBLE);
        confirmButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (handler != null) {
                    Message msg = handler.obtainMessage();
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
                dialog.dismiss();
            }
        });
    }
    // ??????
    if (type == 2) {
        cancelButton.setVisibility(View.VISIBLE);
        lineHoriCenter.setVisibility(View.VISIBLE);
        cancelButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (handler != null) {
                    Message msg = handler.obtainMessage();
                    msg.what = 0;
                    handler.sendMessage(msg);
                }
                dialog.dismiss();
            }
        });
    }
    dialog.addContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // ???????
    dialog.setCancelable(true);
    // ??????
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

82. TwitterAuthUtils#showAuthDialog()

Project: socialize-sdk-android
File: TwitterAuthUtils.java
public Dialog showAuthDialog(final Context context, TwitterAuthProviderInfo info, final TwitterAuthListener listener) {
    Dialog dialog = newDialog(context);
    dialog.setTitle("Twitter Authentication");
    dialog.setCancelable(true);
    dialog.setOnCancelListener(newOnCancelListener(listener));
    TwitterAuthView view = twitterAuthViewFactory.getBean(info.getConsumerKey(), info.getConsumerSecret());
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    view.setLayoutParams(params);
    dialog.setContentView(view);
    view.setTwitterAuthListener(newTwitterAuthDialogListener(dialog, listener));
    view.authenticate();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    DialogRegistration.register(context, dialog);
    dialog.show();
    return dialog;
}

83. RateHelper#showRateDialog()

Project: rate-my-app
File: RateHelper.java
/**
     * Create a custom dialog personalized the way we want and show it, adding onclick listener
     * to its buttons.
     */
public void showRateDialog() {
    // Create the dialog
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    // Set as content to dialog a custom layout
    dialog.setContentView(R.layout.dialog_rate);
    // Set the background color of window to be transparent
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // Prevent user dismissing dialog by back-pressing
    dialog.setCancelable(false);
    // Set that dialog can't be dismissed by touching outside it
    dialog.setCanceledOnTouchOutside(false);
    // Find title textview and content textview
    TextView titleTextView = (TextView) dialog.findViewById(R.id.textview_title);
    TextView contentTextView = (TextView) dialog.findViewById(R.id.textview_content);
    // Find buttons from dialog
    Button rateButton = (Button) dialog.findViewById(R.id.button_rate);
    Button laterButton = (Button) dialog.findViewById(R.id.button_later);
    // Set text to title and content textview
    titleTextView.setText(dialogTitle);
    contentTextView.setText(dialogContent);
    // Apply tint
    titleTextView.setTextColor(tintColor);
    rateButton.setTextColor(tintColor);
    laterButton.setTextColor(tintColor);
    // Set rate button onclick listener
    rateButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Create intent to go to storeLink
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(storeLink));
            // Start it
            mContext.startActivity(i);
            // I have voted, so don't ever show rate-dialog
            noMoreShow();
            // Dismiss dialog
            dialog.dismiss();
        }
    });
    // Set later button onclick listener
    laterButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Just dismiss dialog, because i've already incremented show value
            dialog.dismiss();
        }
    });
    // Rate-dialog has been fully customized, so show it
    dialog.show();
}

84. LinkedIdCreateGithubFragment#oAuthRequest()

Project: open-keychain
File: LinkedIdCreateGithubFragment.java
public void oAuthRequest(String hostAndPath, String clientId, String scope) {
    Activity activity = getActivity();
    if (activity == null) {
        return;
    }
    byte[] buf = new byte[16];
    new Random().nextBytes(buf);
    mOAuthState = new String(Hex.encode(buf));
    mOAuthCode = null;
    final Dialog auth_dialog = new Dialog(activity);
    auth_dialog.setContentView(R.layout.oauth_webview);
    WebView web = (WebView) auth_dialog.findViewById(R.id.web_view);
    web.getSettings().setSaveFormData(false);
    web.getSettings().setUserAgentString("OpenKeychain " + BuildConfig.VERSION_NAME);
    web.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Uri uri = Uri.parse(url);
            if ("oauth-openkeychain".equals(uri.getScheme())) {
                if (mOAuthCode != null) {
                    return true;
                }
                if (uri.getQueryParameter("error") != null) {
                    Log.i(Constants.TAG, "got oauth error: " + uri.getQueryParameter("error"));
                    auth_dialog.dismiss();
                    return true;
                }
                // check if mOAuthState == queryParam[state]
                mOAuthCode = uri.getQueryParameter("code");
                auth_dialog.dismiss();
                return true;
            }
            // don't surf away from github!
            if (!"github.com".equals(uri.getHost())) {
                auth_dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    auth_dialog.setTitle(R.string.linked_webview_title_github);
    auth_dialog.setCancelable(true);
    auth_dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            step1GetOAuthToken();
        }
    });
    auth_dialog.show();
    web.loadUrl("https://" + hostAndPath + "?client_id=" + clientId + "&scope=" + scope + "&redirect_uri=oauth-openkeychain://linked/" + "&state=" + mOAuthState);
}

85. PrefsFragment#showApacheLicenseDialog()

Project: ZhihuDailyPurify
File: PrefsFragment.java
private void showApacheLicenseDialog() {
    final Dialog apacheLicenseDialog = new Dialog(getActivity());
    apacheLicenseDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    apacheLicenseDialog.setCancelable(true);
    apacheLicenseDialog.setContentView(R.layout.dialog_apache_license);
    TextView textView = (TextView) apacheLicenseDialog.findViewById(R.id.dialog_text);
    StringBuilder sb = new StringBuilder();
    sb.append(getString(R.string.licences_header)).append("\n");
    String[] basedOnProjects = getResources().getStringArray(R.array.apache_licensed_projects);
    for (String str : basedOnProjects) {
        sb.append("• ").append(str).append("\n");
    }
    sb.append("\n").append(getString(R.string.licenses_subheader));
    sb.append("\n\n").append(getString(R.string.apache_license));
    textView.setText(sb.toString());
    Button closeDialogButton = (Button) apacheLicenseDialog.findViewById(R.id.close_dialog_button);
    closeDialogButton.setOnClickListener( view -> apacheLicenseDialog.dismiss());
    closeDialogButton.setOnLongClickListener( v -> {
        apacheLicenseDialog.dismiss();
        Toast.makeText(getActivity(), getActivity().getString(R.string.accelerate_server_unlock), Toast.LENGTH_SHORT).show();
        PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putBoolean(Constants.SharedPreferencesKeys.KEY_SHOULD_ENABLE_ACCELERATE_SERVER, true).apply();
        return true;
    });
    apacheLicenseDialog.show();
}

86. VimTouch#showCmdHistory()

Project: vimtouch
File: VimTouch.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void showCmdHistory() {
    final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim);
    // Setting dialogview
    Window window = dialog.getWindow();
    window.setGravity(Gravity.BOTTOM);
    window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    dialog.setTitle(null);
    dialog.setContentView(R.layout.hist_list);
    dialog.setCancelable(true);
    LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout);
    if (AndroidCompat.SDK >= 11) {
        layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE | LinearLayout.SHOW_DIVIDER_END);
    }
    LayoutParams params = layout.getLayoutParams();
    params.width = mScreenWidth;
    layout.setLayoutParams(params);
    LayoutInflater inflater = LayoutInflater.from(this);
    boolean exists = false;
    for (int i = 0; i < 10; i++) {
        TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false);
        //String cmd = Exec.getCmdHistory(i);
        //if(cmd.length() == 0) break;
        //exists = true;
        //button.setText(":"+cmd);
        button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                TextView text = (TextView) v;
                CharSequence cmd = text.getText();
                if (cmd.length() > 1) {
                    ;
                }
                Exec.doCommand(cmd.subSequence(1, cmd.length()).toString());
                dialog.dismiss();
            }
        });
        layout.addView((View) button);
        button.setVisibility(View.GONE);
        mHistoryButtons[i] = button;
    }
    Exec.getHistory();
    //if(exists)
    dialog.show();
}

87. TimePickerDialog#onCreateDialog()

Project: TimePickerDialog
File: TimePickerDialog.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity(), R.style.Dialog_NoTitle);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(initView());
    return dialog;
}

88. HintManager#displayHint()

Project: Book-Catalogue
File: HintManager.java
/** Display the passed hint, if the user has not disabled it */
public static boolean displayHint(Context context, int stringId, final Runnable postRun, Object... args) {
    // Get the hint and return if it has been disabled.
    final Hint h = mHints.getHint(stringId);
    if (!h.shouldBeShown()) {
        if (postRun != null)
            postRun.run();
        return false;
    }
    // Build the hint dialog
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.hint_dialogue);
    // Get the various Views
    final TextView msg = (TextView) dialog.findViewById(R.id.hint);
    // new CheckBox(context);
    final CheckBox cb = (CheckBox) dialog.findViewById(R.id.hide_hint_checkbox);
    final Button ok = (Button) dialog.findViewById(R.id.confirm);
    // Setup the views
    String hintText = BookCatalogueApp.context.getResources().getString(stringId, args);
    msg.setText(Utils.linkifyHtml(hintText, Linkify.ALL));
    // Automatically start a browser (or whatever)
    msg.setMovementMethod(LinkMovementMethod.getInstance());
    //msg.setText(Html.fromHtml(hintText)); //stringId);
    //Linkify.addLinks(msg, Linkify.ALL);
    dialog.setTitle(R.string.hint);
    // Handle the 'OK' click
    ok.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
            // Disable hint if checkbox checked
            if (cb.isChecked()) {
                h.setVisibility(false);
            }
        }
    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            if (postRun != null)
                postRun.run();
        }
    });
    dialog.show();
    h.setHasBeenDisplayed(true);
    return true;
}

89. DateChangedAlerts#showRepeatTaskRescheduledDialog()

Project: astrid
File: DateChangedAlerts.java
public static void showRepeatTaskRescheduledDialog(final AstridActivity activity, final Task task, final long oldDueDate, final long newDueDate, final boolean lastTime) {
    if (!Preferences.getBoolean(PREF_SHOW_HELPERS, true))
        return;
    final Dialog d = new Dialog(activity, R.style.ReminderDialog);
    d.setContentView(R.layout.astrid_reminder_view);
    Button okButton = (Button) d.findViewById(R.id.reminder_complete);
    Button undoButton = (Button) d.findViewById(R.id.reminder_edit);
    Button keepGoing = (Button) d.findViewById(R.id.reminder_snooze);
    if (!lastTime) {
        keepGoing.setVisibility(View.GONE);
    } else {
        keepGoing.setText(R.string.repeat_keep_going);
        keepGoing.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                long startDate = 0;
                DateAndTimeDialog picker = new DateAndTimeDialog(activity, startDate, R.layout.repeat_until_dialog, R.string.repeat_until_title);
                picker.setDateAndTimeDialogListener(new DateAndTimeDialogListener() {

                    @Override
                    public void onDateAndTimeSelected(long date) {
                        d.dismiss();
                        task.setValue(Task.REPEAT_UNTIL, date);
                        RepeatTaskCompleteListener.rescheduleTask(task, newDueDate);
                        Flags.set(Flags.REFRESH);
                    }

                    @Override
                    public void onDateAndTimeCancelled() {
                    //
                    }
                });
                picker.show();
            }
        });
    }
    okButton.setText(R.string.DLG_ok);
    undoButton.setText(R.string.DLG_undo);
    int titleResource = lastTime ? R.string.repeat_rescheduling_dialog_title_last_time : R.string.repeat_rescheduling_dialog_title;
    ((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(titleResource, task.getValue(Task.TITLE)));
    String oldDueDateString = getRelativeDateAndTimeString(activity, oldDueDate);
    String newDueDateString = getRelativeDateAndTimeString(activity, newDueDate);
    String repeatUntilDateString = getRelativeDateAndTimeString(activity, task.getValue(Task.REPEAT_UNTIL));
    int encouragementResource = lastTime ? R.array.repeat_encouragement_last_time : R.array.repeat_encouragement;
    String[] encouragements = activity.getResources().getStringArray(encouragementResource);
    String encouragement = encouragements[(int) (Math.random() * encouragements.length)];
    String speechBubbleText;
    if (lastTime)
        speechBubbleText = activity.getString(R.string.repeat_rescheduling_dialog_bubble_last_time, repeatUntilDateString, encouragement);
    else if (!TextUtils.isEmpty(oldDueDateString))
        speechBubbleText = activity.getString(R.string.repeat_rescheduling_dialog_bubble, encouragement, oldDueDateString, newDueDateString);
    else
        speechBubbleText = activity.getString(R.string.repeat_rescheduling_dialog_bubble_no_date, encouragement, newDueDateString);
    ((TextView) d.findViewById(R.id.reminder_message)).setText(speechBubbleText);
    setupOkAndDismissButtons(d);
    setupHideCheckbox(d);
    undoButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            d.dismiss();
            task.setValue(Task.DUE_DATE, oldDueDate);
            task.setValue(Task.COMPLETION_DATE, 0L);
            long hideUntil = task.getValue(Task.HIDE_UNTIL);
            if (hideUntil > 0)
                task.setValue(Task.HIDE_UNTIL, hideUntil - (newDueDate - oldDueDate));
            PluginServices.getTaskService().save(task);
            Flags.set(Flags.REFRESH);
        }
    });
    setupDialogLayoutParams(activity, d);
    d.setOwnerActivity(activity);
    d.show();
}

90. DateChangedAlerts#showQuickAddMarkupDialog()

Project: astrid
File: DateChangedAlerts.java
public static void showQuickAddMarkupDialog(final AstridActivity activity, Task task, String originalText) {
    if (!Preferences.getBoolean(PREF_SHOW_HELPERS, true))
        return;
    final Dialog d = new Dialog(activity, R.style.ReminderDialog);
    final long taskId = task.getId();
    final boolean editable = task.isEditable();
    d.setContentView(R.layout.astrid_reminder_view);
    Button okButton = (Button) d.findViewById(R.id.reminder_complete);
    okButton.setText(R.string.DLG_ok);
    d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE);
    ((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.TLA_quickadd_confirm_title, originalText));
    Spanned speechBubbleText = constructSpeechBubbleTextForQuickAdd(activity, task);
    ((TextView) d.findViewById(R.id.reminder_message)).setText(speechBubbleText, TextView.BufferType.SPANNABLE);
    setupOkAndDismissButtons(d);
    setupHideCheckbox(d);
    d.findViewById(R.id.reminder_edit).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            d.dismiss();
            activity.onTaskListItemClicked(taskId, editable);
        }
    });
    setupDialogLayoutParams(activity, d);
    d.setOwnerActivity(activity);
    d.show();
}

91. TaskAdapter#showEditNotesDialog()

Project: astrid
File: TaskAdapter.java
private void showEditNotesDialog(final Task task) {
    String notes = null;
    Task t = taskService.fetchById(task.getId(), Task.NOTES);
    if (t != null)
        notes = t.getValue(Task.NOTES);
    if (TextUtils.isEmpty(notes))
        return;
    int theme = ThemeService.getEditDialogTheme();
    final Dialog dialog = new Dialog(fragment.getActivity(), theme);
    dialog.setTitle(R.string.TEA_note_label);
    View notesView = LayoutInflater.from(fragment.getActivity()).inflate(R.layout.notes_view_dialog, null);
    dialog.setContentView(notesView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    notesView.findViewById(R.id.edit_dlg_ok).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    final TextView notesField = (TextView) notesView.findViewById(R.id.notes);
    notesField.setText(notes);
    LayoutParams params = dialog.getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.WRAP_CONTENT;
    Configuration config = fragment.getResources().getConfiguration();
    int size = config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    if (AndroidUtilities.getSdkVersion() >= 9 && size == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        DisplayMetrics metrics = fragment.getResources().getDisplayMetrics();
        params.width = metrics.widthPixels / 2;
    }
    dialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    dialog.show();
}

92. SiteSettingsFragment#showListEditorDialog()

Project: WordPress-Android
File: SiteSettingsFragment.java
private void showListEditorDialog(int titleRes, int footerRes) {
    Dialog dialog = new Dialog(getActivity(), R.style.Calypso_SiteSettingsTheme);
    dialog.setOnDismissListener(this);
    dialog.setContentView(getListEditorView(dialog, getString(footerRes)));
    dialog.show();
    WPActivityUtils.addToolbarToDialog(this, dialog, getString(titleRes));
}

93. VKShareDialogDelegate#onCreateDialog()

Project: vk-android-sdk
File: VKShareDialogDelegate.java
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = dialogFragmentI.getActivity();
    View mInternalView = View.inflate(context, R.layout.vk_share_dialog, null);
    assert mInternalView != null;
    mSendButton = (Button) mInternalView.findViewById(R.id.sendButton);
    mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress);
    mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer);
    mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText);
    mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView);
    LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout);
    mSendButton.setOnClickListener(sendButtonPress);
    //Attachment text
    if (savedInstanceState != null) {
        mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY));
        mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY);
        mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY);
        mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY);
    } else if (mAttachmentText != null) {
        mShareTextField.setText(mAttachmentText);
    }
    //Attachment photos
    mPhotoLayout.removeAllViews();
    if (mAttachmentImages != null) {
        for (VKUploadImage mAttachmentImage : mAttachmentImages) {
            addBitmapToPreview(mAttachmentImage.mImageData);
        }
        mPhotoLayout.setVisibility(View.VISIBLE);
    }
    if (mExistingPhotos != null) {
        processExistingPhotos();
    }
    if (mExistingPhotos == null && mAttachmentImages == null) {
        mPhotoLayout.setVisibility(View.GONE);
    }
    //Attachment link
    if (mAttachmentLink != null) {
        TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle), linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost);
        linkTitle.setText(mAttachmentLink.linkTitle);
        linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl));
        mAttachmentLinkLayout.setVisibility(View.VISIBLE);
    } else {
        mAttachmentLinkLayout.setVisibility(View.GONE);
    }
    Dialog result = new Dialog(context);
    result.requestWindowFeature(Window.FEATURE_NO_TITLE);
    result.setContentView(mInternalView);
    result.setCancelable(true);
    return result;
}

94. VKOpenAuthDialog#show()

Project: vk-android-sdk
File: VKOpenAuthDialog.java
public void show(@NonNull Activity activity, Bundle bundle, int reqCode, @Nullable VKError vkError) {
    mVkError = vkError;
    mBundle = bundle;
    mReqCode = reqCode;
    mView = View.inflate(activity, R.layout.vk_open_auth_dialog, null);
    mProgress = mView.findViewById(R.id.progress);
    mWebView = (WebView) mView.findViewById(R.id.copyUrl);
    final Dialog dialog = new Dialog(activity, R.style.VKAlertDialog);
    dialog.setContentView(mView);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            dialog.dismiss();
        }
    });
    dialog.setOnDismissListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        dialog.getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    mDialog = dialog;
    mDialog.show();
    loadPage();
}

95. PluginImageAD#creatSelectDownloadDialog()

Project: SimplifyReader
File: PluginImageAD.java
// ??2G/3G?????????????
private void creatSelectDownloadDialog(Activity activity) {
    Dialog alertDialog = new AlertDialog.Builder(activity).setMessage("??????WiFi???????????????").setPositiveButton("??", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            new AdvClickProcessor().processAdvClick(mActivity, mADClickURL, mAdForward);
            dismissImageAD();
            if (mediaPlayerDelegate != null) {
                mediaPlayerDelegate.pluginManager.onLoading();
                mediaPlayerDelegate.startPlayAfterImageAD();
            }
        }
    }).setNegativeButton("??", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismissImageAD();
            if (mediaPlayerDelegate != null) {
                mediaPlayerDelegate.pluginManager.onLoading();
                mediaPlayerDelegate.startPlayAfterImageAD();
            }
        }
    }).create();
    alertDialog.setCancelable(false);
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
}

96. ProgressDialogFragment#onCreateDialog()

Project: SimpleCropView
File: ProgressDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // ???????????????
    dialog.setCancelable(false);
    // ?????????
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            // Disable Back key and Search key
            switch(keyCode) {
                case KeyEvent.KEYCODE_BACK:
                case KeyEvent.KEYCODE_SEARCH:
                    return true;
                default:
                    return false;
            }
        }
    });
    return dialog;
}

97. SettingsDialog#showDialog()

Project: QRParserLib
File: SettingsDialog.java
public void showDialog(final Activity activity) {
    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.ark_setting_dialog);
    final CheckBox allowHistoryDuplicate = (CheckBox) dialog.findViewById(R.id.allowDuplicateCheckBox);
    allowHistoryDuplicate.setChecked(HistoryManager.getInstance().isDuplicateHistory());
    allowHistoryDuplicate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            HistoryManager.getInstance().setDuplicateHistory(allowHistoryDuplicate.isChecked());
        }
    });
    Button clearHistory = (Button) dialog.findViewById(R.id.clearHistory);
    clearHistory.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean success = HistoryManager.getInstance().clearHistory(activity);
            if (success)
                Toast.makeText(activity, activity.getResources().getString(R.string.clear_history_success), Toast.LENGTH_SHORT).show();
            else
                Toast.makeText(activity, activity.getResources().getString(R.string.clear_history_failed), Toast.LENGTH_SHORT).show();
            if (listener != null)
                listener.onHistoryCleared();
            dialog.dismiss();
        }
    });
    dialog.show();
}

98. AppRater#showRateDialog()

Project: digitalocean-swimmer
File: AppRater.java
public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
    final Dialog dialog = new Dialog(mContext);
    dialog.setTitle(String.format(mContext.getResources().getString(R.string.rate_app), APP_TITLE));
    LinearLayout ll = new LinearLayout(mContext);
    ll.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(mContext);
    tv.setText(String.format(mContext.getResources().getString(R.string.rate_message), APP_TITLE));
    tv.setWidth(240);
    tv.setPadding(4, 0, 4, 10);
    ll.addView(tv);
    Button b1 = new Button(mContext);
    b1.setText(String.format(mContext.getResources().getString(R.string.rate_app), APP_TITLE));
    b1.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
            if (editor != null) {
                editor.putBoolean("dontshowagain", true);
                editor.commit();
            }
            dialog.dismiss();
        }
    });
    ll.addView(b1);
    Button b2 = new Button(mContext);
    b2.setText(mContext.getString(R.string.reminde_me_later));
    b2.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    ll.addView(b2);
    Button b3 = new Button(mContext);
    b3.setText(mContext.getString(R.string.no_thanks));
    b3.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            if (editor != null) {
                editor.putBoolean("dontshowagain", true);
                editor.commit();
            }
            dialog.dismiss();
        }
    });
    ll.addView(b3);
    dialog.setContentView(ll);
    dialog.show();
}

99. EditSeriesList#editSeries()

Project: Book-Catalogue
File: EditSeriesList.java
private void editSeries(final Series series) {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.edit_book_series);
    dialog.setTitle(R.string.edit_book_series);
    AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
    seriesView.setText(series.name);
    seriesView.setAdapter(mSeriesAdapter);
    EditText numView = (EditText) dialog.findViewById(R.id.series_num);
    numView.setText(series.num);
    setTextOrHideView(dialog.findViewById(R.id.title_label), mBookTitleLabel);
    setTextOrHideView(dialog.findViewById(R.id.title), mBookTitle);
    Button saveButton = (Button) dialog.findViewById(R.id.confirm);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
            EditText numView = (EditText) dialog.findViewById(R.id.series_num);
            String newName = seriesView.getText().toString().trim();
            if (newName == null || newName.length() == 0) {
                Toast.makeText(EditSeriesList.this, R.string.series_is_blank, Toast.LENGTH_LONG).show();
                return;
            }
            Series newSeries = new Series(newName, numView.getText().toString());
            confirmEditSeries(series, newSeries);
            dialog.dismiss();
        }
    });
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

100. EditSeriesDialog#editSeries()

Project: Book-Catalogue
File: EditSeriesDialog.java
public void editSeries(final Series series) {
    final Dialog dialog = new Dialog(mContext);
    dialog.setContentView(R.layout.edit_series);
    dialog.setTitle(R.string.edit_series);
    AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
    try {
        seriesView.setText(series.name);
    } catch (NullPointerException e) {
        Logger.logError(e);
    }
    seriesView.setAdapter(mSeriesAdapter);
    Button saveButton = (Button) dialog.findViewById(R.id.confirm);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
            String newName = seriesView.getText().toString().trim();
            if (newName == null || newName.length() == 0) {
                Toast.makeText(mContext, R.string.series_is_blank, Toast.LENGTH_LONG).show();
                return;
            }
            Series newSeries = new Series(newName, "");
            confirmEditSeries(series, newSeries);
            dialog.dismiss();
        }
    });
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
}