diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index a4e420af1..9f7b387f2 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -8,7 +8,6 @@ import androidx.lifecycle.Observer import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book -import io.legado.app.help.ImageLoader import io.legado.app.ui.changecover.ChangeCoverDialog import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_book_info_edit.* @@ -59,10 +58,8 @@ class BookInfoEditActivity : } private fun upCover() { - viewModel.book?.getDisplayCover()?.let { - ImageLoader.load(this, it) - .centerCrop() - .into(iv_cover) + viewModel.book.let { + iv_cover.load(it?.getDisplayCover(), it?.name) } } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index 04d2e46f8..49127927f 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -67,13 +67,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : } } } - searchBook.coverUrl.let { - ImageLoader.load(context, it)//Glide自动识别http://和file:// - .placeholder(R.drawable.image_cover_default) - .error(R.drawable.image_cover_default) - .centerCrop() - .into(iv_cover) - } + iv_cover.load(searchBook.coverUrl, searchBook.name) onClick { callBack.showBookInfo(searchBook.name, searchBook.author) } diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 8e520d222..33cb24b43 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -71,7 +71,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { } } - fun setName(name: String) { + fun setName(name: String?) { this.name = name invalidate() } @@ -81,7 +81,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { minimumWidth = width } - fun load(path: String?, name: String) { + fun load(path: String?, name: String?) { if (path.isNullOrEmpty()) { setName(name) } else { @@ -106,6 +106,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { dataSource: DataSource?, isFirstResource: Boolean ): Boolean { + setName(null) return false }