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
class AndroidJobsRepositoryImpl( | |
private val jobsCacheDataSource: JobsCacheDataSource, | |
private val remoteDataSource: RemoteDataSource | |
): AndroidJobsRepository |
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
class AndroidJobsRepositoryImpl @Inject constructor( | |
private val serverApi: ServerApi, | |
private val jobsDao: JobsDao, | |
@IoDispatcher | |
private val coroutineDispatcher: CoroutineDispatcher | |
): AndroidJobsRepository |
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
package com.example.mymoduleexample.di | |
@Provides | |
fun provideServerApiWebService( | |
okHttpClient: OkHttpClient, | |
@ApplicationContext context: Context | |
): ServerApi { | |
val moshi = Moshi.Builder() | |
.add(AndroidJobPayloadConverter()) | |
.addLast(KotlinJsonAdapterFactory()) | |
.build() |
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
class AndroidJobPayloadConverter { | |
@WrapperJobsResults | |
@FromJson | |
fun fromJson(json: JobsResults): List<AndroidJob> { | |
return json.jobs | |
} | |
@ToJson | |
fun toJson(@WrapperJobsResults value: List<AndroidJob>): JobsResults { | |
return JobsResults(value) |
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
data class JobsResults( | |
@Json(name = "jobs") val jobs: List<AndroidJob> | |
) |
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
@Retention(AnnotationRetention.RUNTIME) | |
@JsonQualifier | |
annotation class WrapperJobsResults |
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
@GET("/api/android-jobs") | |
@WrapperJobsResults | |
suspend fun fetchJobs(): List<AndroidJob> |
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
fun AndroidJobCache.asExternalModel() = AndroidJob( | |
title = title, | |
experienceTimeRequired = requiredExperienceYears.toString(), | |
native = native, | |
country = country | |
) | |
fun AndroidJob.asCache() = AndroidJobCache( | |
title = title, | |
requiredExperienceYears = experienceTimeRequired.toInt(), |
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
package com.ifucolo.di | |
import dagger.Module | |
import dagger.Provides | |
import dagger.hilt.InstallIn | |
import dagger.hilt.components.SingletonComponent | |
import kotlinx.coroutines.CoroutineDispatcher | |
import kotlinx.coroutines.Dispatchers | |
import javax.inject.Qualifier |
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
//Não esquecer de verificar se é o device utilza Android 5.0 ou mais | |
//se seu app tiver minSdk < 21 | |
val request = reviewManager.requestReviewFlow() | |
request.addOnCompleteListener { result -> | |
if (request.isSuccessful) { | |
// We got the ReviewInfo object | |
val reviewInfo: ReviewInfo = result.result | |
val flow = reviewManager.launchReviewFlow(this, reviewInfo) |