Jihye Han
01/30/2023, 1:53 PM...
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{(view) -> viewModel.onClickButton(view)}"
... />
...
• ViewModel
...
fun onClickButton(view: View) {
val context = view.context
// work on something use context
}
...
Javier
01/30/2023, 1:58 PMJihye Han
01/30/2023, 2:13 PMJavier
01/30/2023, 2:23 PMephemient
01/30/2023, 2:24 PMcurioustechizen
01/30/2023, 2:31 PMJihye Han
01/30/2023, 2:34 PMColton Idle
01/30/2023, 2:41 PMJavier
01/30/2023, 3:14 PMkrzysztof
01/30/2023, 3:18 PMinterface
that does return directories. The implementation of context would be injected at runtime via DI, while in tests, you provide a fake implementationColton Idle
01/30/2023, 3:23 PMLan s
02/04/2023, 8:07 AMMarcin Wisniowski
02/10/2023, 12:50 PMrotation is just the easiest way to get a configuration change, there are many others@ephemient I found the easiest way is to use the quick setting tile to toggle dark mode, especially when testing behavior in apps that have fixed orientation.
ephemient
02/10/2023, 1:07 PMMark
02/15/2023, 2:10 AMContext
as long as the view model doesn’t hold on to it in any way? i.e. if the method is called on the main thread and all the work using the Context
is done synchronously (e.g. no reference is passed to another thread)?curioustechizen
02/15/2023, 4:43 AMMark
02/15/2023, 4:44 AMcurioustechizen
02/15/2023, 5:40 AM