Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to snapshot 6953474. #134

Merged
merged 5 commits into from Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -57,7 +57,7 @@ object Libs {
}

object Compose {
const val snapshot = "6943980"
const val snapshot = "6953474"
const val version = "1.0.0-SNAPSHOT"

@JvmStatic
Expand Down
5 changes: 3 additions & 2 deletions coil/api/coil.api
@@ -1,7 +1,7 @@
public final class dev/chrisbanes/accompanist/coil/CoilImage {
public static final fun CoilImage (Lcoil/request/ImageRequest;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;ZLkotlin/jvm/functions/Function2;Lcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImage (Lcoil/request/ImageRequest;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;ZLkotlin/jvm/functions/Function2;Lcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V
public static final fun CoilImage (Lcoil/request/ImageRequest;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImage (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;ZLkotlin/jvm/functions/Function2;Lcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImage (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;ZLkotlin/jvm/functions/Function2;Lcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V
public static final fun CoilImage (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImageWithCrossfade (Lcoil/request/ImageRequest;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;ILcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImageWithCrossfade (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;ILcoil/ImageLoader;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
Expand All @@ -12,6 +12,7 @@ public final class dev/chrisbanes/accompanist/coil/CoilImage {
}

public final class dev/chrisbanes/accompanist/coil/CoilImageConstants {
public static final field $stable I
public static final field INSTANCE Ldev/chrisbanes/accompanist/coil/CoilImageConstants;
public final fun defaultImageLoader (Landroidx/compose/runtime/Composer;I)Lcoil/ImageLoader;
}
Expand Down
1 change: 1 addition & 0 deletions coil/build.gradle
Expand Up @@ -100,6 +100,7 @@ dependencies {

androidTestImplementation Libs.AndroidX.Compose.test
androidTestImplementation Libs.AndroidX.Compose.ui
androidTestImplementation Libs.AndroidX.Compose.material
androidTestImplementation Libs.AndroidX.Test.rules
androidTestImplementation Libs.AndroidX.Test.runner
}
Expand Down
Expand Up @@ -17,12 +17,13 @@
package dev.chrisbanes.accompanist.coil

import androidx.compose.foundation.Image
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.material.Text
import androidx.compose.runtime.Providers
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.platform.ContextAmbient
import androidx.compose.ui.platform.testTag
Expand All @@ -32,7 +33,7 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertPixels
import androidx.compose.ui.test.assertWidthIsAtLeast
import androidx.compose.ui.test.assertWidthIsEqualTo
import androidx.compose.ui.test.captureToBitmap
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
Expand Down Expand Up @@ -165,7 +166,7 @@ class CoilTest {
}

@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun basicLoad_drawable() {
val latch = CountDownLatch(1)

Expand All @@ -180,11 +181,13 @@ class CoilTest {
// Wait for the onRequestCompleted to release the latch
latch.await(5, TimeUnit.SECONDS)

@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(CoilTestTags.Image)
.assertWidthIsEqualTo(128.dp)
.assertHeightIsEqualTo(128.dp)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Red }
}

Expand Down Expand Up @@ -259,7 +262,7 @@ class CoilTest {

@OptIn(ExperimentalCoroutinesApi::class)
@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun basicLoad_switchData() {
val loadCompleteSignal = Channel<Unit>(Channel.UNLIMITED)
val data = MutableStateFlow(server.url("/red"))
Expand All @@ -277,11 +280,13 @@ class CoilTest {
loadCompleteSignal.awaitNext(5, TimeUnit.SECONDS)

// Assert that the content is completely Red
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(CoilTestTags.Image)
.assertWidthIsEqualTo(128.dp)
.assertHeightIsEqualTo(128.dp)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Red }

// Now switch the data URI to the blue drawable
Expand All @@ -291,11 +296,13 @@ class CoilTest {
loadCompleteSignal.awaitNext(5, TimeUnit.SECONDS)

// Assert that the content is completely Blue
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(CoilTestTags.Image)
.assertWidthIsEqualTo(128.dp)
.assertHeightIsEqualTo(128.dp)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Blue }

// Close the signal channel
Expand Down Expand Up @@ -436,7 +443,7 @@ class CoilTest {
}

@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun content_custom() {
val latch = CountDownLatch(1)

Expand All @@ -455,9 +462,11 @@ class CoilTest {
latch.await(5, TimeUnit.SECONDS)

// Assert that the whole layout is drawn cyan
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(CoilTestTags.Image)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Cyan }
}

Expand Down Expand Up @@ -505,7 +514,7 @@ class CoilTest {
}

@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun error_slot() {
val latch = CountDownLatch(1)

Expand All @@ -525,9 +534,11 @@ class CoilTest {
latch.await(5, TimeUnit.SECONDS)

// Assert that the whole layout is drawn red
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(CoilTestTags.Image)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Red }
}
}
Expand Down
3 changes: 2 additions & 1 deletion glide/api/glide.api
@@ -1,10 +1,11 @@
public final class dev/chrisbanes/accompanist/glide/GlideImage {
public static final fun GlideImage (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;ZLkotlin/jvm/functions/Function2;Lcom/bumptech/glide/RequestManager;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun GlideImage (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;ZLkotlin/jvm/functions/Function2;Lcom/bumptech/glide/RequestManager;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V
public static final fun GlideImage (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/bumptech/glide/RequestManager;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
public static final fun getAmbientRequestManager ()Landroidx/compose/runtime/ProvidableAmbient;
}

public final class dev/chrisbanes/accompanist/glide/GlideImageConstants {
public static final field $stable I
public static final field INSTANCE Ldev/chrisbanes/accompanist/glide/GlideImageConstants;
public final fun defaultRequestManager (Landroidx/compose/runtime/Composer;I)Lcom/bumptech/glide/RequestManager;
}
Expand Down
1 change: 1 addition & 0 deletions glide/build.gradle
Expand Up @@ -97,6 +97,7 @@ dependencies {

androidTestImplementation Libs.AndroidX.Compose.test
androidTestImplementation Libs.AndroidX.Compose.ui
androidTestImplementation Libs.AndroidX.Compose.material
androidTestImplementation Libs.AndroidX.Test.rules
androidTestImplementation Libs.AndroidX.Test.runner
}
Expand Down
Expand Up @@ -18,13 +18,14 @@ package dev.chrisbanes.accompanist.glide

import android.graphics.drawable.Drawable
import androidx.compose.foundation.Image
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.material.Text
import androidx.compose.runtime.Providers
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.onCommit
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.platform.ViewAmbient
import androidx.compose.ui.platform.testTag
Expand All @@ -34,7 +35,7 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertPixels
import androidx.compose.ui.test.assertWidthIsAtLeast
import androidx.compose.ui.test.assertWidthIsEqualTo
import androidx.compose.ui.test.captureToBitmap
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
Expand Down Expand Up @@ -160,7 +161,7 @@ class GlideTest {
}

@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun basicLoad_drawable() {
val latch = CountDownLatch(1)

Expand All @@ -175,17 +176,19 @@ class GlideTest {
// Wait for the onRequestCompleted to release the latch
latch.await(5, TimeUnit.SECONDS)

@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(GlideTestTags.Image)
.assertWidthIsEqualTo(128.dp)
.assertHeightIsEqualTo(128.dp)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Red }
}

@OptIn(ExperimentalCoroutinesApi::class)
@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun basicLoad_switchData() {
val loadCompleteSignal = Channel<Unit>(Channel.UNLIMITED)
val data = MutableStateFlow(server.url("/red"))
Expand All @@ -203,11 +206,13 @@ class GlideTest {
loadCompleteSignal.awaitNext(5, TimeUnit.SECONDS)

// Assert that the content is completely Red
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(GlideTestTags.Image)
.assertWidthIsEqualTo(128.dp)
.assertHeightIsEqualTo(128.dp)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Red }

// Now switch the data URI to the blue drawable
Expand All @@ -217,11 +222,13 @@ class GlideTest {
loadCompleteSignal.awaitNext(5, TimeUnit.SECONDS)

// Assert that the content is completely Blue
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(GlideTestTags.Image)
.assertWidthIsEqualTo(128.dp)
.assertHeightIsEqualTo(128.dp)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Blue }

// Close the signal channel
Expand Down Expand Up @@ -417,7 +424,7 @@ class GlideTest {
}

@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun content_custom() {
val latch = CountDownLatch(1)

Expand All @@ -436,9 +443,11 @@ class GlideTest {
latch.await(5, TimeUnit.SECONDS)

// Assert that the whole layout is drawn cyan
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(GlideTestTags.Image)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Cyan }
}

Expand Down Expand Up @@ -478,7 +487,7 @@ class GlideTest {
}

@Test
@SdkSuppress(minSdkVersion = 26) // captureToBitmap is SDK 26+
@SdkSuppress(minSdkVersion = 26) // captureToImage is SDK 26+
fun error_slot() {
val latch = CountDownLatch(1)

Expand All @@ -498,9 +507,11 @@ class GlideTest {
latch.await(5, TimeUnit.SECONDS)

// Assert that the whole layout is drawn red
@Suppress("DEPRECATION")
composeTestRule.onNodeWithTag(GlideTestTags.Image)
.assertIsDisplayed()
.captureToBitmap()
.captureToImage()
.asAndroidBitmap()
.assertPixels { Color.Red }
}
}
7 changes: 7 additions & 0 deletions imageloading-core/api/imageloading-core.api
@@ -1,4 +1,5 @@
public final class dev/chrisbanes/accompanist/imageloading/AndroidDrawablePainter : androidx/compose/ui/graphics/painter/Painter {
public static final field $stable I
public fun <init> (Landroid/graphics/drawable/Drawable;)V
public fun getIntrinsicSize-NH-jbRc ()J
}
Expand All @@ -22,13 +23,16 @@ public final class dev/chrisbanes/accompanist/imageloading/ImageLoad {
}

public abstract class dev/chrisbanes/accompanist/imageloading/ImageLoadState {
public static final field $stable I
}

public final class dev/chrisbanes/accompanist/imageloading/ImageLoadState$Empty : dev/chrisbanes/accompanist/imageloading/ImageLoadState {
public static final field $stable I
public static final field INSTANCE Ldev/chrisbanes/accompanist/imageloading/ImageLoadState$Empty;
}

public final class dev/chrisbanes/accompanist/imageloading/ImageLoadState$Error : dev/chrisbanes/accompanist/imageloading/ImageLoadState {
public static final field $stable I
public fun <init> (Landroidx/compose/ui/graphics/painter/Painter;Ljava/lang/Throwable;)V
public synthetic fun <init> (Landroidx/compose/ui/graphics/painter/Painter;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Landroidx/compose/ui/graphics/painter/Painter;
Expand All @@ -43,10 +47,12 @@ public final class dev/chrisbanes/accompanist/imageloading/ImageLoadState$Error
}

public final class dev/chrisbanes/accompanist/imageloading/ImageLoadState$Loading : dev/chrisbanes/accompanist/imageloading/ImageLoadState {
public static final field $stable I
public static final field INSTANCE Ldev/chrisbanes/accompanist/imageloading/ImageLoadState$Loading;
}

public final class dev/chrisbanes/accompanist/imageloading/ImageLoadState$Success : dev/chrisbanes/accompanist/imageloading/ImageLoadState {
public static final field $stable I
public fun <init> (Landroidx/compose/ui/graphics/painter/Painter;Ldev/chrisbanes/accompanist/imageloading/DataSource;)V
public final fun component1 ()Landroidx/compose/ui/graphics/painter/Painter;
public final fun component2 ()Ldev/chrisbanes/accompanist/imageloading/DataSource;
Expand All @@ -60,6 +66,7 @@ public final class dev/chrisbanes/accompanist/imageloading/ImageLoadState$Succes
}

public final class dev/chrisbanes/accompanist/imageloading/ImageLoadingColorMatrix : android/graphics/ColorMatrix {
public static final field $stable I
public fun <init> ()V
public fun <init> (FFF)V
public synthetic fun <init> (FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.referentialEqualityPolicy
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.stateFor
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.WithConstraints
import androidx.compose.ui.unit.IntSize
Expand Down Expand Up @@ -68,12 +67,14 @@ fun <R : Any, TR : Any> ImageLoad(
onRequestCompleted: (ImageLoadState) -> Unit = EmptyRequestCompleteLambda,
content: @Composable (imageLoadState: ImageLoadState) -> Unit
) {
var state by stateFor<ImageLoadState>(requestKey) { ImageLoadState.Empty }
var state by remember(requestKey) {
mutableStateOf<ImageLoadState>(ImageLoadState.Empty)
}

// This may look a little weird, but allows the launchInComposition callback to always
// This may look a little weird, but allows the LaunchedEffect callback to always
// invoke the last provided [onRequestCompleted].
//
// If a composition happens *after* launchInComposition has launched, the given
// If a composition happens *after* LaunchedEffect has launched, the given
// [onRequestCompleted] might have changed. If the actor lambda below directly referenced
// [onRequestCompleted] it would have captured access to the initial onRequestCompleted
// value, not the latest.
Expand Down