Open wujushan opened 7 years ago
Hello @wujushan , please can you provide me with a code snippet of how you do this call.
Hi @kofigyan ,if it is necessary to call the method “enableAnimationToCurrentState(true)” before calling the method "setCurrentStateNumber"?This is my code below.
`public class Main2Activity extends AppCompatActivity { private String[] descriptionData = {"one", "two", "three"}; private StateProgressBar mStateProgressBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); mStateProgressBar = (StateProgressBar)findViewById(R.id.state_progress); mStateProgressBar.setStateDescriptionData(descriptionData); mStateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.TWO); //animation }
/**
* no animation if call into button listener
* @param view
*/
public void onClick(View view){
int id = view.getId();
switch (id){
case R.id.one_btn:
mStateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.ONE);
break;
case R.id.two_btn:
mStateProgressBar.enableAnimationToCurrentState(true);
mStateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.TWO);
break;
case R.id.three_btn:
mStateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.THREE);
mStateProgressBar.enableAnimationToCurrentState(true);
break;
}
}
}`
@wujushan have you found the solution? let me know when you find.
Please check out this link -https://youtu.be/-03NBianPfw . Let me know if is helpful.
This wasn't helpful, As you can see the line animation didn't happen on button click. It just changed from state1 to state2.
I have the same problem. And I think I know why it appears. You call enableAnimationToCurrentState(false)
in Animtor.run()
as soon as the animation stops. This disables the animation for further changes via setCurrentStateNumber()
. It doesn't even help to call enableAnimationToCurrentState(true)
before a call to setCurrentStateNumber()
because Animator.run()
happens asynchronously.
I think you need two variables. One mAnimateToCurrentProgressState
which is only settable via public method. And something like a mIsCurrentlyAnimating
which has only private access and which you can set to false inside Animtor.run()
.
Have u find a solution to this problem ? I'm trying to use it but this problem is still there...
When I call the method "setCurrentStateNumber" into a button listener to update current state ,there will be no animation.