LoadingButtonAndroid icon indicating copy to clipboard operation
LoadingButtonAndroid copied to clipboard

The Doc is misleading

Open ueen opened this issue 5 years ago • 12 comments

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!!

ueen avatar May 14 '19 16:05 ueen

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

leandroBorgesFerreira avatar May 14 '19 20:05 leandroBorgesFerreira

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) :/

ueen avatar May 14 '19 21:05 ueen

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

leandroBorgesFerreira avatar May 15 '19 03:05 leandroBorgesFerreira

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<Unit> 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();

ueen avatar May 15 '19 09:05 ueen

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 avatar May 16 '19 07:05 leandroBorgesFerreira

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

leandroBorgesFerreira avatar May 16 '19 07:05 leandroBorgesFerreira

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 avatar May 16 '19 09:05 ueen

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?

ueen avatar May 16 '19 09:05 ueen

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

leandroBorgesFerreira avatar May 16 '19 16:05 leandroBorgesFerreira

Or maybe initialCornerAngle... One of the two.

leandroBorgesFerreira avatar May 16 '19 22:05 leandroBorgesFerreira

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

ueen avatar May 24 '19 13:05 ueen

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.

minhduc0711 avatar May 26 '19 16:05 minhduc0711