1package com.xtremelabs.robolectric.shadows; 2 3 4import android.app.ProgressDialog; 5import android.content.Context; 6import com.xtremelabs.robolectric.Robolectric; 7import com.xtremelabs.robolectric.internal.Implementation; 8import com.xtremelabs.robolectric.internal.Implements; 9 10import static com.xtremelabs.robolectric.Robolectric.shadowOf; 11 12@Implements(ProgressDialog.class) 13public class ShadowProgressDialog extends ShadowAlertDialog { 14 15 private boolean indeterminate; 16 17 @Implementation 18 public static ProgressDialog show(Context context, CharSequence title, CharSequence message) { 19 return show(context, title, message, false); 20 } 21 22 @Implementation 23 public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate) { 24 return show(context, title, message, indeterminate, false, null); 25 } 26 27 @Implementation 28 public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) { 29 return show(context, title, message, indeterminate, cancelable, null); 30 } 31 32 @Implementation 33 public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, ProgressDialog.OnCancelListener onCancelListener) { 34 ProgressDialog progressDialog = new ProgressDialog(context); 35 progressDialog.setTitle(title); 36 progressDialog.setMessage(message); 37 progressDialog.setIndeterminate(indeterminate); 38 progressDialog.setCancelable(cancelable); 39 progressDialog.setOnCancelListener(onCancelListener); 40 progressDialog.show(); 41 Robolectric.getShadowApplication().setLatestAlertDialog(shadowOf(progressDialog)); 42 return progressDialog; 43 } 44 45 @Implementation 46 public void setIndeterminate(boolean indeterminate) { 47 this.indeterminate = indeterminate; 48 } 49 50 @Implementation 51 public boolean isIndeterminate() { 52 return indeterminate; 53 } 54} 55