This app has two modules as given in problem statement:
- app // sample app to demo the ImageLoading library
- imageloader // Image loading library written by me.
The imageloader module contains the classes related to the code used for developing the library. It has two packages:
- memorycache - contains the class ImageLoader which uses MemoryCache class for the implementation
- diskcache - contains the class ImageLoader2 which uses DiskCache class for the implementation
Note: DiskCache uses a class DiskLruCache from the Jake wharton's lib 'com.jakewharton:disklrucache:2.0.2'
The app module follows a basic MVVM architecture.
-
application - Custom Application class for dependency injection using kodein
-
data - repository classes, retrofit api client
-
helper - contains recylerview adapter which uses a generic pattern for creating adapter. The advantage of using this class is that we do not need to create separate adapter class for each recylerview. Also, this module has constants, kotlin extension and listener interfaces.
-
model - entity classes for the data
-
view - activity, adapter and viewholder
-
viewmodel - Viewmodel for communicating with repo layers.
The imageloader library is used in PhotoViewHolder class.imageloader
-
Using ImageLoader which uses MemoryCache.
ImageLoader.displayImage(it, fullImageView)
-
Using ImageLoader2 which uses DiskCache.
ImageLoader2.displayImage(itemView.context, data.urls.thumb, imageView)
-
For cancelling ongoing requests, you can call cancelAll().
ImageLoader.cancelAll()
In fullscreenActivity, I have used ImageLoader2 which uses DiskCache
ImageLoader2.displayImage(applicationContext, it, fullImageView)