00001 package com.github.rosjava.android_remocons.rocon_remocon.dialogs; 00002 00007 import android.app.Activity; 00008 import android.app.ProgressDialog; 00009 import android.util.Log; 00010 00014 public class ProgressDialogWrapper { 00015 private ProgressDialog progressDialog; 00016 private Activity activity; 00017 00018 public ProgressDialogWrapper(Activity activity) { 00019 this.activity = activity; 00020 progressDialog = null; 00021 } 00022 00023 public void dismiss() { 00024 Log.d("Remocon", "Stopping the spinner"); 00025 activity.runOnUiThread(new Runnable() { 00026 public void run() { 00027 if (progressDialog != null) { 00028 progressDialog.dismiss(); 00029 progressDialog = null; 00030 } 00031 } 00032 }); 00033 } 00034 00035 public void show(final String title, final String text) { 00036 activity.runOnUiThread(new Runnable() { 00037 public void run() { 00038 if (progressDialog != null) { 00039 Log.d("Remocon", "Restarting the spinner with a new message"); 00040 progressDialog.dismiss(); 00041 } 00042 00043 progressDialog = ProgressDialog.show(activity, title, text, true, true); 00044 progressDialog.setCancelable(false); 00045 progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 00046 } 00047 }); 00048 } 00049 }