Open ueen opened 5 years ago
That's true =/. I'll fix that this week.
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) :/
Fixed the documentation. Can you provide the code that you are trying to use?
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
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();
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();
This library was optimized to Kotlin, sorry do you have to use those callbacks... Java doesn't recognize the default values
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 :/
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?
Yep, there is. Try: app:finalCornerAngle
. That's the one if I remember correctly.
Or maybe initialCornerAngle... One of the two.
Both also changes the loading shape, which is not what I want, as it should stay round.
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.
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!!