JR's Week1-2Jan2023 reading digest
Here's a quick post of what I read this week!
Kotlin-Parcelize deep dive by Christophe Beyls
When we want to request an action from an app component in Android, such as Activitiy or Service, we have to use Intent
. When we want to pass a non-primitive object through an Intent
, we can either use the Serializable
interface (Serializable doc) or the Parcelable
interface (Parcelable doc).
The difference is that Serialize
is a java interface, and it's using reflection to infer the serialization process while Parcelizable
requires us to specify it (read). Luckily we have the kotlin-parcelize
plugin provides us with the @Parcelize
that will help to generate the code for us.
In this is a post 👇, Christophe Beyls took a deep dive to examine the generated code by the kotlin-parcelize
plugin.
How Upgrading to JDK17 for Android Development improves build time
Android runtime ART (previously Dalvik) runs its own bytecode (dex) which is different from standard JVM in Android. This causes the supported Java version in Android development to have always lagged behind the latest Java features. Now JDK17 has become LTS, we can upgrade it to gain the benefits of speeding up our build.
The blog posts below written by Oliver Falvai on Bitrise blog compares the build time of using JDK 11 vs JDK 17 on 3 open source Android Projects Tivi, Firefox Android, DuckDuckGo Android. The blog also examines the effect of different garbage collectors.
In this post, Inaki Villar measures the build for nowinandroid project using JDK11, JDK17 and JDK19:
Both authors are using https://github.com/gradle/gradle-profiler to measure their build.
Since we are talking about Java versions, the following serves as a bonus post to understand the versions!
Codegen with KSP, say goodbye to stubs (kapt)!
In the following video, David Rawson talks about why ksp
is faster than kapt
, and shows us how to use ksp
to write a processor and how to generate code using codegen:
- Video: https://www.youtube.com/watch?v=MMuc5gkKB9s
- Medium post: https://proandroiddev.com/ksp-fact-or-kapt-7c7e9218c575
- Github repo: https://github.com/drawers/ksp-sample
Kotlin's Reduce vs Fold
Chetan Gupta talks about the accumulator pattern reduce and fold in Kotlin:
https://chetangupta.net/reduce-fold/
Baseline Profile
This video talks about the evolution of code execution in Android from interpreted to JIT, then to Full AOT, then to Partial AOT and eventually with Cloud Profile and Baseline Profile.
https://www.youtube.com/watch?v=yJm5On5Gp4c
Jetpack Compose How Tos
- Philipp Lackner talks about how to use
onTextLayout
ofText
to create an auto resizingText
, with the help ofModifier.drawWithContent
.
https://www.youtube.com/watch?v=ntlyrFw0F9U
- He also showed us how to create a Shimmer effect using
composed
andrememberInfiniteTransition
withBrush.linearGradient
:
https://www.youtube.com/watch?v=NyO99OJPPec
- Another video talking about custom
Modifier
usingcomposed
:
Clap to support the author, help others find it, and make your opinion count.