/
InstrumentsFragment.kt
52 lines (40 loc) · 1.54 KB
/
InstrumentsFragment.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
package com.cleveroad.aropensource.ui.screens.main.chooser
import android.content.Context
import android.os.Bundle
import android.view.View
import com.cleveroad.aropensource.R
import com.cleveroad.aropensource.ui.base.BaseLifecycleFragment
import com.cleveroad.aropensource.ui.base.bindInterfaceOrThrow
import kotlinx.android.synthetic.main.fragment_instruments.*
class InstrumentsFragment : BaseLifecycleFragment(), View.OnClickListener {
companion object {
fun newInstance() =
InstrumentsFragment().apply {
arguments = Bundle()
}
}
override val layoutId = R.layout.fragment_instruments
private var instrumentsCallback: InstrumentsCallback? = null
override fun getScreenTitle() = R.string.instrument_selector
override fun hasToolbar() = true
override fun getToolbarId() = R.id.toolbar
override fun onAttach(context: Context?) {
super.onAttach(context)
instrumentsCallback = bindInterfaceOrThrow<InstrumentsCallback>(context)
}
override fun onDetach() {
instrumentsCallback = null
super.onDetach()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
bArcore.setOnClickListener(this)
bMlKit.setOnClickListener(this)
}
override fun onClick(view: View?) {
when (view?.id) {
R.id.bArcore -> instrumentsCallback?.arCoreSelected()
R.id.bMlKit -> instrumentsCallback?.mlKitlSelected()
}
}
}