pull/1738/head
kunfei 3 years ago
parent 2b4e0637bc
commit 4bb404d87f
  1. 2
      app/src/main/java/io/legado/app/help/config/AppConfig.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowAdapter.kt
  3. 9
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  4. 10
      app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt

@ -288,6 +288,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val recordLog get() = appCtx.getPrefBoolean(PreferKey.recordLog)
val loadOnlyWifi = appCtx.getPrefBoolean(PreferKey.loadCoverOnlyWifi, false)
val doublePageHorizontal: Boolean
get() = appCtx.getPrefBoolean(PreferKey.doublePageHorizontal, true)

@ -8,6 +8,7 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemSearchBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.utils.gone
import io.legado.app.utils.visible
@ -42,7 +43,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
llKind.visible()
llKind.setLabels(kinds)
}
ivCover.load(item.coverUrl, item.name, item.author)
ivCover.load(item.coverUrl, item.name, item.author, AppConfig.loadOnlyWifi)
}
}

@ -9,6 +9,7 @@ import io.legado.app.base.adapter.DiffRecyclerAdapter
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemSearchBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.utils.gone
import io.legado.app.utils.visible
@ -81,8 +82,12 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
upLasted(binding, searchBook.latestChapterTitle)
tvIntroduce.text = searchBook.trimIntro(context)
upKind(binding, searchBook.getKindList())
ivCover.load(searchBook.coverUrl, searchBook.name, searchBook.author)
ivCover.load(
searchBook.coverUrl,
searchBook.name,
searchBook.author,
AppConfig.loadOnlyWifi
)
}
}

@ -11,13 +11,11 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import io.legado.app.constant.AppPattern
import io.legado.app.constant.PreferKey
import io.legado.app.help.config.AppConfig
import io.legado.app.help.glide.ImageLoader
import io.legado.app.help.glide.OkHttpModelLoader
import io.legado.app.lib.theme.accentColor
import io.legado.app.model.BookCover
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.textHeight
import io.legado.app.utils.toStringArray
@ -173,7 +171,12 @@ class CoverImageView @JvmOverloads constructor(
}
}
fun load(path: String? = null, name: String? = null, author: String? = null) {
fun load(
path: String? = null,
name: String? = null,
author: String? = null,
loadOnlyWifi: Boolean = false
) {
this.bitmapPath = path
this.name = name?.replace(AppPattern.bdRegex, "")?.trim()
this.author = author?.replace(AppPattern.bdRegex, "")?.trim()
@ -183,7 +186,6 @@ class CoverImageView @JvmOverloads constructor(
.centerCrop()
.into(this)
} else {
val loadOnlyWifi = context.getPrefBoolean(PreferKey.loadCoverOnlyWifi, false)
ImageLoader.load(context, path)//Glide自动识别http://,content://和file://
.apply(RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi))
.placeholder(BookCover.defaultDrawable)

Loading…
Cancel
Save