RxDownloader is handling DownloadManager event as observable.
add to app/build.gradle
dependencies
repositories {
maven { url "https://dl.bintray.com/reyurnible/maven" }
}
dependencies {
compile 'com.reyurnible:rxdownloader:1.0.0'
}
Simple use.
- create DonwloadManager.Request
- RxDownloader.execute()
- create RxDownloader
- enqueue request
- execute
You can use multi download request.
/* === Step1 Create request object === */
// Uri for download target uri
val uri = Uri.parse("https://dl.dropboxusercontent.com/u/31455721/bg_jpg/150501.jpg")
val request = DownloadManager.Request(uri).apply {
setAllowedNetworkTypes(
DownloadManager.Request.NETWORK_MOBILE or DownloadManager.Request.NETWORK_WIFI
)
setTitle("Sample Download")
setDescription("sample of using download manager")
// and so your reuest settings...
}
/* === Step2 Execute(Kotlin extention) === */
reuest.execute()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Subscriber<RxDownloader.DownloadStatus>() {
override fun onNext(status: RxDownloader.DownloadStatus?) {
// Handling status
}
override fun onError(e: Throwable?) {
// Error action
}
override fun onCompleted() {
// Complete all request
}
})
explain for japanease. Qiita
AndroidStudio > 2.1 RxJava > 1.4.1
To build:
$ git clone git@github.com:Reyurnible/RxDownloader.git
$ cd RxDownloader/
$ ./gradlew build
For bugs, questions and discussions please use the Github Issues.
Copyright 2016 Shun Hosaka.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.