|
|
@ -64,23 +64,29 @@ object BookCover { |
|
|
|
}.getOrDefault(appCtx.resources.getDrawable(R.drawable.image_cover_default, null)) |
|
|
|
}.getOrDefault(appCtx.resources.getDrawable(R.drawable.image_cover_default, null)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 加载封面 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun load( |
|
|
|
fun load( |
|
|
|
context: Context, |
|
|
|
context: Context, |
|
|
|
path: String?, |
|
|
|
path: String?, |
|
|
|
loadOnlyWifi: Boolean = false |
|
|
|
loadOnlyWifi: Boolean = false |
|
|
|
): RequestBuilder<Drawable> { |
|
|
|
): RequestBuilder<Drawable> { |
|
|
|
return if (AppConfig.useDefaultCover) { |
|
|
|
if (AppConfig.useDefaultCover) { |
|
|
|
ImageLoader.load(context, defaultDrawable) |
|
|
|
return ImageLoader.load(context, defaultDrawable) |
|
|
|
.centerCrop() |
|
|
|
.centerCrop() |
|
|
|
} else { |
|
|
|
|
|
|
|
val options = RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi) |
|
|
|
|
|
|
|
ImageLoader.load(context, path) |
|
|
|
|
|
|
|
.apply(options) |
|
|
|
|
|
|
|
.placeholder(defaultDrawable) |
|
|
|
|
|
|
|
.error(defaultDrawable) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
val options = RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi) |
|
|
|
|
|
|
|
return ImageLoader.load(context, path) |
|
|
|
|
|
|
|
.apply(options) |
|
|
|
|
|
|
|
.placeholder(defaultDrawable) |
|
|
|
|
|
|
|
.error(defaultDrawable) |
|
|
|
|
|
|
|
.centerCrop() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 加载模糊封面 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun loadBlur( |
|
|
|
fun loadBlur( |
|
|
|
context: Context, |
|
|
|
context: Context, |
|
|
|
path: String?, |
|
|
|
path: String?, |
|
|
@ -88,16 +94,15 @@ object BookCover { |
|
|
|
): RequestBuilder<Drawable> { |
|
|
|
): RequestBuilder<Drawable> { |
|
|
|
val loadBlur = ImageLoader.load(context, defaultDrawable) |
|
|
|
val loadBlur = ImageLoader.load(context, defaultDrawable) |
|
|
|
.transform(BlurTransformation(25), CenterCrop()) |
|
|
|
.transform(BlurTransformation(25), CenterCrop()) |
|
|
|
return if (AppConfig.useDefaultCover) { |
|
|
|
if (AppConfig.useDefaultCover) { |
|
|
|
loadBlur |
|
|
|
return loadBlur |
|
|
|
} else { |
|
|
|
|
|
|
|
val options = RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi) |
|
|
|
|
|
|
|
ImageLoader.load(context, path) |
|
|
|
|
|
|
|
.apply(options) |
|
|
|
|
|
|
|
.transform(BlurTransformation(25), CenterCrop()) |
|
|
|
|
|
|
|
.transition(DrawableTransitionOptions.withCrossFade(1500)) |
|
|
|
|
|
|
|
.thumbnail(loadBlur) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
val options = RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi) |
|
|
|
|
|
|
|
return ImageLoader.load(context, path) |
|
|
|
|
|
|
|
.apply(options) |
|
|
|
|
|
|
|
.transform(BlurTransformation(25), CenterCrop()) |
|
|
|
|
|
|
|
.transition(DrawableTransitionOptions.withCrossFade(1500)) |
|
|
|
|
|
|
|
.thumbnail(loadBlur) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun searchCover(book: Book): String? { |
|
|
|
suspend fun searchCover(book: Book): String? { |
|
|
|