package dmax.dialog;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;

/**
 * Created by Maxim Dybarsky | maxim.dybarskyy@gmail.com
 * on 13.01.15 at 14:22
 */
public class SpotsDialog extends AlertDialog {

    private static final int DELAY = 150;
    private static final int DURATION = 1500;

    private int size;
    private AnimatedView[] spots;
    private AnimatorPlayer animator;

    public SpotsDialog(Context context) {
        this(context, R.style.SpotsDialogDefault);
    }

    public SpotsDialog(Context context, int theme) {
        super(context, theme);
    }

    public SpotsDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dialog);
        setCanceledOnTouchOutside(false);

        initProgress();
    }

    @Override
    protected void onStart() {
        super.onStart();

        animator = new AnimatorPlayer(createAnimations());
        animator.play();
    }

    @Override
    protected void onStop() {
        super.onStop();

        animator.stop();
    }

    //~

    private void initProgress() {
        ProgressLayout progress = (ProgressLayout) findViewById(R.id.progress);
        size = progress.getSpotsCount();

        spots = new AnimatedView[size];
        int size = getContext().getResources().getDimensionPixelSize(R.dimen.spot_size);
        int progressWidth = getContext().getResources().getDimensionPixelSize(R.dimen.progress_width);
        for (int i = 0; i < spots.length; i++) {
            AnimatedView v = new AnimatedView(getContext());
            v.setBackgroundResource(R.drawable.spot);
            v.setTarget(progressWidth);
            v.setXFactor(-1f);
            progress.addView(v, size, size);
            spots[i] = v;
        }
    }

    private Animator[] createAnimations() {
        Animator[] animators = new Animator[size];
        for (int i = 0; i < spots.length; i++) {
            Animator move = ObjectAnimator.ofFloat(spots[i], "xFactor", 0, 1);
            move.setDuration(DURATION);
            move.setInterpolator(new HesitateInterpolator());
            move.setStartDelay(DELAY * i);
            animators[i] = move;
        }
        return animators;
    }
}

@@ -180,16 +180,48 @@
 .Bundle;
+%0Aimport android.widget.TextView;
 %0A%0A/**%0A *
@@ -532,16 +532,50 @@
 nimator;
+%0A    private CharSequence message;
 %0A%0A    pu
@@ -660,32 +660,158 @@
 efault);%0A    %7D%0A%0A
+    public SpotsDialog(Context context, CharSequence message) %7B%0A        this(context);%0A        this.message = message;%0A    %7D%0A%0A
     public Spots
@@ -1235,24 +1235,47 @@
 de(false);%0A%0A
+        initMessage();%0A
         init
@@ -1552,24 +1552,24 @@
 p();%0A    %7D%0A%0A
-
     //~%0A%0A   
@@ -1565,16 +1565,189 @@
    //~%0A%0A
+    private void initMessage() %7B%0A        if (message != null && message.length() %3E 0) %7B%0A            ((TextView) findViewById(R.id.title)).setText(message);%0A        %7D%0A    %7D%0A%0A
     priv

Fix #5: add constructor with custom dialog message