File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
src/main/java/com/mohamedfadel91/mainthreadschedulerlib Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 11apply plugin : ' com.android.library'
22apply plugin : ' kotlin-android'
3+ apply plugin : ' kotlin-android-extensions'
34
45android {
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'
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 */
1012object 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()
You can’t perform that action at this time.
0 commit comments