use of android.content.DialogInterface.OnCancelListener in project xabber-android by redsolution.
the class ContactListActivity method onCreateDialog.
@Override
protected Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
switch(id) {
case DIALOG_CLOSE_APPLICATION_ID:
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage(getString(R.string.application_state_closing));
progressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
progressDialog.setIndeterminate(true);
return progressDialog;
default:
return null;
}
}
use of android.content.DialogInterface.OnCancelListener in project var3dframe by Var3D.
the class VAndroidLauncher method getTextInput.
public void getTextInput(final TextInputListener listener, final String title, final String text, final String hint) {
final Context context = getContext();
runOnUiThread(new Runnable() {
public void run() {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle(title);
final EditText input = new EditText(context);
input.setHint(hint);
input.setText(text);
input.setSingleLine();
alert.setView(input);
alert.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
listener.input(input.getText().toString());
}
});
}
});
alert.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
listener.canceled();
}
});
}
});
alert.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
listener.canceled();
}
});
}
});
alert.show();
}
});
}
use of android.content.DialogInterface.OnCancelListener in project Inscription by MartinvanZ.
the class ChangeLogDialog method show.
protected void show(final int version) {
//Get resources
final String packageName = mContext.getPackageName();
final Resources resources;
try {
resources = mContext.getPackageManager().getResourcesForApplication(packageName);
} catch (NameNotFoundException ignored) {
return;
}
//Get dialog title
String title = resources.getString(R.string.title_changelog);
title = String.format("%s v%s", title, getAppVersion());
//Create html change log
final String htmlChangelog = getHTMLChangelog(R.xml.changelog, resources, version);
//Get button strings
final String closeString = resources.getString(R.string.changelog_close);
//Check for empty change log
if (htmlChangelog.length() == 0) {
//It seems like there is nothing to show, just bail out.
return;
}
//Create web view and load html
final WebView webView = new WebView(mContext);
webView.loadDataWithBaseURL(null, htmlChangelog, "text/html", "utf-8", null);
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext).setTitle(title).setView(webView).setPositiveButton(closeString, new Dialog.OnClickListener() {
public void onClick(final DialogInterface dialogInterface, final int i) {
dialogInterface.dismiss();
}
}).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(final DialogInterface dialog) {
if (mOnDismissListener != null) {
mOnDismissListener.onDismiss(dialog);
}
}
});
dialog.show();
}
use of android.content.DialogInterface.OnCancelListener in project AndEngine by nicolasgramlich.
the class ActivityUtils method doAsync.
public static <T> void doAsync(final Context pContext, final CharSequence pTitle, final CharSequence pMessage, final Callable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback, final boolean pCancelable) {
new AsyncTask<Void, Void, T>() {
private ProgressDialog mPD;
private Exception mException = null;
@Override
public void onPreExecute() {
this.mPD = ProgressDialog.show(pContext, pTitle, pMessage, true, pCancelable);
if (pCancelable) {
this.mPD.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(final DialogInterface pDialogInterface) {
pExceptionCallback.onCallback(new CancelledException());
pDialogInterface.dismiss();
}
});
}
super.onPreExecute();
}
@Override
public T doInBackground(final Void... params) {
try {
return pCallable.call();
} catch (final Exception e) {
this.mException = e;
}
return null;
}
@Override
public void onPostExecute(final T result) {
try {
this.mPD.dismiss();
} catch (final Exception e) {
Debug.e("Error", e);
}
if (this.isCancelled()) {
this.mException = new CancelledException();
}
if (this.mException == null) {
pCallback.onCallback(result);
} else {
if (pExceptionCallback == null) {
Debug.e("Error", this.mException);
} else {
pExceptionCallback.onCallback(this.mException);
}
}
super.onPostExecute(result);
}
}.execute((Void[]) null);
}
use of android.content.DialogInterface.OnCancelListener in project xabber-android by redsolution.
the class ContactList method onCreateDialog.
@Override
protected Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
switch(id) {
case DIALOG_CLOSE_APPLICATION_ID:
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage(getString(R.string.application_state_closing));
progressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
progressDialog.setIndeterminate(true);
return progressDialog;
default:
return null;
}
}
Aggregations