leandroBorgesFerreira / LoadingButtonAndroid

A button to substitute the ProgressDialog
MIT License
1.94k stars 214 forks source link

Dynamically setting text doesn't reflect after reverting animation #150

Open somesh-basicx opened 4 years ago

somesh-basicx commented 4 years ago

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.

leandroBorgesFerreira commented 4 years ago

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
}
somesh-basicx commented 4 years ago

Any plan to fix this issue?

oth-libs commented 4 years ago

@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

ardevd commented 4 years ago

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

Swati-soni-14 commented 4 years ago

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

ardevd commented 4 years ago

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

sebasira commented 3 years ago

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

leandroBorgesFerreira commented 3 years ago

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!!
            }
        });