mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
chapter timestamps
This commit is contained in:
parent
6578921fe3
commit
51bdc79d34
@ -1,6 +1,7 @@
|
||||
package com.github.libretube.ui.adapters
|
||||
|
||||
import android.graphics.Color
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -27,15 +28,15 @@ class ChaptersAdapter(
|
||||
holder.binding.apply {
|
||||
ImageHelper.loadImage(chapter.image, chapterImage)
|
||||
chapterTitle.text = chapter.title
|
||||
timeStamp.text = chapter.start?.let { DateUtils.formatElapsedTime(it) }
|
||||
|
||||
if (selectedPosition == position) {
|
||||
// get the color for highlighted controls
|
||||
val color =
|
||||
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||
chapterLL.setBackgroundColor(color)
|
||||
val color = if (selectedPosition == position) {
|
||||
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||
} else {
|
||||
chapterLL.setBackgroundColor(Color.TRANSPARENT)
|
||||
Color.TRANSPARENT
|
||||
}
|
||||
chapterLL.setBackgroundColor(color)
|
||||
|
||||
root.setOnClickListener {
|
||||
updateSelectedPosition(position)
|
||||
val chapterStart = chapter.start!! * 1000 // s -> ms
|
||||
|
@ -991,10 +991,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer)
|
||||
|
||||
// enable the chapters dialog in the player
|
||||
val titles = mutableListOf<String>()
|
||||
chapters.forEach {
|
||||
titles += it.title!!
|
||||
}
|
||||
val titles = chapters.map { "${it.title} (${it.start?.let { DateUtils.formatElapsedTime(it) }})" }
|
||||
playerBinding.chapterLL.setOnClickListener {
|
||||
if (viewModel.isFullscreen.value!!) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
|
@ -15,12 +15,40 @@
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="5dp">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/chapter_image"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
app:shapeAppearanceOverlay="@style/roundedImageViewRounded" />
|
||||
android:layout_height="55dp">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/chapter_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:shapeAppearanceOverlay="@style/roundedImageViewRounded"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
app:cardBackgroundColor="@color/duration_background_color"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timeStamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="2dp"
|
||||
android:textColor="@color/duration_text_color"
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp"
|
||||
tools:text="05:36" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chapter_title"
|
||||
|
Loading…
Reference in New Issue
Block a user