neuberfran
neuberfran

Reputation: 271

Transformations.map with ViewModel and LiveData in Androidx (issue)

https://github.com/neuberfran/SmartDrive11/blob/master/app/src/main/java/com/example/neube/smartdrive/controlamotores/SmartViewModel.kt

I have the above project, based on this:

https://firebase.googleblog.com/2017/12/using-android-architecture-components_20.html

and I'm having this image issues:

https://drive.google.com/drive/folders/1_M3KBZnFXkX6I1dMNLejNZAAqrs_QBA9?usp=sharing

Can someone help?

Upvotes: 0

Views: 277

Answers (1)

Gergely Hegedus
Gergely Hegedus

Reputation: 578

You have imported the wrong function type. it should be androidx.arch.core.util.Function and not import java.util.function.Function

In your Activity: if your ViewModel is kotlin you should reference the livedata like hotStockViewModel.hotStockLiveData since it's a property.

On JVM the properties such as "hotStockLiveData" will have a "get HotStockLiveData" and "setHotStockLiveData" which from kotlin is called like hotStockViewModel.hotStockLiveData, but in JAVA you may use hotStockViewModel.getHotStockLiveData() That's why you can't define a "getHotStockLiveData()" function in the viewModel.

Upvotes: 1

Related Questions