diff --git a/stepview/src/main/java/com/shuhart/stepview/StepView.java b/stepview/src/main/java/com/shuhart/stepview/StepView.java index 0655ac5..8c290fe 100644 --- a/stepview/src/main/java/com/shuhart/stepview/StepView.java +++ b/stepview/src/main/java/com/shuhart/stepview/StepView.java @@ -44,6 +44,15 @@ public interface OnStepClickListener { void onStepClick(int step); } + public interface OnStepChangeListener { + /** + * Index of the first step is 0. + * + * @param newStep index of the new step + */ + void onStepChangeTo(int newStep); + } + public static final int ANIMATION_LINE = 0; public static final int ANIMATION_CIRCLE = 1; public static final int ANIMATION_ALL = 2; @@ -63,6 +72,7 @@ public interface OnStepClickListener { } private OnStepClickListener onStepClickListener; + private OnStepChangeListener onStepChangeListener; private static final int ANIMATE_STEP_TRANSITION = 0; private static final int IDLE = 1; @@ -287,9 +297,17 @@ public void go(int step, boolean animate) { currentStep = step; invalidate(); } + if (onStepChangeListener != null) { + onStepChangeListener.onStepChangeTo(step); + } } } + public void changeText(int step, CharSequence newText) { + this.steps.set(step, newText.toString()); + requestLayout(); + } + public void done(boolean isDone) { done = isDone; invalidate();