File tree Expand file tree Collapse file tree 2 files changed +13
-16
lines changed
app/src/main/java/ai/elimu/content_provider/ui/image Expand file tree Collapse file tree 2 files changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class ImagesFragment : Fragment() {
4545
4646 imagesViewModel = ViewModelProvider (this )[ImagesViewModel ::class .java]
4747 binding = FragmentImagesBinding .inflate(layoutInflater)
48- imagesViewModel.text .observe(viewLifecycleOwner) { s ->
48+ imagesViewModel.getText() .observe(viewLifecycleOwner) { s ->
4949 Log .i(TAG , " onChanged" )
5050 binding.textImages.text = s
5151 }
Original file line number Diff line number Diff line change 1- package ai.elimu.content_provider.ui.image ;
1+ package ai.elimu.content_provider.ui.image
22
3- import android.util.Log;
3+ import android.util.Log
4+ import androidx.lifecycle.LiveData
5+ import androidx.lifecycle.MutableLiveData
6+ import androidx.lifecycle.ViewModel
47
5- import androidx.lifecycle.LiveData;
6- import androidx.lifecycle.MutableLiveData;
7- import androidx.lifecycle.ViewModel;
8+ class ImagesViewModel : ViewModel () {
9+ private val text = MutableLiveData <String >()
810
9- public class ImagesViewModel extends ViewModel {
10-
11- private MutableLiveData <String > text;
12-
13- public ImagesViewModel () {
14- text = new MutableLiveData <> ();
15- text.setValue(" ImagesViewModel" );
11+ init {
12+ text.value = " ImagesViewModel"
1613 }
1714
18- public LiveData <String > getText() {
19- Log .i(getClass().getName() , " getText" );
15+ fun getText (): LiveData <String > {
16+ Log .i(javaClass.name , " getText" )
2017
21- return text;
18+ return text
2219 }
2320}
You can’t perform that action at this time.
0 commit comments