Skip to content

Commit cc5669c

Browse files
authored
Merge pull request #12 from phansier/update
Update dependencies versions
2 parents 87166ae + 5737b74 commit cc5669c

29 files changed

Lines changed: 482 additions & 272 deletions

.github/workflows/android.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: set up JDK 1.8
16+
- name: set up JDK 11
1717
uses: actions/setup-java@v1
1818
with:
19-
java-version: 1.8
19+
java-version: 11
2020
- name: Run tests
2121
run: ./gradlew test
2222
- name: Build a library with Gradle

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FlowReactiveNetwork on Coroutines
2-
[![Download](https://img.shields.io/maven-central/v/ru.beryukhov/flowreactivenetwork?versionPrefix=1.0.3) ](https://repo1.maven.org/maven2/ru/beryukhov/flowreactivenetwork/1.0.3/)
3-
[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.4.30-blue.svg)](https://kotlinlang.org)
2+
[![Download](https://img.shields.io/maven-central/v/ru.beryukhov/flowreactivenetwork?versionPrefix=1.0.4) ](https://repo1.maven.org/maven2/ru/beryukhov/flowreactivenetwork/1.0.4/)
3+
[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.5.20-blue.svg)](https://kotlinlang.org)
44

55
[![kotlinweekly](https://img.shields.io/badge/kotlinweekly.net-204-blue.svg)](https://mailchi.mp/kotlinweekly/kotlin-weekly-204)
66
![CI](https://github.com/AndreySBer/FlowReactiveNetwork/workflows/Android%20CI/badge.svg)
@@ -20,7 +20,7 @@ You can depend on the library through Gradle:
2020

2121
```groovy
2222
dependencies {
23-
implementation 'ru.beryukhov:flowreactivenetwork:1.0.3'
23+
implementation 'ru.beryukhov:flowreactivenetwork:1.0.4'
2424
}
2525
// now the library is available in mavenCentral()
2626
allprojects {

artifact-pom-manager.gradle

Lines changed: 0 additions & 100 deletions
This file was deleted.

build.gradle.kts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
buildscript {
2-
val kotlin_version by extra("1.4.30")
3-
val coroutines_version by extra("1.4.2")
4-
val robolectric_version by extra("4.4")
2+
val kotlin_version by extra("1.5.20")
3+
val coroutines_version by extra("1.5.1")
4+
val robolectric_version by extra("4.6.1")
55

66
repositories {
77
google()
88
mavenCentral()
99
}
1010
dependencies {
11-
classpath("com.android.tools.build:gradle:4.1.3")
11+
classpath("com.android.tools.build:gradle:7.0.1")
1212
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
1313
}
1414
}
@@ -17,7 +17,6 @@ allprojects {
1717
repositories {
1818
google()
1919
mavenCentral()
20-
jcenter()
2120
}
2221
}
2322

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ plugins {
33
}
44
repositories {
55
google()
6-
jcenter()
6+
mavenCentral()
77
}

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.8-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

reactiveNetwork/build.gradle.kts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
plugins {
22
id("com.android.library")
33
kotlin("android")
4-
id("maven")
54
}
65

76
android {
8-
compileSdkVersion(29)
7+
compileSdk = 29
98
//testOptions { unitTests { includeAndroidResources = true } }
109

1110
defaultConfig {
12-
minSdkVersion(14)
11+
minSdk = 14
1312
}
1413
compileOptions {
1514
targetCompatibility = JavaVersion.VERSION_1_8
@@ -36,6 +35,10 @@ android {
3635
explicitApi()
3736
}
3837

38+
kotlinOptions {
39+
freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn"
40+
}
41+
3942
dependencies {
4043
val kotlin_version = rootProject.extra["kotlin_version"]
4144
val coroutines_version = rootProject.extra["coroutines_version"]
@@ -45,18 +48,19 @@ android {
4548
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
4649
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
4750

48-
implementation("androidx.annotation:annotation:1.1.0")
51+
implementation("androidx.annotation:annotation:1.2.0")
4952

5053

5154
testImplementation ("org.jetbrains.kotlin:kotlin-test-common:$kotlin_version")
5255
testImplementation ("org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version")
5356

5457
testImplementation ("com.google.truth:truth:1.0.1")
5558
testImplementation ("org.robolectric:robolectric:$robolectric_version")
56-
testImplementation ("io.mockk:mockk:1.10.4")
59+
testImplementation ("io.mockk:mockk:1.12.0")
5760

58-
testImplementation ("at.florianschuster.test:coroutines-test-extensions:0.1.2")
59-
testImplementation ("androidx.test:core:1.3.0")
61+
testImplementation ("org.jetbrains.kotlin:kotlin-test:$kotlin_version")
62+
testImplementation ("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version")
63+
testImplementation ("androidx.test:core:1.4.0")
6064
}
6165

6266
}

reactiveNetwork/src/main/kotlin/ru/beryukhov/reactivenetwork/Preconditions.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ object Preconditions {
5757
*
5858
* @return boolean true if current Android version is Lollipop or higher
5959
*/
60+
@androidx.annotation.ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
6061
fun isAtLeastAndroidLollipop(): Boolean {
6162
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
6263
}
@@ -67,6 +68,7 @@ object Preconditions {
6768
*
6869
* @return boolean true if current Android version is Marshmallow or higher
6970
*/
71+
@androidx.annotation.ChecksSdkIntAtLeast(api = Build.VERSION_CODES.M)
7072
fun isAtLeastAndroidMarshmallow():Boolean {
7173
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
7274
}

reactiveNetwork/src/main/kotlin/ru/beryukhov/reactivenetwork/TickerFlow.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package ru.beryukhov.reactivenetwork
22

3+
import java.util.Timer
4+
import kotlin.concurrent.schedule
35
import kotlinx.coroutines.ExperimentalCoroutinesApi
46
import kotlinx.coroutines.Job
57
import kotlinx.coroutines.channels.awaitClose
68
import kotlinx.coroutines.flow.Flow
79
import kotlinx.coroutines.flow.callbackFlow
8-
import java.util.*
9-
import kotlin.concurrent.schedule
1010

1111
/**
1212
* Creates a flow that produces the first item after the given initial delay and subsequent items with the
@@ -19,7 +19,7 @@ import kotlin.concurrent.schedule
1919
* @param period period between each element in milliseconds.
2020
* @param initialDelay delay after which the first element will be produced (it is equal to [period] by default) in milliseconds.
2121
*/
22-
@ExperimentalCoroutinesApi
22+
@OptIn(ExperimentalCoroutinesApi::class)
2323
internal fun tickerFlow(
2424
period: Long,
2525
initialDelay: Long = period
@@ -29,7 +29,7 @@ internal fun tickerFlow(
2929

3030
val timer = Timer()
3131
timer.schedule(initialDelay, period) {
32-
offer(Unit)
32+
trySend(Unit)
3333
}
3434

3535
awaitClose { timer.cancel() }

reactiveNetwork/src/main/kotlin/ru/beryukhov/reactivenetwork/internet/observing/strategy/SocketInternetObservingStrategy.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package ru.beryukhov.reactivenetwork.internet.observing.strategy
22

3-
import kotlinx.coroutines.ExperimentalCoroutinesApi
3+
import java.io.IOException
4+
import java.net.InetSocketAddress
5+
import java.net.Socket
46
import kotlinx.coroutines.flow.Flow
57
import kotlinx.coroutines.flow.distinctUntilChanged
68
import kotlinx.coroutines.flow.map
79
import ru.beryukhov.reactivenetwork.Preconditions
810
import ru.beryukhov.reactivenetwork.internet.observing.InternetObservingStrategy
911
import ru.beryukhov.reactivenetwork.internet.observing.error.ErrorHandler
1012
import ru.beryukhov.reactivenetwork.tickerFlow
11-
import java.io.IOException
12-
import java.net.InetSocketAddress
13-
import java.net.Socket
1413

1514
/**
1615
* Socket strategy for monitoring connectivity with the Internet.
@@ -21,7 +20,6 @@ class SocketInternetObservingStrategy : InternetObservingStrategy {
2120
return DEFAULT_HOST
2221
}
2322

24-
@ExperimentalCoroutinesApi
2523
override fun observeInternetConnectivity(
2624
initialIntervalInMs: Int,
2725
intervalInMs: Int,
@@ -135,8 +133,7 @@ class SocketInternetObservingStrategy : InternetObservingStrategy {
135133
timeoutInMs: Int,
136134
errorHandler: ErrorHandler
137135
): Boolean {
138-
val isConnected: Boolean
139-
isConnected = try {
136+
return try {
140137
socket.connect(InetSocketAddress(host, port), timeoutInMs)
141138
socket.isConnected
142139
} catch (e: IOException) {
@@ -148,7 +145,6 @@ class SocketInternetObservingStrategy : InternetObservingStrategy {
148145
errorHandler.handleError(exception, "Could not close the socket")
149146
}
150147
}
151-
return isConnected
152148
}
153149

154150
companion object {

0 commit comments

Comments
 (0)