Skip to content

GeniusRUS/MultiProgressBar

Repository files navigation

MultiProgressBar

Maven Central codebeat badge

Short description

This library makes it possible to display a progress bar, as in Instagram Stories, without much effort.

View support state recovery using onSaveInstanceState

Details

These attributes (app in your layout) allow you to fine-tune the behavior of the progress bar:

  1. lineColor (color) default: Color.GRAY
  2. progressColor (color) default: Color.WHITE
  3. progressSteps (integer) default: 1
  4. progressPadding (dimension) default: 8dp
  5. progressWidth (dimension) default: 10F
  6. progressPercents (integer) default: 100
  7. isNeedRestoreProgress (boolean) default: false
  8. singleDisplayedTime (float) default: 1F

Also the following api allows you to control the display of progress:

  1. start() - starts / resumes showing progress. Start from N position is also supported
  2. pause() - pauses showing progress. The scale stops at the current position
  3. previous() - move to the beginning of the previous block of progress. If progress is started, the show will start immediately. Otherwise, it will stop at the beginning of the block.
  4. next() - move to the beginning of the next block of progress. If progress is started, the show will start immediately. Otherwise, it will stop at the beginning of the block.
  5. clear() - clearing the current state of progress, resetting the scale to the very beginning
  6. setListener(listener: ProgressStepChangeListener) - sets the listener ProgressStepChangeListener to switch progress blocks
  7. setFinishListener(finishListener: ProgressFinishListener) - set the listener ProgressFinishListener that indicates end of progress
  8. setProgressPercents(progress: Int - sets the number of percent for calculating the progress scale
  9. setProgressStepsCount(stepsCount: Int) - sets the total number of progress steps
  10. setSingleDisplayTime(singleDisplayedTime: Float) - sets the display time of one cell. Can be used in runtime
interface ProgressStepChangeListener {
    fun onProgressStepChange(newStep: Int)
}

Usage

Artifact is publishing to Maven Central. You can add this repository to your project with:

repositories {
    mavenCentral()
}

Add to your .gradle file:

implementation "io.github.geniusrus:multiprogressbar:$latest_version"

Sample

The sample is on app module

Developers

  1. Viktor Likhanov

Yandex: Gen1usRUS@yandex.ru

License

Apache v2.0 License

Copyright (c) 2019 Viktor Likhanov