-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downloading files bigger than 15 mb doesn't seem to work on lower-end devices #352
Comments
邮件已收到,三日内拜读
|
Found the solution. Posting it here, in case anyone is interested. It's this file, line 17 Change it to this: (I also made the time-outs shorter, because they took too long) By adding protocol HTTP 1.1, RxDownload now also works on lower-end android devices (Android 10 or lower) You'll also need to add the missing dependencies to your build.gradle:
|
No need to be so troublesome, you just need to customize a RequestImpl. //first custom your okhttp
val customOkHttp: OkHttpClient = OkHttpClient().newBuilder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.writeTimeout(120, TimeUnit.SECONDS)
.build()
fun <reified T> request(
baseUrl: String = FAKE_BASE_URL,
client: OkHttpClient = okHttpClient,
callAdapterFactory: CallAdapter.Factory = RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io()),
converterFactory: Converter.Factory = GsonConverterFactory.create()
): T {
val retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.client(customOkHttp)
.addCallAdapterFactory(callAdapterFactory)
.addConverterFactory(converterFactory)
.build()
return retrofit.create(T::class.java)
}
//then create your request impl:
object YourRequestImpl: Request {
private val api = request<Api>()
override fun get(url: String, headers: Map<String, String>): Flowable<Response<ResponseBody>> {
return api.get(url, headers)
}
interface Api {
@GET
@Streaming
fun get(
@Url url: String,
@HeaderMap headers: Map<String, String>
): Flowable<Response<ResponseBody>>
}
}
//and pass your requestImpl into download method:
"url".download(request = YourRequestImpl)
|
No description provided.
The text was updated successfully, but these errors were encountered: