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 client = HttpClient { install(ExpectSuccess } | |
val endPoint = "https://api.unsplash.com" | |
val client = HttpClient { | |
install(JsonFeature) { | |
serializer = KotlinxSerializer(JSON.nonstrict).apply { | |
setMapper(PhotoResponse::class, PhotoResponse.serializer()) | |
} | |
} | |
install(ExpectSuccess) | |
} |
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
commonMainImplementation "io.ktor:ktor-client-core:$ktor_version" | |
androidMainImplementation "io.ktor:ktor-client-android:$ktor_version" | |
androidMainImplementation "io.ktor:ktor-client-json-jvm:$ktor_version" | |
iosMainImplementation "io.ktor:ktor-client-ios:$ktor_version" | |
iosMainImplementation "io.ktor:ktor-client-json-native:$ktor_version" |
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
commonMainImplementation "io.ktor:ktor-client-core:$ktor_version" | |
androidMainImplementation "io.ktor:ktor-client-android:$ktor_version" | |
androidMainImplementation "io.ktor:ktor-client-json-jvm:$ktor_version" | |
iosMainImplementation "io.ktor:ktor-client-ios:$ktor_version" | |
iosMainImplementation "io.ktor:ktor-client-json-native:$ktor_version" |
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
@Serializable | |
data class PhotoResponse(val id: String, val description: String?, val exif: Exif?, val urls: Urls, val user: User) { | |
@Serializable | |
data class Exif(val make: String?, val model: String?) | |
@Serializable | |
data class Urls(val raw: String, val full: String, val regular: String, val thumb: String) | |
@Serializable |
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
interface PhotoView : BaseView { | |
var isUpdating: Boolean | |
fun onUpdate(data: PhotoResponse) | |
} |
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
interface PhotoActions { | |
fun onRequestData() | |
} | |
class PhotoPresenter( | |
uiContext: CoroutineContext, | |
val view: PhotoView | |
) : CoroutinePresenter(uiContext, view), PhotoActions { | |
val api: PhotoApi by kodein.instance("Api") |
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
commonMainImplementation "org.kodein.di:kodein-di-erased:$kodein_version" |
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
// provide dependency Api | |
bind<PhotoApi>("Api") with provider { | |
val client by kodein.instance<HttpClient>() | |
val clientId by kodein.instance<String>("ClientId") | |
val apiHost by kodein.instance<String>("ApiHost") | |
PhotoApiService(client, apiHost, clientId) | |
} | |
// request dependency Api |
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
sealed class LogLevel { | |
object DEBUG : LogLevel() | |
object INFO : LogLevel() | |
object WARN : LogLevel() | |
object ERROR : LogLevel() | |
} | |
expect fun log(level: LogLevel, tag: String, message: String, error: Throwable) |
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
import platform.Foundation.NSLog | |
actual fun log(level: LogLevel, tag: String, message: String, error: Throwable) = | |
NSLog("[$level]: ($tag), $message, $error") |
OlderNewer