Class DynamicActivity

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, DynamicSearchListener, DynamicSnackbar, DynamicTransitionListener, DynamicProductFlavor
Direct Known Subclasses:
DynamicDrawerActivity, DynamicNavigationActivity, DynamicPermissionsActivity, DynamicPreviewActivity, DynamicWidgetActivity

public abstract class DynamicActivity extends DynamicStateActivity implements DynamicSearchListener, DynamicSnackbar
A DynamicStateActivity to handle everything related to design support and the app compat libraries. It has a fragment container to add fragments dynamically with many other useful methods to provide a good looking Material Design UI.

If NavigationMenu is required then, please check DynamicDrawerActivity.

  • Field Details

  • Constructor Details

    • DynamicActivity

      public DynamicActivity()
  • Method Details

    • onCreate

      protected void onCreate(@Nullable Bundle savedInstanceState)
      Overrides:
      onCreate in class DynamicStateActivity
    • onConfigureOnBackPressedDispatcher

      protected void onConfigureOnBackPressedDispatcher()
      Description copied from class: DynamicSystemActivity
      This method will be called to configure on back pressed callback to support API 33 and above.
      Overrides:
      onConfigureOnBackPressedDispatcher 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
    • setWindowBackground

      public void setWindowBackground(@ColorInt int color)
      Description copied from class: DynamicSystemActivity
      Sets the window background color.
      Overrides:
      setWindowBackground in class DynamicSystemActivity
      Parameters:
      color - The window background color to be set.
      See Also:
    • onApplyTransitions

      public void onApplyTransitions(boolean exit)
      Description copied from interface: DynamicTransitionListener
      This method will be called on applying transitions.

      It is recommended to do any shared element adjustments here like postponing the transition.

      Specified by:
      onApplyTransitions in interface DynamicTransitionListener
      Overrides:
      onApplyTransitions in class DynamicSystemActivity
      Parameters:
      exit - true if the activity is exiting.
    • 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:
    • getDefaultNavigationIcon

      @Nullable protected Drawable getDefaultNavigationIcon()
      Returns the default navigation icon for this activity.
      Returns:
      The default navigation icon for this activity.
    • 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.
    • isDrawerActivity

      protected boolean isDrawerActivity()
      Checks whether the navigation drawer is added.
      Returns:
      true if this activity is a drawer activity.
    • onSaveInstanceState

      public void onSaveInstanceState(@NonNull Bundle outState)
      Overrides:
      onSaveInstanceState in class DynamicStateActivity
    • onCreateOptionsMenu

      public boolean onCreateOptionsMenu(@NonNull Menu menu)
      Overrides:
      onCreateOptionsMenu in class Activity
    • onActionModeStarted

      public void onActionModeStarted(@NonNull ActionMode mode)
      Specified by:
      onActionModeStarted in interface Window.Callback
      Overrides:
      onActionModeStarted in class Activity
    • setTitle

      public void setTitle(@Nullable CharSequence title)
      Overrides:
      setTitle in class Activity
    • setTitle

      public void setTitle(@StringRes int titleRes)
      Overrides:
      setTitle in class Activity
    • getSubtitle

      @Nullable public CharSequence getSubtitle()
      Get the subtitle used by the support action bar.
      Returns:
      The subtitle used by the support action bar.
    • setSubtitle

      public void setSubtitle(@Nullable CharSequence subtitle)
      Set the subtitle for the support action bar.
      Parameters:
      subtitle - The subtitle to be set.
    • setSubtitle

      public void setSubtitle(@StringRes int subtitleRes)
      Set the subtitle resource for the support action bar.
      Parameters:
      subtitleRes - The subtitle resource to be set.
    • getFragmentContainerId

      @IdRes protected int getFragmentContainerId()
      Description copied from class: DynamicStateActivity
      Retrieves the fragment container id.

      This method must be implemented in the extended activity to show fragments inside this container.

      Specified by:
      getFragmentContainerId in class DynamicStateActivity
      Returns:
      The fragment container id so that the fragment can be injected into this view.
    • setCollapsingToolbarLayout

      protected boolean setCollapsingToolbarLayout()
      Returns:
      true to enable the collapsing toolbar layout.
    • getLayoutRes

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

      protected int getContentRes()
      Returns the custom content resource if no fragment is required.

      It will automatically add this layout in the mFrameContent.

      Returns:
      The custom content resource if no fragment is required.
    • 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.
    • setNavigationIcon

      public void setNavigationIcon(@Nullable Drawable icon)
      Set the icon for the back or up button in the app bar.
      Parameters:
      icon - The drawable to be used for the back or up button.
    • setNavigationIcon

      public void setNavigationIcon(@DrawableRes int iconRes)
      Set the icon for the back or up button in the app bar.
      Parameters:
      iconRes - The drawable resource to be used for the back or up button.
    • setNavigationClickListener

      public void setNavigationClickListener(@Nullable Drawable icon, @Nullable View.OnClickListener onClickListener)
      Set the icon and on click listener for the back or up button in the app bar.
      Parameters:
      icon - The drawable used for the back or up button.
      onClickListener - The click listener for the back or up button.
    • setNavigationClickListener

      public void setNavigationClickListener(@DrawableRes int iconRes, @Nullable View.OnClickListener onClickListener)
      Set the icon and on click listener for the back or up button in the app bar.
      Parameters:
      iconRes - The drawable resource used for the back or up button.
      onClickListener - The click listener for the back or up button.
    • setNavigationClickListener

      public void setNavigationClickListener(@Nullable View.OnClickListener onClickListener)
      Sets the on click listener for the back or up button in the app bar.

      If no listener is supplied then, it will automatically hide the button.

      Parameters:
      onClickListener - The click listener for the back or up button.
    • getToolbar

      @Nullable public Toolbar getToolbar()
      Returns the app toolbar used by this activity.
      Returns:
      The app toolbar used by this activity.
    • isAppBarVisible

      public boolean isAppBarVisible()
      Returns whether the app bar is visible.
      Returns:
      true if the app bar is visible. It will be used internally to maintain the app bar state.
    • getCollapsingToolbarLayout

      public CollapsingToolbarLayout getCollapsingToolbarLayout()
      Returns the collapsing toolbar layout used by this activity.
      Returns:
      The collapsing toolbar layout used by this activity.
    • setCollapsingToolbarLayoutFlags

      public void setCollapsingToolbarLayoutFlags(int flags)
      Set layout scroll flags for the collapsing toolbar layout.

      Useful to change the collapse mode dynamically.

      Parameters:
      flags - The scroll flags to be set.
    • setToolbarLayoutFlags

      public void setToolbarLayoutFlags(int flagsOrMode)
      Set layout scroll flags or collapse mode for the toolbar.

      Useful to change the collapse mode dynamically.

      Parameters:
      flagsOrMode - The scroll flags or collapse mode to be set.
    • setAppBarVisible

      public void setAppBarVisible(boolean appBarVisible)
      Set the toolbar or collapsing toolbar layout visibility (collectively known as app bar) if available.
      Parameters:
      appBarVisible - true to make the app bar visible.
    • setAppBarBackDrop

      public void setAppBarBackDrop(@Nullable View view, @ColorInt int expandedTitleColor)
      Add a backdrop view for the collapsing toolbar layout which will be shown when it is expanded and will be hidden on collapsing the toolbar.
      Parameters:
      view - The view to be added as the backdrop frame.
      expandedTitleColor - The title color when the toolbar is expanded.
    • setAppBarBackDropRes

      public void setAppBarBackDropRes(@LayoutRes int layoutRes, @ColorRes int expandedTitleColorRes)
      Add a backdrop view for the collapsing toolbar layout which will be shown when it is expanded and will be hidden on collapsing the toolbar.
      Parameters:
      layoutRes - The layout resource to be added as the backdrop frame.
      expandedTitleColorRes - The title color resource when the toolbar is expanded.
    • setAppBarBackDrop

      public void setAppBarBackDrop(@Nullable Drawable drawable)
      Set the drawable for backdrop image used by the collapsing toolbar layout which will be shown when it is expanded and will be hidden on collapsing the toolbar.
      Parameters:
      drawable - The drawable for the backdrop image.
    • setAppBarBackDrop

      public void setAppBarBackDrop(@DrawableRes int drawableRes)
      Set the drawable id for backdrop image used by the collapsing toolbar layout which will be shown when it is expanded and will be hidden on collapsing the toolbar.
      Parameters:
      drawableRes - The drawable resource for the backdrop image.
    • setAppBarTransparent

      public void setAppBarTransparent(boolean transparent)
      Make the app bar transparent or translucent.

      Useful to make it transparent if a backdrop view has been added.

      Parameters:
      transparent - true to make the app bar transparent.
    • setAppBarShadowVisible

      public void setAppBarShadowVisible(boolean visible)
      Set the visibility of app bar shadow.
      Parameters:
      visible - true to show the content shadow below the app bar.
    • addView

      public void addView(@Nullable ViewGroup viewGroup, @Nullable View view, boolean removePrevious)
      Add a view to the view group.
      Parameters:
      viewGroup - The view group to add the view.
      view - The view to be added.
      removePrevious - true to remove all the previous views of the view group.
    • getFrameContent

      @Nullable public ViewGroup getFrameContent()
      Get the main content frame used by this activity.
      Returns:
      The main content frame used by this activity.
    • getFrameHeader

      @Nullable public ViewSwitcher getFrameHeader()
      Get the header frame just below the app toolbar to add custom views like tabs, hints, etc.

      Use the methods addHeader(View, boolean, boolean) or addView(ViewGroup, View, boolean) to add the views.

      Returns:
      The header frame just below the app toolbar to add custom views like tabs, hints, etc.
    • addHeader

      public void addHeader(@Nullable View view, boolean removePrevious, boolean animate)
      Add header view just below the app bar.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      view - The view to be added in the header frame.
      removePrevious - true to remove the previously added views.
      animate - true to animate the changes.
    • addHeader

      public void addHeader(@Nullable View view, boolean removePrevious)
      Add header view just below the app bar.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      view - The view to be added in the header frame.
      removePrevious - true to remove the previously added views.
    • addHeader

      public void addHeader(@LayoutRes int layoutRes, boolean removePrevious, boolean animate)
      Add header view just below the app bar.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      layoutRes - The layout resource to be added in the header frame.
      removePrevious - true to remove the previously added views.
      animate - true to animate the changes.
    • addHeader

      public void addHeader(@LayoutRes int layoutRes, boolean removePrevious)
      Add header view just below the app bar.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      layoutRes - The layout resource to be added in the header frame.
      removePrevious - true to remove the previously added views.
    • onAddHeader

      public void onAddHeader(@Nullable View view)
      This method will be called after adding the header.
      Parameters:
      view - The view added to the header.
    • setAppBarProgressVisible

      public void setAppBarProgressVisible(boolean visible)
      Set the visibility of app bar progress.
      Parameters:
      visible - true to show the progress bar below the app bar.
    • setNavigationShadowVisible

      public void setNavigationShadowVisible(boolean visible)
      Set the visibility of navigation bar shadow.
      Parameters:
      visible - true to show the content shadow adjacent to the navigation.
    • setBottomBarShadowVisible

      public void setBottomBarShadowVisible(boolean visible)
      Set the visibility of bottom bar shadow.
      Parameters:
      visible - true to show the content shadow above the bottom bar.
    • getBottomSheet

      @Nullable public DynamicBottomSheet getBottomSheet()
      Get the bottom sheet frame layout.

      Use the methods addBottomSheet(int, boolean) or addBottomSheet(View, boolean) to add the views.

      Returns:
      The bottom sheet frame layout.
    • addBottomSheet

      public void addBottomSheet(@Nullable View view, boolean removePrevious)
      Add view in the bottom sheet frame layout.
      Parameters:
      view - The view to be added in the bottom sheet.
      removePrevious - true to remove the previously added views.
    • addBottomSheet

      public void addBottomSheet(@LayoutRes int layoutRes, boolean removePrevious)
      Add view in the bottom sheet frame layout.
      Parameters:
      layoutRes - The layout resource to be added in the bottom sheet.
      removePrevious - true to remove the previously added views.
    • getBottomSheetBehavior

      @Nullable public BottomSheetBehavior<?> getBottomSheetBehavior()
      Returns the current bottom sheet behavior.
      Returns:
      The bottom sheet behavior.
    • getBottomSheetState

      public int getBottomSheetState()
      Returns the bottom sheet state if present.
      Returns:
      The bottom sheet state if present. Otherwise, BottomSheetBehavior.STATE_HIDDEN.
    • setBottomSheetState

      public void setBottomSheetState(int bottomSheetState)
      Sets the bottom sheet state if present.
      Parameters:
      bottomSheetState - The state to be set.
    • isExpandBottomSheetOnExit

      protected boolean isExpandBottomSheetOnExit()
      Returns whether to expand bottom sheet on exit.
      Returns:
      true to expand bottom sheet on exit.
    • getFrameFooter

      @Nullable public ViewGroup getFrameFooter()
      Get the footer frame at the bottom of the screen to add custom views like bottom navigation bar, ads, etc.

      Use the methods addFooter(int, boolean) or addFooter(View, boolean) to add the views.

      Returns:
      The footer frame at the bottom of the screen to add custom views like bottom navigation bar, ads, etc.
    • addFooter

      public void addFooter(@Nullable View view, boolean removePrevious)
      Add footer view at the bottom of the screen.

      Useful to add bottom navigation bar, ads, etc. dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color).

      Parameters:
      view - The view to be added in the footer frame.
      removePrevious - true to remove the previously added views.
    • addFooter

      public void addFooter(@LayoutRes int layoutRes, boolean removePrevious)
      Add footer view at the bottom of the screen.

      Useful to add bottom navigation bar, ads, etc. dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color).

      Parameters:
      layoutRes - The layout resource to be added in the header frame.
      removePrevious - true to remove the previously added views.
    • getMenu

      @Nullable public Menu getMenu()
      Returns the menu used by this activity.
      Returns:
      The menu used by this activity.
    • setMenuItemTitle

      public void setMenuItemTitle(@IdRes int id, @Nullable CharSequence title)
      Set the title for the app bar menu item by supplying its id.
      Parameters:
      id - The id to find the menu item.
      title - The title to be set.
    • setMenuItemTitle

      public void setMenuItemTitle(@IdRes int id, @StringRes int titleRes)
      Set the title for the app bar menu item by supplying its id.
      Parameters:
      id - The id to find the menu item.
      titleRes - The title resource to be set.
      See Also:
    • setMenuItemIcon

      public void setMenuItemIcon(@IdRes int id, @Nullable Drawable drawable)
      Set the icon for the app bar menu item by supplying its id.
      Parameters:
      id - The id to find the menu item.
      drawable - The icon drawable to be set.
    • setMenuItemIcon

      public void setMenuItemIcon(@IdRes int id, @DrawableRes int drawableRes)
      Set the icon for the app bar menu item by supplying its id.
      Parameters:
      id - The id to find the menu item.
      drawableRes - The icon resource to be set.
      See Also:
    • setMenuItemVisible

      public void setMenuItemVisible(@IdRes int id, boolean visible)
      Set the visibility of the app bar menu item by supplying its id.
      Parameters:
      id - The id to find the menu item.
      visible - true to make the menu item visible.
    • setSearchView

      protected void setSearchView()
      Setup search view edit text and clear button listeners.
    • restoreSearchViewState

      public void restoreSearchViewState()
      Restore the search view state after the configuration change.
    • expandSearchView

      public void expandSearchView(boolean requestSoftInput)
      Expand search view to start searching.
      Parameters:
      requestSoftInput - true to request the soft input keyboard.
    • collapseSearchView

      public void collapseSearchView()
      Collapse search view to stop searching.
    • getSearchViewRoot

      @Nullable public ViewGroup getSearchViewRoot()
      Returns the root view for the toolbar edit text used by this activity.
      Returns:
      The the root view for the toolbar edit text used by this activity.
    • getSearchViewEditText

      @Nullable public EditText getSearchViewEditText()
      Returns the toolbar edit text used by this activity.
      Returns:
      The toolbar edit text used by this activity.
    • getSearchViewClear

      @Nullable public ImageView getSearchViewClear()
      Returns the clear button for the toolbar edit text used by this activity.
      Returns:
      The clear button for the toolbar edit text used by this activity.
    • isSearchViewExpanded

      public boolean isSearchViewExpanded()
      Checks whether the search view is expanded.
      Returns:
      true if search view is expanded.
    • getSearchViewListener

      @Nullable public DynamicSearchListener getSearchViewListener()
      Returns the listener to listen search view expand and collapse callbacks.
      Returns:
      The listener to listen search view expand and collapse callbacks.
    • setSearchViewListener

      public void setSearchViewListener(@Nullable DynamicSearchListener dynamicSearchListener)
      Sets the listener to listen search view expand and collapse callbacks.
      Parameters:
      dynamicSearchListener - The listener to be set.
    • onSearchViewExpanded

      public void onSearchViewExpanded()
      Description copied from interface: DynamicSearchListener
      This method will be called when the search view is expanded.
      Specified by:
      onSearchViewExpanded in interface DynamicSearchListener
    • onSearchViewCollapsed

      public void onSearchViewCollapsed()
      Description copied from interface: DynamicSearchListener
      This method will be called when the search view is collapsed.
      Specified by:
      onSearchViewCollapsed in interface DynamicSearchListener
    • getTextWatcher

      @Nullable public TextWatcher getTextWatcher()
      Description copied from interface: DynamicSearchListener
      This method will be called to get the text watcher for the search view.
      Specified by:
      getTextWatcher in interface DynamicSearchListener
      Returns:
      The text watcher for the search view.
    • onBackPressed

      public void onBackPressed()
      Overrides:
      onBackPressed in class DynamicSystemActivity
    • getFAB

      Get the floating action button used by this activity.
      Returns:
      The floating action button used by this activity.
    • setFAB

      public void setFAB(@Nullable Drawable drawable, int visibility, @Nullable View.OnClickListener onClickListener)
      Set a floating action button (FAB) used by this activity by supplying an image drawable, current visibility and a click listener.

      The FAB will be tinted automatically according to the accent color used by this activity.

      Please use getFAB() method to perform more operations dynamically.

      Parameters:
      drawable - The image drawable to be set.
      visibility - The visibility to be set.

      View.VISIBLE, View.INVISIBLE or View.GONE.

      onClickListener - Callback that will run when this view is clicked.
    • setFAB

      public void setFAB(@DrawableRes int drawableRes, int visibility, @Nullable View.OnClickListener onClickListener)
      Set a floating action button (FAB) used by this activity by supplying an image drawable, current visibility and a click listener.

      The FAB will be tinted automatically according to the accent color used by this activity.

      Please use getFAB() method to perform more operations dynamically.

      Parameters:
      drawableRes - The image drawable resource to be set.
      visibility - The visibility to be set.

      View.VISIBLE, View.INVISIBLE or View.GONE.

      onClickListener - Callback that will run when this view is clicked.
    • setFABImageDrawable

      public void setFABImageDrawable(@Nullable Drawable drawable)
      Set the FAB image drawable resource.

      Image will be tinted automatically according to its background color to provide best visibility.

      Parameters:
      drawable - The image drawable for the floating action button.
    • setFABImageDrawable

      public void setFABImageDrawable(@DrawableRes int drawableRes)
      Set the FAB image drawable resource.

      Image will be tinted automatically according to its background color to provide best visibility.

      Parameters:
      drawableRes - The image drawable resource for the floating action button.
    • setFABVisibility

      public void setFABVisibility(int visibility)
      Set the FAB visibility to View.VISIBLE, View.INVISIBLE or View.GONE.
      Overrides:
      setFABVisibility in class DynamicStateActivity
      Parameters:
      visibility - The FAB visibility to be set.
    • showFAB

      public void showFAB()
      Show the FAB by setting its visibility to View.VISIBLE.
    • hideFAB

      public void hideFAB()
      Hide the FAB by setting its visibility to View.GONE.
    • removeFAB

      public void removeFAB()
      Remove the FAB associated with this activity.

      Please call the methods setFAB(int, int, View.OnClickListener) or setFAB(Drawable, int, View.OnClickListener) to set it again.

    • getExtendedFAB

      @Nullable public ExtendedFloatingActionButton getExtendedFAB()
      Get the extended floating action button used by this activity.
      Returns:
      The extended floating action button used by this activity.
    • setExtendedFAB

      public void setExtendedFAB(@Nullable Drawable icon, @Nullable CharSequence text, int visibility, @Nullable View.OnClickListener onClickListener)
      Set an extended floating action button (FAB) used by this activity by supplying an icon, a text, current visibility and a click listener.

      The FAB will be tinted automatically according to the accent color used by this activity.

      Please use getExtendedFAB() method to perform more operations dynamically.

      Parameters:
      icon - The icon drawable to be set.
      text - The text to be set.
      visibility - The visibility to be set.

      View.VISIBLE, View.INVISIBLE or View.GONE.

      onClickListener - Callback that will run when this view is clicked.
    • setExtendedFAB

      public void setExtendedFAB(@DrawableRes int drawableRes, @StringRes int resId, int visibility, @Nullable View.OnClickListener onClickListener)
      Set an extended floating action button (FAB) used by this activity by supplying an icon, a text, current visibility and a click listener.

      The FAB will be tinted automatically according to the accent color used by this activity.

      Please use getExtendedFAB() method to perform more operations dynamically.

      Parameters:
      drawableRes - The icon drawable resource to be set.
      resId - The string resource id to be set.
      visibility - The visibility to be set.

      View.VISIBLE, View.INVISIBLE or View.GONE.

      onClickListener - Callback that will run when this view is clicked.
    • updateExtendedFAB

      public void updateExtendedFAB(@Nullable Drawable icon, @Nullable CharSequence text)
      Set the extended FAB icon and text.

      Icon and text will be tinted automatically according to its background color to provide best visibility.

      Parameters:
      icon - The icon drawable to be set.
      text - The text to be set.
    • updateExtendedFAB

      public void updateExtendedFAB(@DrawableRes int drawableRes, @StringRes int resId)
      Set the extended FAB icon and text.

      Icon and text will be tinted automatically according to its background color to provide best visibility.

      Parameters:
      drawableRes - The icon drawable resource to be set.
      resId - The string resource id to be set.
    • setExtendedFABVisibility

      public void setExtendedFABVisibility(int visibility)
      Set the extended FAB visibility to View.VISIBLE, View.INVISIBLE or View.GONE.
      Overrides:
      setExtendedFABVisibility in class DynamicStateActivity
      Parameters:
      visibility - The extended FAB visibility to be set.
    • shrinkFAB

      public void shrinkFAB()
      Shrink the extended FAB.
    • shrinkFAB

      public void shrinkFAB(boolean allowExtended)
      Shrink the extended FAB.
      Parameters:
      allowExtended - true if the FAB can be extended.
    • extendFAB

      public void extendFAB()
      Extend the extended FAB.
    • extendFAB

      public void extendFAB(boolean allowExtended)
      Shrink the extended FAB.
      Parameters:
      allowExtended - true if the FAB can be extended.
    • showExtendedFAB

      public void showExtendedFAB()
      Show the extended FAB by setting its visibility to View.VISIBLE.
    • hideExtendedFAB

      public void hideExtendedFAB()
      Hide the extended FAB by setting its visibility to View.GONE.
    • removeExtendedFAB

      public void removeExtendedFAB()
      Remove the extended FAB associated with this activity.

      Use the methods setExtendedFAB(int, int, int, View.OnClickListener) or setExtendedFAB(Drawable, CharSequence, int, View.OnClickListener) to set it again.

    • 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.