kofigyan / StateProgressBar

Android library to realize the various states and transitions in a ProgressBar.
1.55k stars 234 forks source link

Reset state progress bar? #7

Closed philipphager closed 7 years ago

philipphager commented 7 years ago

I wanted to reset the progress bar in the same view if the corresponding action was restarted, but after all states have been checked, I'm not able to reset the states to its initial state. Is there any way to reuse the progress bar after it completed once?

kofigyan commented 7 years ago

Hi @philipphager , the question looks multi-faceted so l will try and breakdown the answer.

I wanted to reset the progress bar in the same view if the corresponding action was restarted -

You can do this by setting the current state dynamically. ie. setCurrentStateNumber(StateNumber)

but after all states have been checked,

You can equally do this by setting it dynamically , ie. setAllStatesCompleted(boolean)

I'm not able to reset the states to its initial state

You can do this by setting the current state dynamically to ONE. ie. setCurrentStateNumber(StateNumber.ONE)

Is there any way to reuse the progress bar after it completed once?

Yes as shown in the above answers.

Let me know if your question is adequately answered or otherwise. You can equally check out the wiki page for further documentation.

philipphager commented 7 years ago

Thank you for your answer! But when I call the following to reset my progress bar:

stateProgressBar.setAllStatesCompleted(false);
stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.ONE);

I get this strange visually inconsistent state:

bildschirmfoto 2017-02-10 um 10 00 39

This was the actual initial state I want the progress bar to reset to:

bildschirmfoto 2017-02-10 um 10 08 33
kofigyan commented 7 years ago

Looks like you are using the library wrongly hence the inconsistent result. To attain the desired result just use this : stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.ONE);

kofigyan commented 7 years ago

@philipphager Let me know how it went when you are done. If you are still not getting the desired result then you might have to share the content of your xml and .java files with me to further understand how you are using the library. The wiki page also has very good guide on using the library.

Fredrib commented 7 years ago

I got a similar problem trying to reset the bar to its first stage, although I didn't have a problem going back from third stage to second stage, for instance. If I've tried to go back from second stage to first stage, the joining line of this two stages don't get erased. I've looked into the code and find out a solution making a small change and I have submit a PR for this. You might look into the PR and see if that make sense to you.

kofigyan commented 7 years ago

@Fredrib Sorry for the late in reply. I have decided to look into the PR this weekend and give you a feedback. On this issue:

If I've tried to go back from second stage to first stage, the joining line of this two stages don't get erased.

There is a real world example in the sample code labelled Usage(Real world example) where you can move from second stage to first stage. If your use case is not different from this example then you can look into it. This is also available on the Google PlayStore StateProgress Link to PlayStore

If the above solution does not meet your use case then please share with me the particular use case. It could be further explanation,sample codes or screenshots. This will help me to reproduce the case and apply the solution in the PR to it. And thank you for contributing to this project.

kofigyan commented 7 years ago

@philipphager and @Fredrib I have examined the issue raised deeply and is clear the library does not have provision for resetting the stateprogressbar after it has completed. I will add this functionality either this evening or latest by tomorrow. Thanks to @Fredrib for your PR. I will update everyone on this in version 0.03.

Fredrib commented 7 years ago

@kofigyan sorry I couldn't get back to you in time, but I believe you already reproduce the bug. Looking forward to your version update. Thanks and keep up the good work!

philipphager commented 7 years ago

Thank you for the good work and the fast replies! Looking forward to the update!

kofigyan commented 7 years ago

@philipphager and @Fredrib StateProgressBar version 0.0.3 is now officially released with the issue resolved. @Fredrib l have accepted your pull request and merged with the master branch. Thank you all for your contributions.

philipphager commented 7 years ago

Thank you very much @kofigyan! For me, it works like a charm! 👍

kofigyan commented 7 years ago

@philipphager l appreciate your positive feedback.I will keep on working on additional features to further enrich the library.

kofigyan commented 6 years ago

Hi @philipphager and @Fredrib , would you mind writing a short testimonial of your impression using my work and collaborating with me. This is for my application for a master's degree program in computer science. Thanks.