leandroBorgesFerreira/LoadingButtonAndroid

Dynamically setting text doesn't reflect after reverting animation

somesh-basicx opened this issue · 8 comments

I am using CircularProgressButton in XML like this

<br.com.simplepass.loadingbutton.customViews.CircularProgressButton
        android:id="@+id/btnSelfCheckInCheckOut"
        style="@style/Widget.MaterialComponents.Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:spinning_bar_color="@color/color_on_primary"
        tools:text="Check In"
        tools:visibility="visible" />`

and button setting the text on button inside my fragment and start the animation like this btnSelfCheckInCheckOut.startAnimation() and when I revert the animation the dynamically applied text is lost. I found a workout for this by calling saveInitialState() after changing text.

Hello @somesh-basicx. You're right, I can reproduce this bug. Thanks for catching this! I'll take a look and fix it as soon as I can. Mean while, you can workaround this by using the call back in the revertAnimation():

val buttonText = buttonTest1.text

buttonTest1.startAnimation()
buttonTest1.revertAnimation {
        buttonTest1.text = buttonText
}

Any plan to fix this issue?

@somesh-basicx I had the same issue, seems to be fixed in latest version 2.2.0
hmm.. nevermind, still there, but
revertAnimation{btn.text = "blaah"} does the job

Is there any Java equivalent to this workaround? I can't seem to find that constructor.

@ardevd Did you get the solution? I need to set text after revert Animation. Text Setting and being changed as defined in XML class

@Swati-soni-14 No, I haven't found a solution yet.

I'm also looking forward to achieve this in Java. Any updates?

I know that I'm answering this several months later... But the Java workaround was always available:

progressButton.revertAnimation(new OnAnimationEndListener() {
            @Override
            public void onAnimationEnd() {
                //Change the text here!!
            }
        });