Skip to content

Instantly share code, notes, and snippets.

View lukaszkalnik's full-sized avatar

Lukasz Kalnik lukaszkalnik

View GitHub Profile
> Task :core:javaDocReleaseGeneration
Initializing plugins
Dokka is performing: documentation for :core
Validity check
Creating documentation models
WARN: The registry key 'java.correct.class.type.by.place.resolve.scope' accessed, but not loaded yet
WARN: Could not read file: /home/automata/.gradle/caches/transforms-4/dcd95f8b56c207691fdd970aa90eef3d/transformed/lottie-compose-6.4.0-api.jar!/com/airbnb/lottie/compose/LottieCompositionSpec.class; size in bytes: 1392; file type: CLASS
java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9
at org.jetbrains.org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266)
sealed class DataState<T> {
sealed class DataMissing : DataState<Nothing>() {
object NotInitialized : DataMissing()
data class Error(cause: Exception) : DataMissing()
}
data class DataLoaded<T>(val data: T) : DataState<T>()
@lukaszkalnik
lukaszkalnik / build.gradle.kts
Created June 6, 2021 18:29
androidApp build.gradle.kts
import com.lukaszkalnik.tmdbapp.gradle.DependenciesPlugin
plugins {
// ... other plugins (android-application etc.)
id("com.lukaszkalnik.tmdbapp.dependencies")
}
dependencies {
implementation("io.insert-koin:koin-core:${DependenciesPlugin.koinVersion}")
// .. other dependencies
@lukaszkalnik
lukaszkalnik / build.gradle.kts
Created June 6, 2021 17:48
Register DependenciesPlugin
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
gradlePlugin {
plugins {
package com.lukaszkalnik.tmdbapp.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
class DependenciesPlugin : Plugin<Project> {
override fun apply(target: Project) {
}
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
coroutineScope.launch {
tmdbApi.getConfiguration().fold(
ifLeft = { apiError -> showError(apiError) },
ifRight = { configuration -> saveConfiguration(configuration) }
)
}
Retrofit.Builder()
.baseUrl("https://api.themoviedb.org/3/")
.addConverterFactory(Json.asConverterFactory(contentType))
.addCallAdapterFactory(EitherCallAdapterFactory())
.build()
.create(TmdbApi::class.java)
internal class EitherCallAdapterFactory : CallAdapter.Factory() {
override fun get(
returnType: Type,
annotations: Array<Annotation>,
retrofit: Retrofit
): CallAdapter<*, *>? {
if (getRawType(returnType) != Call::class.java) return null
check(returnType is ParameterizedType) { "Return type must be a parameterized type." }
private class EitherCallAdapter<R>(
private val successType: Type
) : CallAdapter<R, Call<Either<ApiError, R>>> {
override fun adapt(call: Call<R>): Call<Either<ApiError, R>> = EitherCall(call, successType)
override fun responseType(): Type = successType
}