Skip to content

Commit

Permalink
Clean up warnings. (#1851)
Browse files Browse the repository at this point in the history
* Clean up warnings.

* Spotless.

* Update API.

* Remove warning.

* Fix R8.
  • Loading branch information
colinrtwhite authored Aug 23, 2023
1 parent 891e203 commit 161eaa9
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ allprojects {
}

// Uninstall test APKs after running instrumentation tests.
tasks.whenTaskAdded {
tasks.configureEach {
if (name == "connectedDebugAndroidTest") {
finalizedBy("uninstallDebugAndroidTest")
}
Expand Down
1 change: 0 additions & 1 deletion buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
rootProject.name = "coil"

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
Expand Down
2 changes: 1 addition & 1 deletion coil-base/src/main/java/coil/util/Lifecycles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.lifecycle.LifecycleOwner
import kotlin.coroutines.resume
import kotlinx.coroutines.suspendCancellableCoroutine

/** Suspend until [Lifecycle.getCurrentState] is at least [STARTED] */
/** Suspend until [Lifecycle.currentState] is at least [STARTED] */
@MainThread
internal suspend fun Lifecycle.awaitStarted() {
// Fast path: we're already started.
Expand Down
3 changes: 3 additions & 0 deletions coil-compose-base/api/coil-compose-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public abstract class coil/compose/AsyncImagePainter$State {
public final class coil/compose/AsyncImagePainter$State$Empty : coil/compose/AsyncImagePainter$State {
public static final field $stable I
public static final field INSTANCE Lcoil/compose/AsyncImagePainter$State$Empty;
public fun equals (Ljava/lang/Object;)Z
public fun getPainter ()Landroidx/compose/ui/graphics/painter/Painter;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class coil/compose/AsyncImagePainter$State$Error : coil/compose/AsyncImagePainter$State {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -162,7 +163,7 @@ class AsyncImagePainter internal constructor(
private val drawSize = MutableStateFlow(Size.Zero)

private var painter: Painter? by mutableStateOf(null)
private var alpha: Float by mutableStateOf(DefaultAlpha)
private var alpha: Float by mutableFloatStateOf(DefaultAlpha)
private var colorFilter: ColorFilter? by mutableStateOf(null)

// These fields allow access to the current value
Expand Down Expand Up @@ -309,7 +310,7 @@ class AsyncImagePainter internal constructor(

// Invoke the transition factory and wrap the painter in a `CrossfadePainter` if it returns
// a `CrossfadeTransformation`.
val transition = result.request.transitionFactory.create(FakeTransitionTarget, result)
val transition = result.request.transitionFactory.create(fakeTransitionTarget, result)
if (transition is CrossfadeTransition) {
return CrossfadePainter(
start = previous.painter.takeIf { previous is State.Loading },
Expand Down Expand Up @@ -344,7 +345,7 @@ class AsyncImagePainter internal constructor(
abstract val painter: Painter?

/** The request has not been started. */
object Empty : State() {
data object Empty : State() {
override val painter: Painter? get() = null
}

Expand Down Expand Up @@ -403,7 +404,7 @@ private fun Size.toSizeOrNull() = when {
else -> null
}

private val FakeTransitionTarget = object : TransitionTarget {
private val fakeTransitionTarget = object : TransitionTarget {
override val view get() = throw UnsupportedOperationException()
override val drawable: Drawable? get() = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package coil.compose
import android.os.SystemClock
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.geometry.Size
Expand Down Expand Up @@ -32,11 +34,11 @@ internal class CrossfadePainter(
private val preferExactIntrinsicSize: Boolean,
) : Painter() {

private var invalidateTick by mutableStateOf(0)
private var invalidateTick by mutableIntStateOf(0)
private var startTimeMillis = -1L
private var isDone = false

private var maxAlpha: Float by mutableStateOf(DefaultAlpha)
private var maxAlpha: Float by mutableFloatStateOf(DefaultAlpha)
private var colorFilter: ColorFilter? by mutableStateOf(null)

override val intrinsicSize get() = computeIntrinsicSize()
Expand Down
2 changes: 1 addition & 1 deletion coil-sample-common/src/main/java/sample/common/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import coil.memory.MemoryCache

sealed class Screen {

object List : Screen()
data object List : Screen()

data class Detail(
val image: Image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -121,7 +120,6 @@ private fun AssetTypeButton(
}

@Composable
@OptIn(ExperimentalFoundationApi::class)
private fun ScaffoldContent(
screen: Screen,
onScreenChange: (Screen) -> Unit,
Expand Down Expand Up @@ -163,7 +161,6 @@ private fun DetailScreen(screen: Screen.Detail) {
}

@Composable
@OptIn(ExperimentalFoundationApi::class)
private fun ListScreen(
gridState: LazyStaggeredGridState,
images: List<Image>,
Expand Down
1 change: 0 additions & 1 deletion coil-svg/src/main/java/coil/request/Svgs.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@file:Suppress("UNCHECKED_CAST")
@file:JvmName("Svgs")

package coil.request
Expand Down
1 change: 1 addition & 0 deletions coil-test-internal/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ setupLibraryModule(name = "coil.test.internal")
dependencies {
api(projects.coilBase)
api(libs.androidx.activity)
api(libs.androidx.appcompat.resources)
api(libs.androidx.core)
api(libs.androidx.test.core)
api(libs.androidx.test.junit)
Expand Down
3 changes: 2 additions & 1 deletion coil-test-internal/src/main/java/coil/util/Bitmaps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package coil.util
import android.graphics.Bitmap
import androidx.annotation.DrawableRes
import androidx.annotation.FloatRange
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.graphics.alpha
import androidx.core.graphics.blue
import androidx.core.graphics.drawable.toBitmap
Expand Down Expand Up @@ -124,5 +125,5 @@ fun Bitmap.assertIsSimilarTo(
@FloatRange(from = -1.0, to = 1.0) threshold: Double = 0.99
) {
val context = InstrumentationRegistry.getInstrumentation().targetContext
assertIsSimilarTo(context.getDrawable(expected)!!.toBitmap(), threshold)
assertIsSimilarTo(AppCompatResources.getDrawable(context, expected)!!.toBitmap(), threshold)
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
org.gradle.jvmargs=-Xmx6g -Dfile.encoding=UTF-8

# Android
android.suppressUnsupportedCompileSdk=34
android.useAndroidX=true

# https://kotlinlang.org/docs/code-style-migration-guide.html#in-gradle
Expand Down

0 comments on commit 161eaa9

Please sign in to comment.