Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setView.

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:com.b44t.ui.Components.PasscodeView.java

private void checkFingerprint() {
    Activity parentActivity = (Activity) getContext();
    if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint
            && !ApplicationLoader.mainInterfacePaused) {
        try {//  ww  w. ja va2 s  .  com
            if (fingerprintDialog != null && fingerprintDialog.isShowing()) {
                return;
            }
        } catch (Exception e) {
            FileLog.e("messenger", e);
        }
        try {
            FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat
                    .from(ApplicationLoader.applicationContext);
            if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
                RelativeLayout relativeLayout = new RelativeLayout(getContext());
                relativeLayout.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(16),
                        AndroidUtilities.dp(16), AndroidUtilities.dp(8));

                fingerprintStatusTextView = new TextView(getContext());
                fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL);
                fingerprintStatusTextView
                        .setText(ApplicationLoader.applicationContext.getString(R.string.FingerprintInfo));
                fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead);
                relativeLayout.addView(fingerprintStatusTextView);
                RelativeLayout.LayoutParams layoutParams = LayoutHelper
                        .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
                fingerprintStatusTextView.setLayoutParams(layoutParams);

                AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
                builder.setView(relativeLayout);
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        if (cancellationSignal != null) {
                            selfCancelled = true;
                            cancellationSignal.cancel();
                            cancellationSignal = null;
                        }
                    }
                });
                if (fingerprintDialog != null) {
                    try {
                        if (fingerprintDialog.isShowing()) {
                            fingerprintDialog.dismiss();
                        }
                    } catch (Exception e) {
                        FileLog.e("messenger", e);
                    }
                }
                fingerprintDialog = builder.show();

                cancellationSignal = new CancellationSignal();
                selfCancelled = false;
                fingerprintManager.authenticate(null, 0, cancellationSignal,
                        new FingerprintManagerCompat.AuthenticationCallback() {
                            @Override
                            public void onAuthenticationError(int errMsgId, CharSequence errString) {
                                if (!selfCancelled) {
                                    showFingerprintError(errString);
                                }
                            }

                            @Override
                            public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
                                showFingerprintError(helpString);
                            }

                            @Override
                            public void onAuthenticationFailed() {
                                showFingerprintError(LocaleController.getString("FingerprintNotRecognized",
                                        R.string.FingerprintNotRecognized));
                            }

                            @Override
                            public void onAuthenticationSucceeded(
                                    FingerprintManagerCompat.AuthenticationResult result) {
                                try {
                                    if (fingerprintDialog.isShowing()) {
                                        fingerprintDialog.dismiss();
                                    }
                                } catch (Exception e) {
                                    FileLog.e("messenger", e);
                                }
                                fingerprintDialog = null;
                                processDone(true);
                            }
                        }, null);
            }
        } catch (Throwable e) {
            //ignore
        }
    }
}

From source file:com.example.zf_android.activity.MerchantEdit.java

private void show3Dialog(int type, final String uri) {
    AlertDialog.Builder builder = new AlertDialog.Builder(MerchantEdit.this);
    final String[] items = getResources().getStringArray(R.array.apply_detail_view);

    MerchantEdit.this.type = type;
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override/*from   w ww .  j  a v  a2s  .  c om*/
        public void onClick(DialogInterface dialog, int which) {

            switch (which) {
            case 0: {

                AlertDialog.Builder build = new AlertDialog.Builder(MerchantEdit.this);
                LayoutInflater factory = LayoutInflater.from(MerchantEdit.this);
                final View textEntryView = factory.inflate(R.layout.show_view, null);
                build.setView(textEntryView);
                final ImageView view = (ImageView) textEntryView.findViewById(R.id.imag);
                //               ImageCacheUtil.IMAGE_CACHE.get(uri, view);
                ImageLoader.getInstance().displayImage(uri, view, options);
                build.create().show();
                break;
            }

            case 1: {

                Intent intent;
                if (Build.VERSION.SDK_INT < 19) {
                    intent = new Intent(Intent.ACTION_GET_CONTENT);
                    intent.setType("image/*");
                } else {
                    intent = new Intent(Intent.ACTION_PICK,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                }
                startActivityForResult(intent, REQUEST_UPLOAD_IMAGE);
                break;
            }
            case 2: {
                String state = Environment.getExternalStorageState();
                if (state.equals(Environment.MEDIA_MOUNTED)) {
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
                    if (!outDir.exists()) {
                        outDir.mkdirs();
                    }
                    File outFile = new File(outDir, System.currentTimeMillis() + ".jpg");
                    photoPath = outFile.getAbsolutePath();
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
                    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
                    startActivityForResult(intent, REQUEST_TAKE_PHOTO);
                } else {
                    CommonUtil.toastShort(MerchantEdit.this, getString(R.string.toast_no_sdcard));
                }
                break;
            }
            }
        }
    });

    builder.show();
}

From source file:com.feathercoin.wallet.feathercoin.ui.EditAddressBookEntryFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String address = args.getString(KEY_ADDRESS);
    final String suggestedAddressLabel = args.getString(KEY_SUGGESTED_ADDRESS_LABEL);

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Uri uri = AddressBookProvider.contentUri(activity.getPackageName()).buildUpon().appendPath(address)
            .build();/*from w ww.j  a  v a  2s . c  o  m*/

    final String label = AddressBookProvider.resolveLabel(activity, address);

    final boolean isAdd = label == null;

    final AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setInverseBackgroundForced(true);
    dialog.setTitle(isAdd ? R.string.edit_address_book_entry_dialog_title_add
            : R.string.edit_address_book_entry_dialog_title_edit);

    final View view = inflater.inflate(R.layout.edit_address_book_entry_dialog, null);

    final TextView viewAddress = (TextView) view.findViewById(R.id.edit_address_book_entry_address);
    viewAddress.setText(WalletUtils.formatHash(address, Constants.ADDRESS_FORMAT_GROUP_SIZE,
            Constants.ADDRESS_FORMAT_LINE_SIZE));

    final TextView viewLabel = (TextView) view.findViewById(R.id.edit_address_book_entry_label);
    viewLabel.setText(label != null ? label : suggestedAddressLabel);

    dialog.setView(view);

    final DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, final int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                final String newLabel = viewLabel.getText().toString().trim();

                if (newLabel.length() > 0) {
                    final ContentValues values = new ContentValues();
                    values.put(AddressBookProvider.KEY_LABEL, newLabel);

                    if (isAdd)
                        contentResolver.insert(uri, values);
                    else
                        contentResolver.update(uri, values, null, null);
                } else if (!isAdd) {
                    contentResolver.delete(uri, null, null);
                }
            } else if (which == DialogInterface.BUTTON_NEUTRAL) {
                contentResolver.delete(uri, null, null);
            }

            dismiss();
        }
    };

    dialog.setPositiveButton(isAdd ? R.string.button_add : R.string.edit_address_book_entry_dialog_button_edit,
            onClickListener);
    if (!isAdd)
        dialog.setNeutralButton(R.string.button_delete, onClickListener);
    dialog.setNegativeButton(R.string.button_cancel, onClickListener);

    return dialog.create();
}

From source file:com.blueverdi.rosietheriveter.PhotoViewActivity.java

private void hintScreen() {
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    showHint = mPrefs.getBoolean(GalleryFragment.showHintPref, true);
    if (showHint) {
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.photo_hint_screen, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        CheckBox cb = (CheckBox) view.findViewById(R.id.chkWelcome);
        cb.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (((CheckBox) buttonView).isChecked()) {
                    showHint = false;/*from  www. j  ava2s .c  o  m*/
                } else {
                    showHint = true;
                }

            }

        });
        Button b = (Button) view.findViewById(R.id.exitPhotoHintButton);
        b.setOnClickListener(this);
        builder.setTitle(null);
        builder.setView(view);
        hintDialog = builder.show();
    }

}

From source file:com.barbrdo.app.activities.UserProfileActivity.java

private void showRadiusDialog(String radius) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    LayoutInflater inflater = this.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_radius, null);
    dialogBuilder.setView(dialogView);

    final TextView textViewRadius = (TextView) dialogView.findViewById(R.id.tv_radius);
    SeekBar seekBarRadius = (SeekBar) dialogView.findViewById(R.id.seekBar_radius);

    seekBarRadius.setProgress(Integer.parseInt(radius.replace(" mi", "")));
    textViewRadius.setText(radius);/*from ww w. ja v  a 2 s  .co  m*/
    final int stepSize = 5;
    seekBarRadius.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progress = ((int) Math.round(progress / stepSize)) * stepSize;
            textViewRadius.setText(progress + " mi");
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    dialogBuilder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            textViewSearchRadius.setText(textViewRadius.getText().toString());
            dialog.dismiss();
        }
    });

    dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    AlertDialog alertDialog = dialogBuilder.create();
    alertDialog.show();

}

