Java Code Examples for android.support.v7.app.AlertDialog

The following are top voted examples for showing how to use android.support.v7.app.AlertDialog. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: CustomTileDimensions.java   View source code 7 votes vote down vote up
@OnClick(R.id.custom_tile_height_size)
public void onHeightClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileHeight);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileHeight = view.getValue();
              widget.setTileHeightDp(currentTileHeight);
            }
          })
          .show();
}
 
Example 2
Project: CatchSpy   File: EditListAdapter.java   View source code 6 votes vote down vote up
public void addWords() {
    LayoutInflater inflater = activity.getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_edit_extra_words, (ViewGroup) activity.findViewById(R.id.dialog_layout_edit_words));
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.add);
    final TextInputEditText word_1 = mView.findViewById(R.id.edittext_edit_word_1);
    final TextInputEditText word_2 = mView.findViewById(R.id.edittext_edit_word_2);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String edit_1 = word_1.getText().toString();
            String edit_2 = word_2.getText().toString();
            if (!edit_1.isEmpty() && !edit_2.isEmpty()) {
                ExtraWord.add(new String[]{edit_1, edit_2});
                hasEdited = true;
                notifyDataSetChanged();
            } else {
                Toast.makeText(activity, R.string.edit_extra_words_error, Toast.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
Example 3
Project: papara-android   File: MainActivity.java   View source code 6 votes vote down vote up
private void showResultDialog(final String message, int code) {

        try {
            final AlertDialog dialog = new AlertDialog.Builder(this)
                    .setTitle(getString(com.mobillium.paparasdk.R.string.title))
                    .setMessage(message + " (" + code + ")")
                    .setPositiveButton(getString(R.string.done), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();

            dialog.setCanceledOnTouchOutside(false);
            dialog.show();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
 
Example 4
Project: KUtils-master   File: Buildable.java   View source code 6 votes vote down vote up
protected BuildBean buildMdLoadingVertical(BuildBean bean) {
    AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
    View root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
    View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
    ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
    TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
    tvMsg.setText(bean.msg);
    if (bean.isWhiteBg) {
        llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
        pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
        tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
    } else {
        llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
        pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
        tvMsg.setTextColor(Color.WHITE);
    }
    builder.setView(root);
    AlertDialog dialog = builder.create();
    bean.alertDialog = dialog;
    return bean;
}
 
Example 5
Project: Bigbang   File: ColorPickerDialogBuilder.java   View source code 6 votes vote down vote up
private ColorPickerDialogBuilder(Context context, int theme) {
	defaultMargin = getDimensionAsPx(context, R.dimen.default_slider_margin);
	final int dialogMarginBetweenTitle = getDimensionAsPx(context, R.dimen.default_slider_margin_btw_title);

	builder = new AlertDialog.Builder(context, theme);
	pickerContainer = new LinearLayout(context);
	pickerContainer.setOrientation(LinearLayout.VERTICAL);
	pickerContainer.setGravity(Gravity.CENTER_HORIZONTAL);
	pickerContainer.setPadding(defaultMargin, dialogMarginBetweenTitle, defaultMargin, defaultMargin);

	LinearLayout.LayoutParams layoutParamsForColorPickerView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
	layoutParamsForColorPickerView.weight = 1;
	colorPickerView = new ColorPickerView(context);

	pickerContainer.addView(colorPickerView, layoutParamsForColorPickerView);

	builder.setView(pickerContainer);
}
 
Example 6
Project: TrackPlan-app   File: MainActivity.java   View source code 6 votes vote down vote up
void gotosetper(float percentageall)
{
    LayoutInflater inflater = getLayoutInflater();
    View alertLayout = inflater.inflate(R.layout.layoutforperall, null);
    TextView pe=(TextView)alertLayout.findViewById(R.id.peralllll);
    AlertDialog.Builder alert = new AlertDialog.Builder(this);




    // this is set the view from XML inside AlertDialog
    alert.setView(alertLayout);
    // disallow cancel of AlertDialog on click of back button and outside touch


    final AlertDialog dialog = alert.create();
    dialog.show();
    pe.setText("Your Overall percentage is : "+percentageall+"%"+"\n");
    Button ok=(Button)alertLayout.findViewById(R.id.button11);
    ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}
 
Example 7
Project: BookReader-master   File: ReadActivity.java   View source code 6 votes vote down vote up
@OnClick(R.id.tvBookReadDownload)
public void downloadBook() {
    gone(rlReadAaSet);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("缓存多少章?")
            .setItems(new String[]{"后面五十章", "后面全部", "全部"}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                        case 0:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, currentChapter + 50));
                            break;
                        case 1:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, mChapterList.size()));
                            break;
                        case 2:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, 1, mChapterList.size()));
                            break;
                        default:
                            break;
                    }
                }
            });
    builder.show();
}
 
Example 8
Project: MuslimMateAndroid   File: Utility.java   View source code 6 votes vote down vote up
public static void getInput(Context context, String title, DialogInterface.OnClickListener onOkListener)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);

    final EditText input = new EditText(context);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setId(R.id.text1);
    builder.setView(input);

    builder.setPositiveButton("OK", onOkListener);

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}
 
Example 9
Project: mDL-ILP   File: PersoActivity.java   View source code 6 votes vote down vote up
@Override
protected void onPostExecute(Certificate certificate) {
    progressDialog.dismiss();

    if (certificate != null) {
        StorageUtils.saveObject(PersoActivity.this, getString(R.string.tls_client_cert_key), certificate);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(PersoActivity.this);
        builder.setTitle(R.string.perso_problem_title);
        builder.setMessage(R.string.perso_problem_register);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.create().show();
    }
}
 
Example 10
Project: Cable-Android   File: RegistrationProgressActivity.java   View source code 6 votes vote down vote up
private void initializeLinks() {
  TextView        failureText     = (TextView) findViewById(R.id.sms_failed_text);
  String          pretext         = getString(R.string.registration_progress_activity__signal_timed_out_while_waiting_for_a_verification_sms_message);
  String          link            = getString(R.string.RegistrationProblemsActivity_possible_problems);
  SpannableString spannableString = new SpannableString(pretext + " " + link);

  spannableString.setSpan(new ClickableSpan() {
    @Override
    public void onClick(View widget) {
      new AlertDialog.Builder(RegistrationProgressActivity.this)
              .setTitle(R.string.RegistrationProblemsActivity_possible_problems)
              .setView(R.layout.registration_problems)
              .setNeutralButton(android.R.string.ok, null)
              .show();
    }
  }, pretext.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

  failureText.setText(spannableString);
  failureText.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 11
Project: MontageCam   File: AspectRatioFragment.java   View source code 6 votes vote down vote up
@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();
}
 
Example 12
Project: Udhari   File: QrCodeActivity.java   View source code 6 votes vote down vote up
@Override
public void handleResult(Result result) {
    if (result.getText().split(":").length > 2) {
        ContentValues contentValues = new ContentValues();
        contentValues.put(DatabaseContract.TableTransactions.COL_DATE, getAmount(result.getText(), DATE)); // bug
        contentValues.put(DatabaseContract.TableTransactions.COL_AMOUNT, getAmount(result.getText(), AMOUNT)); // bug

        AddTxService.insertNewTx(getApplicationContext(), contentValues);
        Intent goBackToMain = new Intent(this, MainActivity.class);
        startActivity(goBackToMain);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Scan Result");
        builder.setMessage("Not a valid value");
        builder.show();
    }
}
 
Example 13
Project: Transmis   File: DialogBuilder.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
public static AlertDialog showEditTextDialog(BaseActivity activity, String title, String content,
                                             boolean isPassword, EditTextDialogCallback callback) {
    View layout = LayoutInflater.from(activity).inflate(R.layout.view_dialog_edit_text, null);
    EditText input = (EditText) layout.findViewById(R.id.edit_text);
    input.setText(content);
    if (isPassword) {
        input.setInputType(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
    }
    input.setSelection(input.getText().length());

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(title);
    builder.setView(layout);
    builder.setPositiveButton("确定", (dialog, which) -> {
        if (callback != null) {
            callback.onSuccess(input.getText().toString());
        }
    });
    builder.setNegativeButton("取消", (dialog, which) -> dialog.dismiss());

    return builder.show();
}
 
Example 14
Project: Channelize   File: ToDoListAdapter.java   View source code 6 votes vote down vote up
private void showPopupMenu(View view) {
    final CharSequence[] items = {"Edit", "Delete"};
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);

    builder.setTitle(mTextName.getText());
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            int position = getAdapterPosition();
            switch (which){
                case 0://Edit
                    listener.editTask(position);
                    break;
                case 1://Delete
                    listener.deleteTask(position);
                    break;
            }
        }
    });
    builder.show();
}
 
