use of android.content.DialogInterface.OnDismissListener in project Android-DialogFragments by wada811.
the class AbstractDialogFragment method setOnDismissListener.
protected void setOnDismissListener(Dialog dialog) {
useOnDismissListener = true;
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
bindDismissListener();
}
});
}
use of android.content.DialogInterface.OnDismissListener in project android-app by spark.
the class TinkerFragment method showTinkerSelect.
private void showTinkerSelect(Pin pin) {
// No current action on the pin
mutePinsExcept(pin);
toggleViewVisibilityWithFade(R.id.tinker_logo, false);
final View selectDialogView = getActivity().getLayoutInflater().inflate(R.layout.tinker_select, null);
selectDialog = new AlertDialog.Builder(getActivity(), R.style.AppTheme_DialogNoDimBackground).setView(selectDialogView).setCancelable(true).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
}
}).create();
selectDialog.setCanceledOnTouchOutside(true);
selectDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
unmutePins();
toggleViewVisibilityWithFade(R.id.tinker_logo, true);
selectDialog = null;
}
});
final View analogRead = Ui.findView(selectDialogView, R.id.tinker_button_analog_read);
final View analogWrite = Ui.findView(selectDialogView, R.id.tinker_button_analog_write);
final View digitalRead = Ui.findView(selectDialogView, R.id.tinker_button_digital_read);
final View digitalWrite = Ui.findView(selectDialogView, R.id.tinker_button_digital_write);
final List<View> allButtons = list(analogRead, analogWrite, digitalRead, digitalWrite);
analogRead.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
setTinkerSelectButtonSelected(analogRead, allButtons);
}
return false;
}
});
analogWrite.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
setTinkerSelectButtonSelected(analogWrite, allButtons);
}
return false;
}
});
digitalRead.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
setTinkerSelectButtonSelected(digitalRead, allButtons);
}
return false;
}
});
digitalWrite.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
setTinkerSelectButtonSelected(digitalWrite, allButtons);
}
return false;
}
});
digitalWrite.setOnClickListener(this);
digitalRead.setOnClickListener(this);
analogRead.setOnClickListener(this);
analogWrite.setOnClickListener(this);
if (!digitalWritePins.contains(pin)) {
digitalWrite.setVisibility(View.INVISIBLE);
} else {
digitalWrite.setVisibility(View.VISIBLE);
}
if (!digitalReadPins.contains(pin)) {
digitalRead.setVisibility(View.INVISIBLE);
} else {
digitalRead.setVisibility(View.VISIBLE);
}
if (!analogReadPins.contains(pin)) {
analogRead.setVisibility(View.INVISIBLE);
} else {
analogRead.setVisibility(View.VISIBLE);
}
if (!analogWritePins.contains(pin)) {
analogWrite.setVisibility(View.INVISIBLE);
} else {
analogWrite.setVisibility(View.VISIBLE);
}
((TextView) selectDialogView.findViewById(R.id.tinker_select_pin)).setText(pin.name);
PinAction action = pin.getConfiguredAction();
switch(action) {
case ANALOG_READ:
setTinkerSelectButtonSelected(analogRead, allButtons);
break;
case ANALOG_WRITE:
setTinkerSelectButtonSelected(analogWrite, allButtons);
break;
case DIGITAL_READ:
setTinkerSelectButtonSelected(digitalRead, allButtons);
break;
case DIGITAL_WRITE:
setTinkerSelectButtonSelected(digitalWrite, allButtons);
break;
case NONE:
setTinkerSelectButtonSelected(null, allButtons);
break;
}
selectDialog.show();
View decorView = selectDialog.getWindow().getDecorView();
noIReallyMeanItIWantThisToBeTransparent(decorView);
}
use of android.content.DialogInterface.OnDismissListener in project platform_frameworks_base by android.
the class PowerNotificationWarnings method showStartSaverConfirmation.
private void showStartSaverConfirmation() {
if (mSaverConfirmation != null)
return;
final SystemUIDialog d = new SystemUIDialog(mContext);
d.setTitle(R.string.battery_saver_confirmation_title);
d.setMessage(com.android.internal.R.string.battery_saver_description);
d.setNegativeButton(android.R.string.cancel, null);
d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
d.setShowForAllUsers(true);
d.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mSaverConfirmation = null;
}
});
d.show();
mSaverConfirmation = d;
}
use of android.content.DialogInterface.OnDismissListener 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.OnDismissListener in project android_frameworks_base by ResurrectionRemix.
the class PowerNotificationWarnings method showStartSaverConfirmation.
private void showStartSaverConfirmation() {
if (mSaverConfirmation != null)
return;
final SystemUIDialog d = new SystemUIDialog(mContext);
d.setTitle(R.string.battery_saver_confirmation_title);
d.setMessage(com.android.internal.R.string.battery_saver_description);
d.setNegativeButton(android.R.string.cancel, null);
d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
d.setShowForAllUsers(true);
d.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mSaverConfirmation = null;
}
});
d.show();
mSaverConfirmation = d;
}
Aggregations