mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 01:39:19 +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:
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()
|
||||
}
|
||||
|
||||
// Create a new pager.
|
||||
pager = createPager(query, filters)
|
||||
@ -200,12 +198,8 @@ open class CataloguePresenter : BasePresenter<CatalogueFragment>() {
|
||||
*/
|
||||
private fun setDisplayMode(asList: Boolean) {
|
||||
isListMode = asList
|
||||
if (asList) {
|
||||
initializerSubscription?.let { remove(it) }
|
||||
} else {
|
||||
subscribeToMangaInitializer()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to the initializer of manga details and updates the view if needed.
|
||||
|
@ -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.
|
||||
|
@ -1,17 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:listPreferredItemHeightSmall"
|
||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:background="?attr/selectable_list_drawable">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.Regular.Body1"
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingLeft="@dimen/material_component_lists_icon_left_padding"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingStart="@dimen/material_component_lists_icon_left_padding"
|
||||
tools:src="@drawable/icon"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="?android:listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?android:listPreferredItemPaddingLeft"/>
|
||||
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">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/unread_text"
|
||||
style="@style/TextAppearance.Regular.Caption.Hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
|
||||
android:visibility="gone"
|
||||
tools:text="22"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.Regular.SubHeading"
|
||||
android:layout_toLeftOf="@id/unread_text"
|
||||
android:layout_toStartOf="@id/unread_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Manga title"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:background="?attr/selectable_list_drawable">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingLeft="@dimen/material_component_lists_icon_left_padding"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingStart="@dimen/material_component_lists_icon_left_padding"
|
||||
tools:src="@drawable/icon"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
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">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/unread_text"
|
||||
style="@style/TextAppearance.Regular.Caption.Hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
|
||||
tools:text="22"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.Regular.SubHeading"
|
||||
android:layout_toLeftOf="@id/unread_text"
|
||||
android:layout_toStartOf="@id/unread_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Manga title"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user