From source file:com.dmsl.anyplace.SelectBuildingActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.main_menu_add_building: {
        AlertDialog.Builder alert = new AlertDialog.Builder(this);

        alert.setTitle("Add Building");
        alert.setMessage("Private Building's ID");

        // Set an EditText view to get user input
        final EditText editText = new EditText(this);
        alert.setView(editText);

        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                try {
                    // http://anyplace.cs.ucy.ac.cy/viewer/?buid=building_2f25420e-3cb1-4bc1-9996-3939e5530d30_1414014035379
                    // OR
                    // building_2f25420e-3cb1-4bc1-9996-3939e5530d30_1414014035379
                    String input = editText.getText().toString().trim();
                    String buid = input;
                    if (input.startsWith("http")) {

                        Uri uri = Uri.parse(URLDecoder.decode(input, "UTF-8"));
                        buid = uri.getQueryParameter("buid");
                        if (buid == null) {
                            throw new Exception("Missing buid parameter");
                        }/*from  w  w w  .ja va2  s.c  o  m*/

                    }
                    new FetchBuildingsByBuidTask(
                            new FetchBuildingsByBuidTask.FetchBuildingsByBuidTaskListener() {

                                @Override
                                public void onSuccess(String result, BuildingModel b) {
                                    ArrayList<BuildingModel> list = new ArrayList<BuildingModel>(1);
                                    list.add(b);
                                    setBuildingSpinner(list);
                                }

                                @Override
                                public void onErrorOrCancel(String result) {
                                    Toast.makeText(getBaseContext(), result, Toast.LENGTH_SHORT).show();
                                }
                            }, SelectBuildingActivity.this, buid).execute();
                } catch (Exception e) {
                    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // Canceled.
            }
        });

        alert.show();
        return true;
    }

    }
    return false;
}

From source file:com.esri.arcgisruntime.sample.rgbrenderer.ParametersDialogFragment.java

