Java Code Examples for android.content.DialogInterface.BUTTON_NEGATIVE

The following are Jave code examples for showing how to use BUTTON_NEGATIVE of the android.content.DialogInterface class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: share-location   File: GroupsFragment.java   Source Code and License Vote up 6 votes
@Override
public void onGroupDelete(int groupPosition, final String groupId) {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    FirebaseHelper.deleteUserFromGroup(groupId); // Delete user from Firebase
                case DialogInterface.BUTTON_NEGATIVE:
                    break;
            }
        }
    };

    // Show alert with 'yes' and 'no' answer options
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getContext());
    alertBuilder.setMessage("Weet je zeker dat je deze groep wilt verlaten?")
            .setPositiveButton("Ja", dialogClickListener).setNegativeButton("Nee",
            dialogClickListener).show();
}
 
Example 2
Project: xmrwallet   File: WalletActivity.java   Source Code and License Vote up 6 votes
private void onWalletDetails() {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    Bundle extras = new Bundle();
                    extras.putString("type", GenerateReviewFragment.VIEW_TYPE_WALLET);
                    replaceFragment(new GenerateReviewFragment(), null, extras);
                    break;
                case DialogInterface.BUTTON_NEGATIVE:
                    // do nothing
                    break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(getString(R.string.details_alert_message))
            .setPositiveButton(getString(R.string.details_alert_yes), dialogClickListener)
            .setNegativeButton(getString(R.string.details_alert_no), dialogClickListener)
            .show();
}
 
Example 3
Project: update-master   File: DefaultPromptClickListener.java   Source Code and License Vote up 6 votes
@Override
public void onClick(DialogInterface dialog, int which) {

    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
        mAgent.update();
        break;
    case DialogInterface.BUTTON_NEUTRAL:
        mAgent.ignore();
        break;
    case DialogInterface.BUTTON_NEGATIVE:
        // not now
        break;
    }
    if (mIsAutoDismiss) {
        dialog.dismiss();
    }
}
 
Example 4
Project: xmrwallet   File: LoginActivity.java   Source Code and License Vote up 6 votes
@Override
public void onWalletArchive(final String walletName) {
    Timber.d("archive for wallet ." + walletName + ".");
    if (checkServiceRunning()) return;
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    new AsyncArchive().execute(walletName);
                    break;
                case DialogInterface.BUTTON_NEGATIVE:
                    // do nothing
                    break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(getString(R.string.archive_alert_message))
            .setTitle(walletName)
            .setPositiveButton(getString(R.string.archive_alert_yes), dialogClickListener)
            .setNegativeButton(getString(R.string.archive_alert_no), dialogClickListener)
            .show();
}
 
Example 5
Project: CollegeDoc   File: Topics.java   Source Code and License Vote up 5 votes
public void confirmation_dialogbox(final DatabaseReference databaseReference1, final String new_topic)
{
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which){
                case DialogInterface.BUTTON_POSITIVE:
                    databaseReference1.push().setValue(new_topic);
                    mStorageRef = FirebaseStorage.getInstance().getReferenceFromUrl
                            ("gs://college-doc.appspot.com//"+u);
                    Intent intent = new Intent();
                    intent.setType("application/pdf");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    try {
                        startActivityForResult(Intent.createChooser(intent, "Select PDF of name "+new_topic+".pdf"), SELECT_PDF);
                    } catch (ActivityNotFoundException f) {
                        Toast.makeText(Topics.this, "Activity Not Found", Toast.LENGTH_SHORT).show();
                    }
                    //Yes button clicked
                    break;

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

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage("Are you sure to add "+new_topic+".pdf ?" +
            " in subject "+ u.toString()).setPositiveButton("Yes", dialogClickListener)
            .setNegativeButton("No", dialogClickListener).show();
}
 
Example 6
Project: youkes_browser   File: BrowserActivity.java   Source Code and License Vote up 5 votes
private void onLinkLongClick2(final String url) {
	DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
               switch (which) {
                   case DialogInterface.BUTTON_POSITIVE:
                       newTab(url, false);
                       break;

                   case DialogInterface.BUTTON_NEGATIVE:
                       getCurrentWebView().loadUrl(url);
                       break;

                   case DialogInterface.BUTTON_NEUTRAL:
                       ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                       ClipData clip = ClipData.newPlainText("label", url);
                       clipboard.setPrimaryClip(clip);
                       break;
               }
           }
       };

	AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
	builder.setTitle(url)
               .setMessage(getResources().getString(R.string.dialog_link))
               .setPositiveButton(getResources().getString(R.string.action_new_tab),
					dialogClickListener)
               .setNegativeButton(getResources().getString(R.string.action_open),
					dialogClickListener)
               .setNeutralButton(getResources().getString(R.string.action_copy),
					dialogClickListener).show();
}
 
