leandroBorgesFerreira / LoadingButtonAndroid

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

The Doc is misleading #133

Open ueen opened 5 years ago

ueen commented 5 years ago

First, it says to use an ImageButton to created in the XML and then casts a Button, this causes the app to crash if you follow the sample code!!

leandroBorgesFerreira commented 5 years ago

That's true =/. I'll fix that this week.

ueen commented 5 years ago

Also, there seems to be an issue with startAnimation() it requires a storage Function<> i can not provide (implemented according to docs with Java in AndroidStudio with AndroidX, everything uptodate) :/

leandroBorgesFerreira commented 5 years ago

Fixed the documentation. Can you provide the code that you are trying to use?

ueen commented 5 years ago

Ok, closely followed the doc on a clean Project in latest Android Studio (Java), AnroidX, everything uptodate,

startAnimation() gets a "Cannot resolve method" Annotation

This is the compile errormessage:

error: method revertAnimation in class CircularProgressButton cannot be applied to given types; required: Function0 found: no arguments reason: actual and formal argument lists differ in length

put Button according to doc in XML (works on its own) then in onCreateView (Fragment) i put this code

final CircularProgressButton btn = (CircularProgressButton) v.findViewById(R.id.btn_id);
        new CountDownTimer(5000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                btn.startAnimation();
            }

            @Override
            public void onFinish() {
                btn.revertAnimation();
            }
        }.start();
leandroBorgesFerreira commented 5 years ago

This will work:

final CircularProgressButton btn = findViewById(R.id.buttonTest1);
        new CountDownTimer(5000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                btn.startAnimation(() -> null);
            }

            @Override
            public void onFinish() {
                btn.revertAnimation(() -> null);
            }
        }.start();
leandroBorgesFerreira commented 5 years ago

This library was optimized to Kotlin, sorry do you have to use those callbacks... Java doesn't recognize the default values

ueen commented 5 years ago

btn.startAnimation(() -> null);

Lambda expressions are not supported at language level '7'

fix: raised language level to 8

still compiling error: cannot access Function0 class file for kotlin.jvm.functions.Function0 not found

could fix this by implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.31' now it does in fact work, thanks! but it is somewhat suboptimal with all this kotlin business :/

ueen commented 5 years ago

One more issue tough, after reverting the Animation, the Button loses its original rounded corners, is there a way to get the Button back its original idle state?

leandroBorgesFerreira commented 5 years ago

Yep, there is. Try: app:finalCornerAngle. That's the one if I remember correctly.

leandroBorgesFerreira commented 5 years ago

Or maybe initialCornerAngle... One of the two.

ueen commented 5 years ago

Both also changes the loading shape, which is not what I want, as it should stay round.

minhduc0711 commented 5 years ago

Hi, I am also using Java and I ran into another problem at this line: btn.startAnimation(() -> null);

Cannot resolve method 'startAnimation(<lambda expression>)'

Can you help me? Thanks.

Update: I added implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.31' as @ueen suggested and it works now.