Skip to content

Offline library suited for Moodle and Canvas Mobile Apps

License

Notifications You must be signed in to change notification settings

2uinc/mobile-offline-downloader-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Offline Mode Library

Usage

Add this library as submodule:
git submodule add git@github.com:2uinc/mobile-offline-downloader-android.git

Dependencies

In build.gradle file of your main module:
dependencies {
    implementation project(path: ':mobile-offline-downloader-android')
}
In settings.gradle file:
include ':mobile-offline-downloader-android'
In the Application class you need to init Offline Mode library:
val client = OkHttpClient.Builder()
    .readTimeout(60, TimeUnit.SECONDS)
    .connectTimeout(60, TimeUnit.SECONDS)
    .addInterceptor(HeadersInterceptor())
    .build()

val offlineBuilder = Offline.Builder()
    .setClient(client)
    .setBaseUrl(Const.getBaseUrl())
    .setOfflineLoggerInterceptor(OfflineLoggerInterceptor())

Offline.init(this, offlineBuilder) {
    OfflineDownloaderCreator(it)
}
Or simple:
Offline.init(this) { OfflineDownloaderCreator(it) }
Implement OfflineDownloaderCreator class:
class OfflineDownloaderCreator(offlineQueueItem: OfflineQueueItem) :
    BaseOfflineDownloaderCreator(offlineQueueItem) {

    override fun prepareOfflineDownloader(unit: (error: Throwable?) -> Unit) {
        super.prepareOfflineDownloader(unit)

        // Prepare all data that need for your downloader here
    }

    override fun createOfflineDownloader(unit: (downloader: BaseOfflineDownloader?, error: Throwable?) -> Unit) {
        // Create your downloader here
    }

    override fun destroy() {
        // Destroy all objects here
    }
}

About

Offline library suited for Moodle and Canvas Mobile Apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages