mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Compact tracker card
This commit is contained in:
parent
8bfe59c8a8
commit
466ec7b962
@ -36,7 +36,7 @@ class TrackAdapter(controller: TrackController) : RecyclerView.Adapter<TrackHold
|
|||||||
|
|
||||||
interface OnClickListener {
|
interface OnClickListener {
|
||||||
fun onLogoClick(position: Int)
|
fun onLogoClick(position: Int)
|
||||||
fun onTitleClick(position: Int)
|
fun onSetClick(position: Int)
|
||||||
fun onStatusClick(position: Int)
|
fun onStatusClick(position: Int)
|
||||||
fun onChaptersClick(position: Int)
|
fun onChaptersClick(position: Int)
|
||||||
fun onScoreClick(position: Int)
|
fun onScoreClick(position: Int)
|
||||||
|
@ -95,7 +95,7 @@ class TrackController : NucleusController<TrackPresenter>(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTitleClick(position: Int) {
|
override fun onSetClick(position: Int) {
|
||||||
val item = adapter?.getItem(position) ?: return
|
val item = adapter?.getItem(position) ?: return
|
||||||
TrackSearchDialog(this, item.service).showDialog(router, TAG_SEARCH_CONTROLLER)
|
TrackSearchDialog(this, item.service).showDialog(router, TAG_SEARCH_CONTROLLER)
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,18 @@ package eu.kanade.tachiyomi.ui.manga.track
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import kotlinx.android.synthetic.main.track_item.chapters_container
|
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.logo_container
|
||||||
import kotlinx.android.synthetic.main.track_item.score_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.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_chapters
|
||||||
import kotlinx.android.synthetic.main.track_item.track_details
|
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_logo
|
||||||
import kotlinx.android.synthetic.main.track_item.track_score
|
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_set
|
||||||
import kotlinx.android.synthetic.main.track_item.track_status
|
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) {
|
class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
|
||||||
|
|
||||||
@ -24,28 +21,20 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
|
|||||||
val listener = adapter.rowClickListener
|
val listener = adapter.rowClickListener
|
||||||
|
|
||||||
logo_container.setOnClickListener { listener.onLogoClick(adapterPosition) }
|
logo_container.setOnClickListener { listener.onLogoClick(adapterPosition) }
|
||||||
title_container.setOnClickListener { listener.onTitleClick(adapterPosition) }
|
track_set.setOnClickListener { listener.onSetClick(adapterPosition) }
|
||||||
status_container.setOnClickListener { listener.onStatusClick(adapterPosition) }
|
status_container.setOnClickListener { listener.onStatusClick(adapterPosition) }
|
||||||
chapters_container.setOnClickListener { listener.onChaptersClick(adapterPosition) }
|
chapters_container.setOnClickListener { listener.onChaptersClick(adapterPosition) }
|
||||||
score_container.setOnClickListener { listener.onScoreClick(adapterPosition) }
|
score_container.setOnClickListener { listener.onScoreClick(adapterPosition) }
|
||||||
|
|
||||||
track_set.setOnClickListener { listener.onTitleClick(adapterPosition) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
fun bind(item: TrackItem) {
|
fun bind(item: TrackItem) {
|
||||||
val track = item.track
|
val track = item.track
|
||||||
track_logo.setImageResource(item.service.getLogo())
|
track_logo.setImageResource(item.service.getLogo())
|
||||||
logo_container.setBackgroundColor(item.service.getLogoColor())
|
logo_container.setBackgroundColor(item.service.getLogoColor())
|
||||||
|
|
||||||
track_details.visibleIf { track != null }
|
track_details.visibleIf { track != null }
|
||||||
track_set.visibleIf { track == null }
|
|
||||||
|
|
||||||
if (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}/" +
|
track_chapters.text = "${track.last_chapter_read}/" +
|
||||||
if (track.total_chapters > 0) track.total_chapters else "-"
|
if (track.total_chapters > 0) track.total_chapters else "-"
|
||||||
track_status.text = item.service.getStatus(track.status)
|
track_status.text = item.service.getStatus(track.status)
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?attr/actionBarSize">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/logo_container"
|
android:id="@+id/logo_container"
|
||||||
@ -29,66 +30,29 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</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
|
<LinearLayout
|
||||||
android:id="@+id/track_details"
|
android:id="@+id/track_details"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/track_set"
|
||||||
app:layout_constraintStart_toEndOf="@+id/logo_container"
|
app:layout_constraintStart_toEndOf="@+id/logo_container"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
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
|
<LinearLayout
|
||||||
android:id="@+id/status_container"
|
android:id="@+id/status_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="?attr/selectable_list_drawable"
|
android:background="?attr/selectable_list_drawable"
|
||||||
android:clickable="true"
|
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
|
<TextView
|
||||||
style="@style/TextAppearance.Regular.Body1"
|
style="@style/TextAppearance.Regular.Body1"
|
||||||
@ -101,26 +65,24 @@
|
|||||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="end"
|
|
||||||
tools:text="Reading" />
|
tools:text="Reading" />
|
||||||
|
|
||||||
</LinearLayout>
|
</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
|
<LinearLayout
|
||||||
android:id="@+id/chapters_container"
|
android:id="@+id/chapters_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="?attr/selectable_list_drawable"
|
android:background="?attr/selectable_list_drawable"
|
||||||
android:clickable="true"
|
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
|
<TextView
|
||||||
style="@style/TextAppearance.Regular.Body1"
|
style="@style/TextAppearance.Regular.Body1"
|
||||||
@ -133,26 +95,24 @@
|
|||||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="end"
|
|
||||||
tools:text="12/24" />
|
tools:text="12/24" />
|
||||||
|
|
||||||
</LinearLayout>
|
</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
|
<LinearLayout
|
||||||
android:id="@+id/score_container"
|
android:id="@+id/score_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="?attr/selectable_list_drawable"
|
android:background="?attr/selectable_list_drawable"
|
||||||
android:clickable="true"
|
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
|
<TextView
|
||||||
style="@style/TextAppearance.Regular.Body1"
|
style="@style/TextAppearance.Regular.Body1"
|
||||||
@ -165,14 +125,26 @@
|
|||||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="end"
|
|
||||||
tools:text="10" />
|
tools:text="10" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</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.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
Loading…
Reference in New Issue
Block a user