@Test public void destroyDialog() { screen.showDialog(new DialogCreator() { @Override public Dialog createDialog(Activity activity) { return dialog; } }); screen.destroyDialog(); verify(dialog).setOnDismissListener(null); verify(dialog).dismiss(); }
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(); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { ArrayList<DonateBean> dataList = (ArrayList<DonateBean>) getArguments().getSerializable("data"); return new AlertDialog.Builder(getActivity()) .setTitle(R.string.preference_support_title_sponsors) .setItems(parseData(dataList), null) .setPositiveButton(R.string.dlg_bt_donate_too, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (onDonateListener != null) { onDonateListener.onDonate(); } } }) .create(); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Bundle args = getArguments(); final AspectRatio[] ratios = (AspectRatio[]) args.getParcelableArray(ARG_ASPECT_RATIOS); if (ratios == null) { throw new RuntimeException("No ratios"); } Arrays.sort(ratios); final AspectRatio current = args.getParcelable(ARG_CURRENT_ASPECT_RATIO); final AspectRatioAdapter adapter = new AspectRatioAdapter(ratios, current); return new AlertDialog.Builder(getActivity()) .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int position) { mListener.onAspectRatioSelected(ratios[position]); } }) .create(); }
private void showRecoveryDialog(int statusCode) { Activity activity = getActivity("showRecoveryDialog()"); if (activity == null) { return; } if (sCanShowAuthUi) { sCanShowAuthUi = false; LOGD(TAG, "Showing recovery dialog for status code " + statusCode); final Dialog d = GooglePlayServicesUtil.getErrorDialog( statusCode, activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR); d.show(); } else { LOGD(TAG, "Not showing Play Services recovery dialog because sCanShowSignInUi==false."); reportAuthFailure(); } }
@Override public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View view = View.inflate(getActivity(), R.layout.bottom_sheet_attachments, null); mRecyclerView = view.findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false)); mEmptyView = view.findViewById(R.id.empty_root); view.findViewById(R.id.button_send).setOnClickListener(v -> { getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, null); getDialog().dismiss(); }); view.findViewById(R.id.button_hide).setOnClickListener(v -> getDialog().dismiss()); view.findViewById(R.id.button_video).setOnClickListener(v -> getPresenter().fireButtonVideoClick()); view.findViewById(R.id.button_doc).setOnClickListener(v -> getPresenter().fireButtonDocClick()); view.findViewById(R.id.button_camera).setOnClickListener(v -> getPresenter().fireButtonCameraClick()); dialog.setContentView(view); fireViewCreated(); }
private static Dialog setCodeDialogContentView(Context context){ switch (Adaptation.proportion){ case Adaptation.SCREEN_9_16: String model = Build.MODEL; if (model.contains("M1") || model.contains("m1")) { return getDialog(context, R.layout.dialog_code_9_16_m1); }else { return getDialog(context, R.layout.dialog_code_9_16); } case Adaptation.SCREEN_3_4: return getDialog(context, R.layout.dialog_code_9_16); case Adaptation.SCREEN_4_3: return getDialog(context, R.layout.dialog_code_16_9); case Adaptation.SCREEN_16_9: return getDialog(context, R.layout.dialog_code_16_9); default: return getDialog(context, R.layout.dialog_code_9_16); } }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View v = getActivity().getLayoutInflater().inflate(R.layout.create_share_dialog, null); pathEdit = (EditText) v.findViewById(R.id.edit_sharepath); pathEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); Dialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.manually_create_share) .setView(v) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.yes, this).create(); // Put the cursor at the end of "smb://" // This must be done after the dialog is created, else it does not work pathEdit.setSelection(pathEdit.getText().length()); return dialog; }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @SuppressLint("InflateParams") View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_board_contributors, null, false); unbinder = ButterKnife.bind(this, view); if (null == getActivity()) { return new AlertDialog.Builder(getActivity()) .setTitle(R.string.contributors) .setView(view) .setNegativeButton(R.string.closed, null) .create(); } else { return new android.support.v7.app.AlertDialog.Builder(getActivity()) .setTitle(R.string.contributors) .setView(view) .setNegativeButton(R.string.closed, null) .create(); } }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
/** * @brief Show the dialog with the help message * @return The new dialog * @details Show the dialog with the help message */ private Dialog openHelpDialog() { final TextView text = new TextView(this); text.setText(R.string.help_message); return new AlertDialog.Builder(this) .setTitle(R.string.help_title) .setView(text) .setPositiveButton(R.string.help_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } } ) .show(); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final List<Playlist> playlists = PlaylistLoader.getPlaylists(getActivity(), false); CharSequence[] chars = new CharSequence[playlists.size() + 1]; chars[0] = "Create new playlist"; for (int i = 0; i < playlists.size(); i++) { chars[i + 1] = playlists.get(i).name; } return new MaterialDialog.Builder(getActivity()).title("Add to playlist").items(chars).itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { long[] songs = getArguments().getLongArray("songs"); if (which == 0) { CreatePlaylistDialog.newInstance(songs).show(getActivity().getSupportFragmentManager(), "CREATE_PLAYLIST"); return; } MusicPlayer.addToPlaylist(getActivity(), songs, playlists.get(which - 1).id); dialog.dismiss(); } }).build(); }
@NonNull @SuppressLint("InflateParams") @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); if (savedInstanceState != null) { mBio = savedInstanceState.getString("bio", mBio); } builder.setView(inflater.inflate(R.layout.dialog_update_profile_info, null)) .setTitle(R.string.update_title) .setPositiveButton(R.string.update, null) .setNegativeButton(R.string.cancel, null); return builder.create(); }
private void onImageGoodsMenuClicked(Dialog d, int position) { switch (position) { case 0: shareImagePublic(currentClickImageUrl); break; case 1: shareImageCircle(currentClickImageUrl); break; case 2: shareImageGoods(currentClickImageUrl); break; case 3: saveImage(currentClickImageUrl); break; case 4: openImageMenuMore(); break; } }
@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.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
/** * Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet * (e.g., because onResume was called before the camera source was created), this will be called * again when the camera source is created. */ private void startCameraSource() throws SecurityException { // check that the device has play services available<uses-permission android:name="android.permission.CAMERA" />. int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( getApplicationContext()); if (code != ConnectionResult.SUCCESS) { Dialog dlg = GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS); dlg.show(); } if (mCameraSource != null) { try { mPreview.start(mCameraSource); } catch (IOException e) { Log.e(TAG, "Unable to start camera source.", e); mCameraSource.release(); mCameraSource = null; } } }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.fragamnt_add_comment, null); ButterKnife.bind(this, v); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v) .setPositiveButton(R.string.add_comment_btn, null) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dismiss(); } }); return builder.create(); }
private void initDialog() { contentLayout = new FrameLayout(activity); contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); contentLayout.setFocusable(true); contentLayout.setFocusableInTouchMode(true); //contentLayout.setFitsSystemWindows(true); dialog = new Dialog(activity); dialog.setCanceledOnTouchOutside(false);//触摸屏幕取消窗体 dialog.setCancelable(false);//按返回键取消窗体 dialog.setOnKeyListener(this); dialog.setOnDismissListener(this); Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //AndroidRuntimeException: requestFeature() must be called before adding content window.requestFeature(Window.FEATURE_NO_TITLE); window.setContentView(contentLayout); } setSize(screenWidthPixels, WRAP_CONTENT); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mSortSelected = getArguments().getInt(SORT); Log.d(getTag(), Integer.toString(mSortSelected)); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.sort_dialog_title); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_sort_issues, null); setRadioButtonSelected(view); setupView(view); return builder.setView(view).create(); }
/** * @brief Show the dialog with the exit question * @return The new dialog * @details Show the dialog with the exit question */ private Dialog exitDialog() { final String titleExit = getString(R.string.DialogTitleExit); final String question = getString(R.string.DialogQuestion); return new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(titleExit) .setMessage(question) .setNegativeButton(android.R.string.cancel, null)//sin listener .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which){ vnc.finishVnc(); finishConnection(); } }) .show(); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { View rootView = LayoutInflater.from(getContext()).inflate(R.layout.playlist_picker, new LinearLayout(getContext()), false); rv = (RecyclerView) rootView.findViewById(R.id.rv); MaterialDialog.Builder pickDialog = new MaterialDialog.Builder(getContext()); pickDialog.title(R.string.choose_playlist); playlistListAdapter = new PlaylistListAdapter(getContext()); playlistListAdapter.setOnItemClickListener(onClick); CustomLayoutManager customLayoutManager = new CustomLayoutManager(getContext()); customLayoutManager.setSmoothScrollbarEnabled(true); rv.addItemDecoration(new DividerItemDecoration(getContext(), 75, false)); rv.setLayoutManager(customLayoutManager); rv.setAdapter(playlistListAdapter); ateKey = Helper.getATEKey(getContext()); colorAccent = Config.accentColor(getContext(), ateKey); CreatePlaylist = (Button) rootView.findViewById(R.id.create_playlist); CreatePlaylist.setOnClickListener(mOnClickListener); CreatePlaylist.setBackgroundColor(colorAccent); pickDialog.customView(rootView, false); loadPlaylist(); return pickDialog.show(); }
/** * gif动画进度 * @param context * * @return */ public static Dialog createJDLoadingDialog(Activity context, DialogInterface.OnCancelListener listener) { final Dialog dialog = new Dialog(context , R.style.NoBackGroundDialog); dialog.show(); dialog.setCanceledOnTouchOutside(false); if(listener != null) dialog.setOnCancelListener(listener); Window window = dialog.getWindow(); assert window != null; window.setGravity(Gravity.CENTER); window.setLayout(android.view.WindowManager.LayoutParams.WRAP_CONTENT, android.view.WindowManager.LayoutParams.WRAP_CONTENT); View view = context.getLayoutInflater().inflate( R.layout.jd_loading_dialog, null); window.setContentView(view);// return dialog; }
public static Dialog buildDialog(Context context, boolean cancleable, boolean outsideTouchable) { if (context instanceof Activity){//todo keycode Activity activity = (Activity) context; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (activity.isDestroyed()){ context = StyledDialog.context; } } } Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(cancleable); dialog.setCanceledOnTouchOutside(outsideTouchable); return dialog; }
@NonNull @Override @SuppressLint("InflateParams") public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View root = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_login_guide, null); View loginButton = root.findViewById(R.id.login_button); RxView.clicks(loginButton) .throttleFirst(RxUtils.WINDOW_DURATION, RxUtils.TIME_UNIT) .subscribe(view -> { dismiss(); startActivity(new Intent(getContext(), AuthActivity.class)); }); builder.setView(root); return builder.create(); }
/** * 显示一个右上角弹出的menu * * @param activity * @param contentView * @param width * @param x * @param y * @return */ public static Dialog showTopRightMenu(Context activity, View contentView, int width, int x, int y) { Dialog dialog = new Dialog(activity, R.style.FullScreenDialog); dialog.setContentView(contentView); Window window = dialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); lp.width = width == 0 ? UIUtils.dip2px(120) : width; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.x = x == 0 ? UIUtils.dip2px(5) : x; lp.y = y == 0 ? UIUtils.dip2px(48) : y; lp.verticalMargin = 0; lp.horizontalMargin = 0; lp.dimAmount = 0.15f; window.setAttributes(lp); window.setWindowAnimations(R.style.topright_dialog); window.setGravity(Gravity.TOP | Gravity.RIGHT); // 此处可以设置dialog显示的位置 dialog.show(); return dialog; }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { View view = LayoutInflater.from(getContext()) .inflate(R.layout.dialog_edit_permissions, null); ButterKnife.bind(this, view); String packageName = getArguments().getString(EXTRA_PACKAGE); presenter.onCreate(this, packageName); return new AlertDialog.Builder(getContext()) .setIcon(R.drawable.ic_settings) .setTitle(R.string.dialog_edit_permissions_tutorial_title) .setPositiveButton(R.string.action_got_it, (dialogInterface, i) -> presenter.onPositiveButtonClicked()) .setNegativeButton(R.string.action_back, null) .setView(view) .create(); }
private ECListDialog getLinkMenuDialog() { if(linkMenuDlg!=null){ return linkMenuDlg; } linkMenuDlg = new ECListDialog(this, R.array.webview_action_link); linkMenuDlg.setTitle(getString(R.string.link)); linkMenuDlg.setOnDialogItemClickListener(new ECListDialog.OnDialogItemClickListener() { @Override public void onDialogItemClick(Dialog d, int position) { onLinkMenuClicked(d, position); } }); return linkMenuDlg; }
/** * @brief Override function to create dialogs * @param id the dialog ID * @return Dialog created * @details Creates the dialog with a showDialog(id) called, * id is the number of the dialog to be created */ @Override protected Dialog onCreateDialog(int id) { Dialog dialog = null; switch(id) { case 0: dialog = infoDialog(); break; case 1: dialog = createNonConnectionDialog(); break; case 2: dialog = createExitDialog(); break; case 3: dialog = createAboutDialog(); break; } return dialog; }
public static final Dialog createCameraAlertDialog(final Context context, int titleId, int messageId, int posiBtntextId){ CustomDialog r = new CustomDialog(context); r.setTitle(titleId); r.setMessage(messageId); DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: dialog.cancel(); break; } } }; r.setPositiveButton(posiBtntextId, onClickListener); r.setCancelable(false); return r; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Bundle arguments = getArguments(); final int requestCode = arguments.getInt(ARGUMENT_PERMISSION_REQUEST_CODE); mFinishActivity = arguments.getBoolean(ARGUMENT_FINISH_ACTIVITY); return new AlertDialog.Builder(getActivity()) // .setMessage(R.string.permission_rationale_location) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // After click on Ok, request the permission. ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, requestCode); // Do not finish the Activity while requesting permission. mFinishActivity = false; } }) .setNegativeButton(android.R.string.cancel, null) .create(); }
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Activity activity = getActivity(); return new AlertDialog.Builder(activity) .setMessage(getArguments().getString(ARG_MESSAGE)) .setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialogInterface, final int i) { activity.finish(); } }) .create(); }
@SuppressWarnings({"WeakerAccess", "unused"}) public Dialog showDialog(AlertDialog dialog) { dismissDialog(); this.dialog = dialog; dialog.show(); return dialog; }
@Override public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View view = View.inflate(getContext(), R.layout.fragment_bottomsheet_watcher, null); ButterKnife.bind(this, view); dialog.setContentView(view); setupViews(); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { ProgressDialog mProgressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.loading), true); mProgressDialog.setCanceledOnTouchOutside(false); return mProgressDialog; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); return new AlertDialog.Builder(activity) .setMessage(getArguments().getString(ARG_MESSAGE)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { activity.finish(); } }) .create(); }
public static void call(Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) { if (activity != null) { Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create(); if (!activity.isFinishing() && !activity.isRestricted()) { try { dialog.show(); } catch (Exception e) { } } } }
@Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.dialog_title) .setItems(R.array.addPillFinish, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AddPillSetTime activity = (AddPillSetTime) getActivity(); switch (which) { case 0: activity.saveIntake(); Intent intent = new Intent(getActivity(), AddPillSetTime.class); intent.putExtra(AddPillSetTime.EXTRA_MEDICINEID, activity.getMedicineId()) .putExtra(AddPillSetTime.EXTRA_RECEIPTID, activity.getReceiptID()); startActivity(intent); activity.finish(); break; case 1: activity.saveIntake(); activity.setNewAlarms(); getActivity().finish(); Intent i = new Intent(getContext(),ClockActivity.class); i.putExtra("pill", true); startActivity(i); break; default: throw new RuntimeException("Programming error! You should never reach default"); } } }); return builder.create(); }
public Dialog makeSimpleDialog(String text) { if (mActivity == null) { logError("*** makeSimpleDialog failed: no current Activity!"); return null; } return makeSimpleDialog(mActivity, text); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(R.string.text_about) .setMessage(R.string.text_dialog_about_msg) .setView(inflateCustom()) .setPositiveButton(R.string.text_dialog_about_positive, null); return builder.create(); }