Skip to content

Commit e2c6d5f

Browse files
authored
Kotlin 1.5.0 (#15)
* bump deps * coroutine 1.5.0-RC * replace safeOffer with trySend * format * deps * deps
1 parent ce19f8f commit e2c6d5f

File tree

10 files changed

+34
-27
lines changed

10 files changed

+34
-27
lines changed

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/hoc/flowmvi/App.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class App : Application() {
2525
startKoin {
2626
androidContext(this@App)
2727

28-
androidLogger(level = Level.DEBUG)
28+
// TODO: Koin
29+
androidLogger(level = Level.NONE)
2930

3031
modules(
3132
coreModule,

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ buildscript {
99
gradlePluginPortal()
1010
}
1111
dependencies {
12-
classpath("com.android.tools.build:gradle:4.0.2")
12+
classpath("com.android.tools.build:gradle:4.2.0")
1313
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
14-
classpath("com.diffplug.spotless:spotless-plugin-gradle:5.10.0")
14+
classpath("com.diffplug.spotless:spotless-plugin-gradle:5.12.4")
1515
}
1616
}
1717

buildSrc/src/main/kotlin/deps.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import org.gradle.plugin.use.PluginDependenciesSpec
66
import org.gradle.plugin.use.PluginDependencySpec
77

88
const val ktlintVersion = "0.41.0"
9-
const val kotlinVersion = "1.5.0-M1"
9+
const val kotlinVersion = "1.5.0"
1010

1111
object appConfig {
1212
const val applicationId = "com.hoc.flowmvi"
1313

1414
const val compileSdkVersion = 30
15-
const val buildToolsVersion = "30.0.2"
15+
const val buildToolsVersion = "30.0.3"
1616

1717
const val minSdkVersion = 21
1818
const val targetSdkVersion = 30
@@ -23,11 +23,11 @@ object appConfig {
2323
object deps {
2424
object androidx {
2525
const val appCompat = "androidx.appcompat:appcompat:1.3.0-rc01"
26-
const val coreKtx = "androidx.core:core-ktx:1.6.0-alpha01"
27-
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.0-beta01"
28-
const val recyclerView = "androidx.recyclerview:recyclerview:1.2.0-rc01"
26+
const val coreKtx = "androidx.core:core-ktx:1.6.0-alpha03"
27+
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.0-beta02"
28+
const val recyclerView = "androidx.recyclerview:recyclerview:1.2.0"
2929
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
30-
const val material = "com.google.android.material:material:1.4.0-alpha01"
30+
const val material = "com.google.android.material:material:1.4.0-beta01"
3131
}
3232

3333
object lifecycle {
@@ -46,20 +46,20 @@ object deps {
4646
}
4747

4848
object coroutines {
49-
private const val version = "1.4.3"
49+
private const val version = "1.5.0-RC"
5050

5151
const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
5252
const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
5353
}
5454

5555
object koin {
56-
private const val version = "3.0.1-beta-2"
56+
private const val version = "3.0.1"
5757

5858
const val core = "io.insert-koin:koin-core:$version"
5959
const val android = "io.insert-koin:koin-android:$version"
6060
}
6161

62-
const val coil = "io.coil-kt:coil:1.1.1"
62+
const val coil = "io.coil-kt:coil:1.2.1"
6363

6464
object test {
6565
const val junit = "junit:junit:4.13"

core/src/main/java/com/hoc/flowmvi/core/FlowBinding+Exts+Utils.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import kotlinx.coroutines.CancellationException
1818
import kotlinx.coroutines.Dispatchers
1919
import kotlinx.coroutines.ExperimentalCoroutinesApi
2020
import kotlinx.coroutines.cancel
21-
import kotlinx.coroutines.channels.SendChannel
2221
import kotlinx.coroutines.channels.awaitClose
2322
import kotlinx.coroutines.coroutineScope
2423
import kotlinx.coroutines.delay
@@ -38,14 +37,10 @@ import java.util.concurrent.atomic.AtomicBoolean
3837
import java.util.concurrent.atomic.AtomicReference
3938
import kotlin.coroutines.EmptyCoroutineContext
4039

41-
fun <T> SendChannel<T>.safeOffer(element: T): Boolean {
42-
return runCatching { offer(element) }.getOrDefault(false)
43-
}
44-
4540
@ExperimentalCoroutinesApi
4641
fun EditText.firstChange(): Flow<Unit> {
4742
return callbackFlow {
48-
val listener = doOnTextChanged { _, _, _, _ -> safeOffer(Unit) }
43+
val listener = doOnTextChanged { _, _, _, _ -> trySend(Unit) }
4944
awaitClose {
5045
Dispatchers.Main.dispatch(EmptyCoroutineContext) {
5146
removeTextChangedListener(listener)
@@ -59,7 +54,7 @@ fun EditText.firstChange(): Flow<Unit> {
5954
@CheckResult
6055
fun SwipeRefreshLayout.refreshes(): Flow<Unit> {
6156
return callbackFlow {
62-
setOnRefreshListener { safeOffer(Unit) }
57+
setOnRefreshListener { trySend(Unit) }
6358
awaitClose { setOnRefreshListener(null) }
6459
}
6560
}
@@ -68,7 +63,7 @@ fun SwipeRefreshLayout.refreshes(): Flow<Unit> {
6863
@CheckResult
6964
fun View.clicks(): Flow<View> {
7065
return callbackFlow {
71-
setOnClickListener { safeOffer(it) }
66+
setOnClickListener { trySend(it) }
7267
awaitClose { setOnClickListener(null) }
7368
}
7469
}
@@ -77,7 +72,7 @@ fun View.clicks(): Flow<View> {
7772
@CheckResult
7873
fun EditText.textChanges(): Flow<CharSequence?> {
7974
return callbackFlow<CharSequence?> {
80-
val listener = doOnTextChanged { text, _, _, _ -> safeOffer(text) }
75+
val listener = doOnTextChanged { text, _, _, _ -> trySend(text) }
8176
addTextChangedListener(listener)
8277
awaitClose { removeTextChangedListener(listener) }
8378
}.onStart { emit(text) }

data/src/main/java/com/hoc/flowmvi/data/UserRepositoryImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import kotlinx.coroutines.flow.flow
1919
import kotlinx.coroutines.flow.onEach
2020
import kotlinx.coroutines.flow.scan
2121
import kotlinx.coroutines.withContext
22+
import kotlin.time.Duration
2223
import kotlin.time.ExperimentalTime
2324
import kotlin.time.milliseconds
2425

@@ -44,7 +45,7 @@ internal class UserRepositoryImpl constructor(
4445
return withContext(dispatchers.io) {
4546
retrySuspend(
4647
times = 3,
47-
initialDelay = 500.milliseconds,
48+
initialDelay = Duration.milliseconds(500),
4849
factor = 2.0,
4950
) {
5051
Log.d("###", "[USER_REPO] Retry times=$it")

feature-main/src/main/java/com/hoc/flowmvi/ui/main/MainActivity.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import com.hoc.flowmvi.core.clicks
1616
import com.hoc.flowmvi.core.collectIn
1717
import com.hoc.flowmvi.core.navigator.Navigator
1818
import com.hoc.flowmvi.core.refreshes
19-
import com.hoc.flowmvi.core.safeOffer
2019
import com.hoc.flowmvi.core.toast
2120
import com.hoc.flowmvi.ui.main.databinding.ActivityMainBinding
2221
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -76,7 +75,7 @@ class MainActivity : AppCompatActivity() {
7675
ItemTouchHelper(
7776
SwipeLeftToDeleteCallback(context) cb@{ position ->
7877
val userItem = mainVM.viewState.value.userItems[position]
79-
removeChannel.safeOffer(userItem)
78+
removeChannel.trySend(userItem)
8079
}
8180
).attachToRecyclerView(this)
8281
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

0 commit comments

Comments
 (0)