Skip to content

Commit 325f5f2

Browse files
committed
update comments
1 parent da885c2 commit 325f5f2

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
34

45
android {
56
compileSdkVersion 26
@@ -32,4 +33,3 @@ dependencies {
3233
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
3334
}
3435

35-
apply plugin: 'kotlin-android-extensions'

library/src/main/java/com/mohamedfadel91/mainthreadschedulerlib/DummyContentProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DummyContentProvider : ContentProvider() {
2323
}
2424

2525
override fun onCreate(): Boolean {
26+
// to post message to the mainThread...
2627
MainThreadScheduler.mainThreadHandler = Handler()
2728
return false
2829
}

library/src/main/java/com/mohamedfadel91/mainthreadschedulerlib/MainThreadScheduler.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ import android.support.test.espresso.Espresso
66

77
/**
88
* Created by fadel on 17/03/18.
9+
* This Class responsible for schedule functions or runnable
10+
* objects to run as soon as MainThread become idle..
911
*/
1012
object MainThreadScheduler {
1113
internal var mainThreadHandler: Handler? = null
1214

15+
/**
16+
* it post [unit] to run as soon as MainThread become Idle..
17+
*/
1318
fun scheduleWhenIdle(unit: () -> Unit) {
1419
val block: () -> Unit = {
15-
Thread(Runnable {
20+
Thread({
1621
Espresso.onIdle()
1722
mainThreadHandler?.post(unit)
1823
}).start()
@@ -29,9 +34,12 @@ object MainThreadScheduler {
2934
}
3035
}
3136

37+
/**
38+
* it post [runnable] to run as soon as MainThread become Idle..
39+
*/
3240
fun scheduleWhenIdle(runnable: Runnable) {
3341
val block: () -> Unit = {
34-
Thread(Runnable {
42+
Thread({
3543
Espresso.onIdle()
3644
mainThreadHandler?.post(runnable)
3745
}).start()

0 commit comments

Comments
 (0)