mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions
This commit is contained in:
@@ -5,6 +5,7 @@ import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestBuilder
|
||||
@@ -36,8 +37,8 @@ object ImageLoader {
|
||||
}
|
||||
}
|
||||
|
||||
fun load(context: Context, lifecycle: Lifecycle, path: String?): RequestBuilder<Drawable> {
|
||||
val requestManager = Glide.with(context).lifecycle(lifecycle)
|
||||
fun load(fragment: Fragment, lifecycle: Lifecycle, path: String?): RequestBuilder<Drawable> {
|
||||
val requestManager = Glide.with(fragment).lifecycle(lifecycle)
|
||||
return when {
|
||||
path.isNullOrEmpty() -> requestManager.load(path)
|
||||
path.isDataUrl() -> requestManager.load(path)
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.legado.app.ui.main.bookshelf.style1.books
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import io.legado.app.base.adapter.ItemViewHolder
|
||||
import io.legado.app.data.entities.Book
|
||||
@@ -15,6 +16,7 @@ import splitties.views.onLongClick
|
||||
|
||||
class BooksAdapterList(
|
||||
context: Context,
|
||||
private val fragment: Fragment,
|
||||
private val callBack: CallBack,
|
||||
private val lifecycle: Lifecycle
|
||||
) : BaseBooksAdapter<ItemBookshelfListBinding>(context) {
|
||||
@@ -52,6 +54,7 @@ class BooksAdapterList(
|
||||
item.author,
|
||||
false,
|
||||
item.origin,
|
||||
fragment,
|
||||
lifecycle
|
||||
)
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
private val bookshelfLayout by lazy { AppConfig.bookshelfLayout }
|
||||
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
||||
if (bookshelfLayout == 0) {
|
||||
BooksAdapterList(requireContext(), this, viewLifecycleOwner.lifecycle)
|
||||
BooksAdapterList(requireContext(), this, this, viewLifecycleOwner.lifecycle)
|
||||
} else {
|
||||
BooksAdapterGrid(requireContext(), this)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import io.legado.app.R
|
||||
@@ -15,8 +16,12 @@ import io.legado.app.help.glide.ImageLoader
|
||||
import io.legado.app.help.glide.OkHttpModelLoader
|
||||
import splitties.views.onLongClick
|
||||
|
||||
class RssAdapter(context: Context, val callBack: CallBack, val lifecycle: Lifecycle) :
|
||||
RecyclerAdapter<RssSource, ItemRssBinding>(context) {
|
||||
class RssAdapter(
|
||||
context: Context,
|
||||
private val fragment: Fragment,
|
||||
private val callBack: CallBack,
|
||||
private val lifecycle: Lifecycle
|
||||
) : RecyclerAdapter<RssSource, ItemRssBinding>(context) {
|
||||
|
||||
override fun getViewBinding(parent: ViewGroup): ItemRssBinding {
|
||||
return ItemRssBinding.inflate(inflater, parent, false)
|
||||
@@ -32,7 +37,7 @@ class RssAdapter(context: Context, val callBack: CallBack, val lifecycle: Lifecy
|
||||
tvName.text = item.sourceName
|
||||
val options = RequestOptions()
|
||||
.set(OkHttpModelLoader.sourceOriginOption, item.sourceUrl)
|
||||
ImageLoader.load(context, lifecycle, item.sourceIcon)
|
||||
ImageLoader.load(fragment, lifecycle, item.sourceIcon)
|
||||
.apply(options)
|
||||
.centerCrop()
|
||||
.placeholder(R.drawable.image_rss)
|
||||
|
||||
@@ -59,7 +59,9 @@ class RssFragment() : VMBaseFragment<RssViewModel>(R.layout.fragment_rss),
|
||||
|
||||
private val binding by viewBinding(FragmentRssBinding::bind)
|
||||
override val viewModel by viewModels<RssViewModel>()
|
||||
private val adapter by lazy { RssAdapter(requireContext(), this, viewLifecycleOwner.lifecycle) }
|
||||
private val adapter by lazy {
|
||||
RssAdapter(requireContext(), this, this, viewLifecycleOwner.lifecycle)
|
||||
}
|
||||
private val searchView: SearchView by lazy {
|
||||
binding.titleBar.findViewById(R.id.search_view)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.text.TextPaint
|
||||
import android.util.AttributeSet
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
@@ -182,6 +183,7 @@ class CoverImageView @JvmOverloads constructor(
|
||||
author: String? = null,
|
||||
loadOnlyWifi: Boolean = false,
|
||||
sourceOrigin: String? = null,
|
||||
fragment: Fragment? = null,
|
||||
lifecycle: Lifecycle? = null
|
||||
) {
|
||||
this.bitmapPath = path
|
||||
@@ -197,8 +199,8 @@ class CoverImageView @JvmOverloads constructor(
|
||||
if (sourceOrigin != null) {
|
||||
options = options.set(OkHttpModelLoader.sourceOriginOption, sourceOrigin)
|
||||
}
|
||||
val builder = if (lifecycle != null) {
|
||||
ImageLoader.load(context, lifecycle, path)
|
||||
val builder = if (fragment != null && lifecycle != null) {
|
||||
ImageLoader.load(fragment, lifecycle, path)
|
||||
} else {
|
||||
ImageLoader.load(context, path)//Glide自动识别http://,content://和file://
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user