refactor: Destructure maps for more idiomatic code (#388)

This commit is contained in:
Nik Clayton 2024-01-26 12:32:45 +01:00 committed by GitHub
parent fc81e8bad7
commit 355244a8e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 16 deletions

View File

@ -156,8 +156,8 @@ class EditFilterActivity : BaseActivity() {
}
lifecycleScope.launch {
viewModel.contexts.collect { contexts ->
for (entry in contextSwitches) {
entry.key.isChecked = contexts.contains(entry.value)
for ((key, value) in contextSwitches) {
key.isChecked = contexts.contains(value)
}
}
}

View File

@ -213,9 +213,9 @@ class ClickableSpanTextView @JvmOverloads constructor(
val y = event.y
// If the user has clicked directly on a span then use it, ignoring any overlap
for (entry in spanRects) {
if (!entry.key.contains(x, y)) continue
clickedSpan = entry.value
for ((rect, span) in spanRects) {
if (!rect.contains(x, y)) continue
clickedSpan = span
Timber.v("span click: ${(clickedSpan as URLSpan).url}")
return super.onTouchEvent(event)
}
@ -354,12 +354,12 @@ class ClickableSpanTextView @JvmOverloads constructor(
// showSpanBoundaries is false.
if (BuildConfig.DEBUG && showSpanBoundaries) {
canvas.save()
for (entry in delegateRects) {
canvas.drawRect(entry.key, paddingDebugPaint)
for (rect in delegateRects.keys) {
canvas.drawRect(rect, paddingDebugPaint)
}
for (entry in spanRects) {
canvas.drawRect(entry.key, spanDebugPaint)
for (rect in spanRects.keys) {
canvas.drawRect(rect, spanDebugPaint)
}
canvas.restore()
}

View File

@ -305,11 +305,11 @@ class ServerVersionTest() {
.that(serverVersions.size)
.isGreaterThan(5)
for (entry in serverVersions.entries) {
for (version in entry.value) {
for ((name, versions) in serverVersions.entries) {
for (version in versions) {
val serverKind = ServerKind.from(
NodeInfo.Software(
name = entry.key,
name = name,
version = version,
),
)
@ -323,7 +323,7 @@ class ServerVersionTest() {
version,
)
assertWithMessage("${entry.key} : $version")
assertWithMessage("$name : $version")
.that(result)
.isInstanceOf(Ok::class.java)
}

View File

@ -123,9 +123,9 @@ class InMemorySharedPreferences(
listeners.forEach { it.onSharedPreferenceChanged(sharedPreferences, key) }
}
edits.forEach { entry ->
store[entry.key] = entry.value
listeners.forEach { it.onSharedPreferenceChanged(sharedPreferences, entry.key) }
edits.forEach { (key, value) ->
store[key] = value
listeners.forEach { it.onSharedPreferenceChanged(sharedPreferences, key) }
}
deletes.clear()