Created
August 19, 2021 04:31
-
-
Save Priyansh-Kedia/5d440d7f325c8cec410fe4a9af5f5389 to your computer and use it in GitHub Desktop.
Document Viewmodel for MediaStore API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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