Skip to content

The purpose of the library is to abstract the downloading (images, pdf, zip, etc) and caching of remote resources (images, JSON, XML, etc) so that client code can easily "swap" a URL for any kind of files ( JSON, XML, etc) without worrying about any of the details. Resources which are reused often should not be continually re-downloaded and shou…

Notifications You must be signed in to change notification settings

Muhaammaad/iLoader

Repository files navigation

ILoader

The application shows the usage of ILoader module. It contains an activity with fragment to show fetched images from a url. Images and rest to url is being loaded and cached by ILoader.

Things which were considered:

  1. Coding in "Kotlin"
  2. Architecture design pattern (MVVM)
  3. Dependency Injection (Koin)
  4. Coroutines for tasks
  5. LruChache for persistence
  6. Data Binding
  7. Networking using OkHttp
  8. Easy to integrate into new Android project
  9. Multiple distinct resources may be requested in parallel
  10. The same image may be requested by multiple sources simultaneously (even before it has loaded), and if one of the sources cancels the load, it should not affect the remaining requests

Note:

* Assumption taken that the same URL will always return the same resource
* On going at the end of the list, Same images are again loading just to show that images and responses are fetched from cache and handled. 

Library Endpoints to be used:

/**
     * Loads data from provided [source] and sets into provided [view]
     *
     * @param source can be url string or [DataRequest]
     * @param view image view in which source should be set
     * @param placeholder default image drawable for provided [view]
     * @param errorPlaceholder default image drawable for provided [view] in case of error
     */
ILoader.load(
        @NotNull source: Any,
        @NotNull view: ImageView,
        @Nullable placeholder: Drawable? = null,
        @Nullable errorPlaceholder: Drawable? = null
    )
/**
     * Loads data from provided [source], maps it accordingly into provided [mapper] and returns via [delegate]
     *
     * @param source can be url string or [DataRequest]
     * @param mapper maps the source response in the given [T]
     * @param delegate provides the callback data and status about source mapping and fetching
     */
   ILoader.load(
        @NotNull source: Any,
        @NotNull mapper: Mapper<ByteArray, T>,
        @NotNull delegate: CompletionCallback<T?, Boolean>
    )
/**
     * Loads data from provided [source] and returns via [delegate]
     *
     * @param source can be url string or [DataRequest]
     * @param delegate provides the callback data and status about source mapping and fetching
     */
    ILoader.load(
        @NotNull source: Any,
        @NotNull delegate: CompletionCallback<ByteArray?, Boolean>
    ) 

About

The purpose of the library is to abstract the downloading (images, pdf, zip, etc) and caching of remote resources (images, JSON, XML, etc) so that client code can easily "swap" a URL for any kind of files ( JSON, XML, etc) without worrying about any of the details. Resources which are reused often should not be continually re-downloaded and shou…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages