package com.welays.sunnyweather.ui.place import androidx.lifecycle.* import com.welays.sunnyweather.logic.Repository import com.welays.sunnyweather.logic.model.Place class PlaceViewModel : ViewModel() { private val searchLiveData = MutableLiveData<String>() val placeList = ArrayList<Place>() val placeLiveData = Transformations.switchMap(searchLiveData) { query -> Repository.searchPlaces(query) } fun searchPlaces(query: String) { searchLiveData.value = query } fun savePlace(place: Place) = Repository.savePlace(place) fun getSavedPlace() = Repository.getSavedPlace() fun isPlaceSaved() = Repository.isPlaceSaved() }
Android Studio 大哥们这些能实现什么功能?
最新推荐文章于 2024-09-07 01:05:35 发布