Conditional navigation is a little tricky when it comes to Navigation Architecture. There are plenty of nice articles and solutions about it, but I’m sharing the way I solve this important problem. So let’s consider this use case: If you don’t put HomeFragment as a start destination, you will have some serious trouble with the fragment back stack and you would need to write the onBackPressDispatcher in every fragment.
This week, I’ve been playing with service locators in Android. I made this repo with 3 different branches. One of them is using Dagger as a DI tool, the other branches are implementation with KodeIn and Koin. The app is pretty simple, just retrieves some data from a Cat API, saves them to a local Room persistence and then renders them to the screen: The screen renders just a the list of cats retrieved by the database after the data are fetched from a remote API.
Basically, in part 3 of this series we managed to fully modularize an Android app. However there are some notes that need to be taken. We didn’t cover too much about resources (res folder) in any of our parts therefore we are handling it now. Here are some things that we should notice about resources in modularization: 1- Strings. No need there for a large file of it. It’s easier when each module has access to it’s own string values rather than accessing them all from a :core_module.
On our latest article, what we did was creating a Dagger component about almost all of our features and provided a ViewModel(Factory) for every Fragment we had inside a module. As said, this is a little too much work for Dagger, the programmer and each feature. It’s a total overkill of using Dagger actually, we could have stuck to a manual DI instead, but I required you to be patient.
This is part 2 of a series of articles about modularizing Android app. If you haven’t yet read the first article, you may find it here. On our first article we just moved some classes outside the application and applied as an independent module. But what if we have dependencies pulled from the application level? This could be a small challenge. First of all, we want to clarify on how are we going to modularize the app.
Inspired by a Martin Fowlers post about Micro Frontends, I decided to break my monolithic app into a modular app. I tried to read a little more about breaking monolithic apps in Android, and as far as I got, I felt confident to share my experience with you. This will be some series of blog posts where we actually try to break a simple app into a modularized Android app.