Compact tracker card

This commit is contained in:
arkon 2020-03-09 16:27:23 -04:00
parent 8bfe59c8a8
commit 466ec7b962
4 changed files with 48 additions and 87 deletions

View File

@ -36,7 +36,7 @@ class TrackAdapter(controller: TrackController) : RecyclerView.Adapter<TrackHold
interface OnClickListener {
fun onLogoClick(position: Int)
fun onTitleClick(position: Int)
fun onSetClick(position: Int)
fun onStatusClick(position: Int)
fun onChaptersClick(position: Int)
fun onScoreClick(position: Int)

View File

@ -95,7 +95,7 @@ class TrackController : NucleusController<TrackPresenter>(),
}
}
override fun onTitleClick(position: Int) {
override fun onSetClick(position: Int) {
val item = adapter?.getItem(position) ?: return
TrackSearchDialog(this, item.service).showDialog(router, TAG_SEARCH_CONTROLLER)
}

View File

@ -2,21 +2,18 @@ package eu.kanade.tachiyomi.ui.manga.track
import android.annotation.SuppressLint
import android.view.View
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.track_item.chapters_container
import kotlinx.android.synthetic.main.track_item.logo_container
import kotlinx.android.synthetic.main.track_item.score_container
import kotlinx.android.synthetic.main.track_item.status_container
import kotlinx.android.synthetic.main.track_item.title_container
import kotlinx.android.synthetic.main.track_item.track_chapters
import kotlinx.android.synthetic.main.track_item.track_details
import kotlinx.android.synthetic.main.track_item.track_logo
import kotlinx.android.synthetic.main.track_item.track_score
import kotlinx.android.synthetic.main.track_item.track_set
import kotlinx.android.synthetic.main.track_item.track_status
import kotlinx.android.synthetic.main.track_item.track_title
class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
@ -24,28 +21,20 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
val listener = adapter.rowClickListener
logo_container.setOnClickListener { listener.onLogoClick(adapterPosition) }
title_container.setOnClickListener { listener.onTitleClick(adapterPosition) }
track_set.setOnClickListener { listener.onSetClick(adapterPosition) }
status_container.setOnClickListener { listener.onStatusClick(adapterPosition) }
chapters_container.setOnClickListener { listener.onChaptersClick(adapterPosition) }
score_container.setOnClickListener { listener.onScoreClick(adapterPosition) }
track_set.setOnClickListener { listener.onTitleClick(adapterPosition) }
}
@SuppressLint("SetTextI18n")
@Suppress("DEPRECATION")
fun bind(item: TrackItem) {
val track = item.track
track_logo.setImageResource(item.service.getLogo())
logo_container.setBackgroundColor(item.service.getLogoColor())
track_details.visibleIf { track != null }
track_set.visibleIf { track == null }
if (track != null) {
track_title.setTextAppearance(itemView.context, R.style.TextAppearance_Regular_Body1_Secondary)
track_title.isAllCaps = false
track_title.text = track.title
track_chapters.text = "${track.last_chapter_read}/" +
if (track.total_chapters > 0) track.total_chapters else "-"
track_status.text = item.service.getStatus(track.status)

View File

@ -8,7 +8,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize">
<FrameLayout
android:id="@+id/logo_container"
@ -29,66 +30,29 @@
</FrameLayout>
<Button
android:id="@+id/track_set"
style="@style/Theme.Widget.Button.Borderless.Small"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/action_edit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/logo_container"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/track_details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/track_set"
app:layout_constraintStart_toEndOf="@+id/logo_container"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="@+id/title_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectable_list_drawable"
android:clickable="true"
android:padding="16dp">
<TextView
style="@style/TextAppearance.Regular.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title" />
<TextView
android:id="@+id/track_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:ellipsize="middle"
android:gravity="end"
android:maxLines="1"
android:text="@string/action_edit" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="?android:attr/divider" />
<LinearLayout
android:id="@+id/status_container"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectable_list_drawable"
android:clickable="true"
android:padding="16dp">
android:focusable="true"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingEnd="8dp"
android:paddingBottom="16dp">
<TextView
style="@style/TextAppearance.Regular.Body1"
@ -101,26 +65,24 @@
style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:gravity="end"
android:layout_marginTop="8dp"
tools:text="Reading" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="?android:attr/divider" />
<LinearLayout
android:id="@+id/chapters_container"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectable_list_drawable"
android:clickable="true"
android:padding="16dp">
android:focusable="true"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingTop="16dp"
android:paddingEnd="8dp"
android:paddingBottom="16dp">
<TextView
style="@style/TextAppearance.Regular.Body1"
@ -133,26 +95,24 @@
style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:gravity="end"
android:layout_marginTop="8dp"
tools:text="12/24" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="?android:attr/divider" />
<LinearLayout
android:id="@+id/score_container"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectable_list_drawable"
android:clickable="true"
android:padding="16dp">
android:focusable="true"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<TextView
style="@style/TextAppearance.Regular.Body1"
@ -165,14 +125,26 @@
style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:gravity="end"
android:layout_marginTop="8dp"
tools:text="10" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/track_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/action_edit"
android:padding="8dp"
android:tint="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_create_white_24dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>