leandroBorgesFerreira / LoadingButtonAndroid

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

Loading Button loading state #114

Closed AlexGZC closed 5 years ago

AlexGZC commented 5 years ago

Hi, i am trying to set the library. There are two things that i would like to do properly:

  1. how to keep circle in the middle of screen, because it moves to the left when is started?

  2. How to return the original button state, I have been trying to set what you have told onto readme, however Stops and reverse are not working, can you help me?

leandroBorgesFerreira commented 5 years ago

1 - The button respects the gravity of the parent view. Use it inside a LinearLayout with center gravity.

2 - If you just want to revert to the initial state, just call revertAnimation without calling stop. If it does't work, provide the code that you're using.

dineshmm23 commented 5 years ago

Hi @leandroBorgesFerreira , I am having trouble calling revertAnimation in java.

Is this possible to use it in java or is there any other method to return the original button state.

Don't know what prarameter needed

leandroBorgesFerreira commented 5 years ago

Uhm, did you try to use null? If you don't need any behaviour of the animation complete, null should be fine

leandroBorgesFerreira commented 5 years ago

Actually, don't use null. You can just use a simple lambda. Like this:

new CircularProgressButton(Mockito.mock(Context.class)).revertAnimation(() -> null)
AlexGZC commented 5 years ago

Hi @leandroBorgesFerreira , thanks for the help. Now i could keep circle non the center, however, I have not been able to call revertAnimation because says that you have to set some params onto function. Is this the same thing as above?

leandroBorgesFerreira commented 5 years ago

Yes. It is the same as the dineshmm23, if you're using Java. I should add some documentation for Java usage

leandroBorgesFerreira commented 5 years ago

Just add a lambda in the callback and you'll be fine

leandroBorgesFerreira commented 5 years ago

Wrong reference

dineshmm23 commented 5 years ago

Yes. It is the same as the dineshmm23, if you're using Java. I should add some documentation for Java usage

I tried with this, it works

btnProceedToPay.revertAnimation(new Function0<Unit>() {
                    @Override
                    public Unit invoke() {
                        return null;
                    }
                });
itsibee commented 5 years ago

btnProceedToPay.revertAnimation(new Function0() { @Override public Unit invoke() { return null; } });

I tried this and it didn't work for me. Please add some documentation for Java