Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Document Viewmodel for MediaStore API
private val _imagesLiveData = MutableLiveData<MutableList<Three<Uri?, String?, Date>>>()
val imagesLiveData: LiveData<MutableList<Three<Uri?, String?, Date>>>
get() = _imagesLiveData
private var start = 0
private var areAllLoaded = false
fun getImages(count: Int) {
if (areAllLoaded)
return
viewModelScope.launch {
val response = documentRepo.getImages(count, start)
start = response.c
areAllLoaded = response.b
val data = response.a
_imagesLiveData.postValue(data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment