Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Fadel committed Mar 19, 2018
1 parent da885c2 commit 325f5f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 26
Expand Down Expand Up @@ -32,4 +33,3 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

apply plugin: 'kotlin-android-extensions'
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DummyContentProvider : ContentProvider() {
}

override fun onCreate(): Boolean {
// to post message to the mainThread...
MainThreadScheduler.mainThreadHandler = Handler()
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import android.support.test.espresso.Espresso

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

/**
* it post [unit] to run as soon as MainThread become Idle..
*/
fun scheduleWhenIdle(unit: () -> Unit) {
val block: () -> Unit = {
Thread(Runnable {
Thread({
Espresso.onIdle()
mainThreadHandler?.post(unit)
}).start()
Expand All @@ -29,9 +34,12 @@ object MainThreadScheduler {
}
}

/**
* it post [runnable] to run as soon as MainThread become Idle..
*/
fun scheduleWhenIdle(runnable: Runnable) {
val block: () -> Unit = {
Thread(Runnable {
Thread({
Espresso.onIdle()
mainThreadHandler?.post(runnable)
}).start()
Expand Down

0 comments on commit 325f5f2

Please sign in to comment.