avast / android-styled-dialogs

Backport of Material dialogs with easy-to-use API based on DialogFragment
Apache License 2.0
2.15k stars 450 forks source link

OnCancelListener support for ProgressDialogBuilder #86

Closed andreabellitto closed 9 years ago

andreabellitto commented 9 years ago

I have done a mod to make possible to set a ISimpleDialogCancelListener with ProgressDialogBuilder inside something different from an activity or a fragment:

ProgressDialogFragment.createBuilder(activity, activity().getSupportFragmentManager()) .setTitle(context.getString(R.string.progressDialogTitle)) .setMessage(context.getString(R.string.progressDialogMessage)) .setCancelable(true) .setOnCancelListener(this) .show();

this snippet of code for example can be executed from inside an AsynkTask and when the dialog is cancelled the task can be interrupted.

davidvavra commented 9 years ago

You ignored our formatting... But anyway this listener is wrong, because it will stop working when you rotate the device. StyledDialogs have different architecture of listeners which survive rotation. You can listen to them in Activity or Fragment. ProgressDialog already has a support for OnCancelListener. Look into DemoActivity how it's used.