Skip to content

Instantly share code, notes, and snippets.

@antew
antew / LogoutDialogFragment.java
Created February 10, 2013 06:18
No args constructor
public LogoutDialogFragment() {};
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (activity instanceof LogoutDialogListener) {
listener = (LogoutDialogListener) activity;
} else {
throw new RuntimeException("The Activity must " +
"implement the LogoutDialogListener interface!");
}
}
@antew
antew / LogoutDialogFragment.java
Last active December 12, 2015 02:58
Alert Dialogs - Part 1 - Communicating with the Activity #2
public class LogoutDialogFragment extends DialogFragment implements
OnClickListener {
// Used to communicate the result back to the Activity
private LogoutDialogListener listener;
@antew
antew / LogoutDialogListener.java
Last active December 12, 2015 02:58
Alert Dialogs - Part 1 - Communicating with the Activity
/**
* Interface for Activities to implement to receive the result
*/
public interface LogoutDialogListener {
public void performLogout();
public void cancelLogout();
}