diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt index 55b8c4b298..388d93f09d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt @@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.manga.MangaActivity +import eu.kanade.tachiyomi.util.connectivityManager import eu.kanade.tachiyomi.util.inflate import eu.kanade.tachiyomi.util.snack import eu.kanade.tachiyomi.util.toast @@ -420,8 +421,8 @@ open class CatalogueFragment : BaseRxFragment(), FlexibleVie val isListMode = presenter.isListMode activity.invalidateOptionsMenu() switcher.showNext() - if (!isListMode) { - // Initialize mangas if going to grid view + if (!isListMode || !context.connectivityManager.isActiveNetworkMetered) { + // Initialize mangas if going to grid view or if over wifi when going to list view presenter.initializeMangas(adapter.items) } } @@ -444,8 +445,10 @@ open class CatalogueFragment : BaseRxFragment(), FlexibleVie * @param manga the manga to find. * @return the holder of the manga or null if it's not bound. */ - private fun getHolder(manga: Manga): CatalogueGridHolder? { - return catalogue_grid.findViewHolderForItemId(manga.id!!) as? CatalogueGridHolder + private fun getHolder(manga: Manga): CatalogueHolder? { + return (catalogue_grid.findViewHolderForItemId(manga.id!!) ?: + catalogue_list.findViewHolderForItemId(manga.id!!)) + as? CatalogueHolder } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueGridHolder.kt index 0dcd4e182f..f057164e83 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueGridHolder.kt @@ -34,13 +34,7 @@ class CatalogueGridHolder(private val view: View, private val adapter: Catalogue setImage(manga) } - /** - * Updates the image for this holder. Useful to update the image when the manga is initialized - * and the url is now known. - * - * @param manga the manga to bind. - */ - fun setImage(manga: Manga) { + override fun setImage(manga: Manga) { Glide.clear(view.thumbnail) if (!manga.thumbnail_url.isNullOrEmpty()) { Glide.with(view.context) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueHolder.kt index 1280a0be82..e6a1c63e75 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueHolder.kt @@ -21,4 +21,13 @@ abstract class CatalogueHolder(view: View, adapter: CatalogueAdapter, listener: * @param manga the manga to bind. */ abstract fun onSetValues(manga: Manga) + + + /** + * Updates the image for this holder. Useful to update the image when the manga is initialized + * and the url is now known. + * + * @param manga the manga to bind. + */ + abstract fun setImage(manga: Manga) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueListHolder.kt index 262311cc2a..10d9e6bed0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueListHolder.kt @@ -1,6 +1,8 @@ package eu.kanade.tachiyomi.ui.catalogue import android.view.View +import com.bumptech.glide.Glide +import com.bumptech.glide.load.engine.DiskCacheStrategy import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.util.getResourceColor import kotlinx.android.synthetic.main.item_catalogue_list.view.* @@ -29,5 +31,22 @@ class CatalogueListHolder(private val view: View, adapter: CatalogueAdapter, lis override fun onSetValues(manga: Manga) { view.title.text = manga.title view.title.setTextColor(if (manga.favorite) favoriteColor else unfavoriteColor) + + setImage(manga) } + + override fun setImage(manga: Manga) { + Glide.clear(view.thumbnail) + if (!manga.thumbnail_url.isNullOrEmpty()) { + Glide.with(view.context) + .load(manga) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .centerCrop() + .dontAnimate() + .skipMemoryCache(true) + .placeholder(android.R.color.transparent) + .into(view.thumbnail) + } + } + } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt index 03adb70e64..b6cb0bfa6c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt @@ -140,9 +140,7 @@ open class CataloguePresenter : BasePresenter() { this.query = query this.appliedFilters = filters - if (!isListMode) { - subscribeToMangaInitializer() - } + subscribeToMangaInitializer() // Create a new pager. pager = createPager(query, filters) @@ -200,11 +198,7 @@ open class CataloguePresenter : BasePresenter() { */ private fun setDisplayMode(asList: Boolean) { isListMode = asList - if (asList) { - initializerSubscription?.let { remove(it) } - } else { - subscribeToMangaInitializer() - } + subscribeToMangaInitializer() } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt index c5bc50303e..2d7e8a75b8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt @@ -91,7 +91,7 @@ class LibraryCategoryAdapter(val fragment: LibraryCategoryView) : } return LibraryGridHolder(view, this, fragment) } else { - val view = parent.inflate(R.layout.item_library_list) + val view = parent.inflate(R.layout.item_catalogue_list) return LibraryListHolder(view, this, fragment) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt index d0928262b7..22dd444c90 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt @@ -5,7 +5,7 @@ import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder -import kotlinx.android.synthetic.main.item_library_list.view.* +import kotlinx.android.synthetic.main.item_catalogue_list.view.* /** * Class used to hold the displayed data of a manga in the library, like the cover or the title. diff --git a/app/src/main/res/layout/item_catalogue_list.xml b/app/src/main/res/layout/item_catalogue_list.xml index f9d1b20f85..dac38717a4 100644 --- a/app/src/main/res/layout/item_catalogue_list.xml +++ b/app/src/main/res/layout/item_catalogue_list.xml @@ -1,17 +1,57 @@ - + + + android:paddingLeft="@dimen/material_component_lists_text_left_padding" + android:paddingStart="@dimen/material_component_lists_text_left_padding" + android:paddingRight="@dimen/material_component_lists_right_padding" + android:paddingEnd="@dimen/material_component_lists_right_padding"> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_library_list.xml b/app/src/main/res/layout/item_library_list.xml deleted file mode 100644 index d846ab9d06..0000000000 --- a/app/src/main/res/layout/item_library_list.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/library_list_recycler.xml b/app/src/main/res/layout/library_list_recycler.xml index 8f5dc91b38..07f543f3d7 100644 --- a/app/src/main/res/layout/library_list_recycler.xml +++ b/app/src/main/res/layout/library_list_recycler.xml @@ -5,5 +5,4 @@ android:id="@+id/library_list" android:layout_width="match_parent" android:layout_height="match_parent" - tools:listitem="@layout/item_library_list" /> - + tools:listitem="@layout/item_catalogue_list" />