package com.xtremelabs.robolectric.shadows;


import android.app.ProgressDialog;
import android.content.Context;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;

import static com.xtremelabs.robolectric.Robolectric.shadowOf;

@Implements(ProgressDialog.class)
public class ShadowProgressDialog extends ShadowAlertDialog {

    private boolean indeterminate;

    @Implementation
    public static ProgressDialog show(Context context, CharSequence title, CharSequence message) {
        return show(context, title, message, false);
    }

    @Implementation
    public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate) {
        return show(context, title, message, indeterminate, false, null);
    }

    @Implementation
    public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) {
        return show(context, title, message, indeterminate, cancelable, null);
    }

    @Implementation
    public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, ProgressDialog.OnCancelListener onCancelListener) {
        ProgressDialog progressDialog = new ProgressDialog(context);
        progressDialog.setTitle(title);
        progressDialog.setMessage(message);
        progressDialog.setIndeterminate(indeterminate);
        progressDialog.setCancelable(cancelable);
        progressDialog.setOnCancelListener(onCancelListener);
        progressDialog.show();
        Robolectric.getShadowApplication().setLatestAlertDialog(shadowOf(progressDialog));
        return progressDialog;
    }

    @Implementation
    public void setIndeterminate(boolean indeterminate) {
        this.indeterminate = indeterminate;
    }

    @Implementation
    public boolean isIndeterminate() {
        return indeterminate;
    }
}

@@ -463,16 +463,63 @@
 rminate;
+%0A    private int max;%0A    private int progress;
 %0A%0A    @I
@@ -2078,11 +2078,357 @@
 e;%0A    %7D
+%0A%0A    @Implementation%0A    public void setMax(int max) %7B%0A        this.max = max;%0A    %7D%0A%0A    @Implementation%0A    public int getMax() %7B%0A        return max;%0A    %7D%0A%0A    @Implementation%0A    public void setProgress(int progress) %7B%0A        this.progress = progress;%0A    %7D%0A%0A    @Implementation%0A    public int getProgress() %7B%0A        return progress;%0A    %7D
 %0A%7D%0A

extend ShadowProgressDialog to enable checking properties max and progress