use of android.content.DialogInterface.OnCancelListener in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method startLoadingIndicator.
public void startLoadingIndicator() {
if (mLoadingDialog == null) {
mLoadingDialog = new ProgressDialog(this);
mLoadingDialog.setMessage(getString(R.string.loading_image));
mLoadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mLoadingDialog.setIndeterminate(true);
mLoadingDialog.setCancelable(true);
mLoadingDialog.setCanceledOnTouchOutside(false);
mLoadingDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
done();
}
});
}
mLoadingDialog.show();
}
use of android.content.DialogInterface.OnCancelListener in project android_packages_apps_Gallery2 by LineageOS.
the class AbstractGalleryActivity method onStart.
@Override
protected void onStart() {
super.onStart();
if (getExternalCacheDir() == null) {
OnCancelListener onCancel = new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
};
OnClickListener onClick = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.no_external_storage_title).setMessage(R.string.no_external_storage).setNegativeButton(android.R.string.cancel, onClick).setOnCancelListener(onCancel);
if (ApiHelper.HAS_SET_ICON_ATTRIBUTE) {
setAlertDialogIconAttribute(builder);
} else {
builder.setIcon(android.R.drawable.ic_dialog_alert);
}
mAlertDialog = builder.show();
registerReceiver(mMountReceiver, mMountFilter);
}
mPanoramaViewHelper.onStart();
}
use of android.content.DialogInterface.OnCancelListener in project MDM-Android-Agent by wso2-attic.
the class AlreadyRegisteredActivity method onResume.
@Override
protected void onResume() {
// TODO Auto-generated method stub
mCheckRegisterTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
state = ServerUtilities.isRegistered(regId, context);
} catch (Exception e) {
e.printStackTrace();
// HandleNetworkError(e);
// Toast.makeText(getApplicationContext(), "No Connection",
// Toast.LENGTH_LONG).show();
}
return null;
}
// declare other objects as per your need
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(AlreadyRegisteredActivity.this, getResources().getString(R.string.dialog_checking_reg), getResources().getString(R.string.dialog_please_wait), true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(cancelListener);
// do initialization of required objects objects here
}
OnCancelListener cancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
showAlert(getResources().getString(R.string.error_connect_to_server), getResources().getString(R.string.error_heading_connection));
}
};
@Override
protected void onPostExecute(Void result) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
SharedPreferences mainPref = context.getSharedPreferences(getResources().getString(R.string.shared_pref_package), Context.MODE_PRIVATE);
String success = mainPref.getString(getResources().getString(R.string.shared_pref_registered), "");
if (success.trim().equals(getResources().getString(R.string.shared_pref_reg_success))) {
state = true;
}
if (!state) {
Intent intent = new Intent(AlreadyRegisteredActivity.this, SettingsActivity.class);
intent.putExtra(getResources().getString(R.string.intent_extra_regid), regId);
intent.putExtra(getResources().getString(R.string.intent_extra_from_activity), AlreadyRegisteredActivity.class.getSimpleName());
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
// finish();
}
mCheckRegisterTask = null;
}
};
mCheckRegisterTask.execute(null, null, null);
super.onResume();
}
use of android.content.DialogInterface.OnCancelListener in project MDM-Android-Agent by wso2-attic.
the class AuthenticationActivity method fetchLicense.
public void fetchLicense() {
SharedPreferences mainPref = context.getSharedPreferences(getResources().getString(R.string.shared_pref_package), Context.MODE_PRIVATE);
isAgreed = mainPref.getString(getResources().getString(R.string.shared_pref_isagreed), "");
String eula = mainPref.getString(getResources().getString(R.string.shared_pref_eula), "");
String type = mainPref.getString(getResources().getString(R.string.shared_pref_reg_type), "");
if (type.trim().equals(getResources().getString(R.string.device_enroll_type_byod))) {
if (!isAgreed.equals("1")) {
/*username.setVisibility(View.GONE);
password.setVisibility(View.GONE);
txtDomain.setVisibility(View.GONE);
authenticate.setVisibility(View.GONE);
txtLoadingEULA.setVisibility(View.VISIBLE);*/
mLicenseTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// boolean registered =
// ServerUtilities.register(context, regId);
String response = "";
try {
response = ServerUtilities.getEULA(context, txtDomain.getText().toString().trim());
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(AuthenticationActivity.this, getResources().getString(R.string.dialog_license_agreement), getResources().getString(R.string.dialog_please_wait), true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(cancelListener);
}
OnCancelListener cancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
showAlertSingle(getResources().getString(R.string.error_enrollment_failed_detail), getResources().getString(R.string.error_enrollment_failed));
// finish();
}
};
@Override
protected void onPostExecute(String result) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (result != null) {
SharedPreferences mainPref = AuthenticationActivity.this.getSharedPreferences(getResources().getString(R.string.shared_pref_package), Context.MODE_PRIVATE);
Editor editor = mainPref.edit();
editor.putString(getResources().getString(R.string.shared_pref_eula), result);
editor.commit();
isAgreed = mainPref.getString(getResources().getString(R.string.shared_pref_isagreed), "");
String eula = mainPref.getString(getResources().getString(R.string.shared_pref_eula), "");
if (!isAgreed.equals("1")) {
if (eula != null && eula != "") {
showAlert(eula, CommonUtilities.EULA_TITLE);
} else {
showErrorMessage(getResources().getString(R.string.error_enrollment_failed_detail), getResources().getString(R.string.error_enrollment_failed));
}
}
} else {
showErrorMessage(getResources().getString(R.string.error_enrollment_failed_detail), getResources().getString(R.string.error_enrollment_failed));
}
mLicenseTask = null;
}
};
mLicenseTask.execute();
} else {
Intent intent = new Intent(AuthenticationActivity.this, PinCodeActivity.class);
intent.putExtra(getResources().getString(R.string.intent_extra_regid), regId);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (txtDomain.getText() != null && txtDomain.getText().toString().trim() != "") {
intent.putExtra(getResources().getString(R.string.intent_extra_email), username.getText().toString().trim() + "@" + txtDomain.getText().toString().trim());
} else {
intent.putExtra(getResources().getString(R.string.intent_extra_email), username.getText().toString().trim());
}
startActivity(intent);
}
} else {
Intent intent = new Intent(AuthenticationActivity.this, PinCodeActivity.class);
intent.putExtra(getResources().getString(R.string.intent_extra_regid), regId);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (txtDomain.getText() != null && txtDomain.getText().toString().trim() != "") {
intent.putExtra(getResources().getString(R.string.intent_extra_email), username.getText().toString().trim() + "@" + txtDomain.getText().toString().trim());
} else {
intent.putExtra(getResources().getString(R.string.intent_extra_email), username.getText().toString().trim());
}
startActivity(intent);
}
}
use of android.content.DialogInterface.OnCancelListener in project MDM-Android-Agent by wso2-attic.
the class SettingsActivity method getSenderID.
public void getSenderID() {
mSenderIDTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
String response = "";
try {
response = ServerUtilities.getSenderID(context);
} catch (Exception e) {
e.printStackTrace();
// HandleNetworkError(e);
// Toast.makeText(getApplicationContext(), "No Connection", Toast.LENGTH_LONG).show();
}
return response;
}
// declare other objects as per your need
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(SettingsActivity.this, getResources().getString(R.string.dialog_sender_id), getResources().getString(R.string.dialog_please_wait), true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(cancelListener);
}
OnCancelListener cancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
showAlert(getResources().getString(R.string.error_connect_to_server), getResources().getString(R.string.error_heading_connection));
}
};
@Override
protected void onPostExecute(String result) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (result != null && !result.equals("")) {
CommonUtilities.setSENDER_ID(result);
}
SharedPreferences mainPref = context.getSharedPreferences(getResources().getString(R.string.shared_pref_package), Context.MODE_PRIVATE);
Editor editor = mainPref.edit();
editor.putString(getResources().getString(R.string.shared_pref_sender_id), senderID);
editor.putString(getResources().getString(R.string.shared_pref_ip), ip.getText().toString().trim());
editor.commit();
CommonUtilities.setSERVER_URL(ip.getText().toString().trim());
Intent intent = new Intent(SettingsActivity.this, EntryActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
mSenderIDTask = null;
}
};
mSenderIDTask.execute(null, null, null);
}
Aggregations