|
|
@ -7,6 +7,7 @@ import android.net.Uri |
|
|
|
import androidx.annotation.DrawableRes |
|
|
|
import androidx.annotation.DrawableRes |
|
|
|
import com.bumptech.glide.RequestBuilder |
|
|
|
import com.bumptech.glide.RequestBuilder |
|
|
|
import io.legado.app.constant.AppPattern.dataUriRegex |
|
|
|
import io.legado.app.constant.AppPattern.dataUriRegex |
|
|
|
|
|
|
|
import io.legado.app.data.appDb |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.utils.isAbsUrl |
|
|
|
import io.legado.app.utils.isAbsUrl |
|
|
|
import io.legado.app.utils.isContentScheme |
|
|
|
import io.legado.app.utils.isContentScheme |
|
|
@ -18,7 +19,7 @@ object ImageLoader { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 自动判断path类型 |
|
|
|
* 自动判断path类型 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun load(context: Context, path: String?): RequestBuilder<Drawable> { |
|
|
|
fun load(context: Context, path: String?, sourceOrigin: String? = null): RequestBuilder<Drawable> { |
|
|
|
return when { |
|
|
|
return when { |
|
|
|
path.isNullOrEmpty() -> GlideApp.with(context).load(path) |
|
|
|
path.isNullOrEmpty() -> GlideApp.with(context).load(path) |
|
|
|
dataUriRegex.find(path) != null -> { |
|
|
|
dataUriRegex.find(path) != null -> { |
|
|
@ -27,7 +28,10 @@ object ImageLoader { |
|
|
|
} |
|
|
|
} |
|
|
|
path.isAbsUrl() -> { |
|
|
|
path.isAbsUrl() -> { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val url = AnalyzeUrl(path).getGlideUrl() |
|
|
|
val source = sourceOrigin?.let { |
|
|
|
|
|
|
|
appDb.bookSourceDao.getBookSource(it) ?: appDb.rssSourceDao.getByKey(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val url = AnalyzeUrl(path, source = source).getGlideUrl() |
|
|
|
GlideApp.with(context).load(url) |
|
|
|
GlideApp.with(context).load(url) |
|
|
|
}.getOrDefault( |
|
|
|
}.getOrDefault( |
|
|
|
GlideApp.with(context).load(path) |
|
|
|
GlideApp.with(context).load(path) |
|
|
|