Created
November 10, 2011 18:26
-
-
Save dhawalhshah/1355665 to your computer and use it in GitHub Desktop.
Android Activity to show the Progress dialog created using DialogFragment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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