This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| startKoin { | |
| androidLogger() | |
| androidContext(this@MyApplication) | |
| modules(appModule + networkModule) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val appModule = module { | |
| // Data Sources | |
| single { DiskHealthInstitutionDataSource() } | |
| single { RemoteHealthInstitutionDataSource() } | |
| // Repositories | |
| single { HealthInstitutionRepository(get(), get()) } | |
| viewModel { HomeViewModel(get(), get()) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun initializeManagers(activity: Activity) { | |
| analyticsManager = AnalyticsManager(activity) | |
| locationKitManager = LocationKitManager(activity) | |
| mapKitManager = MapKitManager() | |
| siteKitManager = SiteKitManager(activity, BuildConfig.HMS_API_KEY) | |
| // For testing purposes | |
| analyticsManager?.sendEvent("XX", Bundle().apply { | |
| putString("TestProperty1", "TestValue1") | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| initializeUIElements() | |
| with (viewModel) { | |
| initialize(this@HomeActivity) | |
| initializeStyle(theme = currentTheme) | |
| isCoordinateAvailable.observe(this@HomeActivity, Observer { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun initialize(activity: Activity) { | |
| initializeManagers(activity) | |
| requestLocationUpdates() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun requestLocationUpdates() { | |
| locationKitManager?.requestLocationUpdatesWithCallback( | |
| locationRequest = LocationRequest().apply { | |
| interval = 10000L | |
| priority = LocationRequest.PRIORITY_HIGH_ACCURACY | |
| needAddress = true // This let you to reach the current address information. | |
| }, | |
| locationCallback = object : LocationCallback() { | |
| override fun onLocationResult(locationResult: LocationResult?) { | |
| if (locationResult != null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun getRoute(`for`: RouteType, onFailed: ((errorMessage: String) -> Unit)? = null) { | |
| val originCoordinates = | |
| Coordinates(userLocation?.coordinate?.first!!, userLocation?.coordinate?.second!!) | |
| val destinationCoordinates = Coordinates( | |
| mapKitManager?.selectedMarker?.position!!.latitude, | |
| mapKitManager?.selectedMarker?.position!!.longitude | |
| ) | |
| val routeDirection = | |
| RouteDirection(origin = originCoordinates, destination = destinationCoordinates) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private suspend fun getNearbyHealthInstitutions(radius: Meter = DEFAULT_KM_RADIUS): List<Site> { | |
| return CoroutineScope(Dispatchers.IO).async { | |
| val list = getHealthInstitutions() | |
| val filteredList = list?.filter { it.city == userLocation?.state?.toUpperCase() } | |
| val result = suspendCoroutine<List<Site>> { continuation -> | |
| addNearbyHospitals( | |
| radius = radius, | |
| onEnd = { nearbyHealthInstitutions -> | |
| compareHealthInstitutionLists( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private inline fun addNearbyHospitals(radius: Float, crossinline onEnd: (nearbyHealthInstitutions: List<Site>) -> Unit) { | |
| if (siteKitManager == null) return | |
| val nearbyHealthInstitutions = mutableListOf<Site>() | |
| for (i in 1..SiteKitManager.MAX_PAGE_INDEX) { | |
| Log.i(TAG, "i is $i") | |
| if (siteKitManager!!.isInTheRangeOfMaxResult(pageIndex = i, pageSize = 20)) | |
| siteKitManager?.searchNearby( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (stepList != null) | |
| rotateCameraToCurrentDirection(locationResult.lastLocation, stepList!!) |
OlderNewer