mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-11 17:00:48 +01:00
Combine chapter date/scanlator lines
This commit is contained in:
parent
63e330b83d
commit
c38026886a
2 changed files with 23 additions and 50 deletions
|
@ -6,12 +6,9 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import kotlinx.android.synthetic.main.chapters_item.chapter_date
|
import kotlinx.android.synthetic.main.chapters_item.chapter_description
|
||||||
import kotlinx.android.synthetic.main.chapters_item.chapter_menu
|
import kotlinx.android.synthetic.main.chapters_item.chapter_menu
|
||||||
import kotlinx.android.synthetic.main.chapters_item.chapter_pages
|
|
||||||
import kotlinx.android.synthetic.main.chapters_item.chapter_scanlator
|
|
||||||
import kotlinx.android.synthetic.main.chapters_item.chapter_title
|
import kotlinx.android.synthetic.main.chapters_item.chapter_title
|
||||||
import kotlinx.android.synthetic.main.chapters_item.download_text
|
import kotlinx.android.synthetic.main.chapters_item.download_text
|
||||||
|
|
||||||
|
@ -39,30 +36,29 @@ class ChapterHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set correct text color
|
// Set correct text color
|
||||||
chapter_title.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor)
|
val chapterColor = if (chapter.read) adapter.readColor else adapter.unreadColor
|
||||||
if (chapter.bookmark) chapter_title.setTextColor(adapter.bookmarkedColor)
|
chapter_title.setTextColor(chapterColor)
|
||||||
|
chapter_description.setTextColor(chapterColor)
|
||||||
|
if (chapter.bookmark) {
|
||||||
|
chapter_title.setTextColor(adapter.bookmarkedColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
val descriptions = mutableListOf<String>()
|
||||||
|
|
||||||
if (chapter.date_upload > 0) {
|
if (chapter.date_upload > 0) {
|
||||||
chapter_date.text = adapter.dateFormat.format(Date(chapter.date_upload))
|
descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload)))
|
||||||
chapter_date.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor)
|
}
|
||||||
} else {
|
if (!chapter.scanlator.isNullOrBlank()) {
|
||||||
chapter_date.text = ""
|
descriptions.add(chapter.scanlator!!)
|
||||||
|
}
|
||||||
|
if (!chapter.read && chapter.last_page_read > 0) {
|
||||||
|
descriptions.add(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// add scanlator if exists
|
if (descriptions.isNotEmpty()) {
|
||||||
chapter_scanlator.text = chapter.scanlator
|
chapter_description.text = descriptions.joinToString(" • ")
|
||||||
// allow longer titles if there is no scanlator (most sources)
|
|
||||||
if (chapter_scanlator.text.isNullOrBlank()) {
|
|
||||||
chapter_title.maxLines = 2
|
|
||||||
chapter_scanlator.gone()
|
|
||||||
} else {
|
} else {
|
||||||
chapter_title.maxLines = 1
|
chapter_description.text = ""
|
||||||
}
|
|
||||||
|
|
||||||
chapter_pages.text = if (!chapter.read && chapter.last_page_read > 0) {
|
|
||||||
itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyStatus(item.status)
|
notifyStatus(item.status)
|
||||||
|
|
|
@ -21,41 +21,17 @@
|
||||||
tools:text="Title" />
|
tools:text="Title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/chapter_scanlator"
|
android:id="@+id/chapter_description"
|
||||||
style="@style/TextAppearance.Regular.Caption.Hint"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:maxLines="1"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/chapter_date"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/chapter_menu"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/chapter_title"
|
|
||||||
tools:text="Scanlator" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/chapter_date"
|
|
||||||
style="@style/TextAppearance.Regular.Caption"
|
style="@style/TextAppearance.Regular.Caption"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
tools:text="22/02/2016" />
|
tools:text="22/02/2016 • Scanlator • Page: 45" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/chapter_pages"
|
|
||||||
style="@style/TextAppearance.Regular.Caption.Hint"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:singleLine="true"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
tools:text="Pages: 45" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/chapter_menu"
|
android:id="@+id/chapter_menu"
|
||||||
|
@ -76,6 +52,7 @@
|
||||||
style="@style/TextAppearance.Regular.Caption.Hint"
|
style="@style/TextAppearance.Regular.Caption.Hint"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|
Loading…
Reference in a new issue