/**
 * Builds parameter dialog with values pulled through from MainActivity.
 *
 * @param savedInstanceState/* w  w  w.  j a v a2  s.  co m*/
 * @return create parameter dialog box
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Bundle rgbParameters = getArguments();
    if (rgbParameters != null) {
        mMinR = rgbParameters.getInt("minR");
        mMaxR = rgbParameters.getInt("maxR");
        mMinG = rgbParameters.getInt("minG");
        mMaxG = rgbParameters.getInt("maxG");
        mMinB = rgbParameters.getInt("minB");
        mMaxB = rgbParameters.getInt("maxB");
        mPercentClipMin = rgbParameters.getInt("percent_clip_min");
        mPercentClipMax = rgbParameters.getInt("percent_clip_max");
        mStdDevFactor = rgbParameters.getInt("std_dev_factor");
        mStretchType = (MainActivity.StretchType) rgbParameters.getSerializable("stretch_type");
        Log.d("Incoming Parameters", "min r: " + mMinR + " max r: " + mMaxR + " min g: " + mMinG + " max g: "
                + mMaxG + " min b: " + mMinB + " max b: " + mMaxB);
    }

    final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext());
    @SuppressLint("InflateParams")
    final View dialogView = inflater.inflate(R.layout.rgb_dialog_box, null);
    paramDialog.setView(dialogView);
    paramDialog.setTitle(R.string.rgb_rendering_parameters);
    paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });
    paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            ParametersListener activity = (ParametersListener) getActivity();
            activity.returnParameters(mMinR, mMaxR, mMinG, mMaxG, mMinB, mMaxB, mPercentClipMin,
                    mPercentClipMax, mStdDevFactor, mStretchType);
        }
    });
    // min max ui elements
    mMinRedTextView = (TextView) dialogView.findViewById(R.id.min_red_value_text_view);
    mMaxRedTextView = (TextView) dialogView.findViewById(R.id.max_red_value_text_view);
    mMinGreenTextView = (TextView) dialogView.findViewById(R.id.min_green_value_text_view);
    mMaxGreenTextView = (TextView) dialogView.findViewById(R.id.max_green_value_text_view);
    mMinBlueTextView = (TextView) dialogView.findViewById(R.id.min_blue_value_text_view);
    mMaxBlueTextView = (TextView) dialogView.findViewById(R.id.max_blue_value_text_view);
    mMinRedSeekBar = (SeekBar) dialogView.findViewById(R.id.min_red_seek_bar);
    mMaxRedSeekBar = (SeekBar) dialogView.findViewById(R.id.max_red_seek_bar);
    mMinGreenSeekBar = (SeekBar) dialogView.findViewById(R.id.min_green_seek_bar);
    mMaxGreenSeekBar = (SeekBar) dialogView.findViewById(R.id.max_green_seek_bar);
    mMinBlueSeekBar = (SeekBar) dialogView.findViewById(R.id.min_blue_seek_bar);
    mMaxBlueSeekBar = (SeekBar) dialogView.findViewById(R.id.max_blue_seek_bar);
    mMinRedSeekBar.setMax(255);
    mMaxRedSeekBar.setMax(255);
    mMinGreenSeekBar.setMax(255);
    mMaxGreenSeekBar.setMax(255);
    mMinBlueSeekBar.setMax(255);
    mMaxBlueSeekBar.setMax(255);
    mCurrMinRedTextView = (TextView) dialogView.findViewById(R.id.curr_min_red_text_view);
    mCurrMaxRedTextView = (TextView) dialogView.findViewById(R.id.curr_max_red_text_view);
    mCurrMinGreenTextView = (TextView) dialogView.findViewById(R.id.curr_min_green_text_view);
    mCurrMaxGreenTextView = (TextView) dialogView.findViewById(R.id.curr_max_green_text_view);
    mCurrMinBlueTextView = (TextView) dialogView.findViewById(R.id.curr_min_blue_text_view);
    mCurrMaxBlueTextView = (TextView) dialogView.findViewById(R.id.curr_max_blue_text_view);
    //update seek bar positions with current mMinMax values
    updateSeekBar(mMinRedSeekBar, mMinR, mCurrMinRedTextView);
    updateSeekBar(mMaxRedSeekBar, mMaxR, mCurrMaxRedTextView);
    updateSeekBar(mMinGreenSeekBar, mMinG, mCurrMinGreenTextView);
    updateSeekBar(mMaxGreenSeekBar, mMaxG, mCurrMaxGreenTextView);
    updateSeekBar(mMinBlueSeekBar, mMinB, mCurrMinBlueTextView);
    updateSeekBar(mMaxBlueSeekBar, mMaxB, mCurrMaxBlueTextView);
    // percent clip ui elements
    mPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.percent_clip_min_value_text_view);
    mPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.percent_clip_max_value_text_view);
    mPercentClipMinSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_min_seek_bar);
    mPercentClipMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_max_seek_bar);
    mPercentClipMinSeekBar.setMax(99);
    mPercentClipMaxSeekBar.setMax(99);
    mCurrPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_min_text_view);
    mCurrPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_max_text_view);
    //update seek bar positions with current PercentClip
    updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView);
    updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView);
    // standard deviation ui elements
    mStdDevTextView = (TextView) dialogView.findViewById(R.id.std_dev_text_view);
    mStdDevSeekBar = (SeekBar) dialogView.findViewById(R.id.std_dev_seek_bar);
    mStdDevSeekBar.setMax(3);
    mCurrStdDevTextView = (TextView) dialogView.findViewById(R.id.curr_std_dev_text_view);
    //update seek bar position with current StandardDeviation
    updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView);

    // set ui to previous selection
    if (mStretchType == MainActivity.StretchType.MIN_MAX) {
        setMinMaxVisibility(true);
        setPercentClipVisibility(false);
        setStdDevVisibility(false);
    } else if (mStretchType == MainActivity.StretchType.PERCENT_CLIP) {
        setMinMaxVisibility(false);
        setPercentClipVisibility(true);
        setStdDevVisibility(false);
    } else if (mStretchType == MainActivity.StretchType.STANDARD_DEVIATION) {
        setMinMaxVisibility(false);
        setPercentClipVisibility(false);
        setStdDevVisibility(true);
    }
    // seek bar listeners
    mMinRedSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mMinR = progress;
            updateSeekBar(mMinRedSeekBar, mMinR, mCurrMinRedTextView);
            // move max to march min if max goes below min
            if (mMaxR < mMinR) {
                mMaxR = mMinR;
                updateSeekBar(mMaxRedSeekBar, mMaxR, mCurrMaxRedTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mMaxRedSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mMaxR = progress;
            updateSeekBar(mMaxRedSeekBar, mMaxR, mCurrMaxRedTextView);
            // move min to match max if min goes above max
            if (mMinR > mMaxR) {
                mMinR = mMaxR;
                updateSeekBar(mMinRedSeekBar, mMinR, mCurrMinRedTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mMinGreenSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mMinG = progress;
            updateSeekBar(mMinGreenSeekBar, mMinG, mCurrMinGreenTextView);
            // move max to march min if max goes below min
            if (mMaxG < mMinG) {
                mMaxG = mMinG;
                updateSeekBar(mMaxGreenSeekBar, mMaxG, mCurrMaxGreenTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mMaxGreenSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mMaxG = progress;
            updateSeekBar(mMaxGreenSeekBar, mMaxG, mCurrMaxGreenTextView);
            // move min to match max if min goes above max
            if (mMinG > mMaxG) {
                mMinG = mMaxG;
                updateSeekBar(mMinGreenSeekBar, mMinG, mCurrMinGreenTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mMinBlueSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mMinB = progress;
            updateSeekBar(mMinBlueSeekBar, mMinB, mCurrMinBlueTextView);
            // move max to march min if max goes below min
            if (mMaxB < mMinB) {
                mMaxB = mMinB;
                updateSeekBar(mMaxBlueSeekBar, mMaxB, mCurrMaxBlueTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mMaxBlueSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mMaxB = progress;
            updateSeekBar(mMaxBlueSeekBar, mMaxB, mCurrMaxBlueTextView);
            // move min to match max if min goes above max
            if (mMinB > mMaxB) {
                mMinB = mMaxB;
                updateSeekBar(mMinBlueSeekBar, mMinB, mCurrMinBlueTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    mPercentClipMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mPercentClipMin = progress;
            updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView);
            if (mPercentClipMin + mPercentClipMax > 100) {
                // constrain min + max <= 100
                mPercentClipMax = 100 - mPercentClipMin;
                updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    mPercentClipMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mPercentClipMax = progress;
            updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView);
            if (mPercentClipMin + mPercentClipMax > 100) {
                // constrain min + max <= 100
                mPercentClipMin = 100 - mPercentClipMax;
                updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mStdDevSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mStdDevFactor = progress;
            updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // stretch type spinner
    List<String> stretchTypeArray = new ArrayList<>();
    stretchTypeArray.add(MainActivity.StretchType.MIN_MAX.toString()); //ordinals:0
    stretchTypeArray.add(MainActivity.StretchType.PERCENT_CLIP.toString()); //1
    stretchTypeArray.add(MainActivity.StretchType.STANDARD_DEVIATION.toString()); //2
    ArrayAdapter<String> stretchTypeSpinnerAdapter = new ArrayAdapter<>(getContext(),
            R.layout.rgb_spinner_text_view, stretchTypeArray);
    Spinner stretchTypeSpinner = (Spinner) dialogView.findViewById(R.id.stretch_type_spinner);
    stretchTypeSpinner.setAdapter(stretchTypeSpinnerAdapter);
    stretchTypeSpinner.setSelection(mStretchType.ordinal());
    stretchTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                mStretchType = MainActivity.StretchType.MIN_MAX;
                setMinMaxVisibility(true);
                setPercentClipVisibility(false);
                setStdDevVisibility(false);
                break;
            case 1:
                mStretchType = MainActivity.StretchType.PERCENT_CLIP;
                setMinMaxVisibility(false);
                setPercentClipVisibility(true);
                setStdDevVisibility(false);
                break;
            case 2:
                mStretchType = MainActivity.StretchType.STANDARD_DEVIATION;
                setMinMaxVisibility(false);
                setPercentClipVisibility(false);
                setStdDevVisibility(true);
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    return paramDialog.create();
}

From source file:com.googlecode.CallerLookup.Main.java

public void doSave() {
    final Context context = this;
    final EditText input = new EditText(context);
    input.setHint(R.string.Name);

    AlertDialog.Builder alert = new AlertDialog.Builder(context);
    alert.setTitle(R.string.SaveTitle);/*from w  w w .  j a  v  a  2s. com*/
    alert.setMessage(R.string.SaveMessage);
    alert.setView(input);

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String name = SAVED_PREFIX + input.getText().toString().trim();
            if (name.length() <= SAVED_PREFIX.length()) {
                AlertDialog.Builder error = new AlertDialog.Builder(context);
                error.setTitle(R.string.NameMissingTitle);
                error.setMessage(R.string.NameMissingMessage);
                error.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        doSave();
                    }
                });
                error.show();
                return;
            }
            if (mLookupEntries.containsKey(name)) {
                AlertDialog.Builder confirm = new AlertDialog.Builder(context);
                confirm.setTitle(R.string.NameConfirmTitle);
                confirm.setMessage(R.string.NameConfirmMessage);
                confirm.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        mLookupEntries.remove(name);
                        mUserLookupEntries.remove(name);
                        addUserLookupEntry(name);

                        int count = mLookup.getCount();
                        for (int i = 1; i < count; i++) {
                            if (mLookup.getItemAtPosition(i).toString().equals(name)) {
                                mLookup.setSelection(i);
                                break;
                            }
                        }
                    }
                });
                confirm.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        doSave();
                    }
                });
                confirm.show();
                return;
            }

            addUserLookupEntry(name);

            ArrayAdapter<CharSequence> adapter = (ArrayAdapter<CharSequence>) mLookup.getAdapter();
            adapter.add(name);
            mLookup.setSelection(mLookup.getCount() - 1);
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    alert.show();
}

From source file:com.mobile.godot.activity.LauncherActivity.java

private AlertDialog buildDialogUserRegistration() {

    AlertDialog dialogUserRegistration;//from  w w  w.j a v a2 s . c  om

    AlertDialog.Builder builderDialogUserRegistration = new AlertDialog.Builder(this);
    builderDialogUserRegistration.setTitle(R.string.dilog_title_user_registration)
            .setIcon(R.drawable.ic_launcher);

    LayoutInflater inflaterDialogUserRegistration = (LayoutInflater) this
            .getSystemService(LAYOUT_INFLATER_SERVICE);
    View contentDialogUserRegistration = inflaterDialogUserRegistration.inflate(
            R.layout.dialog_user_registration, (ViewGroup) findViewById(R.id.dialog_user_registration_root));
    builderDialogUserRegistration.setView(contentDialogUserRegistration);

    final EditText etFirstname = (EditText) contentDialogUserRegistration.findViewById(R.id.etFirstname);
    final EditText etLastname = (EditText) contentDialogUserRegistration.findViewById(R.id.etLastname);
    final EditText etMail = (EditText) contentDialogUserRegistration.findViewById(R.id.etMail);
    final EditText etUsername = (EditText) contentDialogUserRegistration.findViewById(R.id.etUsername);
    final EditText etPassword = (EditText) contentDialogUserRegistration.findViewById(R.id.etPassword);

    builderDialogUserRegistration.setPositiveButton(R.string.register, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {

            String firstname = etFirstname.getText().toString();
            String lastname = etLastname.getText().toString();
            String mail = etMail.getText().toString();
            String username = etUsername.getText().toString();
            String password = etPassword.getText().toString();

            UserBean user = new UserBean().setFirstname(firstname).setLastname(lastname).setMail(mail)
                    .setUsername(username).setPassword(password);

            registerNewUser(user);

        }

    });

    builderDialogUserRegistration.setNegativeButton(R.string.dialog_button_cancel,
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {

                    Toast.makeText(getApplicationContext(), R.string.toast_we_would_be_glad, Toast.LENGTH_SHORT)
                            .show();

                }

            });

    dialogUserRegistration = builderDialogUserRegistration.create();

    return dialogUserRegistration;
}

From source file:com.mendhak.gpslogger.common.PrefsIO.java

public void AskFileName() {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.AskFileName);

    final EditText input = new EditText(context);
    input.setInputType(InputType.TYPE_CLASS_TEXT);

    int pos = curFileName.lastIndexOf(File.separator) + 1;
    String filename = "";
    if (pos > 0)
        filename = curFileName.substring(pos);
    pos = filename.lastIndexOf(extension);
    if (pos > 1)
        input.setText(filename.substring(0, pos - 1));
    else/*from   w  ww. ja va  2s  .co m*/
        input.setText(defFileName);

    Utilities.LogDebug("Asking user the filename to use for export of settings");

    builder.setView(input);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String str = input.getText().toString();
            String fname = "";
            if (str.length() > 0)
                fname = str.replaceAll(filter, "");
            if (fname.length() != 0) {
                curFileName = defPath + File.separator + fname + "." + extension;
                ExportFile();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}