49
49
import com .stepstone .stepper .type .StepperTypeFactory ;
50
50
import com .stepstone .stepper .util .AnimationUtil ;
51
51
import com .stepstone .stepper .util .TintUtil ;
52
+ import com .stepstone .stepper .viewmodel .StepViewModel ;
52
53
53
54
/**
54
55
* Stepper widget implemented according to the <a href="https://www.google.com/design/spec/components/steppers.html">Material documentation</a>.<br>
@@ -531,19 +532,18 @@ private void onComplete(View completeButton) {
531
532
532
533
private void onUpdate (int newStepPosition , boolean animate ) {
533
534
mPager .setCurrentItem (newStepPosition );
534
- boolean isLast = isLastPosition (newStepPosition );
535
- boolean isFirst = newStepPosition == 0 ;
535
+ final boolean isLast = isLastPosition (newStepPosition );
536
+ final boolean isFirst = newStepPosition == 0 ;
536
537
AnimationUtil .fadeViewVisibility (mNextNavigationButton , isLast ? View .GONE : View .VISIBLE , animate );
537
538
AnimationUtil .fadeViewVisibility (mCompleteNavigationButton , !isLast ? View .GONE : View .VISIBLE , animate );
538
539
AnimationUtil .fadeViewVisibility (mBackNavigationButton , isFirst && !mShowBackButtonOnFirstStep ? View .GONE : View .VISIBLE , animate );
539
540
541
+ final StepViewModel viewModel = mStepAdapter .getViewModel (newStepPosition );
542
+
543
+ updateBackButtonText (viewModel );
544
+
540
545
if (!isLast ) {
541
- CharSequence nextButtonTextForStep = mStepAdapter .getViewModel (newStepPosition ).getNextButtonLabel ();
542
- if (nextButtonTextForStep == null ) {
543
- mNextNavigationButton .setText (mNextButtonText );
544
- } else {
545
- mNextNavigationButton .setText (nextButtonTextForStep );
546
- }
546
+ updateNextButtonText (viewModel );
547
547
}
548
548
549
549
mStepperType .onStepSelected (newStepPosition );
@@ -553,4 +553,22 @@ private void onUpdate(int newStepPosition, boolean animate) {
553
553
step .onSelected ();
554
554
}
555
555
}
556
+
557
+ private void updateNextButtonText (@ NonNull StepViewModel viewModel ) {
558
+ CharSequence nextButtonTextForStep = viewModel .getNextButtonLabel ();
559
+ if (nextButtonTextForStep == null ) {
560
+ mNextNavigationButton .setText (mNextButtonText );
561
+ } else {
562
+ mNextNavigationButton .setText (nextButtonTextForStep );
563
+ }
564
+ }
565
+
566
+ private void updateBackButtonText (@ NonNull StepViewModel viewModel ) {
567
+ CharSequence backButtonTextForStep = viewModel .getBackButtonLabel ();
568
+ if (backButtonTextForStep == null ) {
569
+ mBackNavigationButton .setText (mBackButtonText );
570
+ } else {
571
+ mBackNavigationButton .setText (backButtonTextForStep );
572
+ }
573
+ }
556
574
}
0 commit comments