I'm still new to Android development and now I'm g...
# announcements
j
I'm still new to Android development and now I'm getting started with Clean Architecture and I'm wondering about some things. First of all I'm using a single activity pattern and am in the process of modularizing my project by features and adding usecases. I've got a couple of questions if anyone's got some time. 1. What's a good level of dividing features? Could one feature have multiple associated fragments? 2. I find myself not creating repositories for most features. Instead I have 3 repos in the app module, because they must be used in multiple places of the project. Is this right or wrong? 3. How would I handle things like someone sending me a message when that logic will only happen once I'm in an assignment together with that person. This would require that I'm somehow notified about the message in multiple fragments. I would need to observe the same data in multiple viewmodels, use an extra activity, or put the livedata observing in the main viewmodel. This would quickly make the mainviewmodel full of stuff it only needs in certain areas of the app. I have a similar requirement for other areas of the app where I need to receive notifications in the form of popups across certain fragments. Thanks.
s
1 and 2 are both fine. For 3, you probably would want to make a viewmodel that specifically is for messages, and reuse it in different fragments.
j
I see thanks. I didn't even think about the fact that I could use multiple viewmodels in the same fragment since I've so far always coupled one viewmodel for one fragment. That makes sense, thank you.
j
2. You can consider moving your repos/class to core/shared module if you will reuse it in multiple places and let every feature depend on it. 3. Please check this post or this article. Hope it helps.