mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Use single layout for grid badges
This commit is contained in:
		| @@ -39,11 +39,11 @@ class SourceComfortableGridHolder(private val view: View, private val adapter: F | ||||
|         binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f | ||||
|  | ||||
|         // For rounded corners | ||||
|         binding.leftBadges.clipToOutline = true | ||||
|         binding.rightBadges.clipToOutline = true | ||||
|         binding.badges.leftBadges.clipToOutline = true | ||||
|         binding.badges.rightBadges.clipToOutline = true | ||||
|  | ||||
|         // Set favorite badge | ||||
|         binding.favoriteText.isVisible = manga.favorite | ||||
|         binding.badges.favoriteText.isVisible = manga.favorite | ||||
|  | ||||
|         setImage(manga) | ||||
|     } | ||||
|   | ||||
| @@ -9,7 +9,7 @@ import coil.transition.CrossfadeTransition | ||||
| import eu.davidea.flexibleadapter.FlexibleAdapter | ||||
| import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher | ||||
| import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding | ||||
| import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding | ||||
| import eu.kanade.tachiyomi.widget.StateImageViewTarget | ||||
| 
 | ||||
| /** | ||||
| @@ -20,10 +20,10 @@ import eu.kanade.tachiyomi.widget.StateImageViewTarget | ||||
|  * @param adapter the adapter handling this holder. | ||||
|  * @constructor creates a new catalogue holder. | ||||
|  */ | ||||
| open class SourceGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) : | ||||
|     SourceHolder<SourceComfortableGridItemBinding>(view, adapter) { | ||||
| open class SourceCompactGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) : | ||||
|     SourceHolder<SourceCompactGridItemBinding>(view, adapter) { | ||||
| 
 | ||||
|     override val binding = SourceComfortableGridItemBinding.bind(view) | ||||
|     override val binding = SourceCompactGridItemBinding.bind(view) | ||||
| 
 | ||||
|     /** | ||||
|      * Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this | ||||
| @@ -39,11 +39,11 @@ open class SourceGridHolder(private val view: View, private val adapter: Flexibl | ||||
|         binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f | ||||
| 
 | ||||
|         // For rounded corners | ||||
|         binding.leftBadges.clipToOutline = true | ||||
|         binding.rightBadges.clipToOutline = true | ||||
|         binding.badges.leftBadges.clipToOutline = true | ||||
|         binding.badges.rightBadges.clipToOutline = true | ||||
| 
 | ||||
|         // Set favorite badge | ||||
|         binding.favoriteText.isVisible = manga.favorite | ||||
|         binding.badges.favoriteText.isVisible = manga.favorite | ||||
| 
 | ||||
|         setImage(manga) | ||||
|     } | ||||
| @@ -48,7 +48,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo | ||||
|                         Gravity.BOTTOM | ||||
|                     ) | ||||
|                 } | ||||
|                 SourceGridHolder(view, adapter) | ||||
|                 SourceCompactGridHolder(view, adapter) | ||||
|             } | ||||
|             DisplayModeSetting.COMFORTABLE_GRID -> { | ||||
|                 val binding = SourceComfortableGridItemBinding.bind(view) | ||||
|   | ||||
| @@ -36,26 +36,26 @@ class LibraryComfortableGridHolder( | ||||
|         binding.title.text = item.manga.title | ||||
|  | ||||
|         // For rounded corners | ||||
|         binding.leftBadges.clipToOutline = true | ||||
|         binding.rightBadges.clipToOutline = true | ||||
|         binding.badges.leftBadges.clipToOutline = true | ||||
|         binding.badges.rightBadges.clipToOutline = true | ||||
|  | ||||
|         // Update the unread count and its visibility. | ||||
|         with(binding.unreadText) { | ||||
|         with(binding.badges.unreadText) { | ||||
|             isVisible = item.unreadCount > 0 | ||||
|             text = item.unreadCount.toString() | ||||
|         } | ||||
|         // Update the download count and its visibility. | ||||
|         with(binding.downloadText) { | ||||
|         with(binding.badges.downloadText) { | ||||
|             isVisible = item.downloadCount > 0 | ||||
|             text = item.downloadCount.toString() | ||||
|         } | ||||
|         // Update the source language and its visibility | ||||
|         with(binding.languageText) { | ||||
|         with(binding.badges.languageText) { | ||||
|             isVisible = item.sourceLanguage.isNotEmpty() | ||||
|             text = item.sourceLanguage | ||||
|         } | ||||
|         // set local visibility if its local manga | ||||
|         binding.localText.isVisible = item.isLocal | ||||
|         binding.badges.localText.isVisible = item.isLocal | ||||
|  | ||||
|         // For rounded corners | ||||
|         binding.card.clipToOutline = true | ||||
|   | ||||
| @@ -34,26 +34,26 @@ open class LibraryCompactGridHolder( | ||||
|         binding.title.text = item.manga.title | ||||
|  | ||||
|         // For rounded corners | ||||
|         binding.leftBadges.clipToOutline = true | ||||
|         binding.rightBadges.clipToOutline = true | ||||
|         binding.badges.leftBadges.clipToOutline = true | ||||
|         binding.badges.rightBadges.clipToOutline = true | ||||
|  | ||||
|         // Update the unread count and its visibility. | ||||
|         with(binding.unreadText) { | ||||
|         with(binding.badges.unreadText) { | ||||
|             isVisible = item.unreadCount > 0 | ||||
|             text = item.unreadCount.toString() | ||||
|         } | ||||
|         // Update the download count and its visibility. | ||||
|         with(binding.downloadText) { | ||||
|         with(binding.badges.downloadText) { | ||||
|             isVisible = item.downloadCount > 0 | ||||
|             text = item.downloadCount.toString() | ||||
|         } | ||||
|         // Update the source language and its visibility | ||||
|         with(binding.languageText) { | ||||
|         with(binding.badges.languageText) { | ||||
|             isVisible = item.sourceLanguage.isNotEmpty() | ||||
|             text = item.sourceLanguage | ||||
|         } | ||||
|         // set local visibility if its local manga | ||||
|         binding.localText.isVisible = item.isLocal | ||||
|         binding.badges.localText.isVisible = item.isLocal | ||||
|  | ||||
|         // For rounded corners | ||||
|         binding.card.clipToOutline = true | ||||
|   | ||||
		Reference in New Issue
	
	Block a user