refactor: Destructure maps for more idiomatic code (#388)
This commit is contained in:
parent
fc81e8bad7
commit
355244a8e2
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue