android.support.v7.app.AlertDialog Java Examples

The following examples show how to use android.support.v7.app.AlertDialog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingFragment.java    From MemoryCleaner with Apache License 2.0 6 votes vote down vote up
@Override public void showThemeChooseDialog() {
    AlertDialog.Builder builder = DialogUtils.makeDialogBuilder(activity);
    builder.setTitle(R.string.change_theme);
    Integer[] res = new Integer[] { R.drawable.deep_purple_round,
            R.drawable.brown_round, R.drawable.blue_round,
            R.drawable.blue_grey_round, R.drawable.yellow_round,
            R.drawable.red_round, R.drawable.pink_round,
            R.drawable.green_round };
    List<Integer> list = Arrays.asList(res);
    ColorsListAdapter adapter = new ColorsListAdapter(getActivity(), list);
    adapter.setCheckItem(
            ThemeUtils.getCurrentTheme(activity).getIntValue());
    GridView gridView = (GridView) LayoutInflater.from(activity)
                                                 .inflate(
                                                         R.layout.colors_panel_layout,
                                                         null);
    gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    gridView.setCacheColorHint(0);
    gridView.setAdapter(adapter);
    builder.setView(gridView);
    final AlertDialog dialog = builder.show();
    gridView.setOnItemClickListener((parent, view, position, id) -> {
        dialog.dismiss();
        mSettingPresenter.onThemeChoose(position);
    });
}
 
Example #2
Source File: NGActivity.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void requestPermissions(int title, int message, final int requestCode, final String... permissions) {
    boolean shouldShowDialog = false;
    for (String permission : permissions) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) {
            shouldShowDialog = true;
            break;
        }
    }

    if (shouldShowDialog) {
        final Activity activity = this;
        AlertDialog builder = new AlertDialog.Builder(this).setTitle(title)
                .setMessage(message)
                .setPositiveButton(android.R.string.ok, null).create();
        builder.setCanceledOnTouchOutside(false);
        builder.show();

        builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                ActivityCompat.requestPermissions(activity, permissions, requestCode);
            }
        });
    } else
        ActivityCompat.requestPermissions(this, permissions, requestCode);
}
 
Example #3
Source File: ResultDialogHelper.java    From Gojuon with MIT License 6 votes vote down vote up
private void init() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View view = inflater.inflate(R.layout.fragment_result, null);

    builder.setCancelable(false)
            .setView(view)
            .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (mRunnable != null) mRunnable.run();
                }
            });

    mResultDialog = builder.create();
}
 
Example #4
Source File: RegistrationActivity.java    From iroha-android with Apache License 2.0 6 votes vote down vote up
@Override
public void didRegistrationError(Throwable error) {
    dismissProgressDialog();
    AlertDialog alertDialog = new AlertDialog.Builder(this)
            .setTitle(getString(R.string.error_dialog_title))
            .setMessage(error.getCause() instanceof ConnectException ?
                    getString(R.string.general_error) :
                    error.getLocalizedMessage())
            .setCancelable(true)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                if (error.getCause() instanceof ConnectException) {
                    finish();
                }
            })
            .create();
    alertDialog.show();
}
 
Example #5
Source File: WirteStatusActivity.java    From xifan with Apache License 2.0 6 votes vote down vote up
private void showChooseDialog() {
    new AlertDialog.Builder(this).setItems(getResources().getStringArray(R.array.photo_choose),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    switch (i) {
                        case 0:
                            openCamera();
                            break;
                        case 1:
                            pickPhoto();
                            break;
                    }
                }
            }).show();
}
 
Example #6
Source File: WeChatPresenter.java    From YImagePicker with Apache License 2.0 6 votes vote down vote up
/**
 * 拍照点击事件拦截
 *
 * @param activity  当前activity
 * @param takePhoto 拍照接口
 * @return 是否拦截
 */
@Override
public boolean interceptCameraClick(@Nullable final Activity activity, final ICameraExecutor takePhoto) {
    if (activity == null || activity.isDestroyed()) {
        return false;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setSingleChoiceItems(new String[]{"拍照", "录像"}, -1, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (which == 0) {
                takePhoto.takePhoto();
            } else {
                takePhoto.takeVideo();
            }
        }
    });
    builder.show();
    return true;
}
 
