Location management - devrath/RunTracer GitHub Wiki

Notes 🗒️

  • We have the run --> domain layer where we mention what the domain layer is capable of.
  • Actual implementation: We add the location module to remain re-usable.
  • Once we set this class, the callback will be triggered whenever there is a location change. We convert the callback to flow and give it back.

Architecture

📁 - `RunTracer` (Project)
| 
|--- `app`(module)
|
|--- `core`(module)
|      |   
|      |-- `data`(module)    
|      |-- `domain`(module)
|      |      |
|      |      |---`Location`(folder)
|      |
|      |-- `presentation`(module)
|
|--- `Run`(module)
|      |
|      |--- `Data` (module)
|      |--- `Domain` (module)
|      |--- `Presentation` (module)
|      |--- `Location` (module)      
|_________________________________
  • Now the Location-module is part of the run-module itself, So it is nested inside the run-module.
  • We add an interface named LocationObserver.kt in the run-domain layer.
  • We have the Location-module where we have the code that fetches the location data from the Android system.
  • We implement the interface called LocationObserver.kt in the class AndroidLocationObserver.kt located in Location-module.
  • The location folder containing the app-->core-->domain-->location will have location-module related data model classes.
  • The location-module will have a dependency of core-domain and run-domain modules.
  • The domain-module of the run-module will have another class called RunningTracker.
    • This class will have the responsibility to switch on and off the location services.
    • Also we inject the interface LocationObserver.kt in the RunTracker.kt class.