use of android.content.DialogInterface.OnCancelListener in project Anki-Android by Ramblurr.
the class Reviewer method reloadCollection.
private void reloadCollection(Bundle savedInstanceState) {
mSavedInstanceState = savedInstanceState;
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_OPEN_COLLECTION, new DeckTask.TaskListener() {
@Override
public void onPostExecute(DeckTask.TaskData result) {
if (mOpenCollectionDialog.isShowing()) {
try {
mOpenCollectionDialog.dismiss();
} catch (Exception e) {
Log.e(AnkiDroidApp.TAG, "onPostExecute - Dialog dismiss Exception = " + e.getMessage());
}
}
if (AnkiDroidApp.colIsOpen()) {
onCreate(mSavedInstanceState);
} else {
finish();
}
}
@Override
public void onPreExecute() {
mOpenCollectionDialog = StyledOpenCollectionDialog.show(Reviewer.this, getResources().getString(R.string.open_collection), new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
finish();
}
});
}
@Override
public void onProgressUpdate(DeckTask.TaskData... values) {
}
}, new DeckTask.TaskData(AnkiDroidApp.getCurrentAnkiDroidDirectory() + AnkiDroidApp.COLLECTION_PATH, 0, true));
}
use of android.content.DialogInterface.OnCancelListener in project LiveSDK-for-Android by liveservices.
the class SkyDriveActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FilePicker.PICK_FILE_REQUEST) {
if (resultCode == RESULT_OK) {
String filePath = data.getStringExtra(FilePicker.EXTRA_FILE_PATH);
if (TextUtils.isEmpty(filePath)) {
showToast("No file was choosen.");
return;
}
File file = new File(filePath);
final ProgressDialog uploadProgressDialog = new ProgressDialog(SkyDriveActivity.this);
uploadProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
uploadProgressDialog.setMessage("Uploading...");
uploadProgressDialog.setCancelable(true);
uploadProgressDialog.show();
final LiveOperation operation = mClient.uploadAsync(mCurrentFolderId, file.getName(), file, new LiveUploadOperationListener() {
@Override
public void onUploadProgress(int totalBytes, int bytesRemaining, LiveOperation operation) {
int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining);
uploadProgressDialog.setProgress(percentCompleted);
}
@Override
public void onUploadFailed(LiveOperationException exception, LiveOperation operation) {
uploadProgressDialog.dismiss();
showToast(exception.getMessage());
}
@Override
public void onUploadCompleted(LiveOperation operation) {
uploadProgressDialog.dismiss();
JSONObject result = operation.getResult();
if (result.has(JsonKeys.ERROR)) {
JSONObject error = result.optJSONObject(JsonKeys.ERROR);
String message = error.optString(JsonKeys.MESSAGE);
String code = error.optString(JsonKeys.CODE);
showToast(code + ": " + message);
return;
}
loadFolder(mCurrentFolderId);
}
});
uploadProgressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
operation.cancel();
}
});
}
}
}
use of android.content.DialogInterface.OnCancelListener in project LiveSDK-for-Android by liveservices.
the class SkyDriveActivity method onCreateDialog.
@Override
protected Dialog onCreateDialog(final int id, final Bundle bundle) {
Dialog dialog = null;
switch(id) {
case DIALOG_DOWNLOAD_ID:
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Download").setMessage("This file will be downloaded to the sdcard.").setPositiveButton("OK", new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final ProgressDialog progressDialog = new ProgressDialog(SkyDriveActivity.this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage("Downloading...");
progressDialog.setCancelable(true);
progressDialog.show();
String fileId = bundle.getString(JsonKeys.ID);
String name = bundle.getString(JsonKeys.NAME);
File file = new File(Environment.getExternalStorageDirectory(), name);
final LiveDownloadOperation operation = mClient.downloadAsync(fileId + "/content", file, new LiveDownloadOperationListener() {
@Override
public void onDownloadProgress(int totalBytes, int bytesRemaining, LiveDownloadOperation operation) {
int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining);
progressDialog.setProgress(percentCompleted);
}
@Override
public void onDownloadFailed(LiveOperationException exception, LiveDownloadOperation operation) {
progressDialog.dismiss();
showToast(exception.getMessage());
}
@Override
public void onDownloadCompleted(LiveDownloadOperation operation) {
progressDialog.dismiss();
showToast("File downloaded.");
}
});
progressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
operation.cancel();
}
});
}
}).setNegativeButton("Cancel", new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog = builder.create();
break;
}
}
if (dialog != null) {
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
removeDialog(id);
}
});
}
return dialog;
}
use of android.content.DialogInterface.OnCancelListener in project android_packages_apps_Dialer by LineageOS.
the class CreateCustomSmsDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View view = View.inflate(builder.getContext(), R.layout.fragment_custom_sms_dialog, null);
editText = (EditText) view.findViewById(R.id.custom_sms_input);
if (savedInstanceState != null) {
editText.setText(savedInstanceState.getCharSequence(ARG_ENTERED_TEXT));
}
inCallUiLock = FragmentUtils.getParentUnsafe(CreateCustomSmsDialogFragment.this, CreateCustomSmsHolder.class).acquireInCallUiLock("CreateCustomSmsDialogFragment");
builder.setCancelable(true).setView(view).setPositiveButton(R.string.call_incoming_custom_message_send, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
FragmentUtils.getParentUnsafe(CreateCustomSmsDialogFragment.this, CreateCustomSmsHolder.class).customSmsCreated(editText.getText().toString().trim());
dismiss();
}
}).setNegativeButton(R.string.call_incoming_custom_message_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dismiss();
}
}).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
dismiss();
}
}).setTitle(R.string.call_incoming_respond_via_sms_custom_message);
final AlertDialog customMessagePopup = builder.create();
customMessagePopup.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
((AlertDialog) dialogInterface).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
});
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
Button sendButton = customMessagePopup.getButton(DialogInterface.BUTTON_POSITIVE);
sendButton.setEnabled(editable != null && editable.toString().trim().length() != 0);
}
});
customMessagePopup.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
customMessagePopup.getWindow().addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
return customMessagePopup;
}
use of android.content.DialogInterface.OnCancelListener in project android_packages_apps_Dialer by LineageOS.
the class CallLogAdapter method showDeleteSelectedItemsDialog.
private void showDeleteSelectedItemsDialog() {
SparseArray<String> voicemailsToDeleteOnConfirmation = selectedItems.clone();
new AlertDialog.Builder(activity).setCancelable(true).setTitle(activity.getResources().getQuantityString(R.plurals.delete_voicemails_confirmation_dialog_title, selectedItems.size())).setPositiveButton(R.string.voicemailMultiSelectDeleteConfirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int button) {
LogUtil.i("CallLogAdapter.showDeleteSelectedItemsDialog", "onClick, these items to delete " + voicemailsToDeleteOnConfirmation);
deleteSelectedItems(voicemailsToDeleteOnConfirmation);
actionMode.finish();
dialog.cancel();
Logger.get(activity).logImpression(DialerImpression.Type.MULTISELECT_DELETE_ENTRY_VIA_CONFIRMATION_DIALOG);
}
}).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
Logger.get(activity).logImpression(DialerImpression.Type.MULTISELECT_CANCEL_CONFIRMATION_DIALOG_VIA_CANCEL_TOUCH);
dialogInterface.cancel();
}
}).setNegativeButton(R.string.voicemailMultiSelectDeleteCancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int button) {
Logger.get(activity).logImpression(DialerImpression.Type.MULTISELECT_CANCEL_CONFIRMATION_DIALOG_VIA_CANCEL_BUTTON);
dialog.cancel();
}
}).show();
Logger.get(activity).logImpression(DialerImpression.Type.MULTISELECT_DISPLAY_DELETE_CONFIRMATION_DIALOG);
}
Aggregations