Skip to content

Instantly share code, notes, and snippets.

@Priyansh-Kedia
Created August 19, 2021 04:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Priyansh-Kedia/5d440d7f325c8cec410fe4a9af5f5389 to your computer and use it in GitHub Desktop.
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