Skip to content

Commit 30287e0

Browse files
committed
Make changes to the demo app
1 parent 0941960 commit 30287e0

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

app/build.gradle

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

45
android {
56
compileSdkVersion 27

app/src/main/java/boxresin/test/android_thread_switcher/MainActivity.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.Bundle
44
import android.support.v7.app.AppCompatActivity
55
import android.widget.Toast
66
import boxresin.library.android_thread_switcher.ThreadSwitcher
7+
import kotlinx.android.synthetic.main.activity_main.*
78

89
class MainActivity : AppCompatActivity()
910
{
@@ -12,13 +13,17 @@ class MainActivity : AppCompatActivity()
1213
super.onCreate(savedInstanceState)
1314
setContentView(R.layout.activity_main)
1415

15-
ThreadSwitcher.initialize()
16-
1716
ThreadSwitcher.newChain()
1817
.onWorker { Thread.sleep(2000) }
19-
.onUI { Toast.makeText(this, "Hello.", Toast.LENGTH_SHORT).show() }
18+
.onUI {
19+
Toast.makeText(this, "Hello.", Toast.LENGTH_SHORT).show()
20+
button.text = ":/"
21+
}
2022
.onWorker { Thread.sleep(5000) }
21-
.onUI { Toast.makeText(this, "What's", Toast.LENGTH_SHORT).show() }
23+
.onUI {
24+
Toast.makeText(this, "What's", Toast.LENGTH_SHORT).show()
25+
button.text = ":)"
26+
}
2227
.onWorker { Thread.sleep(1200) }
2328
.onUI { Toast.makeText(this, "your", Toast.LENGTH_SHORT).show() }
2429
.onWorker { Thread.sleep(3000) }

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
tools:context = "boxresin.test.android_thread_switcher.MainActivity">
99

1010
<Button
11+
android:id = "@+id/button"
1112
android:layout_width = "wrap_content"
1213
android:layout_height = "wrap_content"
1314
android:text = "Hello World!"

0 commit comments

Comments
 (0)