Skip to content

Commit

Permalink
Update dependency com.diffplug.spotless:spotless-plugin-gradle to v6.…
Browse files Browse the repository at this point in the history
…25.0 (#2400)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
renovate[bot] authored May 28, 2024
1 parent 98306ee commit 91695e2
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 68 deletions.
11 changes: 9 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ root = true

[*]
indent_size = 2
end_of_line = lf
indent_style = space
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.{kt,kts}]
[*.{kt, kts}]
ktlint_code_style = intellij_idea
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,kotlinx.**,^
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false

ktlint_standard_argument-list-wrapping = disabled
ktlint_function_naming_ignore_when_annotated_with = Composable
11 changes: 2 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,8 @@ subprojects {
kotlin {
target('**/*.kt')
licenseHeaderFile(rootProject.file('gradle/license-header.txt'))
// Spotless doesn't read .editorconfig yet: https://github.com/diffplug/spotless/issues/142
ktlint('0.46.1').editorConfigOverride([
'insert_final_newline': 'true',
'end_of_line': 'lf',
'charset': 'utf-8',
'indent_size': '2',
'trim_trailing_whitespace': 'true',
'ij_kotlin_imports_layout': '*,java.**,javax.**,kotlin.**,kotlinx.**,^'
])
ktlint(libs.versions.ktlint.get())
.setEditorConfigPath(rootProject.file(".editorconfig"))
}
}

Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ composeCompiler = '1.5.14'
composeUi = '1.6.7'
javaTarget = '1.8'
kotlin = '1.9.24'
ktlint = '1.2.1'
okhttp = '4.12.0'
okio = '3.2.0'
paparazzi = '1.3.4'
Expand Down Expand Up @@ -54,5 +55,5 @@ plugin-binaryCompatibilityValidator = { module = "org.jetbrains.kotlinx:binary-c
plugin-kotlin = { module = 'org.jetbrains.kotlin:kotlin-gradle-plugin', version.ref = 'kotlin' }
plugin-paparazzi = { module = 'app.cash.paparazzi:paparazzi-gradle-plugin', version.ref = 'paparazzi' }
plugin-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version = '0.28.0' }
plugin-spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = '6.18.0' }
plugin-spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = '6.25.0' }
plugin-test-aggregation = { module = "io.github.gmazzo.test.aggregation:plugin", version = '2.2.0' }
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class SampleContactsActivity : PicassoSampleActivity(), LoaderCallbacks<Cursor>
null,
ContactsQuery.SORT_ORDER
)
} else throw RuntimeException("this shouldn't happen")
} else {
throw RuntimeException("this shouldn't happen")
}
}

