From a6135738a32454fa38a08a06a1aeb4764b046b68 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 May 2021 17:52:53 +0600 Subject: [PATCH] fixes in build --- build.gradle | 2 +- gradle.properties | 3 ++- .../crud/AbstractMutableAndroidCRUDRepo.kt | 6 +++--- .../repos/keyvalue/KeyValueStore.kt | 18 +++++++++++------- .../repos/onetomany/OneToManyAndroidRepo.kt | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 4f15e458e16..c39bf9800a4 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.2' + classpath 'com.android.tools.build:gradle:4.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:$dexcount_version" diff --git a/gradle.properties b/gradle.properties index 4a619fb34ea..8a63f7b156f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,7 @@ kotlin.incremental=true kotlin.incremental.js=true android.useAndroidX=true android.enableJetifier=true +org.gradle.jvmargs=-Xmx2g kotlin_version=1.5.0 kotlin_coroutines_version=1.4.3 @@ -27,7 +28,7 @@ appcompat_version=1.2.0 android_minSdkVersion=19 android_compileSdkVersion=30 -android_buildToolsVersion=30.0.2 +android_buildToolsVersion=30.0.3 dexcount_version=2.0.0 junit_version=4.12 test_ext_junit_version=1.1.2 diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/crud/AbstractMutableAndroidCRUDRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/crud/AbstractMutableAndroidCRUDRepo.kt index ba5861aaad6..fc016c19a5c 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/crud/AbstractMutableAndroidCRUDRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/crud/AbstractMutableAndroidCRUDRepo.kt @@ -50,7 +50,7 @@ abstract class AbstractMutableAndroidCRUDRepo) { val deleted = mutableListOf() helper.blockingWritableTransaction { - ids.forEach { id -> + for (id in ids) { delete(tableName, "$idColumnName=?", arrayOf(id.asId)).also { if (it > 0) { deleted.add(id) @@ -58,8 +58,8 @@ abstract class AbstractMutableAndroidCRUDRepo internal constructor ( init { cachedData ?.let { - sharedPreferences.all.forEach { - if (it.value != null) { - cachedData[it.key] = it.value as Any + for ((key, value) in sharedPreferences.all) { + if (value != null) { + cachedData[key] = value } } sharedPreferences.registerOnSharedPreferenceChangeListener(this) @@ -113,7 +113,7 @@ class KeyValueStore internal constructor ( override suspend fun set(toSet: Map) { sharedPreferences.edit { - toSet.forEach { (k, v) -> + for ((k, v) in toSet) { when(v) { is Int -> putInt(k, v) is Long -> putLong(k, v) @@ -127,16 +127,20 @@ class KeyValueStore internal constructor ( } } } - toSet.forEach { (k, v) -> + for ((k, v) in toSet) { onNewValueChannel.emit(k to v) } } override suspend fun unset(toUnset: List) { sharedPreferences.edit { - toUnset.forEach { remove(it) } + for (item in toUnset) { + remove(item) + } + } + for (it in toUnset) { + _onValueRemovedFlow.emit(it) } - toUnset.forEach { _onValueRemovedFlow.emit(it) } } override suspend fun unsetWithValues(toUnset: List) { diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt index 81c748b172e..bc910985df6 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt @@ -55,7 +55,7 @@ class OneToManyAndroidRepo( override suspend fun add(toAdd: Map>) { val added = mutableListOf>() helper.blockingWritableTransaction { - toAdd.forEach { (k, values) -> + for ((k, values) in toAdd) { values.forEach { v -> insert( tableName,