-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.kt
42 lines (33 loc) · 1.26 KB
/
MainActivity.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
package com.example.custom_snackbar.ui
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.custom_snackbar.databinding.ActivityMainBinding
import com.example.custom_snackbar.utils.themeConst
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnWithCL.setOnClickListener {
startNewActivity(CoordinatorLayoutAct::class.java)
}
binding.btnWithoutCL.setOnClickListener {
startNewActivity(SimpleAct::class.java)
}
binding.btnCustomView.setOnClickListener {
startNewActivity(CustomViewAct::class.java)
}
binding.btnDrawableAct.setOnClickListener {
startNewActivity(DrawableAct::class.java)
}
}
private fun startNewActivity(cls: Class<*>) {
val theme = if (binding.rbAppCompact.isChecked) 0 else 1
val intent = Intent(this, cls).apply {
putExtra(themeConst, theme)
}
startActivity(intent)
}
}