git submodule add git@github.com:2uinc/mobile-offline-downloader-android.git
dependencies {
implementation project(path: ':mobile-offline-downloader-android')
}
include ':mobile-offline-downloader-android'
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)
}
Offline.init(this) { OfflineDownloaderCreator(it) }
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
}
}