mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 16:18:55 +01:00 
			
		
		
		
	Added circular thumbnails to the catalogue list view, like the ones in the library list view (#616)
* Added circular thumbnails to the catalogue list view, like the ones in the library list view * Moved setImage to CatalogueHolder parent class and adapted the code so that when the manga is initialized, the thumbnail is set both in the case of grid and list * In catalog, when switching between grid and list, initialize mangas only if going to grid view or if over wifi
This commit is contained in:
		
				
					committed by
					
						
						Bram van de Kerkhof
					
				
			
			
				
	
			
			
			
						parent
						
							d0260acd3d
						
					
				
				
					commit
					2c8790c545
				
			@@ -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<CataloguePresenter>(), 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<CataloguePresenter>(), 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
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -140,9 +140,7 @@ open class CataloguePresenter : BasePresenter<CatalogueFragment>() {
 | 
			
		||||
        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<CatalogueFragment>() {
 | 
			
		||||
     */
 | 
			
		||||
    private fun setDisplayMode(asList: Boolean) {
 | 
			
		||||
        isListMode = asList
 | 
			
		||||
        if (asList) {
 | 
			
		||||
            initializerSubscription?.let { remove(it) }
 | 
			
		||||
        } else {
 | 
			
		||||
            subscribeToMangaInitializer()
 | 
			
		||||
        }
 | 
			
		||||
        subscribeToMangaInitializer()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user