mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 18:11:53 +01:00
Using a smaller item view for only updates mode
This commit is contained in:
parent
6f78187cb9
commit
bbf3fcab18
@ -21,6 +21,9 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
||||
var showRemoveHistory = true
|
||||
var showTitleFirst = false
|
||||
|
||||
val viewType: Int
|
||||
get() = delegate.getViewType()
|
||||
|
||||
fun updateItems(items: List<IFlexible<*>>?) {
|
||||
updateDataSet(items)
|
||||
}
|
||||
@ -55,6 +58,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
||||
fun markAsRead(position: Int)
|
||||
fun isSearching(): Boolean
|
||||
fun scope(): CoroutineScope
|
||||
fun getViewType(): Int
|
||||
}
|
||||
|
||||
override fun onItemSwiped(position: Int, direction: Int) {
|
||||
|
@ -2,7 +2,9 @@ package eu.kanade.tachiyomi.ui.recents
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
||||
@ -10,6 +12,7 @@ import eu.kanade.tachiyomi.databinding.RecentMangaItemBinding
|
||||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterUtil
|
||||
import eu.kanade.tachiyomi.util.isLocal
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.timeSpanFromNow
|
||||
|
||||
class RecentMangaHolder(
|
||||
@ -32,6 +35,35 @@ class RecentMangaHolder(
|
||||
RecentMangaAdapter.ShowRecentsDLs.All -> true
|
||||
} && !item.mch.manga.isLocal()
|
||||
|
||||
val isUpdates = adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES
|
||||
binding.cardLayout.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
height = (if (isUpdates) 40 else 80).dpToPx
|
||||
width = (if (isUpdates) 40 else 60).dpToPx
|
||||
}
|
||||
listOf(binding.title, binding.subtitle).forEach {
|
||||
it.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
if (isUpdates) {
|
||||
if (it == binding.title) topMargin = 5.dpToPx
|
||||
endToStart = R.id.button_layout
|
||||
endToEnd = -1
|
||||
} else {
|
||||
if (it == binding.title) topMargin = 2.dpToPx
|
||||
endToStart = -1
|
||||
endToEnd = R.id.front_view
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.buttonLayout.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
if (isUpdates) {
|
||||
topToBottom = -1
|
||||
topToTop = R.id.front_view
|
||||
} else {
|
||||
topToTop = -1
|
||||
topToBottom = R.id.subtitle
|
||||
}
|
||||
}
|
||||
binding.subtitle.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
}
|
||||
binding.removeHistory.isVisible = item.mch.history.id != null && showRemoveHistory
|
||||
binding.title.apply {
|
||||
text = if (!showTitleFirst) {
|
||||
@ -50,11 +82,13 @@ class RecentMangaHolder(
|
||||
setTextColor(ChapterUtil.readColor(context, item))
|
||||
}
|
||||
val notValidNum = item.mch.chapter.chapter_number <= 0
|
||||
binding.body.isVisible = !isUpdates
|
||||
binding.body.text = when {
|
||||
item.mch.chapter.id == null -> binding.body.context.getString(
|
||||
R.string.added_,
|
||||
item.mch.manga.date_added.timeSpanFromNow
|
||||
)
|
||||
adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES -> ""
|
||||
item.mch.history.id == null -> binding.body.context.getString(
|
||||
R.string.updated_,
|
||||
item.chapter.date_upload.timeSpanFromNow
|
||||
|
@ -464,6 +464,8 @@ class RecentsController(bundle: Bundle? = null) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun getViewType(): Int = presenter.viewType
|
||||
|
||||
override fun scope() = adapterScope
|
||||
|
||||
override fun onItemClick(view: View?, position: Int): Boolean {
|
||||
|
@ -59,8 +59,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:maxHeight="60dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -85,10 +85,13 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/subtitle"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/card_layout"
|
||||
app:flow_verticalBias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@id/card_layout"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="New Chapter" />
|
||||
|
||||
@ -98,7 +101,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
@ -109,7 +111,7 @@
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
app:layout_constraintBottom_toTopOf="@id/body"
|
||||
tools:text="Manga title" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
@ -118,20 +120,27 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:ellipsize="end"
|
||||
android:lineSpacingExtra="2dp"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toTopOf="@id/space"
|
||||
app:layout_constraintEnd_toStartOf="@id/button_layout"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/subtitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/subtitle"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
tools:text="3 Days ago" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/space"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_line"
|
||||
app:layout_constraintTop_toBottomOf="@id/body" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
@ -166,13 +175,14 @@
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/next_title"
|
||||
android:padding="8dp"
|
||||
app:tint="@color/holo_red"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:tooltipText="@string/reset_chapter_history"
|
||||
app:srcCompat="@drawable/ic_eye_remove_outline_24dp" />
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:srcCompat="@drawable/ic_eye_remove_outline_24dp"
|
||||
app:tint="@color/holo_red" />
|
||||
|
||||
<include
|
||||
layout="@layout/download_button"
|
||||
android:id="@+id/download_button"
|
||||
layout="@layout/download_button"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
@ -184,7 +194,7 @@
|
||||
android:layout_margin="6dp"
|
||||
android:orientation="horizontal"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="card_layout,body" />
|
||||
app:constraint_referenced_ids="space,card_layout" />
|
||||
|
||||
<View
|
||||
android:id="@+id/padding"
|
||||
|
Loading…
Reference in New Issue
Block a user