Class DynamicTutorialActivity<V extends Fragment,T extends Tutorial<T,V>>

Type Parameters:
V - The type of the view or fragment this activity will handle.
T - The type of the tutorial this activity will handle.
All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2, SharedPreferences.OnSharedPreferenceChangeListener, KeyEvent.Callback, LayoutInflater.Factory, LayoutInflater.Factory2, View.OnCreateContextMenuListener, Window.Callback, ContextAware, FullyDrawnReporterOwner, OnBackPressedDispatcherOwner, ActivityResultCaller, ActivityResultRegistryOwner, ActionBarDrawerToggle.DelegateProvider, AppCompatCallback, ActivityCompat.OnRequestPermissionsResultCallback, ActivityCompat.RequestPermissionsRequestCodeValidator, OnMultiWindowModeChangedProvider, OnNewIntentProvider, OnPictureInPictureModeChangedProvider, TaskStackBuilder.SupportParentable, OnConfigurationChangedProvider, OnTrimMemoryProvider, KeyEventDispatcher.Component, MenuHost, HasDefaultViewModelProviderFactory, LifecycleOwner, ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner, DynamicLocale, DynamicListener, DynamicSnackbar, DynamicTransitionListener, DynamicProductFlavor

public abstract class DynamicTutorialActivity<V extends Fragment,T extends Tutorial<T,V>> extends DynamicSystemActivity implements DynamicTransitionListener, DynamicSnackbar
Base activity with a view pager to show the supplied tutorials.

Extend this activity and supply tutorials or dataSet by using the provided methods.

  • Field Details

    • mTutorialsRunnable

      protected final Runnable mTutorialsRunnable
      Runnable to set the tutorials.
    • mAdapterRunnable

      protected final Runnable mAdapterRunnable
      Runnable to update the tutorials adapter.
    • mFooterRunnable

      protected final Runnable mFooterRunnable
      Runnable to animate the footer.

      Animation fix for lower API levels.

  • Constructor Details

    • DynamicTutorialActivity

      public DynamicTutorialActivity()
  • Method Details

    • onCreate

      protected void onCreate(@Nullable Bundle savedInstanceState)
      Overrides:
      onCreate in class DynamicSystemActivity
    • onManageSharedElementTransition

      protected void onManageSharedElementTransition()
      Description copied from class: DynamicSystemActivity
      Setup the shared element transition callbacks to manage it's position on configuration change.
      Overrides:
      onManageSharedElementTransition in class DynamicSystemActivity
    • onAdjustElevation

      protected void onAdjustElevation()
      Description copied from class: DynamicSystemActivity
      This method will be called to adjust elevation of the components like app bar, bottom app bar, etc.
      Overrides:
      onAdjustElevation in class DynamicSystemActivity
    • getLayoutRes

      @LayoutRes protected int getLayoutRes()
      Returns the layout resource for this activity.
      Returns:
      The layout resource for this activity.
    • getContentView

      @Nullable public View getContentView()
      Description copied from class: DynamicSystemActivity
      Returns the parent content view used by this activity.
      Specified by:
      getContentView in class DynamicSystemActivity
      Returns:
      The parent content view used by this activity.
    • getPostponeTransitionView

      @Nullable public View getPostponeTransitionView()
      Description copied from interface: DynamicTransitionListener
      This method will be called to postpone the transition until the returned view is laid.

      It will be called only on API 21 and above.

      Specified by:
      getPostponeTransitionView in interface DynamicTransitionListener
      Overrides:
      getPostponeTransitionView in class DynamicSystemActivity
      Returns:
      The view to postpone the transition.
    • getBackgroundColor

      @ColorInt public int getBackgroundColor()
      Description copied from class: DynamicSystemActivity
      Returns the default background color for this activity.
      Overrides:
      getBackgroundColor in class DynamicSystemActivity
      Returns:
      The default background color for this activity.
    • getTintColor

      @ColorInt public int getTintColor()
      Returns the tint color used by this activity.
      Returns:
      The tint color used by this activity.
    • setStatusBarColor

      public void setStatusBarColor(@ColorInt int color)
      Description copied from class: DynamicSystemActivity
      Set the status bar color.

      It will be applied only on the API 21 and above.

      Overrides:
      setStatusBarColor in class DynamicSystemActivity
      Parameters:
      color - The color to be applied.
    • getEdgeToEdgeView

      @Nullable public View getEdgeToEdgeView()
      Description copied from class: DynamicSystemActivity
      Returns the view to apply edge-to-edge window insets.
      Overrides:
      getEdgeToEdgeView in class DynamicSystemActivity
      Returns:
      The view to apply edge-to-edge window insets.
      See Also:
    • isApplyEdgeToEdgeInsets

      public boolean isApplyEdgeToEdgeInsets()
      Description copied from class: DynamicSystemActivity
      Returns whether to apply edge-to-edge window insets.
      Overrides:
      isApplyEdgeToEdgeInsets in class DynamicSystemActivity
      Returns:
      true to apply edge-to-edge window insets.
      See Also:
    • getCoordinatorLayout

      @Nullable public CoordinatorLayout getCoordinatorLayout()
      Description copied from class: DynamicSystemActivity
      Returns the coordinator layout used by this activity.
      Overrides:
      getCoordinatorLayout in class DynamicSystemActivity
      Returns:
      The coordinator layout used by this activity.
    • onResume

      public void onResume()
      Overrides:
      onResume in class DynamicSystemActivity
    • onPause

      public void onPause()
      Overrides:
      onPause in class DynamicSystemActivity
    • getTutorials

      @NonNull protected List<Tutorial<T,V>> getTutorials()
      Returns the list of Tutorial to be shown by this activity.
      Returns:
      The list of Tutorial to be shown by this activity.
    • getViewPagerAdapter

      @Nullable public DynamicTutorialsAdapter<V,T> getViewPagerAdapter()
      Get the view pager adapter used by this activity.
      Returns:
      The view pager adapter used by this activity.
    • getTutorialsCount

      public int getTutorialsCount()
      Returns the no. of tutorials handled by this activity.
      Returns:
      The no. of tutorials handled by this activity.
    • getDefaultPosition

      protected int getDefaultPosition()
      Returns the default position for the tutorials.
      Returns:
      The default position for the tutorials.
    • getTutorial

      @Nullable public Tutorial<T,V> getTutorial(int position)
      Returns the Tutorial for the supplied position.
      Parameters:
      position - The position to get the tutorial.
      Returns:
      The Tutorial for the supplied position.
    • getDynamicWindowResolver

      @Nullable public DynamicWindowResolver getDynamicWindowResolver()
      Returns the listener to resolve the status and navigation bar color.
      Returns:
      The listener to resolve the status and navigation bar color.
    • setDynamicWindowResolver

      public void setDynamicWindowResolver(@Nullable DynamicWindowResolver dynamicWindowResolver)
      Set resolver to resolve the status and navigation bar.
      Parameters:
      dynamicWindowResolver - The resolver to be set
    • setTutorials

      protected void setTutorials(int page, boolean smoothScroll, boolean reload)
      Set view pager adapter according to the tutorials list.
      Parameters:
      page - The current page to be set.
      smoothScroll - true to smoothly scroll the page.
      reload - true to reload the tutorials state.
    • setTutorials

      protected void setTutorials(int page, boolean smoothScroll)
      Set view pager adapter according to the tutorials list.
      Parameters:
      page - The current page to be set.
      smoothScroll - true to smoothly scroll the page.
      See Also:
    • setTutorials

      protected void setTutorials(boolean smoothScroll)
      Set view pager adapter according to the tutorials list.
      Parameters:
      smoothScroll - true to smoothly scroll the page.
    • setTutorial

      protected void setTutorial(int page, boolean smoothScroll)
      Set the current position for the tutorial list.
      Parameters:
      page - The current page to be set.
      smoothScroll - true to smoothly scroll the page.
    • setTutorial

      protected void setTutorial(int page)
      Set the current position for the tutorial list.
      Parameters:
      page - The current page to be set.
    • onSetColor

      protected void onSetColor(int position, @ColorInt int color, @ColorInt int tintColor)
      Update activity background and system UI according to the supplied color.
      Parameters:
      position - The current position of the tutorial.
      color - The background color to be applied.
      tintColor - The tint color to be applied.
    • onSetTooltip

      protected void onSetTooltip(int position, @ColorInt int color, @ColorInt int tintColor)
      This method will be called to set the tooltip for the tutorial actions.
      Parameters:
      position - The current position of the tutorial.
      color - The background color to be applied.
      tintColor - The tint color to be applied.
    • onUpdate

      protected void onUpdate(int position)
      This method will be called to update the activity according to the tutorial position.
      Parameters:
      position - The current tutorial position.
    • onAnimate

      protected void onAnimate(int position, boolean cancel)
      This method will be called to animate the tutorial background.
      Parameters:
      position - The current tutorial position.
      cancel - true to cancel the animation.
    • setFooter

      public void setFooter(boolean animate)
      Set the tutorial footer and make it visible.
      Parameters:
      animate - true to animate the footer.
    • isTutorialSharedElementTransition

      public boolean isTutorialSharedElementTransition()
      Checks whether the shared element transition is enable for the current tutorial.
      Returns:
      true if the shared element transition is enable for the current tutorial.
    • postFooter

      public void postFooter()
      Post footer animation on main thread.
    • getCurrentPosition

      public int getCurrentPosition()
      Returns the current position of the view pager.
      Returns:
      The current position of the view pager.
    • hasTutorialPrevious

      public boolean hasTutorialPrevious()
      Checks whether the view pager can be moved to the previous tutorial or item.
      Returns:
      true if view pager can be moved to the previous tutorial or item.
    • hasTutorialNext

      public boolean hasTutorialNext()
      Checks whether the view pager can be moved to the next tutorial or item.
      Returns:
      true if view pager can be moved to the next tutorial or item.
    • onTutorialPrevious

      public void onTutorialPrevious(@Nullable View view)
      This method will be called to go to the previous tutorial.
      Parameters:
      view - The optional view triggering the action.
    • onTutorialNext

      public void onTutorialNext(@Nullable View view)
      This method will be called to go to the next tutorial.
      Parameters:
      view - The optional view triggering the action.
    • setAction

      public void setAction(@Nullable CharSequence text, @Nullable View.OnClickListener onClickListener)
      Set an action for the custom action button.
      Parameters:
      text - The text for the action button.
      onClickListener - The on click listener for the action button.
    • getViewPager

      @NonNull public ViewPager2 getViewPager()
      Get the view pager used by this activity.
      Returns:
      The view pager used by this activity.
    • getActionPrevious

      @Nullable public ImageButton getActionPrevious()
      Get the previous action button used by this activity.
      Returns:
      The previous action button used by this activity.
    • getActionNext

      @Nullable public ImageButton getActionNext()
      Get the next action button used by this activity.
      Returns:
      The next action button used by this activity.
    • isBackgroundAnimation

      public boolean isBackgroundAnimation(int position)
      Returns whether the background animation is enabled for the supplied tutorial position.
      Parameters:
      position - The tutorial position to be used.
      Returns:
      true if the background animation is enabled for the supplied tutorial position.
    • isSharedElement

      public boolean isSharedElement(int position)
      Returns whether the shared element is enabled for the supplied tutorial position.
      Parameters:
      position - The tutorial position to be used.
      Returns:
      true if the shared element is enabled for the supplied tutorial position.
    • setKeepScreenOn

      public void setKeepScreenOn(boolean keepScreenOn)
      Sets whether ot keep the screen on.
      Parameters:
      keepScreenOn - true to keep the screen on.
      See Also:
    • onDynamicChanged

      public void onDynamicChanged(boolean context, boolean recreate)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic change event occurs (like theme, locale, etc.).

      Recreate the activity or application here to adapt changes.

      Specified by:
      onDynamicChanged in interface DynamicListener
      Overrides:
      onDynamicChanged in class DynamicSystemActivity
      Parameters:
      context - true if there is a context change and it must be reinitialized.
      recreate - true if listener must be recreated to adapt the changes.
    • finishActivity

      public void finishActivity()
      Description copied from class: DynamicSystemActivity
      Finish the activity properly after checking the shared element transition.
      Overrides:
      finishActivity in class DynamicSystemActivity
    • getSnackbar

      @Nullable public Snackbar getSnackbar(@NonNull CharSequence text, int duration)
      Description copied from interface: DynamicSnackbar
      Make a themed snackbar with text and action.

      The background of the snackbar will be the tint background color to blend it smoothly and it will automatically use its tint color for the text and action to provide best visibility.

      Specified by:
      getSnackbar in interface DynamicSnackbar
      Parameters:
      text - The text to show. Can be formatted text.
      duration - The duration of the snackbar.

      BaseTransientBottomBar.LENGTH_SHORT, BaseTransientBottomBar.LENGTH_LONG or BaseTransientBottomBar.LENGTH_INDEFINITE.

      Returns:
      The snackbar with the supplied parameters.

      Use Snackbar.show() to display the snackbar.

    • getSnackbar

      @Nullable public Snackbar getSnackbar(@StringRes int stringRes, int duration)
      Description copied from interface: DynamicSnackbar
      Make a themed snackbar with text and action.

      The background of the snackbar will be the tint background color to blend it smoothly and it will automatically use its tint color for the text and action to provide best visibility.

      Specified by:
      getSnackbar in interface DynamicSnackbar
      Parameters:
      stringRes - The string resource for the snackbar.
      duration - The duration of the snackbar.

      BaseTransientBottomBar.LENGTH_SHORT, BaseTransientBottomBar.LENGTH_LONG or BaseTransientBottomBar.LENGTH_INDEFINITE.

      Returns:
      The snackbar with the supplied parameters.

      Use Snackbar.show() to display the snackbar.

    • getSnackbar

      @Nullable public Snackbar getSnackbar(@NonNull CharSequence text)
      Description copied from interface: DynamicSnackbar
      Make a themed snackbar with text and action.

      The background of the snackbar will be the tint background color to blend it smoothly and it will automatically use its tint color for the text and action to provide best visibility.

      Specified by:
      getSnackbar in interface DynamicSnackbar
      Parameters:
      text - The text to show. Can be formatted text.
      Returns:
      The snackbar with the supplied parameters.

      Use Snackbar.show() to display the snackbar.

    • getSnackbar

      @Nullable public Snackbar getSnackbar(@StringRes int stringRes)
      Description copied from interface: DynamicSnackbar
      Make a themed snackbar with text and action.

      The background of the snackbar will be the tint background color to blend it smoothly and it will automatically use its tint color for the text and action to provide best visibility.

      Specified by:
      getSnackbar in interface DynamicSnackbar
      Parameters:
      stringRes - The string resource for the snackbar.
      Returns:
      The snackbar with the supplied parameters.

      Use Snackbar.show() to display the snackbar.

    • onSnackbarShow

      public void onSnackbarShow(@Nullable Snackbar snackbar)
      Description copied from interface: DynamicSnackbar
      This method will be called to show the snackbar.
      Specified by:
      onSnackbarShow in interface DynamicSnackbar
      Parameters:
      snackbar - The snackbar to be shown.
    • onSetPadding

      protected <T, V> void onSetPadding(@Nullable Tutorial<T,V> tutorial, int left, int top, int right, int bottom)
      Type Parameters:
      T - The type of the tutorial.
      V - The type of the tutorial fragment.
      Parameters:
      tutorial - The dynamic tutorial to be used.
      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.