forked from microsoft/fluentui-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionBarLayoutActivity.kt
58 lines (49 loc) · 2.19 KB
/
ActionBarLayoutActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.microsoft.fluentuidemo.demos
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import com.microsoft.fluentui.actionbar.ActionBarLayout
import com.microsoft.fluentui.snackbar.Snackbar
import com.microsoft.fluentuidemo.Demo
import com.microsoft.fluentuidemo.DemoActivity
import com.microsoft.fluentuidemo.R
import com.microsoft.fluentuidemo.databinding.ActivityActionBarLayoutBinding
import com.microsoft.fluentuidemo.demos.actionbar.ActionBarDemoActivity
class ActionBarLayoutActivity : DemoActivity() {
private lateinit var actionBarBinding: ActivityActionBarLayoutBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
actionBarBinding = ActivityActionBarLayoutBinding.inflate(
LayoutInflater.from(container.context),
container,
true
)
actionBarBinding.startDemoBtn.setOnClickListener {
var position = actionBarBinding.actionBarPositionRgroup.checkedRadioButtonId
var type = actionBarBinding.actionBarTypeRgroup.checkedRadioButtonId
if (position == -1 || type == -1) {
Snackbar.make(
demoBinding.rootView,
"Please select position and type",
Snackbar.LENGTH_SHORT
).show()
} else {
position = when (position) {
R.id.action_bar_position_top -> 1
else -> 0
}
type = when (type) {
R.id.action_bar_type_icon -> ActionBarLayout.Type.ICON.ordinal
R.id.action_bar_type_carousel -> ActionBarLayout.Type.CAROUSEL.ordinal
else -> ActionBarLayout.Type.BASIC.ordinal
}
val demo = Demo("DEMOACTIONBAR", ActionBarDemoActivity::class)
val actionBarIntent = Intent(this, demo.demoClass.java)
actionBarIntent.putExtra(DEMO_ID, demo.id)
actionBarIntent.putExtra("POSITION", position)
actionBarIntent.putExtra("TYPE", type)
startActivity(actionBarIntent)
}
}
}
}