-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
App open weather api and models to service layer
- Loading branch information
1 parent
897b1e8
commit 5c1ccba
Showing
19 changed files
with
210 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
20 changes: 11 additions & 9 deletions
20
service-di/src/main/java/com/wednesday/template/service/ServiceModule.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
package com.wednesday.template.service | ||
|
||
import com.wednesday.template.service.base.getRetrofit | ||
import com.wednesday.template.service.base.getOpenWeatherRetrofit | ||
import com.wednesday.template.service.base.getRoomDatabase | ||
import com.wednesday.template.service.openWeather.OpenWeatherLocalServiceImpl | ||
import com.wednesday.template.service.room.AndroidTemplateDatabase | ||
import com.wednesday.template.service.weather.WeatherLocalService | ||
import com.wednesday.template.service.weather.WeatherLocalServiceImpl | ||
import com.wednesday.template.service.weather.WeatherRemoteService | ||
import com.wednesday.template.service.weather.OpenWeatherLocalService | ||
import com.wednesday.template.service.weather.OpenWeatherRemoteService | ||
import org.koin.dsl.module | ||
import retrofit2.Retrofit | ||
|
||
val serviceModule = module { | ||
|
||
// Retrofit | ||
single { getRetrofit(get()) } | ||
single { getOpenWeatherRetrofit(get()) } | ||
|
||
// Room | ||
single { getRoomDatabase(get()) } | ||
|
||
// Weather | ||
single { getWeatherRemoteService(get()) } | ||
single<WeatherLocalService> { getWeatherLocalService(get()) } | ||
single<OpenWeatherLocalService> { getWeatherLocalService(get()) } | ||
|
||
// OpenWeather | ||
} | ||
|
||
fun getWeatherLocalService(database: AndroidTemplateDatabase): WeatherLocalServiceImpl { | ||
fun getWeatherLocalService(database: AndroidTemplateDatabase): OpenWeatherLocalServiceImpl { | ||
return database.databaseDao() | ||
} | ||
|
||
fun getWeatherRemoteService(retrofit: Retrofit): WeatherRemoteService { | ||
return retrofit.create(WeatherRemoteService::class.java) | ||
fun getWeatherRemoteService(retrofit: Retrofit): OpenWeatherRemoteService { | ||
return retrofit.create(OpenWeatherRemoteService::class.java) | ||
} |
11 changes: 11 additions & 0 deletions
11
...ntity/src/main/java/com/wednesday/template/service/openWeather/geoCoding/LocalLocation.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.wednesday.template.service.openWeather.geoCoding | ||
|
||
import androidx.room.Entity | ||
|
||
@Entity(tableName = "favorite_locations", primaryKeys = ["lat", "lon"]) | ||
data class LocalLocation( | ||
val country: String, | ||
val lat: Double, | ||
val lon: Double, | ||
val name: String, | ||
) |
19 changes: 19 additions & 0 deletions
19
...tity/src/main/java/com/wednesday/template/service/openWeather/geoCoding/RemoteLocation.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.wednesday.template.service.openWeather.geoCoding | ||
|
||
|
||
import androidx.annotation.Keep | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Keep | ||
@Serializable | ||
data class RemoteLocation( | ||
@SerialName("country") | ||
val country: String, | ||
@SerialName("lat") | ||
val lat: Double, | ||
@SerialName("lon") | ||
val lon: Double, | ||
@SerialName("name") | ||
val name: String, | ||
) |
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
...com/wednesday/template/service/base/retrofit/interceptors/OpenWeatherApiKeyInterceptor.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wednesday.template.service.base.retrofit.interceptors | ||
|
||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
|
||
class OpenWeatherApiKeyInterceptor: Interceptor { | ||
override fun intercept(chain: Interceptor.Chain): Response { | ||
|
||
} | ||
} |
Oops, something went wrong.