ssseasonnn / RxDownload

A multi-threaded download tool written with RxJava and Kotlin
Apache License 2.0
4.14k stars 612 forks source link

Can't download file from github #319

Closed X1nto closed 4 years ago

X1nto commented 4 years ago

Hi, I encountered some problems whilst trying to download files from github. I'm implementing auto-update system to my app and could not get the library to download apk. Here's my code

updatebtn.setOnClickListener {
    val url = "https://github.com/X1nto/VancedFiles/blob/master/release.apk"
    url.download()
        .observeOn(AndroidSchedulers.mainThread())
        .subscribeBy(
            onNext = { progress ->
                loadBar.visibility = View.VISIBLE
                loadBar.progress = "${progress.downloadSizeStr()}/${progress.totalSizeStr()}".toInt()
            },
            onComplete = {
                val apk = url.file()
                val uri = Uri.fromFile(apk)
                val intent = Intent(Intent.ACTION_VIEW)
                intent.setDataAndType(uri, "application/vnd.android.package-archive")
                startActivity(intent)
            },
            onError = {
                checkingTxt.text = "Something went wrong"
            }
        )
}

But this always returns onError. Am I doing something wrong?

X1nto commented 4 years ago

Nevermind. Problem was with progressbar