jeasonlzy / okhttp-OkGo

OkGo - 3.0 震撼来袭,该库是基于 Http 协议,封装了 OkHttp 的网络请求框架,比 Retrofit 更简单易用,支持 RxJava,RxJava2,支持自定义缓存,支持批量断点下载管理和批量上传管理功能
Apache License 2.0
10.6k stars 2.55k forks source link

下载进度只回调一次返回1.0 #555

Open qrh672114236 opened 6 years ago

qrh672114236 commented 6 years ago

OkGo.get(updateBean!!.updatePath) .tag(this) .execute(object :FileCallback(){ override fun onSuccess(response: Response?) { val it = Intent() it.action = Intent.ACTION_VIEW it.setDataAndType(Uri.fromFile(response!!.body().absoluteFile), "application/vnd.android.package-archive") it.flags = Intent.FLAG_ACTIVITY_NEW_TASK startActivity(it) }

                override fun downloadProgress(progress: Progress?) {
                    super.downloadProgress(progress)
                        update.isEnabled = false
                        update.text = "更新" + (progress!!.fraction * 100).toInt() + "%"
                        wvprogress.setCurrent((progress.fraction.toDouble() * 100.0 * 0.4).toInt(), "")
                    Log.d("progress==",progress.toString()+"fraction=="+progress.fraction)

                }
            })

从下载到成功只回调了一次 downloadProgress 没法看下载进度

Joslyn-Chen commented 6 years ago

看这个:https://github.com/jeasonlzy/okhttp-OkGo/issues/388