Skip to content

Commit 2a55874

Browse files
committed
Demo: Update
Signed-off-by: Fung <fython@163.com>
1 parent 4ec23b0 commit 2a55874

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

demo/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838
compile project(':kotlinyan-recyclerview-support')
3939
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
4040
compile "org.jetbrains.anko:anko:0.10.1"
41+
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
4142
}
4243
repositories {
4344
mavenCentral()
@@ -47,3 +48,5 @@ kotlin {
4748
coroutines "enable"
4849
}
4950
}
51+
buildscript {
52+
}

demo/src/main/kotlin/moe/feng/kotlinyan/ActivityExtDemoFragment.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package moe.feng.kotlinyan
22

33
import android.app.Fragment
4+
import android.content.Intent
45
import android.os.Bundle
56
import android.support.design.widget.Snackbar
7+
import android.util.Log
68
import android.view.LayoutInflater
79
import android.view.View
810
import android.view.ViewGroup
@@ -14,6 +16,12 @@ import org.jetbrains.anko.toast
1416

1517
class ActivityExtDemoFragment : Fragment(), AndroidExtensions, AppCompatExtensions, SupportDesignExtensions {
1618

19+
companion object {
20+
21+
val TAG = ActivityExtDemoFragment::class.simpleName
22+
23+
}
24+
1725
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View
1826
= inflater.inflate(R.layout.fragment_activity_ext, container, false)
1927

@@ -62,6 +70,13 @@ class ActivityExtDemoFragment : Fragment(), AndroidExtensions, AppCompatExtensio
6270
}
6371
}.show()
6472
}
73+
view[R.id.btn_test_intent].onClick {
74+
val intent = Intent()
75+
intent["intExtra"] = 15
76+
intent["stringExtra"] = "Hello"
77+
Log.i(TAG, intent["intExtra"]?.asInt()?.toString())
78+
Log.i(TAG, intent["stringExtra"]?.asString())
79+
}
6580
}
6681

6782
}

demo/src/main/res/layout/fragment_activity_ext.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@
4646
android:layout_marginStart="16dp"
4747
android:text="Show Snackbar"/>
4848

49+
<TextView
50+
style="@style/HeaderText"
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:padding="16dp"
54+
android:text="Intent/Extra Getter and Setter (AndroidExtensions)"/>
55+
56+
<Button
57+
android:id="@+id/btn_test_intent"
58+
android:layout_width="wrap_content"
59+
android:layout_height="wrap_content"
60+
android:layout_marginStart="16dp"
61+
android:text="Test Intent (See log for results)"/>
62+
63+
<Button
64+
android:id="@+id/btn_test_bundle"
65+
android:layout_width="wrap_content"
66+
android:layout_height="wrap_content"
67+
android:layout_marginStart="16dp"
68+
android:text="Test Bundle (See log for results)"/>
69+
4970
</LinearLayout>
5071

5172
</ScrollView>

0 commit comments

Comments
 (0)