layout improvements

This commit is contained in:
Jay 2020-02-20 00:10:15 -08:00
parent 49d95e2dd0
commit c88fc38238
4 changed files with 51 additions and 49 deletions

View File

@ -2,17 +2,13 @@ package eu.kanade.tachiyomi.ui.library
import android.view.Gravity import android.view.Gravity
import android.view.View import android.view.View
import android.view.ViewTreeObserver
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.constraintlayout.widget.ConstraintLayout
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.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.source.LocalSource import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.catalogue_grid_item.* import kotlinx.android.synthetic.main.catalogue_grid_item.*
import kotlinx.android.synthetic.main.unread_download_badge.* import kotlinx.android.synthetic.main.unread_download_badge.*
@ -35,8 +31,7 @@ class LibraryGridHolder(
init { init {
play_layout.setOnClickListener { playButtonClicked() } play_layout.setOnClickListener { playButtonClicked() }
if (fixedSize) { if (fixedSize) {
title.gone() text_layout.gone()
subtitle.gone()
} }
else { else {
compact_title.gone() compact_title.gone()
@ -61,7 +56,7 @@ class LibraryGridHolder(
title.text = item.manga.currentTitle() title.text = item.manga.currentTitle()
subtitle.text = item.manga.originalAuthor()?.trim() subtitle.text = item.manga.originalAuthor()?.trim()
if (!fixedSize) { /* if (!fixedSize) {
title.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { title.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean { override fun onPreDraw(): Boolean {
title.viewTreeObserver.removeOnPreDrawListener(this) title.viewTreeObserver.removeOnPreDrawListener(this)
@ -81,7 +76,7 @@ class LibraryGridHolder(
return true return true
} }
}) })
} }*/
compact_title.text = title.text compact_title.text = title.text
@ -103,10 +98,10 @@ 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(view.context).load(item.manga) var glide = GlideApp.with(adapter.recyclerView.context).load(item.manga)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString())) .signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
glide = if (fixedSize) glide.centerCrop() else glide.override(width) glide = if (fixedSize) glide.centerCrop() else glide.override(cover_thumbnail.maxHeight)
glide.into(cover_thumbnail) glide.into(cover_thumbnail)
} }
} }

View File

@ -17,6 +17,8 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.library_category_header_item.view.* import kotlinx.android.synthetic.main.library_category_header_item.view.*
@ -92,15 +94,15 @@ class LibraryHeaderItem(val category: Category) : AbstractHeaderItem<LibraryHead
when { when {
item.category.id == -1 -> { item.category.id == -1 -> {
catProgress.alpha = 1f catProgress.gone()
updateButton.invisible() updateButton.invisible()
} }
LibraryUpdateService.categoryInQueue(item.category.id) -> { LibraryUpdateService.categoryInQueue(item.category.id) -> {
catProgress.alpha = 1f catProgress.visible()
updateButton.invisible() updateButton.invisible()
} }
else -> { else -> {
catProgress.alpha = 0f catProgress.gone()
updateButton.visible() updateButton.visible()
} }
} }
@ -108,8 +110,10 @@ class LibraryHeaderItem(val category: Category) : AbstractHeaderItem<LibraryHead
private fun addCategoryToUpdate() { private fun addCategoryToUpdate() {
if (adapter.libraryListener.updateCategory(adapterPosition)) { if (adapter.libraryListener.updateCategory(adapterPosition)) {
catProgress.alpha = 1f
updateButton.invisible() updateButton.invisible()
launchUI {
adapter.notifyItemChanged(adapterPosition)
}
} }
} }
private fun showCatSortOptions() { private fun showCatSortOptions() {

View File

@ -24,7 +24,7 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/title" app:layout_constraintBottom_toTopOf="@+id/text_layout"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -122,21 +122,28 @@
app:layout_constraintBottom_toBottomOf="@id/badge_guide" app:layout_constraintBottom_toBottomOf="@id/badge_guide"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:id="@+id/text_layout"
android:layout_width="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
android:layout_height="32sp">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
style="@style/TextAppearance.Regular.Body1.Light" style="@style/TextAppearance.Regular.Body1.Light"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/subtitle" app:layout_constraintBottom_toTopOf="@+id/subtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Sample name" /> tools:text="Sample name" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
@ -147,15 +154,13 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="-1dp" android:layout_marginTop="-1dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Sample artist" /> tools:text="Sample artist" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout> </FrameLayout>

View File

@ -64,11 +64,9 @@
<ProgressBar <ProgressBar
android:id="@+id/cat_progress" android:id="@+id/cat_progress"
android:layout_width="wrap_content" android:layout_width="30dp"
android:indeterminate="true" android:indeterminate="true"
android:layout_height="30dp" android:layout_height="30dp"
android:alpha="0.0"
tools:alpha="1.0"
android:layout_marginStart="0dp" android:layout_marginStart="0dp"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintBottom_toBottomOf="@+id/update_button" app:layout_constraintBottom_toBottomOf="@+id/update_button"