-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavigationFragment.kt
More file actions
50 lines (40 loc) · 1.42 KB
/
Copy pathNavigationFragment.kt
File metadata and controls
50 lines (40 loc) · 1.42 KB
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
package com.example.qwe2r.myapplication
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import java.util.*
open class NavigationFragment : BaseFragment(), NavigationView {
private val router = Router()
override val onExecuteState = State.STARTED
override fun onAttach(context: Context?) {
super.onAttach(context)
router.fragmentManager = childFragmentManager
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_base, container, false).apply {
val rnd = Random()
findViewById<View>(R.id.base_root).setBackgroundColor(
Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))
)
}
}
override fun openBaseNavigation() {
executeDeferredAction {
router.openNavigation()
}
}
override fun openBaseNavigation(action: (NavigationView) -> Unit) {
executeDeferredAction {
router.openNavigation().also { action.invoke(it) }
}
}
override fun showToast(text: String) {
executeDeferredAction {
Toast.makeText(requireContext(), text, Toast.LENGTH_LONG).show()
}
}
}