GalleryViewModel

class GalleryViewModel(application: Application) : AndroidViewModel

ViewModel that provides two way data bindings for images stored in the internal gallery.

See also

MVVM Architecture For more information about how this software architectural pattern works.

Constructors

GalleryViewModel
Link copied to clipboard
fun GalleryViewModel(application: Application)

An instance of the current Application

Types

Factory
Link copied to clipboard
internal class Factory(application: Application) : ViewModelProvider.Factory

Factory to initiate this GalleryViewModel

Functions

deleteImagePair
Link copied to clipboard
fun deleteImagePair(imagesToDelete: ArrayList<File>)

Deletes an image pair from images and the external file directory.

fileBelongsToImageArrayItem
Link copied to clipboard
private fun fileBelongsToImageArrayItem(file: File, item: ArrayList<File>): Boolean

Helper function to check whether a file is in an item

getImages
Link copied to clipboard
fun getImages(): LiveData<ArrayList<ArrayList<File>>>

Getter that returns images as MutableLiveData

loadImages
Link copied to clipboard
private fun loadImages(images: MutableLiveData<ArrayList<ArrayList<File>>>)

Updates images to be the same as the images in the external file directory

reloadImages
Link copied to clipboard
fun reloadImages()

Calls loadImages to refresh images

Properties

imageDirectory
Link copied to clipboard
private val imageDirectory: File

Directory of the internal gallery

images
Link copied to clipboard
private val images: MutableLiveData<ArrayList<ArrayList<File>>>

Data binding for the images stored in the internal gallery