Hello, good morning everybody. I have implement `*...
# android
s
Hello, good morning everybody. I have implement 
*Modular Android* App *Architecture*
 , so I would like to discuss these two solutions: • Problems: ◦ Target : 
Module A
 send Event to show 
Dialog
 on the screens and exclude a some screens. ◦ Features divided into separate modules. ◦ Example Requirement: Class SocketService in
Module A
get events from server in Application class , we use ActivityLifecycleCallbacks to get
Current Activity
, We do not display dialog on Search Screens, Map Screen, … etc ( 2 cases : several screens or large screens should not show dialog) • Solution 1: ◦ Create an Interface
DoNotShowDialog
in
Common Module
◦ You will implement this interface to prevent to display
Dialog
in each modules/Activity class • Solution 2: ▪︎
Module A
use activity.javaClass.simpleName to compare with array of strings ▪︎ Example :
Copy code
arrayListOf("SearchActivity", "MapActivity").contains(this.javaClass.simpleName)
Which solution will you choose? Thanks.
2️⃣ 2
1️⃣ 4
p
I would go with solution 2 to make rest of the app agnostic to this Dialog thing
👍 1
s
Thanks for comment @pepos I think solution 2 have more
Pros
Example: 1. Easy to write UnitTest -> compare class name 2. Some features do not include common module code 3. It is not impact to any feature modules code -> No more write code in each modules.
p
yep + new features loaded by the app will get the dialogs for free, no added code needed
K 1
+ what if you also open an Activity from 3rd party lib and your requirement is also show the dialog over that Activity? you can only do that with solution 2
👍 1
s
yeah great example about 3rd
Do you think solution 1 is match
*Modular Android* App *Architecture*
Concept?
In my view, if I remove this interface ,it will impact everything code relevant to this interface in common module, I think its not clean code + modular android app architecture. Small thing but big impact.
p
both solutions fits the diagram you posted, but solution 2 is cleaner