Example 7
Project: Brevent   File: AppsFeedbackFragment.java   Source Code and License Vote up 5 votes
@Override
public void onClick(DialogInterface dialog, int which) {
    Activity activity = getActivity();
    if (activity == null) {
        return;
    }
    if (DialogInterface.BUTTON_POSITIVE == which) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.FEEDBACK));
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        activity.startActivity(intent);
    } else if (DialogInterface.BUTTON_NEGATIVE == which) {
        BreventActivity.sendEmail(activity, null, Build.FINGERPRINT);
    }
}
 
Example 8
Project: planetcon   File: ListPlayersPreference.java   Source Code and License Vote up 5 votes
@Override
public void onClick(DialogInterface dialog, int which) {
    super.onClick(dialog, which);

    if (which == DialogInterface.BUTTON_POSITIVE) {
        putPreferences(mPrefs.edit(), aPlayersPrefs);
    }
    else if (which == DialogInterface.BUTTON_NEGATIVE) {
        // Needed to revert the changes when the dialog is closed
        // (else the changes are restored by onRestoreInstanceState when the dialog is opened again)
        loadPreferences(mPrefs, aPlayersPrefs);
    }
}
 
Example 9
Project: MakiLite   File: FiveStarsDialog.java   Source Code and License Vote up 5 votes
@Override
public void onClick(DialogInterface dialogInterface, int i) {
    if(i == DialogInterface.BUTTON_POSITIVE){
        if(ratingBar.getRating() < upperBound){
            if(negativeReviewListener == null){
                sendEmail();
            }else{
                negativeReviewListener.onNegativeReview((int)ratingBar.getRating());
            }

        }else if(!isForceMode){
            openMarket();
        }
        disable();
        if(reviewListener != null)
            reviewListener.onReview((int)ratingBar.getRating());
    }
    if(i == DialogInterface.BUTTON_NEUTRAL){
        disable();
    }
    if(i == DialogInterface.BUTTON_NEGATIVE){
        SharedPreferences.Editor editor = sharedPrefs.edit();
        editor.putInt(SP_NUM_OF_ACCESS, 0);
        editor.apply();
    }
    alertDialog.hide();
}
 
Example 10
Project: app_secompufscar   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
public void onBackPressed() {
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        if (current_fragment == HOME_POSITION) {

            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                        case DialogInterface.BUTTON_POSITIVE:
                            finish();
                            break;

                        case DialogInterface.BUTTON_NEGATIVE:
                            break;
                    }
                }
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage(R.string.sair).setPositiveButton("Sim", dialogClickListener)
                    .setNegativeButton("Não", dialogClickListener).show();
        } else {
            current_fragment = HOME_POSITION;
            itemSelected = R.id.nav_home;
            previousItemSelected = itemSelected;
            setFragment();
        }
    }
}
 
Example 11
Project: Ships   File: SettingsFragment.java   Source Code and License Vote up 5 votes
@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which){
    case DialogInterface.BUTTON_POSITIVE:
        // Yes button clicked
    	useOtherRtlSdrDevice();
        break;

    case DialogInterface.BUTTON_NEGATIVE:
        // No button clicked
    	// Ignore
        break;
    }
}
 
Example 12
Project: AOSP-Kayboard-7.1.2   File: CustomInputStylePreference.java   Source Code and License Vote up 5 votes
@Override
public void onClick(final DialogInterface dialog, final int which) {
    super.onClick(dialog, which);
    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
        final boolean isEditing = !isIncomplete();
        final SubtypeLocaleItem locale =
                (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem();
        final KeyboardLayoutSetItem layout =
                (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
        final InputMethodSubtype subtype =
                AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
                        locale.mLocaleString, layout.mLayoutName);
        setSubtype(subtype);
        notifyChanged();
        if (isEditing) {
            mProxy.onSaveCustomInputStyle(this);
        } else {
            mProxy.onAddCustomInputStyle(this);
        }
        break;
    case DialogInterface.BUTTON_NEUTRAL:
        // Nothing to do
        break;
    case DialogInterface.BUTTON_NEGATIVE:
        mProxy.onRemoveCustomInputStyle(this);
        break;
    }
}
 
