updated version

This commit is contained in:
Mariotaku Lee 2017-03-07 22:17:34 +08:00
parent 2ab0c19bd8
commit 29b8be7341
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
3 changed files with 45 additions and 13 deletions

View File

@ -34,8 +34,8 @@ android {
applicationId "org.mariotaku.twidere" applicationId "org.mariotaku.twidere"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 25 targetSdkVersion 25
versionCode 294 versionCode 295
versionName '3.4.32' versionName '3.4.33'
multiDexEnabled true multiDexEnabled true
buildConfigField 'boolean', 'LEAK_CANARY_ENABLED', 'Boolean.parseBoolean("true")' buildConfigField 'boolean', 'LEAK_CANARY_ENABLED', 'Boolean.parseBoolean("true")'

View File

@ -20,7 +20,6 @@
package org.mariotaku.twidere.util.glide package org.mariotaku.twidere.util.glide
import android.content.Context import android.content.Context
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.GlideBuilder import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
@ -29,7 +28,7 @@ import com.bumptech.glide.module.GlideModule
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.mariotaku.twidere.util.HttpClientFactory import org.mariotaku.twidere.util.HttpClientFactory
import org.mariotaku.twidere.util.dagger.DependencyHolder import org.mariotaku.twidere.util.dagger.DependencyHolder
import org.mariotaku.twidere.util.media.ThumborInterceptor
import java.io.InputStream import java.io.InputStream
class OkHttpGlideModule : GlideModule { class OkHttpGlideModule : GlideModule {
@ -43,15 +42,8 @@ class OkHttpGlideModule : GlideModule {
val conf = HttpClientFactory.HttpClientConfiguration(holder.preferences) val conf = HttpClientFactory.HttpClientConfiguration(holder.preferences)
val thumbor = holder.thumbor val thumbor = holder.thumbor
HttpClientFactory.initOkHttpClient(conf, builder, holder.dns, holder.connectionPool, holder.cache) HttpClientFactory.initOkHttpClient(conf, builder, holder.dns, holder.connectionPool, holder.cache)
builder.addInterceptor { chain -> builder.addInterceptor(ThumborInterceptor(thumbor))
val request = chain.request()
if (!thumbor.available) {
return@addInterceptor chain.proceed(request)
}
val rb = request.newBuilder()
rb.url(thumbor.buildUri(request.url().toString()))
return@addInterceptor chain.proceed(rb.build())
}
glide.register(GlideUrl::class.java, InputStream::class.java, OkHttpUrlLoader.Factory(builder.build())) glide.register(GlideUrl::class.java, InputStream::class.java, OkHttpUrlLoader.Factory(builder.build()))
} }
} }

View File

@ -0,0 +1,40 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.util.media
import android.os.Build
import okhttp3.Interceptor
import okhttp3.Response
class ThumborInterceptor(val thumbor: ThumborWrapper) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
if (!thumbor.available) {
return chain.proceed(request)
}
val rb = request.newBuilder()
rb.url(thumbor.buildUri(request.url().toString()))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
rb.header("Accept", "image/webp, */*")
}
return chain.proceed(rb.build())
}
}