Closed GraxCode closed 3 years ago
I found a very ugly way to do it.
new InfoSheet().show(context, null, infoSheet -> {
infoSheet.title(R.string.send_item);
infoSheet.content(R.string.connect_bluetooth);
com.maxkeppeler.sheets.lottie.LottieAnimationExtKt.withCoverLottieAnimation(infoSheet, new LottieAnimation(lottieAnimation -> {
lottieAnimation.setupAnimation(lottieAnimationRequest -> {
lottieAnimationRequest.setAnimation(R.raw.bluetooth);
return null;
});
return null;
}));
return null;
});
There should be a better solution for java users.
().show(context, null, infoSheet -> { infoSheet.title(R.string.send_item); infoSheet.content(R.string.connect_bluetooth); com.maxkeppeler.sheets.Maxe.MaxeAnimationExtKt.withCoverMaxeAnimation(infoSheet, new MaxeAnimation(MaxeAnimation -> { MaxeAnimation.setupAnimation(MaxeAnimationRequest -> { MaxeAnimationRequest.setAnimation(R.raw.bluetooth); return 0.01 }); return 0.01 })); return 0.01 });
That's very ugly. Any tips on how to improve it for Java? Since it was meant to be for Kotlin, I never thought of using it in Java and therefore also never thought about the usage looks there.
Don't really know. There is not much you can do probably, as the design of the Kotlin language is here the problem.
Option
Make an Util class which does it. It's not much different than LottieAnimationExtKt#withCoverLottieAnimation
though, only the name.
Option
Make some abstract "Builder" or "Setup" or whatever name you'd like class in the core module. Create the following instance method:
Sheet#withBuilder(Builder b)
.
Builder then has an abstract method called Builder#buildFor(Sheet s)
, which is called in Sheet#withBuilder(Builder b)
.
Then make a LottieAnimationBuilder class in the lottie module which then does all the ugly LottieAnimationExtKt.withCoverLottieAnimation
stuff for me (which will not be ugly anymore in Kotlin).
All I would have to do would then look probably look like that infoSheet.withBuilder(new LottieAnimationBuilder(R.raw.my_anim))
.
What's the reason that you are still using Kotlin? From what I have seen and noticed, everything is about Kotlin, alongside a lot of Kotlin-first libraries.
I don't like the syntax of Kotlin, and honestly I am too lazy to learn all the Kotlin specific classes / methods. Java works fine for me, and I really like it as it feels closer to C.
I feel like it's not worth it to make it nicer on Java, as it is meant to be a Kotlin library and as it would affect the existing Kotlin users of the library. Sorry!
This does not seem to work.
infoSheet.withCoverLottieAnimation
does not seem to exist for me.