Class Step<T extends java.io.Serializable>

  • Type Parameters:
    T - The type of the data that the step will hold. E.g., For a user email, T = String

    public abstract class Step<T extends java.io.Serializable>
    extends java.lang.Object
    This class represents a step of the form (e.g., user email). It holds the step's data and offers useful methods. It should be implemented and passed to the form builder as a parameter.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  Step.IsDataValid
      This class holds information about whether the data is valid in a boolean.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Step​(java.lang.String title)  
      protected Step​(java.lang.String title, java.lang.String subtitle)  
      protected Step​(java.lang.String title, java.lang.String subtitle, java.lang.String nextButtonText)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract android.view.View createStepContentLayout()
      This method will be called automatically by the form in order to get the layout of the step.
      android.view.View getContentLayout()
      Gets the content layout of the step, which was generated on createStepContentLayout(), if any.
      android.content.Context getContext()
      Gets the context of the form.
      android.view.View getEntireStepLayout()
      This method returns the entire step layout.
      java.lang.String getErrorMessage()
      Gets the current error message of this step.
      VerticalStepperFormView getFormView()
      Gets the instance of the vertical stepper form that this step belongs to.
      java.lang.String getNextButtonText()
      Gets the text for the step's button.
      int getPosition()
      Gets the position of the step within the form, counting from 0.
      abstract T getStepData()
      Gets the data of this step (i.e., the information that the user has filled in for this field).
      abstract java.lang.String getStepDataAsHumanReadableString()
      Gets the data of this step (i.e., the information that the user has filled in for this field) as a human-readable string.
      java.lang.String getSubtitle()
      Gets the subtitle of this step.
      java.lang.String getTitle()
      Gets the title of this step.
      boolean hasError()
      Returns whether or not the step is currently considered to be in an error state because its data is invalid.
      boolean isCompleted()
      Determines whether the step is marked as completed or not.
      boolean isOpen()
      Determines whether the step is open or not.
      boolean isStepDataValid()
      Determines whether the step data (i.e., the information the user has filled up in this field) is valid or not.
      protected abstract Step.IsDataValid isStepDataValid​(T stepData)
      Returns an instance of IsDataValid that indicates whether the step data is valid or not.
      void markAsCompleted​(boolean useAnimations)
      Marks the step as completed.
      boolean markAsCompletedOrUncompleted​(boolean useAnimations)
      Marks the step as completed or uncompleted depending on whether the step data is valid or not.
      void markAsUncompleted​(java.lang.String errorMessage, boolean useAnimations)
      Marks the step as uncompleted.
      protected abstract void onStepClosed​(boolean animated)
      This method will be called every time the step is closed.
      protected abstract void onStepMarkedAsCompleted​(boolean animated)
      This method will be called every time the step is marked as completed.
      protected abstract void onStepMarkedAsUncompleted​(boolean animated)
      This method will be called every time the step is marked as uncompleted.
      protected abstract void onStepOpened​(boolean animated)
      This method will be called every time the step is opened.
      protected abstract void restoreStepData​(T data)
      Restores the step data.
      protected void updateNextButtonText​(java.lang.String buttonText, boolean useAnimations)
      Sets the text of the of the step's button, updating the view if necessary,
      protected void updateSubtitle​(java.lang.String subtitle, boolean useAnimations)
      Sets the subtitle of the step, updating the view if necessary,
      protected void updateTitle​(java.lang.String title, boolean useAnimations)
      Sets the title of the step, updating the view if necessary,
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Step

        protected Step​(java.lang.String title)
      • Step

        protected Step​(java.lang.String title,
                       java.lang.String subtitle)
      • Step

        protected Step​(java.lang.String title,
                       java.lang.String subtitle,
                       java.lang.String nextButtonText)
    • Method Detail

      • getStepData

        public abstract T getStepData()
        Gets the data of this step (i.e., the information that the user has filled in for this field).
        Returns:
        The step data.
      • getStepDataAsHumanReadableString

        public abstract java.lang.String getStepDataAsHumanReadableString()
        Gets the data of this step (i.e., the information that the user has filled in for this field) as a human-readable string. When the option displayStepDataInSubtitleOfClosedSteps is activated, the text returned by this method will be the one displayed in the step's subtitle.
        Returns:
        The step data as a human-readable string.
      • restoreStepData

        protected abstract void restoreStepData​(T data)
        Restores the step data. Will be called automatically by the form view upon restoration.
        Parameters:
        data - The step data to restore.
      • isStepDataValid

        protected abstract Step.IsDataValid isStepDataValid​(T stepData)
        Returns an instance of IsDataValid that indicates whether the step data is valid or not. This instance also contains an optional error message for when the data is not valid.
        Parameters:
        stepData - The data whose validity will be checked.
        Returns:
        An instance of IsDataValid with information about the validity of the data.
      • createStepContentLayout

        protected abstract android.view.View createStepContentLayout()
        This method will be called automatically by the form in order to get the layout of the step.
        Returns:
        The step's layout.
      • onStepOpened

        protected abstract void onStepOpened​(boolean animated)
        This method will be called every time the step is opened.
        Parameters:
        animated - True if the step was opened using animations; false otherwise. Generally, it will only be false if the step was opened on loading or on restoration.
      • onStepClosed

        protected abstract void onStepClosed​(boolean animated)
        This method will be called every time the step is closed.
        Parameters:
        animated - True if the step was closed using animations; false otherwise. Generally, it will only be false if the step was closed on loading or on restoration.
      • onStepMarkedAsCompleted

        protected abstract void onStepMarkedAsCompleted​(boolean animated)
        This method will be called every time the step is marked as completed.
        Parameters:
        animated - True if the step was marked as completed using animations; false otherwise. Generally, it will only be false if the step was marked as completed on loading or on restoration.
      • onStepMarkedAsUncompleted

        protected abstract void onStepMarkedAsUncompleted​(boolean animated)
        This method will be called every time the step is marked as uncompleted.
        Parameters:
        animated - True if the step was marked as uncompleted using animations; false otherwise. Generally, it will only be false if the step was marked as uncompleted on loading or on restoration.
      • getTitle

        public java.lang.String getTitle()
        Gets the title of this step.
        Returns:
        The title.
      • getSubtitle

        public java.lang.String getSubtitle()
        Gets the subtitle of this step.
        Returns:
        The subtitle.
      • getNextButtonText

        public java.lang.String getNextButtonText()
        Gets the text for the step's button.
        Returns:
        The button text.
      • getErrorMessage

        public java.lang.String getErrorMessage()
        Gets the current error message of this step.
        Returns:
        The error message.
      • isCompleted

        public boolean isCompleted()
        Determines whether the step is marked as completed or not.
        Returns:
        True if the step is marked as completed; false otherwise.
      • isOpen

        public boolean isOpen()
        Determines whether the step is open or not.
        Returns:
        True if the step is open; false otherwise.
      • hasError

        public boolean hasError()
        Returns whether or not the step is currently considered to be in an error state because its data is invalid. Please note that even if the data is invalid, this method will only return true after the step has been opened at least once (or after its completion state has been updated manually). This way, a step with invalid data whose content hasn't been seen by the user won't appear to be in an error state until the user opens it for the first time. On this regard, it is also worth noting that this method won't update the state of the step; it will just return the value that indicates whether the step is currently in an error state.
        Returns:
        True if the step is in an error state; false otherwise.
      • getContentLayout

        public android.view.View getContentLayout()
        Gets the content layout of the step, which was generated on createStepContentLayout(), if any.
        Returns:
        The step's content layout.
      • getEntireStepLayout

        public android.view.View getEntireStepLayout()
        This method returns the entire step layout. Please note that this is not the layout of the step's content; this layout is for the entire step and includes the header, the "Next" button, etc.
        Returns:
        The entire step layout.
      • getPosition

        public int getPosition()
        Gets the position of the step within the form, counting from 0.
        Returns:
        The position of the step.
      • getFormView

        public VerticalStepperFormView getFormView()
        Gets the instance of the vertical stepper form that this step belongs to.
        Returns:
        The instance of the form.
      • getContext

        public android.content.Context getContext()
        Gets the context of the form.
        Returns:
        The context.
      • isStepDataValid

        public boolean isStepDataValid()
        Determines whether the step data (i.e., the information the user has filled up in this field) is valid or not.
        Returns:
        True if the data is valid; false otherwise.
      • markAsCompletedOrUncompleted

        public boolean markAsCompletedOrUncompleted​(boolean useAnimations)
        Marks the step as completed or uncompleted depending on whether the step data is valid or not. It should be called every time the step data changes.
        Parameters:
        useAnimations - True to animate the changes in the views, false to not.
        Returns:
        True if the step was marked as completed; false otherwise.
      • markAsCompleted

        public void markAsCompleted​(boolean useAnimations)
        Marks the step as completed.
        Parameters:
        useAnimations - True to animate the changes in the views, false to not.
      • markAsUncompleted

        public void markAsUncompleted​(java.lang.String errorMessage,
                                      boolean useAnimations)
        Marks the step as uncompleted.
        Parameters:
        errorMessage - The optional error message that explains why the step is uncompleted.
        useAnimations - True to animate the changes in the views, false to not.
      • updateTitle

        protected void updateTitle​(java.lang.String title,
                                   boolean useAnimations)
        Sets the title of the step, updating the view if necessary,
        Parameters:
        title - The new title of the step.
        useAnimations - Determines whether or not the necessary layout changes should be animated.
      • updateSubtitle

        protected void updateSubtitle​(java.lang.String subtitle,
                                      boolean useAnimations)
        Sets the subtitle of the step, updating the view if necessary,
        Parameters:
        subtitle - The new subtitle of the step.
        useAnimations - Determines whether or not the necessary layout changes should be animated.
      • updateNextButtonText

        protected void updateNextButtonText​(java.lang.String buttonText,
                                            boolean useAnimations)
        Sets the text of the of the step's button, updating the view if necessary,
        Parameters:
        buttonText - The new text for the button of the step.
        useAnimations - Determines whether or not the necessary layout changes should be animated.