mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:51:48 +01:00
Fixed bug with uniform gird
Also fixed search text being cleared
This commit is contained in:
parent
96d322afbe
commit
c62ec99aff
@ -5,6 +5,7 @@ import android.view.View
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
@ -66,15 +67,28 @@ class LibraryGridHolder(
|
|||||||
if (item.manga.thumbnail_url == null) GlideApp.with(view.context).clear(cover_thumbnail)
|
if (item.manga.thumbnail_url == null) GlideApp.with(view.context).clear(cover_thumbnail)
|
||||||
else {
|
else {
|
||||||
val id = item.manga.id ?: return
|
val id = item.manga.id ?: return
|
||||||
var glide = GlideApp.with(adapter.recyclerView.context).load(item.manga)
|
if (cover_thumbnail.height == 0) {
|
||||||
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
val oldPos = adapterPosition
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
|
adapter.recyclerView.post {
|
||||||
glide = if (fixedSize) glide.centerCrop().override(cover_thumbnail.maxHeight)
|
if (oldPos == adapterPosition)
|
||||||
else glide.override(cover_thumbnail.maxHeight)
|
setCover(item.manga, id)
|
||||||
glide.into(cover_thumbnail)
|
}
|
||||||
|
}
|
||||||
|
else setCover(item.manga, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setCover(manga: Manga, id: Long) {
|
||||||
|
GlideApp.with(adapter.recyclerView.context).load(manga)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
||||||
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
|
||||||
|
.apply {
|
||||||
|
if (fixedSize) centerCrop()
|
||||||
|
else override(cover_thumbnail.maxHeight)
|
||||||
|
}
|
||||||
|
.into(cover_thumbnail)
|
||||||
|
}
|
||||||
|
|
||||||
private fun playButtonClicked() {
|
private fun playButtonClicked() {
|
||||||
adapter.libraryListener.startReading(adapterPosition)
|
adapter.libraryListener.startReading(adapterPosition)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx
|
|||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
|
||||||
import timber.log.Timber
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class LibraryItem(val manga: LibraryManga,
|
class LibraryItem(val manga: LibraryManga,
|
||||||
@ -71,8 +70,8 @@ class LibraryItem(val manga: LibraryManga,
|
|||||||
constraint_layout.layoutParams = FrameLayout.LayoutParams(
|
constraint_layout.layoutParams = FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
)
|
)
|
||||||
cover_thumbnail.maxHeight = (parent.itemWidth / 3f * 3.7f).toInt()
|
cover_thumbnail.maxHeight = Int.MAX_VALUE
|
||||||
cover_thumbnail.minimumHeight = (parent.itemWidth / 3f * 3.7f).toInt()
|
cover_thumbnail.minimumHeight = 0
|
||||||
constraint_layout.minHeight = 0
|
constraint_layout.minHeight = 0
|
||||||
cover_thumbnail.scaleType = ImageView.ScaleType.CENTER_CROP
|
cover_thumbnail.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||||
cover_thumbnail.adjustViewBounds = false
|
cover_thumbnail.adjustViewBounds = false
|
||||||
|
@ -96,31 +96,14 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
activeCategory = order
|
activeCategory = order
|
||||||
val category = presenter.categories.find { it.order == order }
|
val category = presenter.categories.find { it.order == order }
|
||||||
|
|
||||||
//val categortPosition = presenter.categories.indexOf(category)
|
|
||||||
customTitleSpinner.category_title.text = category?.name ?: ""
|
customTitleSpinner.category_title.text = category?.name ?: ""
|
||||||
/*if (spinner.selectedItemPosition != categortPosition) {
|
|
||||||
updateScroll = true
|
|
||||||
spinner.setSelection(categortPosition, true)
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
/*launchUI {
|
|
||||||
view.updateLayoutParams<FrameLayout.LayoutParams> {
|
|
||||||
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
|
|
||||||
val array = view.context.obtainStyledAttributes(attrsArray)
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
topMargin =
|
|
||||||
view.rootWindowInsets.systemWindowInsetTop + array.getDimensionPixelSize(
|
|
||||||
0, 0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
array.recycle()
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
// pad the recycler if the filter bottom sheet is visible
|
// pad the recycler if the filter bottom sheet is visible
|
||||||
if (!phoneLandscape) {
|
if (!phoneLandscape) {
|
||||||
val height = view.context.resources.getDimensionPixelSize(R.dimen.rounder_radius) + 4.dpToPx
|
val height = view.context.resources.getDimensionPixelSize(R.dimen.rounder_radius) + 4.dpToPx
|
||||||
@ -135,19 +118,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
|
|
||||||
override fun layoutView(view: View) {
|
override fun layoutView(view: View) {
|
||||||
adapter = LibraryCategoryAdapter(this)
|
adapter = LibraryCategoryAdapter(this)
|
||||||
/* recycler =
|
|
||||||
(library_layout.inflate(R.layout.library_grid_recycler) as AutofitRecyclerView).apply {
|
|
||||||
spanCount = if (libraryLayout == 0) 1 else mangaPerRow
|
|
||||||
manager.spanSizeLookup = (object : GridLayoutManager.SpanSizeLookup() {
|
|
||||||
override fun getSpanSize(position: Int): Int {
|
|
||||||
if (libraryLayout == 0) return 1
|
|
||||||
val item = this@LibraryListController.adapter.getItem(position)
|
|
||||||
return if (item is LibraryHeaderItem) manager.spanCount else 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//recycler.spanCount = if (libraryLayout == 0) 1 else mangaPerRow
|
|
||||||
if (libraryLayout == 0)recycler.spanCount = 1
|
if (libraryLayout == 0)recycler.spanCount = 1
|
||||||
else recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx
|
else recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx
|
||||||
recycler.manager.spanSizeLookup = (object : GridLayoutManager.SpanSizeLookup() {
|
recycler.manager.spanSizeLookup = (object : GridLayoutManager.SpanSizeLookup() {
|
||||||
@ -159,22 +129,12 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
})
|
})
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(true)
|
||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
//recycler_layout.addView(recycler)
|
|
||||||
adapter.fastScroller = fast_scroller
|
adapter.fastScroller = fast_scroller
|
||||||
recycler.addOnScrollListener(scrollListener)
|
recycler.addOnScrollListener(scrollListener)
|
||||||
|
|
||||||
/* val dropdown = library_layout.inflate(R.layout.expanded_dropdown_menu) as
|
|
||||||
TextInputLayout // ReSpinner(view .context)
|
|
||||||
spinner = dropdown.filled_exposed_dropdown*/
|
|
||||||
|
|
||||||
val tv = TypedValue()
|
val tv = TypedValue()
|
||||||
activity!!.theme.resolveAttribute(R.attr.actionBarTintColor, tv, true)
|
activity!!.theme.resolveAttribute(R.attr.actionBarTintColor, tv, true)
|
||||||
|
|
||||||
/*spinner.backgroundTintList = ContextCompat.getColorStateList(
|
|
||||||
view.context, tv.resourceId
|
|
||||||
)
|
|
||||||
(spinner.parent.parent as ViewGroup).removeView(spinner.parent as View)
|
|
||||||
(activity as MainActivity).supportActionBar?.customView = spinner.parent as View*/
|
|
||||||
customTitleSpinner = library_layout.inflate(R.layout.spinner_title) as LinearLayout
|
customTitleSpinner = library_layout.inflate(R.layout.spinner_title) as LinearLayout
|
||||||
(activity as MainActivity).supportActionBar?.setDisplayShowCustomEnabled(false)
|
(activity as MainActivity).supportActionBar?.setDisplayShowCustomEnabled(false)
|
||||||
spinnerAdapter = SpinnerAdapter(
|
spinnerAdapter = SpinnerAdapter(
|
||||||
@ -192,9 +152,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
(activity as MainActivity).supportActionBar?.customView = customTitleSpinner
|
(activity as MainActivity).supportActionBar?.customView = customTitleSpinner
|
||||||
//spinnerAdapter?.setDropDownViewResource(R.layout.library_spinner_entry_text)
|
|
||||||
//spinner.setAdapter(spinnerAdapter)
|
|
||||||
// spinner.adapter = spinnerAdapter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
@ -230,15 +187,11 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
}
|
}
|
||||||
adapter.setItems(mangaMap)
|
adapter.setItems(mangaMap)
|
||||||
|
|
||||||
|
|
||||||
//spinner.onItemSelectedListener = null
|
|
||||||
val categoryNames = presenter.categories.map { it.name }.toTypedArray()
|
val categoryNames = presenter.categories.map { it.name }.toTypedArray()
|
||||||
spinnerAdapter = SpinnerAdapter(recyclerLayout.context, R.layout.library_spinner_textview,
|
spinnerAdapter = SpinnerAdapter(recyclerLayout.context, R.layout.library_spinner_textview,
|
||||||
if (categoryNames.isNotEmpty()) categoryNames
|
if (categoryNames.isNotEmpty()) categoryNames
|
||||||
else arrayOf(recyclerLayout.context.getString(R.string.label_library))
|
else arrayOf(recyclerLayout.context.getString(R.string.label_library))
|
||||||
)
|
)
|
||||||
//spinnerAdapter?.setDropDownViewResource(R.layout.library_spinner_entry_text)
|
|
||||||
//spinner.setAdapter(spinnerAdapter)
|
|
||||||
|
|
||||||
val isCurrentController = router?.backstack?.lastOrNull()?.controller() ==
|
val isCurrentController = router?.backstack?.lastOrNull()?.controller() ==
|
||||||
this
|
this
|
||||||
@ -246,7 +199,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
?.setDisplayShowCustomEnabled(isCurrentController && presenter.categories.size > 1)
|
?.setDisplayShowCustomEnabled(isCurrentController && presenter.categories.size > 1)
|
||||||
if (isCurrentController) setTitle()
|
if (isCurrentController) setTitle()
|
||||||
|
|
||||||
//spinner.setSelection(min(presenter.categories.size - 1, activeCategory))
|
|
||||||
customTitleSpinner.category_title.text =
|
customTitleSpinner.category_title.text =
|
||||||
presenter.categories[clamp(activeCategory,
|
presenter.categories[clamp(activeCategory,
|
||||||
0,
|
0,
|
||||||
@ -265,7 +217,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
updateScroll = true
|
updateScroll = true
|
||||||
}
|
}
|
||||||
adapter.isLongPressDragEnabled = canDrag()
|
adapter.isLongPressDragEnabled = canDrag()
|
||||||
//tabsVisibilityRelay.call(false)
|
|
||||||
|
|
||||||
titlePopupMenu.menu.clear()
|
titlePopupMenu.menu.clear()
|
||||||
presenter.categories.forEach { category ->
|
presenter.categories.forEach { category ->
|
||||||
@ -275,13 +226,6 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
|
|
||||||
titlePopupMenu.show()
|
titlePopupMenu.show()
|
||||||
}
|
}
|
||||||
/*spinner.onItemSelectedListener = IgnoreFirstSpinnerListener { pos ->
|
|
||||||
if (updateScroll) {
|
|
||||||
updateScroll = false
|
|
||||||
return@IgnoreFirstSpinnerListener
|
|
||||||
}
|
|
||||||
scrollToHeader(presenter.categories[pos].order)
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scrollToHeader(pos: Int, fade:Boolean = false) {
|
private fun scrollToHeader(pos: Int, fade:Boolean = false) {
|
||||||
|
@ -507,7 +507,7 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
suspend fun updateView(categories: List<Category>, mangaMap: LibraryMap, freshStart:Boolean
|
suspend fun updateView(categories: List<Category>, mangaMap: LibraryMap, freshStart:Boolean
|
||||||
= false) {
|
= false) {
|
||||||
if (!preferences.libraryAsSingleList().getOrDefault()) {
|
if (view !is LibraryListController) {
|
||||||
view.onNextLibraryUpdate(categories, mangaMap, freshStart)
|
view.onNextLibraryUpdate(categories, mangaMap, freshStart)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -536,7 +536,7 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
fun updateViewBlocking() {
|
fun updateViewBlocking() {
|
||||||
val mangaMap = currentMangaMap ?: return
|
val mangaMap = currentMangaMap ?: return
|
||||||
if (!preferences.libraryAsSingleList().getOrDefault()) {
|
if (view !is LibraryListController) {
|
||||||
if (mangaMap.values.firstOrNull()?.firstOrNull()?.header != null)
|
if (mangaMap.values.firstOrNull()?.firstOrNull()?.header != null)
|
||||||
return
|
return
|
||||||
view.onNextLibraryUpdate(categories, mangaMap, true)
|
view.onNextLibraryUpdate(categories, mangaMap, true)
|
||||||
|
@ -161,7 +161,7 @@ class MangaDetailsController : BaseController,
|
|||||||
DividerItemDecoration.VERTICAL
|
DividerItemDecoration.VERTICAL
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(false)
|
||||||
adapter?.fastScroller = fast_scroller
|
adapter?.fastScroller = fast_scroller
|
||||||
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
|
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
|
||||||
val array = view.context.obtainStyledAttributes(attrsArray)
|
val array = view.context.obtainStyledAttributes(attrsArray)
|
||||||
@ -290,6 +290,7 @@ class MangaDetailsController : BaseController,
|
|||||||
else if (type == ControllerChangeType.PUSH_EXIT || type == ControllerChangeType.POP_EXIT) {
|
else if (type == ControllerChangeType.PUSH_EXIT || type == ControllerChangeType.POP_EXIT) {
|
||||||
if (router.backstack.lastOrNull()?.controller() is DialogController)
|
if (router.backstack.lastOrNull()?.controller() is DialogController)
|
||||||
return
|
return
|
||||||
|
if (type == ControllerChangeType.POP_EXIT) setHasOptionsMenu(false)
|
||||||
colorAnimator?.cancel()
|
colorAnimator?.cancel()
|
||||||
|
|
||||||
(activity as MainActivity).toolbar.setBackgroundColor(activity?.getResourceColor(
|
(activity as MainActivity).toolbar.setBackgroundColor(activity?.getResourceColor(
|
||||||
@ -333,17 +334,10 @@ class MangaDetailsController : BaseController,
|
|||||||
fun refreshAdapter() = adapter?.notifyDataSetChanged()
|
fun refreshAdapter() = adapter?.notifyDataSetChanged()
|
||||||
|
|
||||||
override fun onItemClick(view: View?, position: Int): Boolean {
|
override fun onItemClick(view: View?, position: Int): Boolean {
|
||||||
val adapter = adapter ?: return false
|
val chapter = adapter?.getItem(position)?.chapter ?: return false
|
||||||
val chapter = adapter.getItem(position)?.chapter ?: return false
|
|
||||||
if (chapter.isHeader) return false
|
if (chapter.isHeader) return false
|
||||||
/*if (actionMode != null && adapter.mode == SelectableAdapter.Mode.MULTI) {
|
openChapter(chapter)
|
||||||
lastClickPosition = position
|
return false
|
||||||
toggleSelection(position)
|
|
||||||
return true
|
|
||||||
} else {*/
|
|
||||||
openChapter(chapter)
|
|
||||||
return false
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
|
@ -208,6 +208,19 @@ fun View.applyWindowInsetsForController() {
|
|||||||
requestApplyInsetsWhenAttached()
|
requestApplyInsetsWhenAttached()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun View.checkHeightThen(f: () -> Unit) {
|
||||||
|
viewTreeObserver.addOnGlobalLayoutListener(
|
||||||
|
object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
override fun onGlobalLayout() {
|
||||||
|
if (height > 0) {
|
||||||
|
viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun View.applyWindowInsetsForRootController(bottomNav: View) {
|
fun View.applyWindowInsetsForRootController(bottomNav: View) {
|
||||||
viewTreeObserver.addOnGlobalLayoutListener(
|
viewTreeObserver.addOnGlobalLayoutListener(
|
||||||
object : ViewTreeObserver.OnGlobalLayoutListener {
|
object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
@ -279,10 +292,13 @@ fun Controller.setOnQueryTextChangeListener(searchView: SearchView, f: (text: St
|
|||||||
if (router.backstack.lastOrNull()?.controller() == this@setOnQueryTextChangeListener) {
|
if (router.backstack.lastOrNull()?.controller() == this@setOnQueryTextChangeListener) {
|
||||||
return f(newText)
|
return f(newText)
|
||||||
}
|
}
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||||
|
if (router.backstack.lastOrNull()?.controller() == this@setOnQueryTextChangeListener) {
|
||||||
|
return f(query)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -36,11 +36,6 @@
|
|||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:background="?android:attr/colorBackground"
|
android:background="?android:attr/colorBackground"
|
||||||
android:maxHeight="250dp"
|
android:maxHeight="250dp"
|
||||||
app:layout_constrainedHeight="true"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:background="?android:attr/colorBackground"
|
tools:background="?android:attr/colorBackground"
|
||||||
tools:ignore="ContentDescription"
|
tools:ignore="ContentDescription"
|
||||||
tools:src="@mipmap/ic_launcher" />
|
tools:src="@mipmap/ic_launcher" />
|
||||||
|
@ -449,7 +449,7 @@
|
|||||||
<string name="remember_choice">Remember this choice</string>
|
<string name="remember_choice">Remember this choice</string>
|
||||||
<string name="already_in_category">Manga already in category</string>
|
<string name="already_in_category">Manga already in category</string>
|
||||||
<string name="category">Category</string>
|
<string name="category">Category</string>
|
||||||
<string name="uniform_grid">Uniform Grid</string>
|
<string name="uniform_grid">Uniform covers</string>
|
||||||
<string name="small">Small</string>
|
<string name="small">Small</string>
|
||||||
<string name="medium">Medium</string>
|
<string name="medium">Medium</string>
|
||||||
<string name="large">Large</string>
|
<string name="large">Large</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user