Java Code Examples for android.app.AlertDialog#BUTTON_NEGATIVE

The following examples show how to use android.app.AlertDialog#BUTTON_NEGATIVE . 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: AbstractListenerWrapper.java    From AndroidMaterialDialog with Apache License 2.0 6 votes vote down vote up
/**
 * Attempts to close the dialog depending on the type of the buttonType or list view, the
 * listener belongs to.
 */
protected final void attemptCloseDialog() {
    switch (buttonType) {
        case AlertDialog.BUTTON_NEGATIVE:
            dialog.cancel();
            break;
        case AlertDialog.BUTTON_NEUTRAL:
            dialog.cancel();
            break;
        case AlertDialog.BUTTON_POSITIVE:
            dialog.dismiss();
            break;
        default:
            break;
    }
}
 
Example 2
Source File: DlgSave.java    From drmips with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			String path = txtFilename.getText().toString().trim();
			if(!path.isEmpty()) { // save the file
				if(!path.contains(".")) path += ".asm"; // append extension if missing
				File file = new File(DrMIPS.getApplication().getCodeDir().getAbsolutePath() + File.separator + path);
				DrMIPSActivity activity = (DrMIPSActivity)getActivity();

				if(!file.exists()) { // new file
					activity.saveFile(file);
				} else { // file exists
					DlgConfirmReplace.newInstance(file.getPath()).show(getFragmentManager(), "confirm-replace-dialog");
				}
			}
			break;

		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 3
Source File: DlgConfirmReplace.java    From drmips with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			Bundle args = getArguments();
			DrMIPSActivity activity = (DrMIPSActivity)getActivity();
			String path = args.getString("path");
			if(path != null) {
				activity.saveFile(new File(path));
			}
			break;

		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 4
Source File: DlgConfirmDelete.java    From drmips with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			Bundle args = getArguments();
			DrMIPSActivity activity = (DrMIPSActivity)getActivity();
			String path = args.getString("path");
			File file;

			if(path != null && (file = new File(path)).exists()) {
				if(file.delete()) {
					Toast.makeText(getActivity(), R.string.file_deleted, Toast.LENGTH_SHORT).show();
					activity.newFile();
				} else
					Toast.makeText(getActivity(), R.string.error_deleting_file, Toast.LENGTH_SHORT).show();
			}
			break;

		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 5
Source File: CommCareWiFiDirectActivity.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void showDialog(Activity activity, String title, String message) {
    StandardAlertDialog d = new StandardAlertDialog(activity, title, message);
    DialogInterface.OnClickListener listener = (dialog, which) -> {
        switch (which) {
            case AlertDialog.BUTTON_POSITIVE:
                beSubmitter();
                break;
            case AlertDialog.BUTTON_NEUTRAL:
                beReceiver();
                break;
            case AlertDialog.BUTTON_NEGATIVE:
                beSender();
                break;
        }
        dismissAlertDialog();
    };
    d.setNeutralButton(localize("wifi.direct.receive.forms"), listener);
    d.setNegativeButton(localize("wifi.direct.transfer.forms"), listener);
    d.setPositiveButton(localize("wifi.direct.submit.forms"), listener);
    showAlertDialog(d);
}
 
Example 6
Source File: ExecuteRecoveryMeasuresPresenter.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void showInstallMethodChooser() {
    String title = StringUtils.getStringRobust(mActivity, R.string.recovery_measure_reinstall_method);
    String message = StringUtils.getStringRobust(mActivity, R.string.recovery_measure_reinstall_detail);
    StandardAlertDialog d = new StandardAlertDialog(mActivity, title, message);
    DialogInterface.OnClickListener listener = (dialog, which) -> {
        mActivity.dismissAlertDialog();
        if (which == AlertDialog.BUTTON_POSITIVE) {
            doOnlineAppInstall();
        } else if (which == AlertDialog.BUTTON_NEGATIVE) {
            showOfflineInstallActivity();
        }
    };
    d.setPositiveButton(StringUtils.getStringRobust(mActivity, R.string.recovery_measure_reinstall_online_method), listener);
    d.setNegativeButton(StringUtils.getStringRobust(mActivity, R.string.recovery_measure_reinstall_offline_method), listener);
    mActivity.showAlertDialog(d);
}
 
