Skip to content

Commit fb7e893

Browse files
Merge pull request #8 from Omega-R/feature/coroutines_launch_methods
Feature/coroutines launch methods
2 parents 353da7f + d79207c commit fb7e893

File tree

13 files changed

+204
-23
lines changed

13 files changed

+204
-23
lines changed

.idea/codeStyles/Project.xml

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

.idea/compiler.xml

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

.idea/jarRepositories.xml

Lines changed: 45 additions & 0 deletions
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/modules.xml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ Add it in your root build.gradle at the end of repositories:
1616
Step 2. Add the dependency
1717

1818
dependencies {
19-
implementation 'com.github.Omega-R:OmegaExtensions:1.0.1'
19+
implementation 'com.github.Omega-R:OmegaExtensions:1.0.4'
2020
}

app/build.gradle

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
44

55
android {
6-
compileSdkVersion 28
6+
compileSdkVersion 30
77
defaultConfig {
88
applicationId "omega_r.com.extensions.simple"
99
minSdkVersion 14
10-
targetSdkVersion 28
10+
targetSdkVersion 30
1111
versionCode 1
1212
versionName "1.0"
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14+
15+
kotlinOptions.freeCompilerArgs += [
16+
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
17+
"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
18+
"-Xuse-experimental=kotlin.time.ExperimentalTime"]
1419
}
1520
buildTypes {
1621
release {
@@ -22,12 +27,13 @@ android {
2227

2328
dependencies {
2429
implementation fileTree(dir: 'libs', include: ['*.jar'])
30+
implementation project(':extensionslib')
2531
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
2632
implementation "androidx.appcompat:appcompat:$appcompat"
27-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
28-
implementation project(':extensionslib')
33+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
34+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
2935

30-
testImplementation 'junit:junit:4.12'
31-
androidTestImplementation 'androidx.test:runner:1.2.0-alpha03'
32-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha03'
36+
testImplementation 'junit:junit:4.13.1'
37+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
38+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3339
}

app/src/main/java/omega_r/com/extensions/simple/MainActivity.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,50 @@ package omega_r.com.extensions.simple
22

33
import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
5+
import android.util.Log
6+
import com.omega_r.libs.extensions.coroutines.launchDelayed
7+
import com.omega_r.libs.extensions.coroutines.launchWithTicker
8+
import kotlinx.coroutines.CoroutineScope
9+
import kotlinx.coroutines.Dispatchers
10+
import kotlin.time.DurationUnit
11+
import kotlin.time.seconds
512

613
class MainActivity : AppCompatActivity() {
714

815
override fun onCreate(savedInstanceState: Bundle?) {
916
super.onCreate(savedInstanceState)
1017
setContentView(R.layout.activity_main)
18+
19+
CoroutineScope(Dispatchers.Default).apply {
20+
launchDelayed(4900) {
21+
Log.d("MainActivity", "launchDelayed(4900)")
22+
}
23+
launchDelayed(5.seconds) {
24+
Log.d("MainActivity", "launchDelayed(5.seconds)")
25+
}
26+
launchWithTicker(
27+
ticksCount = 10,
28+
tickDurationMillis = 1000,
29+
initialDelayMillis = 5000,
30+
onTick = {
31+
Log.d("MainActivity", "launchWithTicker($it)")
32+
},
33+
onEnd = {
34+
Log.d("MainActivity", "launchWithTicker(end)")
35+
}
36+
)
37+
launchWithTicker(
38+
ticksCount = 10,
39+
tickDuration = 1.seconds,
40+
initialDelay = 15.seconds,
41+
onTick = {
42+
Log.d("MainActivity", "launchWithTicker2($it)")
43+
},
44+
onEnd = {
45+
Log.d("MainActivity", "launchWithTicker2(end)")
46+
}
47+
)
48+
}
1149
}
1250

1351
}

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.30'
5-
ext.appcompat = '1.1.0-alpha04'
4+
ext.kotlin_version = '1.4.10'
5+
ext.appcompat = '1.2.0'
66

77
repositories {
88
google()
99
jcenter()
1010

1111
}
1212
dependencies {
13-
classpath 'com.android.tools.build:gradle:3.3.2'
13+
classpath 'com.android.tools.build:gradle:4.1.1'
1414
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1515
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1616
// NOTE: Do not place your application dependencies here; they belong

extensionslib/build.gradle

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ apply plugin: 'kotlin-android'
33
apply plugin: 'com.github.dcendents.android-maven'
44

55
android {
6-
compileSdkVersion 28
6+
compileSdkVersion 30
77

88
defaultConfig {
99
minSdkVersion 14
10-
targetSdkVersion 28
10+
targetSdkVersion 30
1111
versionCode 1
1212
versionName "1.0"
1313

1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515

16+
kotlinOptions.freeCompilerArgs += [
17+
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
18+
"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
19+
"-Xuse-experimental=kotlin.time.ExperimentalTime"]
1620
}
1721

1822
buildTypes {
@@ -28,9 +32,10 @@ dependencies {
2832
implementation fileTree(dir: 'libs', include: ['*.jar'])
2933
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3034
implementation "androidx.appcompat:appcompat:$appcompat"
31-
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha04'
35+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
36+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
3237

33-
testImplementation 'junit:junit:4.12'
38+
testImplementation 'junit:junit:4.13.1'
3439
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3540
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3641
}

0 commit comments

Comments
 (0)