Example #7
Source File: OMADownloadHandler.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
Example #8
Source File: StartupDialogFragment.java    From RememBirthday with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.dialog_startup_title)
            .setNegativeButton(R.string.dialog_startup_negative_button, null)
            .setPositiveButton(R.string.dialog_startup_positive_button, onPositiveButtonClickListener);
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View viewRoot = inflater.inflate(R.layout.dialog_startup, null);
    HtmlTextView htmlTextView = (HtmlTextView) viewRoot.findViewById(R.id.html_text);

    String htmlContent =
            "<p>"+getString(R.string.html_text_purpose)+"</p>"+
            "<p>"+getString(R.string.html_text_free)+"</p>"+
            "<p>"+getString(R.string.html_text_donation)+"</p>";

    htmlTextView.setHtml(htmlContent);
    builder.setView(viewRoot);

    return builder.create();
}
 
Example #9
Source File: SpendingActivity.java    From accountBook with Apache License 2.0 6 votes vote down vote up
/**
 * Add an income and expense record
 * @param v
 */
public void OnAddRecordClick(View v){
    final String[] items = {"收入", "支出"};
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
    alertBuilder.setTitle("请选择添加类别");
    alertBuilder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            //Toast.makeText(SpendingActivity.this, items[i], Toast.LENGTH_SHORT).show();
            Intent intent=new Intent(SpendingActivity.this,ExpenseProcesActivity.class);
            intent.putExtra("strType", i);
            SpendingActivity.this.startActivity(intent);
            alertDialog_AddRecord.dismiss();
        }
    });
    alertDialog_AddRecord = alertBuilder.create();
    alertDialog_AddRecord.show();
}
 
Example #10
Source File: MainActivity.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
private void showMLSLimitedServiceDisclaimer() {
    int initialGuideVersion = PreferenceManager.getDefaultSharedPreferences(getBaseContext())
            .getInt(Constants.APP_INITIAL_GUIDE_VERSION, 0);
    if (initialGuideVersion != 4) {
        return;
    }
    final Context localContext = getBaseContext();
    final AlertDialog.Builder settingsAlert = new AlertDialog.Builder(MainActivity.this);
    settingsAlert.setTitle(R.string.alertDialog_mls_service_title);
    settingsAlert.setMessage(R.string.alertDialog_mls_service_message);
    settingsAlert.setNeutralButton(R.string.alertDialog_battery_optimization_proceed,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences.Editor preferences = PreferenceManager.getDefaultSharedPreferences(localContext).edit();
                    preferences.putInt(Constants.APP_INITIAL_GUIDE_VERSION, 5);
                    preferences.apply();
                    checkAndShowInitialGuide();
                }
            });
    settingsAlert.show();
}
 
Example #11
Source File: AboutDialogFragment.java    From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    final View alertDialogView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_dialog_about, null);

    final AlertDialog alertDialog = alertDialogBuilder.setView(alertDialogView).setPositiveButton(getString(R.string.ok), null).show();
    alertDialog.setCanceledOnTouchOutside(false);

    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                dismiss();
        }
    });

    return alertDialog;
}
 
Example #12
Source File: RepeatSelector.java    From recurrence with GNU General Public License v3.0 6 votes vote down vote up
@Override @NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final String[] repeatArray = getResources().getStringArray(R.array.repeat_array);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.Dialog);
    builder.setItems(repeatArray, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (which == Reminder.SPECIFIC_DAYS) {
                DialogFragment daysOfWeekDialog = new DaysOfWeekSelector();
                daysOfWeekDialog.show(getActivity().getSupportFragmentManager(), "DaysOfWeekSelector");
            }  else if (which == Reminder.ADVANCED) {
                DialogFragment advancedDialog = new AdvancedRepeatSelector();
                advancedDialog.show(getActivity().getSupportFragmentManager(), "AdvancedSelector");
            } else {
                listener.onRepeatSelection(RepeatSelector.this, which, repeatArray[which]);
            }
        }
    });
    return builder.create();
}
 
Example #13
Source File: LocationAlarmActivity.java    From LocationAware with Apache License 2.0 6 votes vote down vote up
@Override public void showAddCheckPointDialog() {
  LatLng target = mMap.getCameraPosition().target;
  AlertDialog.Builder builder = new AlertDialog.Builder(context);
  View dialogView =
      LayoutInflater.from(context).inflate(R.layout.set_checkpoint_dialog_view, null, false);
  ((TextView) dialogView.findViewById(R.id.check_point_lat_tv)).setText(
      String.valueOf(target.latitude));
  ((TextView) dialogView.findViewById(R.id.check_point_long_tv)).setText(
      String.valueOf(target.longitude));
  EditText nameEditText = dialogView.findViewById(R.id.check_point_name_et);
  AlertDialog alertDialog = builder.setView(dialogView).show();
  RxView.clicks(dialogView.findViewById(R.id.set_checkpoint_done_btn)).subscribe(__ -> {
    String enteredText = nameEditText.getText().toString();
    if (enteredText.length() >= 4) {
      locationPresenter.onSetCheckPoint(enteredText, target.latitude, target.longitude);
      alertDialog.dismiss();
    } else {
      nameEditText.setError("Name should have minimum of 4 characters.");
    }
  });
  RxView.clicks(dialogView.findViewById(R.id.set_checkpoint_cancel_btn))
      .subscribe(__ -> alertDialog.dismiss());
}
 
Example #14
Source File: ActivityImportSms.java    From fingen with Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case HANDLER_OPERATION_SHOW:
            progressbarArr[0].setVisibility(View.VISIBLE);
            break;
        case HANDLER_OPERATION_UPDATE:
            progressbarArr[0].setProgress(msg.arg1);
            break;
        case HANDLER_OPERATION_HIDE:
            break;
        case HANDLER_OPERATION_COMPLETE:
            if (activityArr[0].isFinishing()) return;
            AlertDialog.Builder builder = new AlertDialog.Builder(activityArr[0]);
            builder.setTitle(R.string.ttl_import_complete);

            builder.setMessage((String) msg.obj);

            // Set up the buttons
            builder.setPositiveButton("OK", onDialogOkListenerArr[0]);

            builder.show();
            break;
    }
}
 
Example #15
Source File: PortraitPickerDialog.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View rootView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_portrait_seletor_layout, null);

    RecyclerView recyclerView = rootView.findViewById(R.id.recyclerview);
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 5));
    PortraitAdapter adapter = new PortraitAdapter();
    recyclerView.setAdapter(adapter);
    int padding = ViewUtils.dp2Px(getContext(), 2);
    recyclerView.addItemDecoration(new SpaceItemDecoration(padding, padding, padding, padding));

    return new AlertDialog.Builder(getContext())
            .setTitle(R.string.pick_portrait)
            .setNegativeButton(R.string.text_cancel, null)
            .setView(rootView)
            .create();
}
 
Example #16
Source File: PigstyMode.java    From CatchPiggy with GNU General Public License v3.0 6 votes vote down vote up
private void initExitDialog(OnExitedListener listener) {
    OnClickListener onClickListener = v -> {
        switch (v.getId()) {
            case R.id.continue_game_btn:
                mExitDialog.dismiss();
                break;
            case R.id.back_to_menu_btn:
                mExitDialog.dismiss();
                exitNow();
                listener.onExited();
                break;
            default:
                break;
        }
    };
    View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_exit_view, null, false);
    dialogView.findViewById(R.id.continue_game_btn).setOnClickListener(onClickListener);
    dialogView.findViewById(R.id.back_to_menu_btn).setOnClickListener(onClickListener);
    mExitDialog = new AlertDialog.Builder(getContext(), R.style.DialogTheme).setView(dialogView).create();
}
 
Example #17
Source File: ItemFragment.java    From Companion-For-PUBG-Android with MIT License 6 votes vote down vote up
private void showDisclaimerForFirstTime() {
    final SharedPreferences preferences = getActivity().getSharedPreferences("temp", Context.MODE_PRIVATE);
    final String hasShown = "hasShown";
    if (preferences.getBoolean(hasShown, false)) {
        return;
    }

    AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle("This is still in beta!")
            .setMessage("Data is not yet finished nor complete. Please help us via Github. Links available in the drawer.")
            .setPositiveButton("Ok no problem!", null)
            .show();
    alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            preferences.edit().putBoolean(hasShown, true).apply();
        }
    });
}
 
