# Stories by Gabor Varadi on Medium

Stories by Gabor Varadi on Medium

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Reclaim the reactivity of your state management, say no to imperative MVI

DevFeed: [Reclaim the reactivity of your state management, say no to imperative MVI](<https://devfeed.tech/articles/reclaim-the-reactivity-of-your-state-management-say-no-to-imperative-mvi-25932.md>)

Original publisher: [Read original article](<https://proandroiddev.com/reclaim-the-reactivity-of-your-state-management-say-no-to-imperative-mvi-3b23ca6b8537?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2022-05-02T05:05:46Z

Content type: opinion

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [reactive](<https://devfeed.tech/topics/reactive.md>), [Redux](<https://devfeed.tech/topics/redux.md>), [Elm](<https://devfeed.tech/topics/elm.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-pattern](<https://devfeed.tech/tags/architecture-pattern.md>), [clean-code](<https://devfeed.tech/tags/clean-code.md>), [elm](<https://devfeed.tech/tags/elm.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [model-view-intent](<https://devfeed.tech/tags/model-view-intent.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [redux](<https://devfeed.tech/tags/redux.md>), [state](<https://devfeed.tech/tags/state.md>), [state-management](<https://devfeed.tech/tags/state-management.md>)

### AI overview

The article critiques imperative MVI-style state management as overly complex and boilerplate-heavy. It traces MVI's web-oriented history through Cycle.js, The Elm Architecture, and Redux, and questions whether those patterns fit statically typed application development.

### Source excerpt

Do you find yourself chasing for "clean code, clean architecture, clean design, clean state management" yet still feel bogged down in a sea of boilerplate for even the simplest of tasks -- such as showing a simple list fetched with a coroutine? Surely this could be done in a single line or maybe about seven, but it certainly shouldn't need gigantic case-whens, three layers of indirection, and so on? Well, normally you could just invoke functions on ViewModel and it would work, but if you're forced to seek the "architectural holy grail", no one around you will trust your code unless you add at least one sealed class called ViewActions, and increase the cyclomatic complexity of your "action handler" function until it feels "just clean enough". (After all, surely the more completely unrelated things a single function does based on its argument, the more it has a "single responsibility" of handling literally everything, which is why you know it's definitely the best possible way to do it. 😏) Anyway, the boilerplate of coupling together all aspects into a single class, whether it is a function call or state property, this all has a history: namely, it came from the web. The brief history of MVI MVI stands for "model-view-intent" and comes from a (not very popular for use in production) Javascript framework called Cycle.js, hand-in-hand with a (not popular anymore) concept called "The Elm Architecture" defined as the best practices and intended use of an experimental (and since 2019, unmaintained) "functional-reactive programming language for the web" called ELM. Then again, these didn't come from a vacuum either -- the originator is Redux, in 2015. The general idea was to implement a state machine using the command processor pattern in Javascript, thereby supporting "undo" functionality (also often referred to as "time-travel debugging"). Of course, most design decisions of Redux only make sense for Javascript -- as it is a language with no static typing. It makes sense to

## Simplified navigation between Composables of Jetpack Compose using Simple-Stack

DevFeed: [Simplified navigation between Composables of Jetpack Compose using Simple-Stack](<https://devfeed.tech/articles/simplified-navigation-between-composables-of-jetpack-compose-using-simple-stack-25936.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/simplified-navigation-between-composables-of-jetpack-compose-using-simple-stack-9a796a909128?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-03-09T15:10:09Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Compose](<https://devfeed.tech/topics/compose.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [android-jetpack-compose](<https://devfeed.tech/tags/android-jetpack-compose.md>), [compose](<https://devfeed.tech/tags/compose.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>), [state](<https://devfeed.tech/tags/state.md>), [state-management](<https://devfeed.tech/tags/state-management.md>)

### AI overview

This tutorial explains how to use Simple-Stack's Compose integration for navigation between Jetpack Compose screens. It covers dependency and Activity setup, key classes, backstack navigation, configuration-change data storage, scoped services, lifecycle callbacks, and state persistence. The integration is described as beta.

### Source excerpt

Have you ever wanted to navigate between two Composables? Do you wish it were as easy as backstack.goTo(SomeScreen(arg1, arg2)) and you would go there? Good news, because now that seems to be possible with Simple-Stack's Compose integration -- which I consider BETA for now, but nonetheless, it's possible. What it looks likeInitial setup and dependencies: First, you would add the dependencies: implementation 'com.github.Zhuinden:simple-stack:2.6.0' implementation 'com.github.Zhuinden:simple-stack-extensions:2.2.0' implementation 'com.github.Zhuinden:simple-stack-compose-integration:0.2.0' And of course, you'd add Jitpack (not JCenter): // build.gradle allprojects { repositories { // ... maven { url "https://jitpack.io" } } // ... } And most importantly, you'd enable Compose: compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' useIR = true } buildFeatures { compose true }Setup To use Simple-Stack within an Activity, we use the Navigator, as always. The Compose integration is merely a different implementation of StateChanger, along with a helper that allows exposing the Backstack as a CompositionLocal for children within the composable tree. class MainActivity : AppCompatActivity() { private val composeStateChanger = AnimatingComposeStateChanger() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val backstack = Navigator.configure() .setScopedServices(DefaultServiceProvider()) .setStateChanger(AsyncStateChanger(composeStateChanger)) .install(this, androidContentFrame, History.of(FirstKey())) setContent { BackstackProvider(backstack) { MaterialTheme { Box(Modifier.fillMaxSize()) { composeStateChanger.RenderScreen() } } } } } override fun onBackPressed() { if (!Navigator.onBackPressed(this)) { super.onBackPressed() } } } This implementation of StateChanger is able to switch between keys that extend from DefaultComposeKey. In the samples, I genera

## Creating a BottomNavigation Multi-Stack using Child Fragments with Jetpack Navigation

DevFeed: [Creating a BottomNavigation Multi-Stack using Child Fragments with Jetpack Navigation](<https://devfeed.tech/articles/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-jetpack-navigation-25934.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-jetpack-navigation-5d4c24ea6f4f?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-26T06:14:32Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [Framework](<https://devfeed.tech/topics/framework.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [bottom-navigation](<https://devfeed.tech/tags/bottom-navigation.md>), [bottomnavigationview](<https://devfeed.tech/tags/bottomnavigationview.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-navigation](<https://devfeed.tech/tags/jetpack-navigation.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [navigation-component](<https://devfeed.tech/tags/navigation-component.md>), [screen](<https://devfeed.tech/tags/screen.md>), [state](<https://devfeed.tech/tags/state.md>)

### AI overview

This tutorial explains how to implement bottom navigation with a separate Jetpack Navigation NavController and back stack for each tab. It uses child fragments, adding all tab fragments while detaching those that are not visible, and initializes each tab with its own navigation graph.

### Source excerpt

It's been a recurring question, regardless of navigation framework of choice: how is it possible to create a screen with a bottom navigation view, that would host a navigation history stack per each tab? Each framework has its own unique ways. For example, with Jetpack Navigation you might use the NavigationExtensions, which requires you to host the BottomNavigationView at the Activity-level. But how would you do it with Jetpack Navigation, in such a way that the BottomNavigationView is confined to a single child fragment, and that child fragment would host all tabs that each have a NavController (backstack) available to them? How bottom navigation with child fragments normally works If you intend to create a BottomNavigationView that is hosted by a Fragment (and that Fragment hosts each tab as a child fragment), there's a bit of work needed to be done. To keep the fragments alive while switching between them, they must all be added. However, to make sure that the fragments are in the correct lifecycle (stopped while not showing), it makes sense to detach them (and attach the one that is meant to be showing). https://medium.com/media/82eb957284cfe5def31160ac33d277ba/href This example is also available here. Please note that there is nothing specific to Jetpack Navigation in this snippet, this is how a fragment can manage its child fragments and keep only one of them attached, while the rest are detached. We will use this knowledge later in the article. What Jetpack Navigation normally does When you use Jetpack Navigation (using its XML-based DSL) you typically create a navigation.xml (typically 1 per compilation module, but multiple nav graphs + include can be used too), which is then given to a NavHostFragment in a FragmentContainerView. This is what allows the NavController to be initialized with a graph, and save/restore its state. https://medium.com/media/4cc60fc3c96786f7f9adcbb3a1053853/hrefCreating a NavController and backstack for each bottom navigation tab T

## An opinionated guide on how to make your Kotlin code fun to read and joy to work with

DevFeed: [An opinionated guide on how to make your Kotlin code fun to read and joy to work with](<https://devfeed.tech/articles/an-opinionated-guide-on-how-to-make-your-kotlin-code-fun-to-read-and-joy-to-work-with-25931.md>)

Original publisher: [Read original article](<https://proandroiddev.com/an-opinionated-guide-on-how-to-make-your-kotlin-code-fun-to-read-and-joy-to-work-with-caa3a4036f9e?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-15T06:16:05Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [code](<https://devfeed.tech/tags/code.md>), [code-style](<https://devfeed.tech/tags/code-style.md>), [guide](<https://devfeed.tech/tags/guide.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [maintainability](<https://devfeed.tech/tags/maintainability.md>), [readability](<https://devfeed.tech/tags/readability.md>)

### AI overview

An opinionated guide to writing Kotlin code that is easier to read and maintain. It recommends formatting multi-argument constructors across lines, using let mainly in assignments or return statements, avoiding it for general control flow or side effects, and replacing implicit lambda arguments with meaningful names in complex expressions.

### Source excerpt

I've been meaning to write this article in a while. Hopefully, the following tips and style recommendations (in no particular order) will help you write better Kotlin! Let's get on with it, shall we? For 2 or more constructor arguments, prefer not to keep the properties on the same line as the class name in the constructor definitionclass MyClass( val a: A, val b: B, ): MyParentClass(a, b), MyInterface { // ... } This format is preferable, because when adding the 3rd argument, important bits (such as a possible base class or interface) can appear too far on the right side of the screen. Listing them one after the other (including the trailing comma since 1.4.21+) allows for better readability and extensibility (reducing the chance of causing merge conflicts with future code changes, for example). Prefer to use the scoping function 'let' only in assignments or return statements, but NOT as general control flow, or a "quick rename to 'it'" Oftentimes, Kotlin code tends to do something like this: fun myMethod(nullableA: A?) { nullableA?.let { // no it.x() // no it.y() // no it.z() // no } } (Note: in a method like this, A? could be replaced with A to take advantage of typed nullability, this is just an example.) To allow better maintainability and readability, we should instead prefer to only use ?.let { in simple assignments, or return statements, but not as general control flow. For example, the following chain is easy to understand: val protoClass = savedInstanceState?.getByteArray("protoValue") ?.let { ProtoClass.parseFrom(it) } However, in this case, ?.let { is part of an assignment. Also, while ?.let { can be chained with a ?: to provide a default value (especially in combination with takeIf) it shouldn't be used to execute side-effects (also is more suitable for that). In fact, it needs to be said: x?.let {} ?: run {} is NOT a general purpose replacement for if-else statements and null-checks, and should never be used in this particular format for that purpose!

## Dagger Tips: Guide to using Dagger-Android effectively

DevFeed: [Dagger Tips: Guide to using Dagger-Android effectively](<https://devfeed.tech/articles/dagger-tips-guide-to-using-dagger-android-effectively-25929.md>)

Original publisher: [Read original article](<https://itnext.io/dagger-tips-guide-to-using-dagger-android-effectively-c3e5b2883b38?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-13T05:05:50Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Dagger](<https://devfeed.tech/topics/dagger.md>), [Android](<https://devfeed.tech/topics/android.md>), [Architecture & Design](<https://devfeed.tech/topics/architecture-design.md>), [Development](<https://devfeed.tech/topics/development.md>), [Scalability](<https://devfeed.tech/topics/scalability.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dagger-2](<https://devfeed.tech/tags/dagger-2.md>), [dagger-android](<https://devfeed.tech/tags/dagger-android.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [development](<https://devfeed.tech/tags/development.md>), [guide](<https://devfeed.tech/tags/guide.md>), [interface](<https://devfeed.tech/tags/interface.md>), [modularization](<https://devfeed.tech/tags/modularization.md>), [module](<https://devfeed.tech/tags/module.md>), [scalability](<https://devfeed.tech/tags/scalability.md>)

### AI overview

A guide to using Dagger-Android, explaining its field-injection approach, the modularization constraints it addresses, and alternatives involving interfaces or shared superclasses. The article notes that Dagger-Android has been superseded by Hilt for common injection cases.

### Source excerpt

Something people could ask me as they're reading this title: "Hold on a second, isn't Dagger-Android no longer in active development? Isn't it made obsolete with the introduction of Hilt?" Technically, yes. Dagger-Android is superseded by Hilt. So there is a good chance that if you are already using Hilt, then for the most common cases (injecting Activity, Fragment, ViewModel, Worker), you don't need to think about Dagger-Android whatsoever. However, as I still see @ContributesAndroidInjector popping up every now and then, I feel that it's best if I write an article on how it works, what it intended to solve, how to use it, and how NOT to use it (for better scalability). What was Dagger-Android? Dagger-Android was a way to field-inject classes (not necessarily just Android classes since Dagger 2.20+) without having to define a fun inject(target: MyConcreteClassTarget) injector method on the component -- as we don't know the class itself. When do you want to avoid creating fun inject(t: T) in a component? After all, this is what normally allows field injection to be type-safe. The answer is, when you can't. If you use a modularization pattern where :app contains the ApplicationComponent(or SingletonComponent), then while ApplicationComponent can see any Activity or Fragment within the app, the submodules don't see :app and therefore don't see ApplicationComponent. Therefore, they can't call component.inject(this)! On the other hand, if you were to define an Application.ActivityLifecycleCallbacks to do it automatically, that wouldn't work with the standard approach -- as you see only the superclass, but not the concrete class! So if one wants to use field injection with our provided restrictions, there are two options: Expose an interface from the child module that defines the injection targets, and implement that on the ApplicationComponent -- then make it possible to access it (for example, using the ApplicationContext for lookup) and cast it to the interface to be abl

## Creating a BottomNavigation Multi-Stack using child Fragments with Simple-Stack

DevFeed: [Creating a BottomNavigation Multi-Stack using child Fragments with Simple-Stack](<https://devfeed.tech/articles/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-simple-stack-25935.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-simple-stack-c73c1ca3bbd4?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-01-25T17:03:22Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [navigation](<https://devfeed.tech/topics/navigation.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [configuration](<https://devfeed.tech/topics/configuration.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [bottom-navigation](<https://devfeed.tech/tags/bottom-navigation.md>), [bottomnavigationview](<https://devfeed.tech/tags/bottomnavigationview.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-navigation](<https://devfeed.tech/tags/jetpack-navigation.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>)

### AI overview

A tutorial on implementing bottom navigation with a separate navigation history stack for each tab using child fragments and Simple-Stack. It explains fragment attachment and detachment, lifecycle management, and keeping back stacks alive across configuration changes.

### Source excerpt

It's been a recurring question, regardless of navigation framework of choice: how is it possible to create a screen with a bottom navigation view, that would host a navigation history stack per each tab? Each framework has its own unique ways. For example, Jetpack Navigation provides NavigationExtensions as a sample, there's FragNav, but how would you do it with Simple-Stack? How bottom navigation with child fragments normally works If you intend to create a BottomNavigationView that is hosted by a Fragment (and that Fragment hosts each tab as a child fragment), there's a bit of work needed to be done. To keep the fragments alive while switching between them, they must all be added. However, to make sure that the fragments are in the correct lifecycle (stopped while not showing), it makes sense to detach them (and attach the one that is meant to be showing). https://medium.com/media/1667d9733c198c3ae611fd45504f6bd0/href This example is also available here. Please note that there is nothing specific to Simple-Stack in this snippet, this is how a fragment can manage its child fragments and keep only one of them attached, while the rest are detached. In fact, the NavigationAdvancedSample works the same way. We will use this knowledge later in the article. What Simple-Stack normally does When you use Simple-Stack, you typically install a Navigator using Navigator.install(). This allows a single global Backstack instance to be accessible through the Activity's context (and thus making it available to all views within the Activity), and provides automatic lifecycle management to ensure that navigation is handled correctly. https://medium.com/media/03bde713eca4e7ef47d7dae31f6e095d/href This is important to know, because if we want to create a Backstack for each Fragment within our BottomNavigationView, we must manage the lifecycle (and keep the Backstack instance alive across configuration changes) ourselves. Thankfully, this is actually quite simple to do! After all, frag

## An update to the FragmentViewBindingDelegate: the bug we've inherited from AutoClearedValue

DevFeed: [An update to the FragmentViewBindingDelegate: the bug we've inherited from AutoClearedValue](<https://devfeed.tech/articles/an-update-to-the-fragmentviewbindingdelegate-the-bug-we-ve-inherited-from-autoclearedvalue-25927.md>)

Original publisher: [Read original article](<https://itnext.io/an-update-to-the-fragmentviewbindingdelegate-the-bug-weve-inherited-from-autoclearedvalue-7fc0a89fcae1?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-01-24T00:40:53Z

Content type: article

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [bug](<https://devfeed.tech/topics/bug.md>), [navigation](<https://devfeed.tech/topics/navigation.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-view-binding](<https://devfeed.tech/tags/android-view-binding.md>), [bottom-navigation](<https://devfeed.tech/tags/bottom-navigation.md>), [bug](<https://devfeed.tech/tags/bug.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-lifecycle](<https://devfeed.tech/tags/jetpack-lifecycle.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [navigation](<https://devfeed.tech/tags/navigation.md>)

### AI overview

The article identifies a bug in an AutoClearedValue-based FragmentViewBindingDelegate. A fragment can move directly from view creation to view destruction without becoming active, so the observer never runs and the binding is not cleared. The proposed fix is to observe the view lifecycle without using the fragment as the lifecycle owner.

### Source excerpt

Jetpack Lifecycle is quite powerful. We can extract logic, and make it lifecycle-aware. In fact, this allowed us in a previous article to simplify viewbinding and make it a single line. However, I need to provide a quick heads-up: all is not as it seems. The provided gists and code snippets assumed that the code in AutoClearedValue is always correct. In this article, I'll show you how to break it. The original sourcehttps://medium.com/media/74ef2eaf8bac6a656cece1f95796034a/href The general idea behind AutoClearedValue is that a value hidden by this delegate would only be created when it is set (in our case, when it is accessed), and when viewLifecycleOwner becomes DESTROYED, it would null out the value. Makes sense, right? In order to access the view lifecycle, the code waits until Fragment.onCreate(), and registers the lifecycle observer there. Then, using the fragment as the lifecycle owner (!), it attempts to register a lifecycle observer on the view lifecycle owner. The bug hiding in plain sight The problem is that it is possible for the view lifecycle to be initialized in such a way that fragment.onStart() and therefore viewLifecycleOwner.lifecycle.addObserver never actually happens. The fragment goes directly from onViewCreated to onDestroyView. Meaning, fragment.onStart() and fragment.onStop() never happen. This means that fragment.viewLifecycleOwner.observe(fragment) will NEVER be ACTIVE, and therefore the observe block will never be called. The viewLifecycle reaches DESTROYED without it being observed. When does this happen? If a fragment is added with commitNow(), but then is detach()ed. This would mean that this could happen with FragmentPagerAdapter, as that also uses attach/detach under the hood. In my case, the bug surfaced when using the binding along with the following construct: https://medium.com/media/942d1d2a1b2b4bbdc77e4d11ef112b97/href In case of a bottom navigation view, where fragments were added but attached/detached, the view in the binding

## Structural and navigation anti-patterns in modularized Android applications

DevFeed: [Structural and navigation anti-patterns in modularized Android applications](<https://devfeed.tech/articles/structural-and-navigation-anti-patterns-in-modularized-android-applications-25933.md>)

Original publisher: [Read original article](<https://proandroiddev.com/structural-and-navigation-anti-patterns-in-modularized-android-applications-a7d667e35cd6?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-12-25T11:38:05Z

Content type: article

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [modules](<https://devfeed.tech/topics/modules.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [Code](<https://devfeed.tech/topics/code.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [antipattern](<https://devfeed.tech/tags/antipattern.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [clean-architecture](<https://devfeed.tech/tags/clean-architecture.md>), [code](<https://devfeed.tech/tags/code.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dagger-2](<https://devfeed.tech/tags/dagger-2.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [domain-driven-design](<https://devfeed.tech/tags/domain-driven-design.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [modularization](<https://devfeed.tech/tags/modularization.md>), [modules](<https://devfeed.tech/tags/modules.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [navigation-architecture](<https://devfeed.tech/tags/navigation-architecture.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>)

### AI overview

This article examines structural and navigation anti-patterns in modularized Android applications. It traces the history of Android Clean Architecture and argues that organizing an application around top-level data, domain, and presentation modules can be problematic, particularly when the structure is adopted from educational examples rather than feature-based organization.

### Source excerpt

Structural and navigation anti-patterns in multi-module and modularized applications: The case against "Android Clean Architecture" and the "domain" moduleTop-level "domain" module is a code smell. Merry Christmas to all! The subject of this article is one that has been on my mind for a very long time. After all, "Clean Architecture" is often seen as the end goal, the hallmark of the finest of Android application code structure -- it is the best of the very best. The name itself, "Clean Architecture", signals that it's a good thing ~ after all, who wants to work with "messy" code in comparison? Of course, the title of this article shows that this isn't the conclusion we'll come to. The following tweet is closer to our final evaluation -- let us analyze why it might be accurate. Clean architecture + Android for us was like building a beautiful sailing boat in your backyard because someone on TV convinced you it's better for crossing the sea than an inflatable, while you live in the mountains and also your house is on fire. https://t.co/iGqy25wk7m The history of "Android Clean Architecture"The origins To understand "Clean Architecture" as done on Android, we must trace it back to its roots, and where/when it was made popular in the first place. As far as I'm aware, it dates back to 2014, the original proposition in "Fernando Cejas: Architecting Android... the clean way?". It was a highly influential article, as it revolutionized the structure of Android apps. Code that is actually separated across layers (back when Fragments were untrustworthy, and all code was in OS-level components), rather than just throwing everything into 2000+ line Activities? A pioneer of its time. One interesting decision however in the representative sample code was that in order to signify the strict separation of layers, these layers were each separated from one another using top-level Gradle modules, each labeled data, domain, and presentation. As we will see, this is the downfall of the sampl

## Simplified Android Development Using Simple-Stack

DevFeed: [Simplified Android Development Using Simple-Stack](<https://devfeed.tech/articles/simplified-android-development-using-simple-stack-25930.md>)

Original publisher: [Read original article](<https://medium.com/swlh/simplified-android-development-using-simple-stack-6e44ce808c35?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-11-14T03:32:51Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [navigation](<https://devfeed.tech/topics/navigation.md>), [android-development](<https://devfeed.tech/topics/android-development.md>), [Android](<https://devfeed.tech/topics/android.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [android-apps](<https://devfeed.tech/topics/android-apps.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [dagger-hilt](<https://devfeed.tech/tags/dagger-hilt.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>)

### AI overview

An Android development article explains Simple-Stack, a navigation framework for tracking navigation state with immutable Parcelable screen identifiers. It describes the framework's origins in Flow and Mortar and its use for type-safe Fragment navigation.

### Source excerpt

It's been a long time since I've wanted to write this article. Time to go at it, shall we? :) People always seem to be surprised and say, "wait, you DON'T use Jetpack ViewModel, Jetpack Navigation, and Dagger-Hilt? Then what DO you use?" This article intends to answer that. We use Simple-Stack. (If you prefer watching talks, then a talk on the same subject is available at https://www.youtube.com/watch?v=5ACcin1Z2HQ) What is Simple-Stack? Simple-Stack is a navigation framework that I've been working on since the beginning of 2017, although its roots go back to 2015 -- when we were still experimenting with multiple versions of Mortar & Flow. (The 90s kids might still remember). Following up on the original proposition by Square, "Advocating Against Android Fragments" and "Simpler Android Apps with Flow and Mortar", we've been using Single-Activity approach in our apps since 2015. Now, the history of Flow and Mortar isn't all roses. I've heard people say "we tried it and it didn't work for us". I can attest to that: we had to manage our own fork, but even with that, we hit some of its limitations over time. We needed something reliable and versioned, so we rewrote Flow's original behavior, and intended to improve upon its limitations. This rewrite is what resulted in the creation of Simple-Stack. Why Simple-Stack? Simple-Stack is based on the idea that you intend to track your navigation state as a list of immutable and Parcelable classes -- screen identifiers (which the library calls "keys"). As long as the underlying navigation implementation allows for "navigation from any state to any state", it is possible to wrap that implementation using Simple-Stack. For example, something I hear often is that "navigation with Fragments is hard". I always point out that in our code, it's been like this since 2016: backstack.goTo(new SecondScreen(detailId)); // java No explicit fragment transaction, no Bundle, no newInstance(), just calling a method. How is this possible? Isn't Fr

## Building Reactive UIs with LiveData and SavedStateHandle (or equivalent approaches)

DevFeed: [Building Reactive UIs with LiveData and SavedStateHandle (or equivalent approaches)](<https://devfeed.tech/articles/building-reactive-uis-with-livedata-and-savedstatehandle-or-equivalent-approaches-25928.md>)

Original publisher: [Read original article](<https://itnext.io/building-reactive-uis-with-livedata-and-savedstatehandle-or-equivalent-approaches-4e934487035f?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-10-04T19:53:05Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [reactive](<https://devfeed.tech/topics/reactive.md>), [Android](<https://devfeed.tech/topics/android.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [observable](<https://devfeed.tech/tags/observable.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>), [room](<https://devfeed.tech/tags/room.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [savedstatehandle](<https://devfeed.tech/tags/savedstatehandle.md>)

### AI overview

This article explains LiveData as a reactive, observable, lifecycle-aware data holder for Android applications. It argues that LiveData remains useful alongside RxJava and Kotlin coroutines because its lifecycle activation states allow it to represent reactive data sources, including Room-backed data that refreshes after invalidation.

### Source excerpt

Building Reactive UIs with LiveData and SavedStateHandle (or equivalent approaches like Rx) You can also follow the related discussion thread on /r/android_devs. LiveData is a misunderstood beast. Every so often, you see comments like "LiveData does not belong in Repositories", or that with the existence of RxJava, Coroutine Channels, or Coroutine Flows -- there's "no reason to use LiveData at all". While there are components in these libraries that have overlapping responsibilities (BehaviorRelay, ConflatedBroadcastChannel, MutableStateFlow), that doesn't mean LiveData is useless. With the relatively new additions to Jetpack, such as the liveData { coroutine builder, LiveData is actually quite interesting. What is LiveData? If you try to find a definition for LiveData, you'll find that it's a "reactive, observable, lifecycle-aware data holder". We know it can be observed, and we know it holds 1 data value that is re-emitted for any new observer (and any changes made to it are also emitted), just like any BehaviorRelay. But what makes it special? Due to LiveData's lifecycle-awareness, it comes with its own "activation state" ( onActive and onInactive). It lets you know when there is an active observer, and when there are no longer any active observers. The trick is that this makes it far more than "just an every-day data holder". This allows LiveData to represent reactive datasources. I'd even wager that this is the original purpose for which LiveData was created, if Room's ComputableLiveData is any indication (as that also relies on onActive to trigger the refresh of the query results, if the table had been invalidated by a write to it). Why do I want reactive datasources? If you have data or state that can change over time, it's significantly easier to be notified of changes, than it is to poll for possible changes (and potentially miss out on changes if we tried to fetch data at the wrong time). This means that by using an "observer" (or change listener), we can r