@@ -9,7 +9,7 @@ import android.view.LayoutInflater
9
9
import android.view.View
10
10
import android.view.ViewGroup
11
11
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
12
- import kotlinx. android.synthetic.main.bottom_sheet.*
12
+ import com.yoti.mobile. android.sdk.yotidocscan.websample.databinding.BottomSheetBinding
13
13
14
14
private const val SESSION_PREFERENCES_ID = " SESSION_PREFERENCES_ID"
15
15
private const val SESSION_CONFIGURATION_KEY = " SESSION_CONFIGURATION_KEY"
@@ -19,30 +19,38 @@ class SessionBottomSheet: BottomSheetDialogFragment() {
19
19
private var sessionConfigurationListener: SessionConfigurationListener ? = null
20
20
lateinit var sharedPreferences: SharedPreferences
21
21
22
+ private var _binding : BottomSheetBinding ? = null
23
+ private val binding: BottomSheetBinding get() = _binding !!
24
+
22
25
interface SessionConfigurationListener {
23
26
fun onSessionConfigurationSuccess (sessionUrl : String )
24
27
fun onSessionConfigurationDismiss ()
25
28
}
26
29
27
30
override fun onCreateView (
28
31
inflater : LayoutInflater , container : ViewGroup ? , savedInstanceState : Bundle ?
29
- ): View ? = inflater.inflate(R .layout.bottom_sheet, container, false )
32
+ ): View {
33
+ _binding = BottomSheetBinding .inflate(inflater, container, false )
34
+ return binding.root
35
+ }
30
36
31
37
override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
32
38
super .onViewCreated(view, savedInstanceState)
33
39
34
- session_url.setText(sharedPreferences.getString(SESSION_CONFIGURATION_KEY , " " ))
40
+ with (binding) {
41
+ sessionUrl.setText(sharedPreferences.getString(SESSION_CONFIGURATION_KEY , " " ))
35
42
36
- start_session_button.setOnClickListener {
37
- sessionConfigurationListener?.onSessionConfigurationSuccess(
38
- session_url.text.toString()
39
- )
40
- this .dismiss()
43
+ startSessionButton.setOnClickListener {
44
+ sessionConfigurationListener?.onSessionConfigurationSuccess(
45
+ sessionUrl.text.toString()
46
+ )
47
+ dismiss()
48
+ }
41
49
}
42
50
}
43
51
44
52
override fun onDismiss (dialog : DialogInterface ) {
45
- sharedPreferences.edit().putString(SESSION_CONFIGURATION_KEY , session_url .text.toString()).apply ()
53
+ sharedPreferences.edit().putString(SESSION_CONFIGURATION_KEY , binding.sessionUrl .text.toString()).apply ()
46
54
sessionConfigurationListener?.onSessionConfigurationDismiss()
47
55
super .onDismiss(dialog)
48
56
}
@@ -53,6 +61,11 @@ class SessionBottomSheet: BottomSheetDialogFragment() {
53
61
sessionConfigurationListener = context as ? SessionConfigurationListener
54
62
}
55
63
64
+ override fun onDestroyView () {
65
+ super .onDestroyView()
66
+ _binding = null
67
+ }
68
+
56
69
override fun onDetach () {
57
70
sessionConfigurationListener = null
58
71
super .onDetach()
0 commit comments