List of usage examples for android.app AlertDialog.Builder getContext
public final @NonNull Context getContext()
From source file:com.android.deskclock.RingtonePickerDialogFragment.java
@Override public AlertDialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.DialogTheme); final Bundle args = getArguments(); mRingtoneAdapter = new RingtoneAdapter(builder.getContext()) .addStaticRingtone(R.string.silent_ringtone_title, Utils.RINGTONE_SILENT) .addStaticRingtone(args.getInt(ARGS_KEY_DEFAULT_RINGTONE_TITLE), (Uri) args.getParcelable(ARGS_KEY_DEFAULT_RINGTONE_URI)); mDialog = builder.setTitle(args.getInt(ARGS_KEY_TITLE)) .setSingleChoiceItems(mRingtoneAdapter, -1, this /* listener */) .setPositiveButton(android.R.string.ok, this /* listener */) .setNegativeButton(android.R.string.cancel, null /* listener */).create(); return mDialog; }
From source file:com.wizardsofm.deskclock.RingtonePickerDialogFragment.java
@Override public AlertDialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), com.wizardsofm.deskclock.R.style.DialogTheme); final Bundle args = getArguments(); mRingtoneAdapter = new RingtoneAdapter(builder.getContext()) .addStaticRingtone(com.wizardsofm.deskclock.R.string.silent_ringtone_title, Utils.RINGTONE_SILENT) .addStaticRingtone(args.getInt(ARGS_KEY_DEFAULT_RINGTONE_TITLE), (Uri) args.getParcelable(ARGS_KEY_DEFAULT_RINGTONE_URI)); mDialog = builder.setTitle(args.getInt(ARGS_KEY_TITLE)) .setSingleChoiceItems(mRingtoneAdapter, -1, this /* listener */) .setPositiveButton(android.R.string.ok, this /* listener */) .setNegativeButton(android.R.string.cancel, null /* listener */).create(); return mDialog; }
From source file:com.ruesga.rview.fragments.EditDialogFragment.java
@Override public void buildDialog(AlertDialog.Builder builder, Bundle savedInstanceState) { String title = getArguments().getString(EXTRA_TITLE); String action = getArguments().getString(EXTRA_ACTION); if (TextUtils.isEmpty(action)) { action = getString(R.string.action_change); }/*from w ww . ja v a 2 s. co m*/ boolean allowSuggestions = getArguments().getBoolean(EXTRA_ALLOW_SUGGESTIONS, false); int inputType = InputType.TYPE_CLASS_TEXT | (mModel.isMultiLine ? InputType.TYPE_TEXT_FLAG_MULTI_LINE : 0) | (allowSuggestions ? 0 : InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); LayoutInflater inflater = LayoutInflater.from(builder.getContext()); mBinding = DataBindingUtil.inflate(inflater, R.layout.edit_dialog, null, true); mBinding.edit.setInputType(inputType); mBinding.edit.addTextChangedListener(mTextWatcher); mBinding.setModel(mModel); builder.setTitle(title).setView(mBinding.getRoot()).setNegativeButton(R.string.action_cancel, null) .setPositiveButton(action, (dialog, which) -> performEditChanged()); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
@SuppressLint("NewApi") private View createUpdatesFoundDialogContentsView(Update update) { Context context = activity;// w ww .ja v a 2 s . c om final AlertDialog.Builder builder; // Workaround for dialog theme problems if (android.os.Build.VERSION.SDK_INT > 10) { builder = new AlertDialog.Builder(context); context = builder.getContext(); } else { context = new ContextThemeWrapper(context, android.R.style.Theme_Dialog); builder = new AlertDialog.Builder(context); } builder.setTitle("Send feedback"); final LayoutInflater inflater = LayoutInflater.from(context); final View dialogContentsView = inflater.inflate(R.layout.updater_dialog_update_found, null, false); final TextView messageTextView = (TextView) dialogContentsView .findViewById(R.id.dialog_update_found_message); final TextView warningTextView = (TextView) dialogContentsView .findViewById(R.id.dialog_update_found_warning); final TextView whatIsNewTextView = (TextView) dialogContentsView .findViewById(R.id.dialog_update_found_what_is_new); String warnings = null; String message = null; String whatIsNew = null; if (update.description != null) { warnings = update.description.get(UpdateDescription.KEY_WARNINGS); message = update.description.get(UpdateDescription.KEY_MESSAGE); whatIsNew = update.description.get(UpdateDescription.KEY_WHAT_IS_NEW); } if (Utilities.isNullOrEmpty(message)) { messageTextView.setVisibility(View.GONE); } else { messageTextView.setText(message); } if (Utilities.isNullOrEmpty(warnings)) { warningTextView.setVisibility(View.GONE); } else { warningTextView.setText(warnings); } if (Utilities.isNullOrEmpty(whatIsNew)) { whatIsNewTextView.setVisibility(View.GONE); } else { whatIsNewTextView.setText(whatIsNew); } return dialogContentsView; }
From source file:org.gateshipone.odyssey.dialogs.SaveDialog.java
/** * Create the dialog to save an object of the current type. *///from w w w. ja v a 2s . c o m @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // read arguments to identify type of the object which should be saved Bundle mArgs = getArguments(); final OBJECTTYPE type = OBJECTTYPE.values()[mArgs.getInt(ARG_OBJECTTYPE)]; String dialogTitle = ""; String editTextDefaultTitle = ""; if (type != null) { // set textfield titles according to type switch (type) { case PLAYLIST: dialogTitle = getString(R.string.dialog_save_playlist); editTextDefaultTitle = getString(R.string.default_playlist_title); break; case BOOKMARK: dialogTitle = getString(R.string.dialog_create_bookmark); editTextDefaultTitle = getString(R.string.default_bookmark_title); break; } } // create edit text for title final EditText editTextTitle = new EditText(builder.getContext()); editTextTitle.setText(editTextDefaultTitle); // Add a listener that just removes the text on first clicking editTextTitle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!mFirstClick) { editTextTitle.setText(""); mFirstClick = true; } } }); builder.setView(editTextTitle); builder.setMessage(dialogTitle) .setPositiveButton(R.string.dialog_action_save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // accept title and call callback method String objectTitle = editTextTitle.getText().toString(); mSaveCallback.onSaveObject(objectTitle, type); } }).setNegativeButton(R.string.dialog_action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog dont save object getDialog().cancel(); } }); // Create the AlertDialog object and return it return builder.create(); }
From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java
@SuppressLint("InflateParams") private void showFavoritesInfoDialog() { Context context = getContext2(); if (null == context || null == mFavCatArray || null == mFavCountArray) { return;//from ww w.ja v a 2 s. c om } AlertDialog.Builder builder = new AlertDialog.Builder(context); context = builder.getContext(); final LayoutInflater inflater = LayoutInflater.from(context); EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null); rv.setAdapter(new InfoAdapter(inflater)); rv.setLayoutManager(new LinearLayoutManager(context)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1)); decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding)); rv.addItemDecoration(decoration); rv.setSelector(Ripple.generateRippleDrawable(context, false)); rv.setClipToPadding(false); builder.setView(rv).show(); }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private void showStickerDialog() { if (stickerDialog == null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.drawable.ic_sentiment_satisfied_black_48dp); builder.setTitle(getResources().getString(R.string.supersede_feedbacklibrary_sticker_dialog_title)); builder.setNegativeButton(getResources().getString(R.string.supersede_feedbacklibrary_cancel_string), new DialogInterface.OnClickListener() { @Override/*from www. j a va 2s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); if (stickerArrayAdapter == null) { stickerArrayAdapter = new StickerArrayAdapter(builder.getContext(), stickerIcons, stickerLabels); } builder.setAdapter(stickerArrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { addSticker(stickerArrayAdapter.getIcons().get(which)); } }); builder.setCancelable(false); stickerDialog = builder.create(); } stickerDialog.show(); }