Example 15
Project: RxGallery   File: MainActivity.java   View source code 6 votes vote down vote up
public void takePhoto(View view) {
    String[] items = new String[]{getString(R.string.output_dialog_external),
            getString(R.string.output_dialog_mediastore)};

    new AlertDialog.Builder(this)
            .setTitle(getString(R.string.output_dialog_title))
            .setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Uri outputUri = null;
                    if (which == 0) {
                        outputUri = getExternalStorageUri();
                    }
                    takePhoto(outputUri);
                    dialog.dismiss();
                }
            }).show();
}
 
Example 16
Project: MyCalendar   File: AddEditDetailCancelDialogFragment.java   View source code 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    if (!initData()) {
        this.getDialog().cancel();
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    // Get the layout inflater
    LayoutInflater inflater = mActivity.getLayoutInflater();

    @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.dialog_fragment_add_edit_detail_cancel, null);

    initView(view);

    builder.setView(view)
            .setTitle(getTitle());

    setButton(builder);

    return builder.create();
}
 
Example 17
Project: GitHub   File: ReadActivity.java   View source code 6 votes vote down vote up
@OnClick(R.id.tvBookReadDownload)
public void downloadBook() {
    gone(rlReadAaSet);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("缓存多少章?")
            .setItems(new String[]{"后面五十章", "后面全部", "全部"}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                        case 0:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, currentChapter + 50));
                            break;
                        case 1:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, mChapterList.size()));
                            break;
                        case 2:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, 1, mChapterList.size()));
                            break;
                        default:
                            break;
                    }
                }
            });
    builder.show();
}
 
Example 18
Project: readingNotes   File: ListDiaryFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    final int location = position;
    new AlertDialog.Builder(activity)
            .setTitle("警告")
            .setMessage("确定删除此条数据吗?")
            .setPositiveButton("是", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    SQLiteDatabase sqLiteDatabase = openHelper.getReadableDatabase();
                    DiaryDao diaryDao = new DiaryDao(sqLiteDatabase);
                    diaryDao.delete(diaryList.get(location));
                    diaryList.remove(location);
                    sqLiteDatabase.close();
                    dataList.remove(location);
                    simpleAdapter.notifyDataSetChanged();
                }
            })
            .setNegativeButton("否", null)
            .show();
    return true;
}
 
Example 19
Project: AndroidUtilCode-master   File: KeyboardDialog.java   View source code 6 votes vote down vote up
public void show(){
    final Activity activity = mActivityWeakReference.get();
    if (activity != null) {
        final View dialogView = LayoutInflater.from(activity).inflate(R.layout.dialog_keyboard, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        etInput = (EditText) dialogView.findViewById(R.id.et_input);
        dialog = builder.setView(dialogView).create();
        dialog.setCanceledOnTouchOutside(false);
        dialogView.findViewById(R.id.btn_hide_soft_input).setOnClickListener(this);
        dialogView.findViewById(R.id.btn_show_soft_input).setOnClickListener(this);
        dialogView.findViewById(R.id.btn_toggle_soft_input).setOnClickListener(this);
        dialogView.findViewById(R.id.btn_close_dialog).setOnClickListener(this);
        dialog.show();
        KeyboardUtils.showSoftInput(activity);
    }
}
 
Example 20
Project: GitHub   File: MessageDialog.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
	View dialogView = LayoutInflater.from(getActivity())
			.inflate(R.layout.dialog_message, null);

	TextView messageView = (TextView) dialogView.findViewById(R.id.message);
	messageView.setMovementMethod(LinkMovementMethod.getInstance());
	messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));

	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
	builder.setTitle(getArguments().getString(ARG_TITLE))
			.setIcon(getArguments().getInt(ARG_ICON))
			.setView(dialogView)
			.setPositiveButton(R.string.OK, new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
			});

	return builder.create();
}
 
