Skip to content

Commit

Permalink
Merge pull request #364 from skydoves/improve/types
Browse files Browse the repository at this point in the history
Change the data object types and stabilities for Compose
  • Loading branch information
skydoves authored Nov 7, 2023
2 parents 6b6618f + 7fde1d3 commit 2e2e380
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 13 deletions.
6 changes: 6 additions & 0 deletions coil/api/coil.api
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ public final class com/skydoves/landscapist/coil/CoilImageState$Failure : com/sk
public final class com/skydoves/landscapist/coil/CoilImageState$Loading : com/skydoves/landscapist/coil/CoilImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/coil/CoilImageState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil/CoilImageState$None : com/skydoves/landscapist/coil/CoilImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/coil/CoilImageState$None;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil/CoilImageState$Success : com/skydoves/landscapist/coil/CoilImageState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public sealed class CoilImageState : ImageState {

/** Request not started. */
@Immutable
public object None : CoilImageState()
public data object None : CoilImageState()

/** Request is currently in progress. */
@Immutable
public object Loading : CoilImageState()
public data object Loading : CoilImageState()

/** Request is completed successfully and ready to use an [ImageBitmap]. */
@Immutable
Expand Down
6 changes: 6 additions & 0 deletions fresco/api/fresco.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ public final class com/skydoves/landscapist/fresco/FrescoImageState$Failure : co
public final class com/skydoves/landscapist/fresco/FrescoImageState$Loading : com/skydoves/landscapist/fresco/FrescoImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/fresco/FrescoImageState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/fresco/FrescoImageState$None : com/skydoves/landscapist/fresco/FrescoImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/fresco/FrescoImageState$None;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/fresco/FrescoImageState$Success : com/skydoves/landscapist/fresco/FrescoImageState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public sealed class FrescoImageState : ImageState {

/** Request not started. */
@Immutable
public object None : FrescoImageState()
public data object None : FrescoImageState()

/** Request is currently in progress. */
@Immutable
public object Loading : FrescoImageState()
public data object Loading : FrescoImageState()

/** Request is completed successfully and ready to use an [ImageBitmap]. */
@Immutable
Expand Down
6 changes: 6 additions & 0 deletions glide/api/glide.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ public final class com/skydoves/landscapist/glide/GlideImageState$Failure : com/
public final class com/skydoves/landscapist/glide/GlideImageState$Loading : com/skydoves/landscapist/glide/GlideImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/glide/GlideImageState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/glide/GlideImageState$None : com/skydoves/landscapist/glide/GlideImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/glide/GlideImageState$None;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/glide/GlideImageState$Success : com/skydoves/landscapist/glide/GlideImageState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public sealed class GlideImageState : ImageState {

/** Request not started. */
@Immutable
public object None : GlideImageState()
public data object None : GlideImageState()

/** Request is currently in progress. */
@Immutable
public object Loading : GlideImageState()
public data object Loading : GlideImageState()

/** Request is completed successfully and ready to use an [ImageBitmap]. */
@Immutable
Expand Down Expand Up @@ -63,6 +63,7 @@ public fun ImageLoadState.toGlideImageState(glideRequestType: GlideRequestType):
dataSource = dataSource,
glideRequestType = glideRequestType,
)

is ImageLoadState.Failure -> GlideImageState.Failure(
errorDrawable = data as? Drawable,
reason = reason,
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ androidx-test-runner = { group = "androidx.test", name = "runner", version.ref =
androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidxTestRules" }
androidx-test-junit = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxJunit" }
androidx-test-uiautomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "androidxUiAutomator" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
Expand Down
6 changes: 6 additions & 0 deletions landscapist/api/landscapist.api
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ public final class com/skydoves/landscapist/ImageLoadState$Failure : com/skydove
public final class com/skydoves/landscapist/ImageLoadState$Loading : com/skydoves/landscapist/ImageLoadState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/ImageLoadState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/ImageLoadState$None : com/skydoves/landscapist/ImageLoadState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/ImageLoadState$None;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/ImageLoadState$Success : com/skydoves/landscapist/ImageLoadState {
Expand Down
3 changes: 1 addition & 2 deletions landscapist/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ baselineProfile {
}
}


dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.foundation)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.coroutines.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.view.View
import androidx.compose.runtime.Composable
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -58,7 +59,7 @@ import kotlin.math.roundToInt
internal class DrawablePainter(
val drawable: Drawable,
) : Painter(), RememberObserver {
private var drawInvalidateTick by mutableStateOf(0)
private var drawInvalidateTick by mutableIntStateOf(0)
private var drawableIntrinsicSize by mutableStateOf(drawable.intrinsicSize)

private val callback: Drawable.Callback by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public sealed class ImageLoadState {

/** Request not started. */
@Immutable
public object None : ImageLoadState()
public data object None : ImageLoadState()

/** Request is currently in progress. */
@Immutable
public object Loading : ImageLoadState()
public data object Loading : ImageLoadState()

/** Request is completed successfully and ready to use an [ImageBitmap]. */
@Immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
*/
package com.skydoves.landscapist

import androidx.compose.runtime.Stable

/** The highest level interface of the image loading states. */
@Stable
public interface ImageState
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package com.skydoves.landscapist
AnnotationTarget.FUNCTION,
AnnotationTarget.TYPEALIAS,
)
@Retention(AnnotationRetention.BINARY)
@RequiresOptIn(
message = "This is internal API for the landscapist libraries. Do not depend on " +
"this API in your own client code.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package com.skydoves.landscapist

import androidx.compose.runtime.Stable
import androidx.compose.runtime.Immutable

@Stable
@Immutable
@InternalLandscapistApi
public data class StableHolder<T>(public val value: T)

0 comments on commit 2e2e380

Please sign in to comment.