public class LoadingHelper { private static ProgressDialog progress; public void run(Context context, final CallbackInterface callback){ progress = ProgressDialog.show(context, "Carregando", "Por favor, aguarde :D", true); new Thread(new Runnable() { @Override public void run() { if(callback != null) callback.run(); } }).start(); } public static void dismiss(){ progress.dismiss(); } public interface CallbackInterface { public void run (); } }
A continuación, para mostrar el ProgressDialog:
LoadingHelper.run(context, null); // Ou usando a função de callback LoadingHelper.run(context, new CallbackInterface(){ @Override void run(){ } });
Para ocultar el ProgressDialog:
LoadingHelper.dismiss();
- Tags:
- ProgressDialog