Example 21
Project: javaide   File: ColorPickerDialogBuilder.java   View source code 6 votes vote down vote up
private ColorPickerDialogBuilder(Context context, int theme) {
	defaultMargin = getDimensionAsPx(context, R.dimen.default_slider_margin);
	final int dialogMarginBetweenTitle = getDimensionAsPx(context, R.dimen.default_slider_margin_btw_title);

	builder = new AlertDialog.Builder(context, theme);
	pickerContainer = new LinearLayout(context);
	pickerContainer.setOrientation(LinearLayout.VERTICAL);
	pickerContainer.setGravity(Gravity.CENTER_HORIZONTAL);
	pickerContainer.setPadding(defaultMargin, dialogMarginBetweenTitle, defaultMargin, defaultMargin);

	LinearLayout.LayoutParams layoutParamsForColorPickerView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
	layoutParamsForColorPickerView.weight = 1;
	colorPickerView = new ColorPickerView(context);

	pickerContainer.addView(colorPickerView, layoutParamsForColorPickerView);

	builder.setView(pickerContainer);
}
 
Example 22
Project: MovingGdufe-Android   File: MeFragment.java   View source code 6 votes vote down vote up
@OnClick(R.id.tv_me_share) void clickShare() {
    android.app.AlertDialog.Builder builder=new android.app.AlertDialog.Builder(getActivity());
    builder.setIcon(R.mipmap.app_icon);
    builder.setTitle("爱分享的人运气总不会差");
    builder.setItems(R.array.shareList, new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialog, int which) {
            int scene = SendMessageToWX.Req.WXSceneSession;
            if(which == 1) {
                scene = SendMessageToWX.Req.WXSceneTimeline;
            }else if(which == 2){
                scene = SendMessageToWX.Req.WXSceneFavorite;
            }
            ShareUtils.install(getActivity());
            ShareUtils.shareWeb(getActivity(),getResources().getString(R.string.app_name)+",你的掌上校园伴侣","广财专用APP,学生开发,课表饭卡校园网,一样不少",AppConfig.WXSHARE_URL, scene);
        }
    });
    builder.create().show();
}
 
Example 23
Project: readingNotes   File: OtherListDiaryFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    final int location = position;
    new AlertDialog.Builder(activity)
            .setTitle("警告")
            .setMessage("确定删除此条数据吗?")
            .setPositiveButton("是", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    SQLiteDatabase sqLiteDatabase = openHelper.getReadableDatabase();
                    DiaryDao diaryDao = new DiaryDao(sqLiteDatabase);
                    diaryDao.delete(diaryList.get(location));
                    diaryList.remove(location);
                    sqLiteDatabase.close();
                    dataList.remove(location);
                    simpleAdapter.notifyDataSetChanged();
                }
            })
            .setNegativeButton("否", null)
            .show();
    return true;
}
 
Example 24
Project: SmartButler   File: SettingActivity.java   View source code 6 votes vote down vote up
private void showVersionDialog()
{
    AlertDialog.Builder builder=new AlertDialog.Builder(SettingActivity.this);
    builder.setTitle(getString(R.string.new_version_existed));
    builder.setMessage(getString(R.string.update_or_not));
    builder.setPositiveButton(getString(R.string.update_dialog_positive), new DialogInterface.OnClickListener()
    {
        @Override
        public void onClick(DialogInterface dialog, int which)
        {
            //用户点击更新按钮则跳转到更新界面
            Intent intent=new Intent(SettingActivity.this,UpdateActivity.class);
            intent.putExtra("downloadUrl",latestDownloadUrl);
            startActivity(intent);
        }
    });
    builder.setNegativeButton(getString(R.string.update_dialog_nagetive),null);
    //显示Dialog
    builder.create().show();
}
 
Example 25
Project: CameraKitView   File: AspectRatioFragment.java   View source code 6 votes vote down vote up
@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();
}
 
Example 26
Project: TripBuyer   File: ReleaseTravelActivity.java   View source code 6 votes vote down vote up
private void showSetPasswordDialog(final Context mContext) {

        final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        View mView = LayoutInflater.from(mContext).inflate(R.layout.item_timepicker, null);

        inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
        ll = (LinearLayout) mView.findViewById(R.id.ll);
        ll.addView(getDataPick());
        //tv1 = (TextView) mView.findViewById(R.id.tv1);//
        //tv2 = (TextView) mView.findViewById(R.id.tv2);//
        TextView sure = (TextView) mView.findViewById(R.id.sure);
        sure.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View view) {
                setPasswordDialog.dismiss();
            }
        });
        builder.setView(mView);
        builder.setCancelable(true);
        setPasswordDialog = builder.create();
        setPasswordDialog.show();

    }
 
Example 27
Project: CollegeDoc   File: Subjects.java   View source code 6 votes vote down vote up
public void confirmation_dialogbox(final DatabaseReference databaseReference1, final String new_subject)
{
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which){
                case DialogInterface.BUTTON_POSITIVE:
                    databaseReference1.push().setValue(new_subject);
                    //Yes button clicked
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    //No button clicked
                    break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage("Are you sure want to create new subject with name "+new_subject+" ?").setPositiveButton("Yes", dialogClickListener)
            .setNegativeButton("No", dialogClickListener).show();
}
 
Example 28
Project: AndroidDonate   File: MainActivity.java   View source code 6 votes vote down vote up
private void showDonateTipDialog() {
    new AlertDialog.Builder(this)
            .setTitle("微信捐赠操作步骤")
            .setMessage("点击确定按钮后会跳转微信扫描二维码界面:\n\n" + "1. 点击右上角的菜单按钮\n\n" + "2. 点击'从相册选取二维码'\n\n" + "3. 选择第一张二维码图片即可\n\n")
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (isGooglePlay){
                        gotoTipShowActivity("微信捐赠", "在实际操作中用户必须手动输入金额。" + endString, R.drawable.p3);
                    }else {
                        donateWeixin();
                    }

                }
            })
            .setNegativeButton("取消", null)
            .show();
}
 
Example 29
Project: SpySms   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public void smsDetails(String from, String message) {
    try {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("New SMS from: " + from);
        builder
                .setMessage(message)
                .setCancelable(true);
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    } catch (Exception e) {
        e.getLocalizedMessage();
    }

    Snackbar.make(fab, "New Sms from " + from + "\n " + message, Snackbar.LENGTH_LONG)
            .setActionTextColor(Color.GREEN)
            .show();

    Toast.makeText(getApplicationContext(), "New Sms from " + from + "\n " + message, Toast.LENGTH_LONG).show();
}
 
Example 30
Project: chromium-for-android-56-debug-video   File: SignOutDialogFragment.java   View source code 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mGaiaServiceType = AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE;
    if (getArguments() != null) {
        mGaiaServiceType = getArguments().getInt(
                SHOW_GAIA_SERVICE_TYPE_EXTRA, mGaiaServiceType);
    }

    String managementDomain = SigninManager.get(getActivity()).getManagementDomain();
    String message;
    if (managementDomain == null) {
        message = getActivity().getResources().getString(R.string.signout_message);
    } else {
        message = getActivity().getResources().getString(
                R.string.signout_managed_account_message, managementDomain);
    }

    return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setTitle(R.string.signout_title)
            .setPositiveButton(R.string.signout_dialog_positive_button, this)
            .setNegativeButton(R.string.cancel, this)
            .setMessage(message)
            .create();
}
 
