@@ -43,7 +43,7 @@ public class VerticalStepperItemView extends FrameLayout {
43
43
/**
44
44
* Step state
45
45
*/
46
- private String mTitle , mSummary ;
46
+ private String mTitle , mSummary , mSummaryFinished = null ;
47
47
private int mIndex = 1 ;
48
48
private boolean isLastStep = false ;
49
49
private int mState = STATE_NORMAL ;
@@ -87,6 +87,7 @@ public VerticalStepperItemView(Context context, AttributeSet attrs, int defStyle
87
87
88
88
mTitle = a .getString (R .styleable .VerticalStepperItemView_step_title );
89
89
mSummary = a .getString (R .styleable .VerticalStepperItemView_step_summary );
90
+ mSummaryFinished = a .getString (R .styleable .VerticalStepperItemView_step_summary_done );
90
91
mIndex = a .getInt (R .styleable .VerticalStepperItemView_step_index , 1 );
91
92
mState = a .getInt (R .styleable .VerticalStepperItemView_step_state , STATE_NORMAL );
92
93
isLastStep = a .getBoolean (R .styleable .VerticalStepperItemView_step_is_last , false );
@@ -105,7 +106,7 @@ public VerticalStepperItemView(Context context, AttributeSet attrs, int defStyle
105
106
}
106
107
107
108
setTitle (mTitle );
108
- setSummary ( mSummary );
109
+ updateSummaryView ( );
109
110
setIndex (mIndex );
110
111
setState (mState );
111
112
setIsLastStep (isLastStep );
@@ -263,6 +264,7 @@ public synchronized void setState(@State int state) {
263
264
mState = state ;
264
265
265
266
updateMarginBottom ();
267
+ updateSummaryView ();
266
268
}
267
269
268
270
/**
@@ -343,8 +345,7 @@ public void setErrorText(@StringRes int errorTextRes) {
343
345
*/
344
346
public void setSummary (@ Nullable String summary ) {
345
347
mSummary = summary ;
346
- mSummaryText .setText (mErrorText != null ? mErrorText : summary );
347
- mSummaryText .setVisibility (mState != STATE_SELECTED && !TextUtils .isEmpty (mSummaryText .getText ()) ? View .VISIBLE : View .GONE );
348
+ updateSummaryView ();
348
349
}
349
350
350
351
/**
@@ -365,6 +366,46 @@ public String getSummary() {
365
366
return mSummary ;
366
367
}
367
368
369
+ /**
370
+ * Set finished summary for this step.
371
+ * If you set a null value, it will hide the summary view or show default summary.
372
+ *
373
+ * @param summary The summary should be set or null
374
+ */
375
+ public void setSummaryFinished (@ Nullable String summary ) {
376
+ mSummaryFinished = summary ;
377
+ updateSummaryView ();
378
+ }
379
+
380
+ /**
381
+ * Set summary for this step.
382
+ *
383
+ * @param summaryRes The summary resource should be set
384
+ */
385
+ public void setSummaryFinished (@ StringRes int summaryRes ) {
386
+ setSummaryFinished (getResources ().getString (summaryRes ));
387
+ }
388
+
389
+ /**
390
+ * Get the summary of this step
391
+ *
392
+ * @return The summary of this step
393
+ */
394
+ public String getSummaryFinished () {
395
+ return mSummaryFinished ;
396
+ }
397
+
398
+ /**
399
+ * Update summary view
400
+ */
401
+ private void updateSummaryView () {
402
+ mSummaryText .setText (
403
+ mErrorText != null ? mErrorText
404
+ : (mSummaryFinished != null && mState == STATE_DONE ) ? mSummaryFinished : mSummary
405
+ );
406
+ mSummaryText .setVisibility (mState != STATE_SELECTED && !TextUtils .isEmpty (mSummaryText .getText ()) ? View .VISIBLE : View .GONE );
407
+ }
408
+
368
409
/**
369
410
* Set index for this step
370
411
*
@@ -691,6 +732,7 @@ public Parcelable onSaveInstanceState() {
691
732
ItemViewState state = new ItemViewState (super .onSaveInstanceState ());
692
733
state .title = mTitle ;
693
734
state .summary = mSummary ;
735
+ state .summaryFinished = mSummaryFinished ;
694
736
state .index = mIndex ;
695
737
state .isLastStep = isLastStep ;
696
738
state .state = mState ;
@@ -713,6 +755,7 @@ public void onRestoreInstanceState(Parcelable state) {
713
755
super .onRestoreInstanceState (viewState .getSuperState ());
714
756
setTitle (viewState .title );
715
757
setSummary (viewState .summary );
758
+ setSummaryFinished (viewState .summaryFinished );
716
759
setIndex (viewState .index );
717
760
setIsLastStep (viewState .isLastStep );
718
761
setState (viewState .state );
@@ -732,7 +775,7 @@ protected static class ItemViewState extends BaseSavedState {
732
775
733
776
private static final String STATE = VerticalStepperItemView .class .getSimpleName () + ".STATE" ;
734
777
735
- String title , summary ;
778
+ String title , summary , summaryFinished ;
736
779
int index = 1 ;
737
780
boolean isLastStep = false ;
738
781
int state = STATE_NORMAL ;
0 commit comments