snackprogressbar

lib / com.tingyik90.snackprogressbar / SnackProgressBarManager

SnackProgressBarManager

class SnackProgressBarManager : LifecycleObserver

Manager class handling all the SnackProgressBars added.

This class queues the SnackProgressBars to be shown. It will dismiss the SnackProgressBar according to its desired duration before showing the next in queue.

In the constructor, provide a view to search for a suitable parent view to hold the SnackProgressBar. If possible, it should be the root view of the activity and can be any type of layout. If a CoordinatorLayout is provided, the FloatingActionButton will animate with the SnackProgressBar. Else, setViewsToMove needs to be called to select the views to be animated. Note that setViewsToMove can still be used for CoordinatorLayout to move other views.

Swipe to dismiss behaviour can be set via SnackProgressBar.setSwipeToDismiss. This is provided via BaseTransientBottomBar for CoordinatorLayout, but provided via SnackProgressBarLayout for other layout types.

Starting v6.0, you can provide a LifecycleOwner of an activity / fragment. This provides a quick way to automatically dismissAll and remove onDisplayListener during onDestroy of the activity / fragment to prevent memory leak.

Types

Name Summary
OnDisplayListener Interface definition for a callback to be invoked when the SnackProgressBar is shown or dismissed.interface OnDisplayListener

Annotations

Name Summary
OneUp annotation class OneUp
ShowDuration annotation class ShowDuration

Constructors

Name Summary
<init> Create an instance of SnackProgressBarManager.SnackProgressBarManager(providedView: View, lifecycleOwner: LifecycleOwner? = null)

Functions

Name Summary
disable Call dismissAll and remove onDisplayListener to prevent memory leak. This is called automatically during Lifecycle.Event.ON_DESTROY of activity / fragment if a LifecycleOwner is provided.fun disable(): Unit
dismiss Dismisses the currently showing SnackProgressBar and show the next in queue.fun dismiss(): Unit
dismissAll Dismisses all the SnackProgressBar that is in queue. The currently shown SnackProgressBar will also be dismissed.fun dismissAll(): Unit
getLastShown Retrieves the SnackProgressBar that is currently or was showing.fun getLastShown(): SnackProgressBar?
getSnackProgressBar Retrieves the SnackProgressBar that was previously added into SnackProgressBarManager.fun getSnackProgressBar(storeId: Int): SnackProgressBar?
put Stores a SnackProgressBar into SnackProgressBarManager to perform further action. The SnackProgressBar is uniquely identified by the storeId and will be overwritten by another SnackProgressBar with the same storeId.fun put(snackProgressBar: SnackProgressBar, storeId: Int): Unit
setActionTextColor Sets the action text color.fun setActionTextColor(colorId: Int): SnackProgressBarManager
setBackgroundColor Sets the SnackProgressBar background color.fun setBackgroundColor(colorId: Int): SnackProgressBarManager
setMessageMaxLines Sets the max lines for message.fun setMessageMaxLines(maxLines: Int): SnackProgressBarManager
setMessageTextColor Sets the message text color.fun setMessageTextColor(colorId: Int): SnackProgressBarManager
setOnDisplayListener Registers a callback to be invoked when the SnackProgressBar is shown or dismissed.fun setOnDisplayListener(onDisplayListener: OnDisplayListener?): SnackProgressBarManager
setOverlayLayoutAlpha Sets the transparency of the overlayLayout which blocks user input.fun setOverlayLayoutAlpha(alpha: Float): SnackProgressBarManager
setOverlayLayoutColor Sets the overlayLayout color.fun setOverlayLayoutColor(colorId: Int): SnackProgressBarManager
setProgress Sets the progress for SnackProgressBar that is currently showing. It will also update the progress in % if it is shown.fun setProgress(progress: Int): SnackProgressBarManager
setProgressBarColor Sets the ProgressBar color.fun setProgressBarColor(colorId: Int): SnackProgressBarManager
setProgressTextColor Sets the ProgressText color.fun setProgressTextColor(colorId: Int): SnackProgressBarManager
setTextSize Sets the text size of SnackProgressBar.fun setTextSize(sp: Float): SnackProgressBarManager
setViewsToMove Passes the views (e.g. FloatingActionButton) to move up or down as SnackProgressBar is shown or dismissed.fun setViewsToMove(viewsToMove: Array<View>): SnackProgressBarManager
setViewToMove Passes the view (e.g. FloatingActionButton) to move up or down as SnackProgressBar is shown or dismissed.fun setViewToMove(viewToMove: View): SnackProgressBarManager
show Shows the SnackProgressBar based on its storeId with the specified duration. If another SnackProgressBar is already showing, this SnackProgressBar will be queued and shown accordingly after those queued are dismissed.fun show(storeId: Int, duration: Int): Unit
fun show(storeId: Int, duration: Int, onDisplayId: Int): Unit
Shows the SnackProgressBar with the specified duration. If another SnackProgressBar is already showing, this SnackProgressBar will be queued and shown accordingly after those queued are dismissed.fun show(snackProgressBar: SnackProgressBar, duration: Int): Unit
fun show(snackProgressBar: SnackProgressBar, duration: Int, onDisplayId: Int): Unit
updateTo Updates the currently showing SnackProgressBar without dismissing it to the SnackProgressBar with the corresponding storeId i.e. updating without animation. Note: This does not change the queue.fun updateTo(storeId: Int): Unit
Updates the currently showing SnackProgressBar without dismissing it to the new SnackProgressBar i.e. updating without animation. Note: This does not change the queue.fun updateTo(snackProgressBar: SnackProgressBar): Unit
useRoundedCornerBackground Sets whether to use rounded corner background for SnackProgressBar according to new Material Design. Note that the background cannot be changed after being shown.fun useRoundedCornerBackground(useRoundedCornerBackground: Boolean): SnackProgressBarManager

Companion Object Properties

Name Summary
ACTION_COLOR_DEFAULT Default action text color as per Material Design i.e. R.color.colorAccent.val ACTION_COLOR_DEFAULT: Int
BACKGROUND_COLOR_DEFAULT Default SnackProgressBar background color as per Material Design.val BACKGROUND_COLOR_DEFAULT: Int
LENGTH_INDEFINITE Show the SnackProgressBar indefinitely. Note that this will be changed to LENGTH_SHORT and dismissed if there is another SnackProgressBar in queue before and after.const val LENGTH_INDEFINITE: Int
LENGTH_LONG Show the SnackProgressBar for a long period of time.const val LENGTH_LONG: Int
LENGTH_SHORT Show the SnackProgressBar for a short period of time.const val LENGTH_SHORT: Int
MESSAGE_COLOR_DEFAULT Default message text color as per Material Design.val MESSAGE_COLOR_DEFAULT: Int
OVERLAY_COLOR_DEFAULT Default overlayLayout color i.e. android.R.color.white.val OVERLAY_COLOR_DEFAULT: Int
PROGRESSBAR_COLOR_DEFAULT Default progressBar color as per Material Design i.e. R.color.colorAccent.val PROGRESSBAR_COLOR_DEFAULT: Int
PROGRESSTEXT_COLOR_DEFAULT Default progressText color as per Material Design.val PROGRESSTEXT_COLOR_DEFAULT: Int