Example 31
Project: Checkerboard-IMU-Comparator   File: MainActivity.java   View source code 6 votes vote down vote up
private void showCalibrationResultDialog(){
    AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
    alert.setTitle(getString(R.string.calibration_results_dialog_title));
    alert.setMessage(getString(
            R.string.calibration_results_dialog_message) +" "+
            checkerboardPatternComputingInitializer.getRejectedImage() +
            "/"
            + checkerboardPatternComputingInitializer.getNecessaryImagesNumber());
    alert.setPositiveButton(getString(R.string.calibration_results_dialog_positive_button_text), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alertDialog = alert.create();
    alertDialog.show();
}
 
Example 32
Project: LittleLight   File: InventoryFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_send:
            List<Item> toTransfer = new ArrayList<>();
            for (ItemBagView instance : bagViewMap.values()) {
                for (Integer itemPosition : instance.getSelectedItems()) {
                    toTransfer.add(instance.getItem(itemPosition));
                }
            }

            new AlertDialog.Builder(getActivity())
                    .setTitle("Transfer to:")
                    .setAdapter(new ItemBagDestinationAdapter(getContext(), R.layout.view_itembagdestination_row, destinations), (dialog, which) -> {
                        presenter.sendItems(toTransfer, destinations.get(which).itemBagId);
                        mode.finish();
                    })
                    .show();
    }
    return true;
}
 
Example 33
Project: CardSimulator   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.about) {
        ((TextView)new AlertDialog.Builder(this).setTitle(getString(R.string.about))
                .setMessage(Html.fromHtml(getString(R.string.aboutmsg)))
                .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                })
                .show().findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
        return true;
    }
    if(id == R.id.license){
        ld.show();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 34
Project: Neuronizer   File: BaseDialogs.java   View source code 5 votes vote down vote up
public static void showHtmlDialog(Context context, String title, String htmlMessage) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
    final View dialogView = inflater.inflate(R.layout.dialog_rich_text, null);
    dialogBuilder.setView(dialogView);
    RichEditor richEditor = dialogView.findViewById(R.id.richEditor_dialog);
    richEditor.setHtml(htmlMessage);
    richEditor.setInputEnabled(false);
    richEditor.setFocusable(false);
    setupRichEditor(richEditor);

    dialogBuilder.setTitle(context.getResources().getString(R.string.details_title, title));
    dialogBuilder.setPositiveButton(R.string.done, null);
    dialogBuilder.create().show();
}
 