override fun onLoadFinished(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class PlatformLruCacheTest {
// The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
private val A = Bitmap.createBitmap(1, 1, ALPHA_8)
private val B = Bitmap.createBitmap(1, 1, ALPHA_8)
private val C = Bitmap.createBitmap(1, 1, ALPHA_8)
private val D = Bitmap.createBitmap(1, 1, ALPHA_8)
private val E = Bitmap.createBitmap(1, 1, ALPHA_8)
private val bitmapA = Bitmap.createBitmap(1, 1, ALPHA_8)
private val bitmapB = Bitmap.createBitmap(1, 1, ALPHA_8)
private val bitmapC = Bitmap.createBitmap(1, 1, ALPHA_8)
private val bitmapD = Bitmap.createBitmap(1, 1, ALPHA_8)
private val bitmapE = Bitmap.createBitmap(1, 1, ALPHA_8)

private var expectedPutCount = 0
private var expectedHitCount = 0
Expand All @@ -40,55 +40,55 @@ class PlatformLruCacheTest {
val cache = PlatformLruCache(3)
assertStatistics(cache)

cache["a"] = A
cache["a"] = bitmapA
expectedPutCount++
assertStatistics(cache)
assertHit(cache, "a", A)
assertHit(cache, "a", bitmapA)

cache["b"] = B
cache["b"] = bitmapB
expectedPutCount++
assertStatistics(cache)
assertHit(cache, "a", A)
assertHit(cache, "b", B)
assertSnapshot(cache, "a", A, "b", B)
assertHit(cache, "a", bitmapA)
assertHit(cache, "b", bitmapB)
assertSnapshot(cache, "a", bitmapA, "b", bitmapB)

cache["c"] = C
cache["c"] = bitmapC
expectedPutCount++
assertStatistics(cache)
assertHit(cache, "a", A)
assertHit(cache, "b", B)
assertHit(cache, "c", C)
assertSnapshot(cache, "a", A, "b", B, "c", C)
assertHit(cache, "a", bitmapA)
assertHit(cache, "b", bitmapB)
assertHit(cache, "c", bitmapC)
assertSnapshot(cache, "a", bitmapA, "b", bitmapB, "c", bitmapC)

cache["d"] = D
cache["d"] = bitmapD
expectedPutCount++
expectedEvictionCount++ // a should have been evicted
assertStatistics(cache)
assertMiss(cache, "a")
assertHit(cache, "b", B)
assertHit(cache, "c", C)
assertHit(cache, "d", D)
assertHit(cache, "b", B)
assertHit(cache, "c", C)
assertSnapshot(cache, "d", D, "b", B, "c", C)

cache["e"] = E
assertHit(cache, "b", bitmapB)
assertHit(cache, "c", bitmapC)
assertHit(cache, "d", bitmapD)
assertHit(cache, "b", bitmapB)
assertHit(cache, "c", bitmapC)
assertSnapshot(cache, "d", bitmapD, "b", bitmapB, "c", bitmapC)

cache["e"] = bitmapE
expectedPutCount++
expectedEvictionCount++ // d should have been evicted
assertStatistics(cache)
assertMiss(cache, "d")
assertMiss(cache, "a")
assertHit(cache, "e", E)
assertHit(cache, "b", B)
assertHit(cache, "c", C)
assertSnapshot(cache, "e", E, "b", B, "c", C)
assertHit(cache, "e", bitmapE)
assertHit(cache, "b", bitmapB)
assertHit(cache, "c", bitmapC)
assertSnapshot(cache, "e", bitmapE, "b", bitmapB, "c", bitmapC)
}

@Test fun evictionWithSingletonCache() {
val cache = PlatformLruCache(1)
cache["a"] = A
cache["b"] = B
assertSnapshot(cache, "b", B)
cache["a"] = bitmapA
cache["b"] = bitmapB
assertSnapshot(cache, "b", bitmapB)
}

/**
Expand All @@ -98,29 +98,29 @@ class PlatformLruCacheTest {
@Test fun putCauseEviction() {
val cache = PlatformLruCache(3)

cache["a"] = A
cache["b"] = B
cache["c"] = C
cache["b"] = D
assertSnapshot(cache, "a", A, "c", C, "b", D)
cache["a"] = bitmapA
cache["b"] = bitmapB
cache["c"] = bitmapC
cache["b"] = bitmapD
assertSnapshot(cache, "a", bitmapA, "c", bitmapC, "b", bitmapD)
}

@Test fun evictAll() {
val cache = PlatformLruCache(4)
cache["a"] = A
cache["b"] = B
cache["c"] = C
cache["a"] = bitmapA
cache["b"] = bitmapB
cache["c"] = bitmapC
cache.clear()
assertThat(cache.cache.snapshot()).isEmpty()
}

@Test fun clearPrefixedKey() {
val cache = PlatformLruCache(3)

cache["Hello\nAlice!"] = A
cache["Hello\nBob!"] = B
cache["Hello\nEve!"] = C
cache["Hellos\nWorld!"] = D
cache["Hello\nAlice!"] = bitmapA
cache["Hello\nBob!"] = bitmapB
cache["Hello\nEve!"] = bitmapC
cache["Hellos\nWorld!"] = bitmapD

cache.clearKeyUri("Hello")
assertThat(cache.cache.snapshot()).hasSize(1)
Expand All @@ -129,7 +129,7 @@ class PlatformLruCacheTest {

@Test fun invalidate() {
val cache = PlatformLruCache(3)
cache["Hello\nAlice!"] = A
cache["Hello\nAlice!"] = bitmapA
assertThat(cache.size()).isEqualTo(1)
cache.clearKeyUri("Hello")
assertThat(cache.size()).isEqualTo(0)
Expand Down
7 changes: 6 additions & 1 deletion picasso/src/main/java/com/squareup/picasso3/BitmapHunter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ internal open class BitmapHunter(
}

fun cancel(): Boolean =
action == null && actions.isNullOrEmpty() && future?.cancel(false) ?: job?.let { it.cancel(); true } ?: false
action == null && actions.isNullOrEmpty() && future?.cancel(false)
?: job?.let {
it.cancel()
true
}
?: false

fun shouldRetry(airplaneMode: Boolean, info: NetworkInfo?): Boolean {
val hasRetries = retryCount > 0
Expand Down
4 changes: 3 additions & 1 deletion picasso/src/main/java/com/squareup/picasso3/BitmapUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ internal object BitmapUtils {
inPreferredConfig = data.config
}
}
} else null
} else {
null
}
}

fun requiresInSampleSize(options: BitmapFactory.Options?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal class MediaStoreRequestHandler(context: Context) : ContentStreamRequest
internal enum class PicassoKind(val androidKind: Int, val width: Int, val height: Int) {
MICRO(MediaStore.Images.Thumbnails.MICRO_KIND, 96, 96),
MINI(MediaStore.Images.Thumbnails.MINI_KIND, 512, 384),
FULL(MediaStore.Images.Thumbnails.FULL_SCREEN_KIND, -1, -1);
FULL(MediaStore.Images.Thumbnails.FULL_SCREEN_KIND, -1, -1)
}

companion object {
Expand Down
6 changes: 4 additions & 2 deletions picasso/src/main/java/com/squareup/picasso3/Picasso.kt
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ class Picasso internal constructor(
internal fun resumeAction(action: Action) {
val bitmap = if (shouldReadFromMemoryCache(action.request.memoryPolicy)) {
quickMemoryCacheCheck(action.request.key)
} else null
} else {
null
}

if (bitmap != null) {
// Resumed action is cached, complete immediately.
Expand Down Expand Up @@ -816,7 +818,7 @@ class Picasso internal constructor(
enum class LoadedFrom(@get:JvmName("-debugColor") internal val debugColor: Int) {
MEMORY(Color.GREEN),
DISK(Color.BLUE),
NETWORK(Color.RED);
NETWORK(Color.RED)
}

internal companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal class PicassoDrawable(
var placeholder: Drawable? = null
var startTimeMillis: Long = 0
var animating = false
private var _alpha = 0xFF
private var alpha = 0xFF

init {
val fade = loadedFrom != MEMORY && !noFade
Expand All @@ -70,10 +70,10 @@ internal class PicassoDrawable(
}

// setAlpha will call invalidateSelf and drive the animation.
val partialAlpha = (_alpha * normalized).toInt()
val partialAlpha = (alpha * normalized).toInt()
super.setAlpha(partialAlpha)
super.draw(canvas)
super.setAlpha(_alpha)
super.setAlpha(alpha)
}
}

Expand All @@ -83,7 +83,7 @@ internal class PicassoDrawable(
}

override fun setAlpha(alpha: Int) {
this._alpha = alpha
this.alpha = alpha
if (placeholder != null) {
placeholder!!.alpha = alpha
}
Expand Down
2 changes: 1 addition & 1 deletion picasso/src/main/java/com/squareup/picasso3/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal object Utils {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 'W' | 'E' | 'B' | 'P' |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
*/
private val WEBP_FILE_HEADER_RIFF: ByteString = "RIFF".encodeUtf8()
private val WEBP_FILE_HEADER_WEBP: ByteString = "WEBP".encodeUtf8()

Expand Down

0 comments on commit 91695e2

Please sign in to comment.