Example #18
Source File: ws_Main3Activity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void eoou2(String dec) {
    //com.tencent.mm.plugin.scanner.ui.BaseScanUI
    final SharedPreferences i = this.getSharedPreferences("Hero", 0);
    Boolean o0 = i.getBoolean("FIRST", true);
    if (o0) {//第一次
        AppCompatDialog alertDialog = new AlertDialog.Builder(ws_Main3Activity.this)
                .setTitle("快捷功能")
                .setMessage("需要ROOT才能使用")
                .setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        i.edit().putBoolean("FIRST", false).apply();
                    }
                }).setCancelable(false).create();
        alertDialog.show();
    } else {
        ShellUtils.execCommand("am start -n com.eg.android.AlipayGphone/" + dec, true, true);
    }
}
 
Example #19
Source File: MainActivity.java    From Leisure with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void showSearchDialog(){
    final EditText editText = new EditText(this);
    editText.setGravity(Gravity.CENTER);
    editText.setSingleLine();
    new AlertDialog.Builder(this)
            .setTitle(getString(R.string.text_search_books))
            .setIcon(R.mipmap.ic_search)
            .setView(editText)
            .setPositiveButton(getString(R.string.text_ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if(Utils.hasString(editText.getText().toString())){
                        Intent intent = new Intent(MainActivity.this,SearchBooksActivity.class);
                        Bundle bundle = new Bundle();
                        bundle.putString(getString(R.string.id_search_text),editText.getText().toString());
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }
                }
            }).show();
}
 
Example #20
Source File: MainActivity.java    From CameraMaskDemo with Apache License 2.0 6 votes vote down vote up
private void showNewVersionDialog(String content, final String fileName) {
    new AlertDialog.Builder(this)
            .setTitle("新版本提示")
            .setMessage(content)
            .setPositiveButton("更新", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String url = BuildConfig.BASE_URL + BuildConfig.DOWNLOAD_URL;
                    Uri uri = Uri.parse(String.format(Locale.CHINA, url, fileName));
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(intent);

                }
            })
            .setNegativeButton("知道了", null)
            .show();
}
 
Example #21
Source File: DialogUtil.java    From AppPlus with MIT License 6 votes vote down vote up
public static AlertDialog getProgressDialog(Activity context,String title, String message){
    View view = LayoutInflater.from(context).inflate(R.layout.dialog_progress, null);
    ProgressBar progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
    TextView textView = (TextView) view.findViewById(R.id.content);

    //改变Progress的背景为MaterialDesigner规范的样式
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setIndeterminateDrawable(new CircularProgressDrawable(Utils.getColorWarp(context, R.color.colorAccent), context.getResources().getDimension(R.dimen.loading_border_width)));
    }

    final AlertDialog progressDialog = new AlertDialog.Builder(context)
            .setTitle(title)
            .setView(view).create();
    //设置显示文字
    textView.setText(message);

    return progressDialog;
}
 
Example #22
Source File: ColorPickerDialogBuilder.java    From javaide with GNU General Public License v3.0 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 #23
Source File: TagSwipeActivity.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void askForOSMUsername() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("OpenStreetMap User Name");
    builder.setMessage("Please enter your OpenStreetMap user name.");
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    builder.setView(input);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String userName = input.getText().toString();
            SharedPreferences.Editor editor = userNamePref.edit();
            editor.putString("userName", userName);
            editor.apply();
            if (TagEdit.saveToODKCollect(userName)) {
                setResult(Activity.RESULT_OK);
                finish();
            }
        }
    });
    builder.show();
}
 
