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
plugins { | |
id 'com.android.application' | |
id 'kotlin-android' | |
id 'kotlin-kapt' | |
id 'dagger.hilt.android.plugin' | |
} | |
android { | |
compileSdkVersion 30 | |
buildToolsVersion "30.0.3" |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
ext.kotlin_version = "1.5.10" | |
repositories { | |
google() | |
mavenCentral() | |
} | |
dependencies { | |
classpath "com.android.tools.build:gradle:4.2.1" | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
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
plugins { | |
id 'com.android.application' | |
id 'kotlin-android' | |
id 'kotlin-kapt' | |
id 'dagger.hilt.android.plugin' | |
} | |
android { | |
compileSdkVersion 30 | |
buildToolsVersion "30.0.3" |
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.cleanarchitectkotlinflowhiltsimplestway.utils | |
import com.cleanarchitectkotlinflowhiltsimplestway.domain.AuthenticationException | |
import com.cleanarchitectkotlinflowhiltsimplestway.domain.NetworkErrorException | |
import com.cleanarchitectkotlinflowhiltsimplestway.domain.State | |
import retrofit2.HttpException | |
import java.net.ConnectException | |
import java.net.SocketTimeoutException | |
import java.net.UnknownHostException |
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.cleanarchitectkotlinflowhiltsimplestway.utils | |
import android.content.Context | |
import com.cleanarchitectkotlinflowhiltsimplestway.data.APIs | |
import com.cleanarchitectkotlinflowhiltsimplestway.presentation.App | |
import com.google.gson.GsonBuilder | |
import dagger.Module | |
import dagger.Provides | |
import dagger.hilt.InstallIn |
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.cleanarchitectkotlinflowhiltsimplestway.data | |
import com.google.gson.JsonObject | |
import retrofit2.http.GET | |
interface APIs { | |
@GET("api/users") | |
suspend fun sampleGet(): JsonObject | |
} |
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.cleanarchitectkotlinflowhiltsimplestway.domain | |
import com.google.gson.JsonObject | |
import com.cleanarchitectkotlinflowhiltsimplestway.data.APIs | |
import javax.inject.Inject | |
class SampleUseCase @Inject constructor( | |
private val apIs: APIs | |
) { | |
suspend operator fun invoke(): JsonObject { |
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.cleanarchitectkotlinflowhiltsimplestway.presentation | |
sealed class State<out T> { | |
object LoadingState : State<Nothing>() | |
data class ErrorState(var exception: Throwable) : State<Nothing>() | |
data class DataState<T>(var data: T) : State<T>() | |
} |
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.cleanarchitectkotlinflowhiltsimplestway.presentation | |
import org.json.JSONObject | |
import retrofit2.HttpException | |
open class NetworkErrorException( | |
val errorCode: Int = -1, | |
val errorMessage: String, | |
val response: String = "" | |
) : Exception() { |
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.cleanarchitectkotlinflowhiltsimplestway.presentation | |
import android.app.Application | |
import dagger.hilt.android.HiltAndroidApp | |
@HiltAndroidApp | |
class App : Application() { | |
override fun onCreate() { | |
super.onCreate() |
OlderNewer