Example 13
Project: TaipeiTechRefined   File: CalendarListAdapter.java   Source Code and License Vote up 5 votes
@Override
public void onClick(DialogInterface dialog, int position) {
    switch (position) {
        case DialogInterface.BUTTON_NEGATIVE:
            try {
                Intent calendar_intent = new Intent(Intent.ACTION_EDIT);
                calendar_intent.setType("vnd.android.cursor.item/event");
                calendar_intent.putExtra("beginTime", selectedEvent
                        .getStartDate().getTime());
                calendar_intent.putExtra("allDay", true);
                calendar_intent.putExtra("endTime", selectedEvent.getEndDate()
                        .getTime() + 60 * 60 * 1000);
                calendar_intent.putExtra("title", selectedEvent.getEvent());
                getContext().startActivity(calendar_intent);
            } catch (Exception e) {
                Toast.makeText(getContext(), R.string.calendar_not_support,
                        Toast.LENGTH_SHORT).show();
            }
            break;
        case DialogInterface.BUTTON_POSITIVE:
            String shareBody = null;
            if (selectedEvent.getStartDate().compareTo(
                    selectedEvent.getEndDate()) == 0) {
                shareBody = Utility.getDateString("yyyy/MM/dd (E)",
                        selectedEvent.getStartDate(), getContext())
                        + " "
                        + selectedEvent.getEvent();
            } else {
                shareBody = Utility.getDateString("yyyy/MM/dd (E)",
                        selectedEvent.getStartDate(), getContext())
                        + "~"
                        + Utility.getDateString("yyyy/MM/dd (E)",
                        selectedEvent.getEndDate(), getContext())
                        + " "
                        + selectedEvent.getEvent();
            }
            Intent sharing_intent = new Intent(
                    android.content.Intent.ACTION_SEND);
            sharing_intent.setType("text/plain");
            sharing_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
            sharing_intent.putExtra(android.content.Intent.EXTRA_TEXT,
                    shareBody);
            getContext().startActivity(
                    Intent.createChooser(sharing_intent, getContext()
                            .getResources().getString(R.string.share_using)));
            break;
    }
}
 
Example 14
Project: browser   File: BrowserActivity.java   Source Code and License Vote up 5 votes
private void onLinkLongClick2(final String url) {
	DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
               switch (which) {
                   case DialogInterface.BUTTON_POSITIVE:
                       newTab(url, false);
                       break;

                   case DialogInterface.BUTTON_NEGATIVE:
                       getCurrentWebView().loadUrl(url);
                       break;

                   case DialogInterface.BUTTON_NEUTRAL:
                       ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                       ClipData clip = ClipData.newPlainText("label", url);
                       clipboard.setPrimaryClip(clip);
                       break;
               }
           }
       };

	AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
	builder.setTitle(url)
               .setMessage(getResources().getString(R.string.dialog_link))
               .setPositiveButton(getResources().getString(R.string.action_new_tab),
					dialogClickListener)
               .setNegativeButton(getResources().getString(R.string.action_open),
					dialogClickListener)
               .setNeutralButton(getResources().getString(R.string.action_copy),
					dialogClickListener).show();
}
 
Example 15
Project: browser   File: BrowserActivity.java   Source Code and License Vote up 5 votes
/***
 * 功能:用线程保存图片
 *
 *
 */


private void onImageLongClick1(final String url) {
	DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
			switch (which) {
				case DialogInterface.BUTTON_POSITIVE:
					newTab(url, false);
					break;

				case DialogInterface.BUTTON_NEGATIVE:
					getCurrentWebView().loadUrl(url);
					break;

				case DialogInterface.BUTTON_NEUTRAL:
					if (API > 8) {
						Utils.downloadFile(mActivity, url,
								getCurrentWebView().getUserAgent(), "attachment", false);
					}
					break;
			}
		}
	};

	AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
	builder.setTitle(url.replace(Constants.HTTP, ""))
			.setMessage(getResources().getString(R.string.dialog_image))
			.setPositiveButton(getResources().getString(R.string.action_new_tab),
					dialogClickListener)
			.setNegativeButton(getResources().getString(R.string.action_open),
					dialogClickListener)
			.setNeutralButton(getResources().getString(R.string.action_download),
					dialogClickListener).show();
}
 
Example 16
Project: simple-keyboard   File: CustomInputStylePreference.java   Source Code and License Vote up 5 votes
@Override
public void onClick(final DialogInterface dialog, final int which) {
    super.onClick(dialog, which);
    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
        final boolean isEditing = !isIncomplete();
        final SubtypeLocaleItem locale =
                (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem();
        final KeyboardLayoutSetItem layout =
                (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
        final InputMethodSubtype subtype =
                AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
                        locale.mLocaleString, layout.mLayoutName);
        setSubtype(subtype);
        notifyChanged();
        if (isEditing) {
            mProxy.onSaveCustomInputStyle(this);
        } else {
            mProxy.onAddCustomInputStyle(this);
        }
        break;
    case DialogInterface.BUTTON_NEUTRAL:
        // Nothing to do
        break;
    case DialogInterface.BUTTON_NEGATIVE:
        mProxy.onRemoveCustomInputStyle(this);
        break;
    }
}
 
Example 17
Project: orgzly-android   File: MainActivity.java   Source Code and License Vote up 4 votes
/**
 * Ask user to confirm, then delete book.
 */
@Override
public void onBookDeleteRequest(final long bookId) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "Get name for the book " + bookId + "...");

    final Book book = BooksClient.get(this, bookId);

    if (book == null) {
        return;
    }

    View view = View.inflate(this, R.layout.dialog_book_delete, null);
    final CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);

    DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                boolean deleteLinked = checkBox.isChecked();

                /* Delete book. */
                mSyncFragment.deleteBook(book, deleteLinked);
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                break;
        }
    };

    AlertDialog.Builder builder =
            new AlertDialog.Builder(this)
                    .setTitle("Delete " + MiscUtils.quotedString(book.getName()))
                    .setMessage("Delete this notebook?")
                    .setPositiveButton(R.string.ok, dialogClickListener)
                    .setNegativeButton(R.string.cancel, dialogClickListener);

    if (book.getLink() != null) {
        builder.setView(view);
    }

    builder.show();

}
 
Example 18
Project: chromium-for-android-56-debug-video   File: PassphraseTypeDialogFragment.java   Source Code and License Vote up 4 votes
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == DialogInterface.BUTTON_NEGATIVE) {
        dismiss();
    }
}
 
Example 19
Project: OSchina_resources_android   File: TeamNewIssueActivity.java   Source Code and License Vote up 4 votes
private void showIssueDeadlineTime() {

        final DatePickerDialog dateDialog = new DatePickerDialog(this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                    }

                }, mYear, mMonth, mDay);
        DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case DialogInterface.BUTTON_NEGATIVE:
                        break;
                    case DialogInterface.BUTTON_NEUTRAL:
                        issueTime = "";
                        mTvTime.setText(issueTime);
                        break;
                    case DialogInterface.BUTTON_POSITIVE:
                        mYear = dateDialog.getDatePicker().getYear();
                        mMonth = dateDialog.getDatePicker().getMonth();
                        mDay = dateDialog.getDatePicker().getDayOfMonth();
                        issueTime = mYear + "-" + (mMonth + 1) + "-" + mDay;
                        mTvTime.setText(issueTime);
                        break;

                    default:
                        break;
                }
            }
        };
        dateDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消",
                clickListener);
        dateDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "清除",
                clickListener);
        dateDialog.setButton(DialogInterface.BUTTON_POSITIVE, "确认",
                clickListener);
        dateDialog.show();
    }
 
Example 20
Project: couch-potatoes   File: UploadImageFragment.java   Source Code and License Vote up 4 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if ( resultCode != RESULT_OK )
        return;

    // Get photo URI if photo chosen from SD Card
    if ( requestCode == PICK_FROM_FILE) {
        imageCaptureUri = data.getData();
    }

    // Get an InputStream of the photo
    try {
        is = view.getContext().getContentResolver().openInputStream(imageCaptureUri);
    } catch ( FileNotFoundException e ) {
        e.printStackTrace();
    }

    // Handler for photo upload AlertDialog
    dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which){
                // Case to upload photo
                case DialogInterface.BUTTON_POSITIVE:
                    UploadImage( is );
                    break;
                // Case to cancel photo upload
                case DialogInterface.BUTTON_NEGATIVE:
                    break;
            }
        }
    };

    // Create EditText field for AlertDialog
    input = new EditText(view.getContext());
    input.setInputType(InputType.TYPE_CLASS_TEXT);

    // Prompt user to upload the photo and allow user to enter a photo description
    AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
    builder.setMessage( "Enter description:" )
            .setNegativeButton("Cancel", dialogClickListener)
            .setPositiveButton("Upload", dialogClickListener)
            .setView(input)
            .show();
}