My activity have a ProgressBar. When start activity, I\'ll check value get from another place and update to ProgressBar. Here\'s my code:
final ProgressBar p
You can auto-advance progress bar using RXJava.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (autoProgress) {
autoProgressSubscriber = Observable.interval(0, 1000/60, TimeUnit.MILLISECONDS) //~60fps
.map(index -> calculateAutoProgress())
.subscribe(progress -> {
if (progressBar != null) {
progressBar.setProgress(progress);
}
});
}
}
@Override
protected void onDetachedFromWindow() {
if (autoProgress) {
autoProgressSubscriber.unsubscribe();
}
super.onDetachedFromWindow();
}