Skip to content

Commit 33bee07

Browse files
committed
Demo layout with state
1 parent c3fcb64 commit 33bee07

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

demo/src/main/java/com/sothree/slidinguppanel/demo/DemoActivity.kt

+17-7
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,29 @@ class DemoActivity : AppCompatActivity() {
6969
binding.slidingLayout.addPanelSlideListener(object : PanelSlideListener {
7070
override fun onPanelSlide(panel: View, slideOffset: Float) {
7171
Log.i(TAG, "onPanelSlide, offset $slideOffset")
72+
binding.slideOffset.text = slideOffset.toString()
7273
}
7374

7475
override fun onPanelStateChanged(panel: View, previousState: PanelState, newState: PanelState) {
7576
Log.i(TAG, "onPanelStateChanged $newState")
77+
binding.state.text = binding.slidingLayout.panelState.toString()
7678
}
7779
})
78-
binding.slidingLayout.setFadeOnClickListener { binding.slidingLayout.setPanelState(PanelState.COLLAPSED) }
79-
val textName = findViewById<TextView>(R.id.name)
80-
textName.text = Html.fromHtml(getString(R.string.hello))
81-
val followButton = findViewById<Button>(R.id.follow)
82-
followButton.text = Html.fromHtml(getString(R.string.follow))
83-
followButton.movementMethod = LinkMovementMethod.getInstance()
84-
followButton.setOnClickListener {
80+
binding.slidingLayout.setFadeOnClickListener {
81+
binding.slidingLayout.setPanelState(PanelState.COLLAPSED)
82+
Log.i(TAG, "FadeOnClickListener ${binding.slidingLayout.panelState}")
83+
}
84+
binding.nameMain.text = Html.fromHtml(getString(R.string.hello))
85+
binding.state.text = binding.slidingLayout.panelState.toString()
86+
binding.followMain.text = Html.fromHtml(getString(R.string.follow))
87+
binding.follow.text = Html.fromHtml(getString(R.string.follow))
88+
binding.follow.movementMethod = LinkMovementMethod.getInstance()
89+
binding.followMain.setOnClickListener {
90+
val i = Intent(Intent.ACTION_VIEW)
91+
i.data = Uri.parse("http://www.twitter.com/umanoapp")
92+
startActivity(i)
93+
}
94+
binding.follow.setOnClickListener {
8595
val i = Intent(Intent.ACTION_VIEW)
8696
i.data = Uri.parse("http://www.twitter.com/umanoapp")
8797
startActivity(i)

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

+34-12
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,30 @@
2525
android:background="?attr/colorPrimary"
2626
sothree:theme="@style/ActionBar" />
2727

28-
<TextView
29-
android:id="@+id/main"
30-
android:layout_width="match_parent"
31-
android:layout_height="match_parent"
32-
android:layout_marginTop="?attr/actionBarSize"
33-
android:clickable="true"
34-
android:focusable="false"
35-
android:focusableInTouchMode="true"
36-
android:gravity="center"
37-
android:text="Main Content"
38-
android:textSize="16sp" />
28+
<LinearLayout
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:layout_gravity="center"
32+
android:orientation="vertical">
33+
34+
<TextView
35+
android:id="@+id/nameMain"
36+
android:layout_width="wrap_content"
37+
android:layout_height="0dp"
38+
android:layout_weight="1"
39+
android:gravity="center_vertical"
40+
android:textSize="14sp" />
41+
42+
<Button
43+
android:id="@+id/followMain"
44+
android:layout_width="wrap_content"
45+
android:layout_height="match_parent"
46+
android:gravity="center_vertical|right"
47+
android:paddingLeft="10dp"
48+
android:paddingRight="10dp"
49+
android:textSize="14sp" />
50+
51+
</LinearLayout>
3952
</FrameLayout>
4053

4154
<!-- SLIDING LAYOUT -->
@@ -54,7 +67,16 @@
5467
android:orientation="horizontal">
5568

5669
<TextView
57-
android:id="@+id/name"
70+
android:id="@+id/state"
71+
android:layout_width="0dp"
72+
android:layout_height="match_parent"
73+
android:layout_weight="1"
74+
android:gravity="center_vertical"
75+
android:paddingLeft="10dp"
76+
android:textSize="14sp" />
77+
78+
<TextView
79+
android:id="@+id/slideOffset"
5880
android:layout_width="0dp"
5981
android:layout_height="match_parent"
6082
android:layout_weight="1"

0 commit comments

Comments
 (0)