Class DynamicTutorial

java.lang.Object
com.pranavpandey.android.dynamic.support.tutorial.DynamicTutorial
All Implemented Interfaces:
Parcelable, ViewPager.OnPageChangeListener, Tutorial<DynamicTutorial,DynamicTutorialFragment>, Tutorial.Motion<DynamicTutorial,DynamicTutorialFragment>

public class DynamicTutorial extends Object implements Parcelable, Tutorial.Motion<DynamicTutorial,DynamicTutorialFragment>
A Tutorial item to display a title, subtitle and description along with an image which can be tinted according to the tutorial colors.
  • Field Details

  • Constructor Details

    • DynamicTutorial

      public DynamicTutorial(int id, @ColorInt int color, @ColorInt int tintColor, @Nullable String title, @Nullable String description, @DrawableRes int imageRes)
      Constructor to initialize an object of this class.
      Parameters:
      id - The id to uniquely identify this tutorial.
      color - The color for this tutorial.
      tintColor - The tint color for this tutorial.
      title - The title for this tutorial.
      description - The description for this tutorial.
      imageRes - The image resource for this tutorial.
    • DynamicTutorial

      public DynamicTutorial(int id, @ColorInt int color, @ColorInt int tintColor, @Nullable String title, @Nullable String subtitle, @Nullable String description, @DrawableRes int imageRes)
      Constructor to initialize an object of this class.
      Parameters:
      id - The id to uniquely identify this tutorial.
      color - The color for this tutorial.
      tintColor - The tint color for this tutorial.
      title - The title for this tutorial.
      subtitle - The subtitle for this tutorial.
      description - The description for this tutorial.
      imageRes - The image resource for this tutorial.
    • DynamicTutorial

      public DynamicTutorial(int id, @ColorInt int color, @ColorInt int tintColor, @Nullable String title, @Nullable String subtitle, @Nullable String description, @DrawableRes int imageRes, boolean tintImage)
      Constructor to initialize an object of this class.
      Parameters:
      id - The id to uniquely identify this tutorial.
      color - The color for this tutorial.
      tintColor - The tint color for this tutorial.
      title - The title for this tutorial.
      subtitle - The subtitle for this tutorial.
      description - The description for this tutorial.
      imageRes - The image resource for this tutorial.
      tintImage - true to tint the image according to the tint color.
    • DynamicTutorial

      public DynamicTutorial(int id, @ColorInt int color, @ColorInt int tintColor, @Nullable String title, @Nullable String subtitle, @Nullable String description, @DrawableRes int imageRes, boolean tintImage, boolean sharedElement)
      Constructor to initialize an object of this class.
      Parameters:
      id - The id to uniquely identify this tutorial.
      color - The color for this tutorial.
      tintColor - The tint color for this tutorial.
      title - The title for this tutorial.
      subtitle - The subtitle for this tutorial.
      description - The description for this tutorial.
      imageRes - The image resource for this tutorial.
      tintImage - true to tint the image according to the tint color.
      sharedElement - true to set the shared element.
    • DynamicTutorial

      public DynamicTutorial(int id, @ColorInt int color, @ColorInt int tintColor, @Nullable String title, @Nullable String subtitle, @Nullable String description, @DrawableRes int imageRes, boolean tintImage, boolean backgroundAnimation, boolean sharedElement)
      Constructor to initialize an object of this class.
      Parameters:
      id - The id to uniquely identify this tutorial.
      color - The color for this tutorial.
      tintColor - The tint color for this tutorial.
      title - The title for this tutorial.
      subtitle - The subtitle for this tutorial.
      description - The description for this tutorial.
      imageRes - The image resource for this tutorial.
      tintImage - true to tint the image according to the tint color.
      backgroundAnimation - true to enable background animation.
      sharedElement - true to set the shared element.
    • DynamicTutorial

      public DynamicTutorial(@NonNull Parcel in)
      Read an object of this class from the parcel.
      Parameters:
      in - The parcel to read the values.
  • Method Details

    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface Parcelable
    • writeToParcel

      public void writeToParcel(Parcel dest, int flags)
      Specified by:
      writeToParcel in interface Parcelable
    • onPageScrolled

      public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
      Specified by:
      onPageScrolled in interface ViewPager.OnPageChangeListener
    • onPageSelected

      public void onPageSelected(int position)
      Specified by:
      onPageSelected in interface ViewPager.OnPageChangeListener
    • onPageScrollStateChanged

      public void onPageScrollStateChanged(int state)
      Specified by:
      onPageScrollStateChanged in interface ViewPager.OnPageChangeListener
    • getTutorialId

      public int getTutorialId()
      Description copied from interface: Tutorial
      Returns the id for this tutorial.
      Specified by:
      getTutorialId in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      The id of this tutorial.
    • getTutorial

      @NonNull public DynamicTutorial getTutorial()
      Description copied from interface: Tutorial
      Returns the tutorial object.
      Specified by:
      getTutorial in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      The tutorial object.
    • createTutorial

      @NonNull public DynamicTutorialFragment createTutorial()
      Description copied from interface: Tutorial
      Returns the tutorial view or fragment.
      Specified by:
      createTutorial in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      The tutorial view or fragment.
    • getColor

      @ColorInt public int getColor()
      Description copied from interface: Tutorial
      Returns the color used by this tutorial.
      Specified by:
      getColor in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      The color used by this tutorial.
    • getTintColor

      @ColorInt public int getTintColor()
      Description copied from interface: Tutorial
      Returns the tint color used by this tutorial.
      Specified by:
      getTintColor in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      The tint color used by this tutorial.
    • onColorChanged

      public void onColorChanged(@ColorInt int color, @ColorInt int tintColor)
      Description copied from interface: Tutorial
      This method will be called when there is a change in the colors of the activity.

      Implement this method to update any views during the transition.

      Specified by:
      onColorChanged in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Parameters:
      color - The color used by the tutorial.
      tintColor - The tint color used by this tutorial.
    • onSetPadding

      public void onSetPadding(int left, int top, int right, int bottom)
      Description copied from interface: Tutorial
      This method will be called on setting the padding of the tutorial.

      Implement this method to update any views according to the container.

      Specified by:
      onSetPadding in interface Tutorial<DynamicTutorial,DynamicTutorialFragment>
      Parameters:
      left - The left padding supplied by the container.
      top - The top padding supplied by the container.
      right - The right padding supplied by the container.
      bottom - The bottom padding supplied by the container.
    • isBackgroundAnimation

      public boolean isBackgroundAnimation()
      Description copied from interface: Tutorial.Motion
      Returns whether this tutorial supports the background animation.
      Specified by:
      isBackgroundAnimation in interface Tutorial.Motion<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      true if this tutorial supports the background animation.
    • isSharedElement

      public boolean isSharedElement()
      Description copied from interface: Tutorial.Motion
      Returns whether this tutorial supports shared element(s) transition.
      Specified by:
      isSharedElement in interface Tutorial.Motion<DynamicTutorial,DynamicTutorialFragment>
      Returns:
      true if this tutorial supports shared element(s) transition.
    • setTutorialId

      @NonNull public DynamicTutorial setTutorialId(int id)
      Set the id to uniquely identify this tutorial.
      Parameters:
      id - The id to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • setColor

      @NonNull public DynamicTutorial setColor(@ColorInt int color, @ColorInt int tintColor)
      Set the colors used by this tutorial.
      Parameters:
      color - The tutorial color to be set.
      tintColor - The tint color to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • setColor

      @NonNull public DynamicTutorial setColor(@ColorInt int color)
      Set the color used by this tutorial.
      Parameters:
      color - The color to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • getTitle

      @Nullable public String getTitle()
      Get the title used by this tutorial.
      Returns:
      The title used by this tutorial.
    • setTitle

      @NonNull public DynamicTutorial setTitle(@Nullable String title)
      Set the title used by this tutorial.
      Parameters:
      title - The subtitle to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • getSubtitle

      @Nullable public String getSubtitle()
      Get the subtitle used by this tutorial.
      Returns:
      The subtitle used by this tutorial.
    • setSubtitle

      @NonNull public DynamicTutorial setSubtitle(@Nullable String subtitle)
      Set the subtitle used by this tutorial.
      Parameters:
      subtitle - The subtitle to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • getDescription

      @Nullable public String getDescription()
      Get the description used by this tutorial.
      Returns:
      The description used by this tutorial.
    • setDescription

      @NonNull public DynamicTutorial setDescription(@Nullable String description)
      Set the description used by this tutorial.
      Parameters:
      description - The description to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • getImageRes

      @DrawableRes public int getImageRes()
      Get the image resource used by this tutorial.
      Returns:
      The image resource used by this tutorial.
    • setImageRes

      @NonNull public DynamicTutorial setImageRes(@DrawableRes int imageRes)
      Set the image resource used by this tutorial.
      Parameters:
      imageRes - The image resource to be set.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • isTintImage

      public boolean isTintImage()
      Returns whether to tint the image according to the tint color.
      Returns:
      true to tint the image according to the tint color.
    • setTintImage

      @NonNull public DynamicTutorial setTintImage(boolean tintImage)
      Set the image to be tinted or not.
      Parameters:
      tintImage - true to tint the image.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • setBackgroundAnimation

      @NonNull public DynamicTutorial setBackgroundAnimation(boolean backgroundAnimation)
      Set whether to animate the background color.
      Parameters:
      backgroundAnimation - true to animate the background color.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • setSharedElement

      @NonNull public DynamicTutorial setSharedElement(boolean sharedElement)
      Set whether to set the shared element.
      Parameters:
      sharedElement - true to set the shared element.
      Returns:
      The DynamicTutorial object to allow for chaining of calls to set methods.
    • getTutorialFragment

      @Nullable public DynamicTutorialFragment getTutorialFragment()
      Returns the fragment associated with this tutorial.
      Returns:
      The fragment associated with this tutorial.
    • setTutorialFragment

      public void setTutorialFragment(@Nullable DynamicTutorialFragment fragment)
      Set the fragment for this tutorial.
      Parameters:
      fragment - The fragment to be set.