Example #24
Source File: PurchaseActivity.java    From YTPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void setSuccess(String uid, DatabaseReference ref) {
    ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Processing...");
    dialog.setCancelable(false);
    dialog.show();
    ref.child(uid).setValue("paypal").addOnSuccessListener(runnable -> {
        dialog.dismiss();
        doOnSuccess();
    }).addOnFailureListener(runnable -> {
        dialog.dismiss();
        new AlertDialog.Builder(this)
                .setTitle("Error")
                .setMessage("Payment has completed successfully, but the app could not process it. Click on LEARN MORE to solve this error!")
                .setCancelable(false)
                .setPositiveButton("Learn More",(dialogInterface, i) -> {
                    helpClick(null);
                })
                .setNegativeButton("Cancel",null)
                .show();
    });
}
 
Example #25
Source File: MainActivity.java    From iroha-android with Apache License 2.0 6 votes vote down vote up
@Override
public void showError(Throwable throwable) {
    AlertDialog alertDialog = new AlertDialog.Builder(this)
            .setTitle(getString(R.string.error_dialog_title))
            .setMessage(
                    throwable.getCause() instanceof ConnectException ?
                            getString(R.string.general_error) :
                            throwable.getLocalizedMessage()
            )
            .setCancelable(true)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                if (throwable.getCause() instanceof ConnectException) {
                    //  finish();
                }
            })
            .create();
    alertDialog.show();
}
 
Example #26
Source File: CustomTileDimensions.java    From material-calendarview with MIT License 6 votes vote down vote up
@OnClick(R.id.custom_tile_width_size)
public void onWidthClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileWidth);
  new AlertDialog.Builder(this)
      .setView(view)
      .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(@NonNull DialogInterface dialog, int which) {
          currentTileWidth = view.getValue();
          widget.setTileWidthDp(currentTileWidth);
        }
      })
      .show();
}
 
Example #27
Source File: Utils.java    From PKUCourses with GNU General Public License v3.0 6 votes vote down vote up
public static void showPrivacyPolicyDialog(Context context) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogTheme);

        TextView msg = new TextView(context);
        msg.setText(Html.fromHtml(Utils.privacyPolicy));
        msg.setMovementMethod(LinkMovementMethod.getInstance());
        builder.setView(msg);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        lp.setMargins(50, 50, 50, 50);
        msg.setLayoutParams(lp);

        ScrollView ll = new ScrollView(context);
        ll.addView(msg);

        builder.setView(ll);
//                builder.setMessage("声明:\n所有用户的密码将不会被开发者获取,如仍有疑问,可访问\"https://github.com/cbwang2016/PKUCourses\"查看源码,谢谢您的信任。");
        builder.setPositiveButton("好的", null).create().show();
    }
 
Example #28
Source File: DiscoverDeviceActivity.java    From spark-setup-android with Apache License 2.0 6 votes vote down vote up
private void onWifiDisabled() {
    log.d("Wi-Fi disabled; prompting user");
    new AlertDialog.Builder(this)
            .setTitle(R.string.wifi_required)
            .setPositiveButton(R.string.enable_wifi, (dialog, which) -> {
                dialog.dismiss();
                log.i("Enabling Wi-Fi at the user's request.");
                wifiFacade.setWifiEnabled(true);
                wifiListFragment.scanAsync();
            })
            .setNegativeButton(R.string.exit_setup, (dialog, which) -> {
                dialog.dismiss();
                finish();
            })
            .show();
}
 
Example #29
Source File: HomeFragment.java    From InstaTag with Apache License 2.0 6 votes vote down vote up
public void showDeleteAllPhotosAlertDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setTitle(getString(R.string.remove_all_tagged_posts));
    alert.setMessage(getString(R.string.are_you_sure_you_want_to_delete_all_posts));
    alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            InstaTagApplication.getInstance().savePhotos(new ArrayList<Photo>());
            photos.clear();
            photoAdapter.notifyDataSetChanged();
            showEmptyContainer();
        }
    });
    alert.setNegativeButton(getString(R.string.cancel), null);
    alert.show();
}
 
Example #30
Source File: ActivityEditTransaction.java    From fingen with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
    if (sms == null) {
        return;
    }

    ListView lw = ((AlertDialog) dialog).getListView();
    SmsMarkerManager.SmsMarkerType checkedItem = (SmsMarkerManager.SmsMarkerType) lw.getAdapter().getItem(which);

    createSmsMarker(checkedItem.id, selectedText);
}