Example 35
Project: CatchSpy   File: ImportActivity.java   View source code 5 votes vote down vote up
private void advancedImportDialog(Context context) {
    LayoutInflater inflater = getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_advanced_import, (ViewGroup) findViewById(R.id.dialog_layout_import_advanced));
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.import_advanced);
    final TextInputEditText group = mView.findViewById(R.id.edittext_import_advanced_group);
    final TextInputEditText word = mView.findViewById(R.id.edittext_import_advanced_word);
    final CheckBox ignoreChangeLine = mView.findViewById(R.id.checkbox_import_advanced_ignore_change_line);
    builder.setPositiveButton(R.string.import_file, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String groupReg = group.getText().toString();
            String wordReg = word.getText().toString();
            if (!groupReg.isEmpty()) {
                if (!wordReg.isEmpty()) {
                    int result = ImportMethod.extraFileRegImporter(DictionaryPath, DictionaryName, groupReg, wordReg, ignoreChangeLine.isChecked());
                    if (result == Config.IMPORT_OK) {
                        Toast.makeText(ImportActivity.this, R.string.import_success, Toast.LENGTH_SHORT).show();
                        finish();
                    } else if (result == Config.IMPORT_FILE_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_file_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_OUTPUT_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_output_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_GROUP_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_group_match_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_WORDS_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_word_match_error, Snackbar.LENGTH_SHORT).show();
                    }
                } else {
                    Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_word_match_error, Snackbar.LENGTH_SHORT).show();
                }
            } else {
                Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_group_match_error, Snackbar.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
Example 36
Project: CatchSpy   File: ExtraDictionarySettingsFragment.java   View source code 5 votes vote down vote up
private void addNewDictionary() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_edittext, (ViewGroup) getActivity().findViewById(R.id.layout_dialog_edit_text));
    final TextInputEditText editText = mView.findViewById(R.id.edittext_dialog);
    editText.setHint(R.string.default_new_dictionary_name);
    String name = getString(R.string.default_new_dictionary_name) + "_" + System.currentTimeMillis();
    editText.setText(name);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.settings_extra_words_add);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String result = editText.getText().toString();
            if (result.replace(" ", "").equalsIgnoreCase("")) {
                Toast.makeText(getActivity(), R.string.settings_extra_words_add_error, Toast.LENGTH_SHORT).show();
            } else {
                try {
                    File file = new File(Config.DEFAULT_APPLICATION_DATA_DIR + result);
                    if (!file.exists()) {
                        if (file.createNewFile()) {
                            if (IOMethod.writeFile(new JSONObject().put(Config.DEFAULT_EXTRA_WORDS_DATA_NAME, new JSONArray()).toString(), file.getAbsolutePath())) {
                                String newName = Code.unicodeEncode(result) + "-" + Code.getFileMD5String(file.getAbsolutePath());
                                if (IOMethod.renameFile(file.getAbsolutePath(), newName)) {
                                    editWords(file.getParent() + File.separator + newName, result);
                                    return;
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                Toast.makeText(getActivity(), R.string.settings_extra_words_add_error, Toast.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
Example 37
Project: Rxjava2.0Demo   File: MPermissionUtils.java   View source code 5 votes vote down vote up
/**
 * 显示提示对话框
 */
public static void showTipsDialog(final Context context) {
    new AlertDialog.Builder(context)
            .setTitle("提示信息")
            .setMessage("当前应用缺少必要权限,该功能暂时无法使用。如若需要,请单击【确定】按钮前往设置中心进行权限授权。")
            .setNegativeButton("取消", null)
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    startAppSettings(context);
                }
            }).show();
}
 
Example 38
Project: Inshorts   File: ArticleListActivity.java   View source code 5 votes vote down vote up
private void showFilterDialogue() {
    //get alert dialog view
    View alertDialogView = Utils.getAlertDialogView(this);

    //get alert dialog instance
    AlertDialog dialog = Utils.getAlertDialog(this, alertDialogView,
            this::refreshList);

    dialog.show();
}
 
Example 39
Project: Xndroid   File: DisplaySettingsFragment.java   View source code 5 votes vote down vote up
private void textSizePicker() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_seek_bar, null);
    final SeekBar bar = view.findViewById(R.id.text_size_seekbar);
    final TextView sample = new TextView(getActivity());
    sample.setText(R.string.untitled);
    sample.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT));
    sample.setGravity(Gravity.CENTER_HORIZONTAL);
    view.addView(sample);
    bar.setOnSeekBarChangeListener(new TextSeekBarListener(sample));
    final int MAX = 5;
    bar.setMax(MAX);
    bar.setProgress(MAX - mPreferenceManager.getTextSize());
    builder.setView(view);
    builder.setTitle(R.string.title_text_size);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            mPreferenceManager.setTextSize(MAX - bar.getProgress());
        }

    });
    Dialog dialog = builder.show();
    BrowserDialog.setDialogSize(mActivity, dialog);
}
 
Example 40
Project: ScreenShotAnywhere   File: MainActivity.java   View source code 5 votes vote down vote up
private void showDialog(String message, DialogInterface.OnClickListener apply,
                        DialogInterface.OnClickListener denial) {
    new AlertDialog.Builder(MainActivity.this)
            .setMessage(message)
            .setPositiveButton("Apply", apply)
            .setNegativeButton("Denial", denial)
            .create()
            .show();
}