Skip to content

Instantly share code, notes, and snippets.

@dhawalhshah
Created November 10, 2011 18:26
Show Gist options
  • Save dhawalhshah/1355665 to your computer and use it in GitHub Desktop.
Save dhawalhshah/1355665 to your computer and use it in GitHub Desktop.
Android Activity to show the Progress dialog created using DialogFragment
public class ProgressDialogActivity extends FragmentActivity {
final static String LOADING_DIALOG_TAG = "progress_dialog";
/**
* Shows the loading progress dialog
*/
public void showLoadingDialog() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag(
LOADING_DIALOG_TAG);
if (prev != null) {
ft.remove(prev);
}
// Create and show the dialog.
LoadingDialogFragment newFragment = ProgressDialogFragment.newInstance();
newFragment.show(ft, LOADING_DIALOG_TAG);
}
/**
* Dismisses the loading progress dialog
*/
public void dismissLoadingDialog() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag(
LOADING_DIALOG_TAG);
if (prev != null) {
ft.remove(prev);
ft.commit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment