parent
588fbd918a
commit
b74b0cd103
@ -0,0 +1,47 @@
|
|||||||
|
package com.common.commonlib.image.loader
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import com.bumptech.glide.RequestBuilder
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||||
|
import com.common.commonlib.image.config.GlideBaseConfig
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载配置辅助类
|
||||||
|
*/
|
||||||
|
object ConfigHelper {
|
||||||
|
|
||||||
|
fun loadWithTransformation(
|
||||||
|
requestBuilder: RequestBuilder<Drawable>,
|
||||||
|
transformations: List<BitmapTransformation>
|
||||||
|
): RequestBuilder<Drawable> {
|
||||||
|
var temp = requestBuilder
|
||||||
|
for (item in transformations) {
|
||||||
|
temp = temp.transform(item)
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
fun loadWithMod(
|
||||||
|
requestBuilder: RequestBuilder<Drawable>,
|
||||||
|
loadingMode: GlideBaseConfig.LoadMode
|
||||||
|
): RequestBuilder<Drawable> {
|
||||||
|
var request = requestBuilder
|
||||||
|
request = when (loadingMode) {
|
||||||
|
GlideBaseConfig.LoadMode.DEFAULT ->
|
||||||
|
request
|
||||||
|
GlideBaseConfig.LoadMode.ALL ->
|
||||||
|
request.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
|
GlideBaseConfig.LoadMode.SKIP_CACHE ->
|
||||||
|
request.skipMemoryCache(true)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
GlideBaseConfig.LoadMode.SKIP_DISK ->
|
||||||
|
request.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
GlideBaseConfig.LoadMode.SKIP_MEM ->
|
||||||
|
request.skipMemoryCache(true)
|
||||||
|
GlideBaseConfig.LoadMode.SKIP_NET ->
|
||||||
|
request.onlyRetrieveFromCache(true)
|
||||||
|
}
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue