|
|
@ -2,6 +2,7 @@ package com.common.commonlib.image.loader
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.drawable.Drawable
|
|
|
|
import android.graphics.drawable.Drawable
|
|
|
|
import com.bumptech.glide.RequestBuilder
|
|
|
|
import com.bumptech.glide.RequestBuilder
|
|
|
|
|
|
|
|
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
|
|
|
import com.common.commonlib.image.config.GlideHolderConfig
|
|
|
|
import com.common.commonlib.image.config.GlideHolderConfig
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -9,14 +10,23 @@ import com.common.commonlib.image.config.GlideHolderConfig
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
object GlobalConfigHelper {
|
|
|
|
object GlobalConfigHelper {
|
|
|
|
var globalHolderConfig: GlideHolderConfig? = null
|
|
|
|
var globalHolderConfig: GlideHolderConfig? = null
|
|
|
|
|
|
|
|
var globalTransition: DrawableTransitionOptions? = null
|
|
|
|
|
|
|
|
|
|
|
|
fun loadWithGlobalConfig(requestBuilder: RequestBuilder<Drawable>): RequestBuilder<Drawable> {
|
|
|
|
fun loadWithGlobalConfig(requestBuilder: RequestBuilder<Drawable>): RequestBuilder<Drawable> {
|
|
|
|
return loadWithGlobalConfig(requestBuilder, globalHolderConfig)
|
|
|
|
return loadWithGlobalConfig(requestBuilder, globalHolderConfig, globalTransition)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun loadWithGlobalConfig(
|
|
|
|
fun loadWithGlobalConfig(
|
|
|
|
requestBuilder: RequestBuilder<Drawable>,
|
|
|
|
requestBuilder: RequestBuilder<Drawable>,
|
|
|
|
holderConfig: GlideHolderConfig?
|
|
|
|
holderConfig: GlideHolderConfig?
|
|
|
|
|
|
|
|
): RequestBuilder<Drawable> {
|
|
|
|
|
|
|
|
return loadWithGlobalConfig(requestBuilder, holderConfig, globalTransition)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun loadWithGlobalConfig(
|
|
|
|
|
|
|
|
requestBuilder: RequestBuilder<Drawable>,
|
|
|
|
|
|
|
|
holderConfig: GlideHolderConfig?,
|
|
|
|
|
|
|
|
transition: DrawableTransitionOptions?
|
|
|
|
): RequestBuilder<Drawable> {
|
|
|
|
): RequestBuilder<Drawable> {
|
|
|
|
var request = requestBuilder
|
|
|
|
var request = requestBuilder
|
|
|
|
if (holderConfig != null) {
|
|
|
|
if (holderConfig != null) {
|
|
|
@ -42,6 +52,10 @@ object GlobalConfigHelper {
|
|
|
|
request = request.fallback(holderConfig.fallBackId)
|
|
|
|
request = request.fallback(holderConfig.fallBackId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transition != null) {
|
|
|
|
|
|
|
|
request = request.transition(transition)
|
|
|
|
|
|
|
|
}
|
|
|
|
return request
|
|
|
|
return request
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|