Example 7
Source File: SizeLimitActivity.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
    boolean isRequired =
            mCurrentIntent.getExtras().getBoolean(DownloadInfo.EXTRA_IS_WIFI_REQUIRED);
    if (isRequired && which == AlertDialog.BUTTON_NEGATIVE) {
        getContentResolver().delete(mCurrentUri, null, null);
    } else if (!isRequired && which == AlertDialog.BUTTON_POSITIVE) {
        ContentValues values = new ContentValues();
        values.put(Downloads.COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT, true);
        getContentResolver().update(mCurrentUri, values , null, null);
    }
    dialogClosed();
}
 
Example 8
Source File: DlgAbout.java    From drmips with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			dismiss();
			break;
		case AlertDialog.BUTTON_NEUTRAL: // License
			DlgLicense.newInstance().show(getFragmentManager(), "license-dialog");
			break;
		case AlertDialog.BUTTON_NEGATIVE: // Credits
			DlgCredits.newInstance().show(getFragmentManager(), "credits-dialog");
			break;
	}
}
 
Example 9
Source File: DlgConfirmExit.java    From drmips with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			dismiss();
			getActivity().finish();
			break;
		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 10
Source File: DlgEditRegister.java    From drmips with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: //OK
			String value = txtRegisterValue.getText().toString().trim();
			int val;
			if(!value.isEmpty()) {
				try {
					Bundle args = getArguments();
					DrMIPSActivity activity = (DrMIPSActivity)getActivity();
					int index = args.getInt("index");
					if (index >= 0 && index <= activity.getCPU().getRegBank().getNumberOfRegisters()) {
						val = Integer.parseInt(value);
						activity.setRegisterValue(index, val);
						activity.refreshRegistersTableValues();
					}
				} catch(NumberFormatException ex) {
					Toast.makeText(getActivity(), R.string.invalid_value, Toast.LENGTH_SHORT).show();
				}
			}
			break;

		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 11
Source File: DlgEditDataMemory.java    From drmips with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			String value = txtDataMemoryValue.getText().toString().trim();
			int val;
			if(!value.isEmpty()) {
				try {
					Bundle args = getArguments();
					DrMIPSActivity activity = (DrMIPSActivity)getActivity();
					int index = args.getInt("index");

					if(index >= 0 && index < activity.getCPU().getDataMemory().getMemorySize()) {
						val = Integer.parseInt(value);
						activity.getCPU().getDataMemory().setDataInIndex(index, val);
						activity.refreshDataMemoryTableValues();
						if(activity.getDatapath() != null) activity.getDatapath().refresh();
					}
				} catch(NumberFormatException ex) {
					Toast.makeText(getActivity(), R.string.invalid_value, Toast.LENGTH_SHORT).show();
				}
			}
			break;

		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 12
Source File: DlgChangeLatency.java    From drmips with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
	switch(which) {
		case AlertDialog.BUTTON_POSITIVE: // OK
			try {
				Bundle args = getArguments();
				DrMIPSActivity activity = (DrMIPSActivity)getActivity();
				Component component = activity.getCPU().getComponent(args.getString("id", ""));

				int lat = Integer.parseInt(txtLatency.getText().toString());
				if(lat >= 0 && component != null) {
					component.setLatency(lat);
					activity.getCPU().calculatePerformance();
					activity.getDatapath().refresh();
					activity.getDatapath().invalidate();
				} else {
					Toast.makeText(getActivity(), R.string.invalid_value, Toast.LENGTH_SHORT).show();
				}
			} catch(NumberFormatException ex) {
				Toast.makeText(getActivity(), R.string.invalid_value, Toast.LENGTH_SHORT).show();
			}
			break;

		case AlertDialog.BUTTON_NEGATIVE: // Cancel
			dismiss();
			break;
	}
}
 
Example 13
Source File: WVersionManager.java    From KinoCast with MIT License 5 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which) {
        case AlertDialog.BUTTON_POSITIVE:
            updateNow(getUpdateUrl());
            break;
        case AlertDialog.BUTTON_NEUTRAL:
            remindMeLater(getReminderTimer());
            break;
        case AlertDialog.BUTTON_NEGATIVE:
            ignoreThisVersion();
            break;
    }
}