-
- All Implemented Interfaces:
-
android.content.DialogInterface.OnClickListener
public final class DetachableClickListener implements DialogInterface.OnClickListener
Wrapper class for DialogInterface.OnClickListener to clear the reference to the listener when the dialog window is detached. This fixes the issue of potential memory leaks on OS prior to Android Lollipop when using dialogs.
-
-
Method Summary
Modifier and Type Method Description static DetachableClickListenerwrap(DialogInterface.OnClickListener delegate)voidonClick(DialogInterface dialog, int which)voidclearOnDetach(Dialog dialog)Nulls out listener when dialog is detached from window.Must be set after Dialog.show() is called. -
-
Method Detail
-
wrap
@NonNull() static DetachableClickListener wrap(DialogInterface.OnClickListener delegate)
-
onClick
void onClick(DialogInterface dialog, int which)
-
clearOnDetach
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) void clearOnDetach(Dialog dialog)
Nulls out listener when dialog is detached from window.Must be set after Dialog.show() is called.
-
-
-
-