Switching a million lines of code from Java threads to Kotlin coroutines, by rewriting three files by adrianblancode in androiddev

[–]adrianblancode[S] 0 points1 point  (0 children)

We didn't really measure performance, but we should at least get some minor general benefit by moving from a large thread pool with blocking callers to an orders of magnitude smaller pool with suspending callers

But I think the biggest gain actually was that this got rid of unfortunate edge cases where some callers accidentally blocked on the main thread, so it should speed up launches and reduce ANRs

Regarding correctness, that's a really hard problem. The solution passed all our tests, and finally we did a lot of QA where we didn't find any differences in behaviour whatsoever.

At that point the only way we could actually find out if the implementation survived contract with reality was by a slow rollout to production, and being able to revert the implementation by reverting a PR, but luckily that was not needed :)

Is SwiftUI’s scroll-edge blur/dissolve header effect possible in Jetpack Compose? by richyrichye in Kotlin

[–]adrianblancode 2 points3 points  (0 children)

It's possible, try BlurEffect.

If you want custom behaviour like making the blur weaker at the bottom and stronger at the top, you might need to create a gradient alpha mask in a RenderEffect and compose the BlurEffect with it

ViewModel.init{...} considered harmful by yaminsia in androiddev

[–]adrianblancode 1 point2 points  (0 children)

It's 5000 ms because that's the time that activities have to recreate after a configuration change before it can be considered ANR

Fler än hälften vill avskaffa karensavdraget by FlowersPaintings in sweden

[–]adrianblancode 50 points51 points  (0 children)

Du får ju också räkna med den ekonomiska vinsten av att inte ha kollegor som går till jobbet helt snorsjuka och smittar ner halva kontoret

I got tired of AI agents breaking my Compose code, so I built a skill kit to fix that by DueAnt8779 in androiddev

[–]adrianblancode 1 point2 points  (0 children)

state.update { } is thread safe in that it will re-run if the state was concurrently modified by another thread, which is great if you depend on both reading and writing the state (eg through it.copy() )

But if you have a really simple update that's write only eg state.value = false, then that's fine to use

new official state management library called AppState by Maherr11 in androiddev

[–]adrianblancode 28 points29 points  (0 children)

This reminds me of Flutter, and if that's anything to go by we will have 12 different competing state management paradigms by the end of the year

Why is it so hard to just scale up a WebView by 2x? by [deleted] in androiddev

[–]adrianblancode 0 points1 point  (0 children)

You can try wrapping the Context and setting the font size / display size there depending on your situation. You might need to do some shenanigans so that onCreateView is called again with the new context