mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
fix: overflowing downloads layout on some devices
This commit is contained in:
parent
c40ab20c20
commit
d23b64dcec
@ -12,7 +12,7 @@ import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.databinding.DownloadedMediaRowBinding
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
import com.github.libretube.db.DatabaseHolder
|
||||
import com.github.libretube.db.obj.DownloadWithItems
|
||||
import com.github.libretube.extensions.formatAsFileSize
|
||||
@ -41,7 +41,7 @@ class DownloadsAdapter(
|
||||
private val toggleDownload: (DownloadWithItems) -> Boolean
|
||||
) : RecyclerView.Adapter<DownloadsViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DownloadsViewHolder {
|
||||
val binding = DownloadedMediaRowBinding.inflate(
|
||||
val binding = VideoRowBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
@ -53,9 +53,13 @@ class DownloadsAdapter(
|
||||
override fun onBindViewHolder(holder: DownloadsViewHolder, position: Int) {
|
||||
val download = downloads[position].download
|
||||
val items = downloads[position].downloadItems
|
||||
|
||||
holder.binding.apply {
|
||||
title.text = download.title
|
||||
uploaderName.text = download.uploader
|
||||
fileSize.isVisible = true
|
||||
|
||||
channelImageContainer.isGone = true
|
||||
videoTitle.text = download.title
|
||||
channelName.text = download.uploader
|
||||
videoInfo.text = download.uploadDate?.let { TextUtils.localizeDate(it) }
|
||||
watchProgress.setWatchProgressLength(download.videoId, download.duration ?: 0)
|
||||
|
||||
@ -81,14 +85,14 @@ class DownloadsAdapter(
|
||||
} else {
|
||||
downloadOverlay.isGone = true
|
||||
fileSize.text = totalSizeInfo
|
||||
durationContainer.isVisible = true
|
||||
thumbnailDurationCard.isVisible = true
|
||||
download.duration?.let {
|
||||
thumbnailDuration.text = DateUtils.formatElapsedTime(it)
|
||||
}
|
||||
}
|
||||
|
||||
download.thumbnailPath?.let { path ->
|
||||
ImageHelper.loadImage(path.toString(), thumbnailImage)
|
||||
ImageHelper.loadImage(path.toString(), thumbnail)
|
||||
}
|
||||
|
||||
progressBar.setOnClickListener {
|
||||
|
@ -81,7 +81,7 @@ class PlaylistAdapter(
|
||||
holder.binding.apply {
|
||||
videoTitle.text = streamItem.title
|
||||
videoInfo.text = streamItem.uploaderName
|
||||
channelImage.isGone = true
|
||||
channelImageContainer.isGone = true
|
||||
|
||||
thumbnailDuration.setFormattedDuration(streamItem.duration ?: -1, streamItem.isShort, streamItem.uploaded)
|
||||
|
||||
|
@ -68,7 +68,7 @@ class WatchHistoryAdapter(
|
||||
if (video.uploaderAvatar != null) {
|
||||
ImageHelper.loadImage(video.uploaderAvatar, channelImage, true)
|
||||
} else {
|
||||
channelImage.isGone = true
|
||||
channelImageContainer.isGone = true
|
||||
}
|
||||
|
||||
channelImage.setOnClickListener {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.github.libretube.ui.viewholders
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.databinding.DownloadedMediaRowBinding
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
|
||||
class DownloadsViewHolder(
|
||||
val binding: DownloadedMediaRowBinding
|
||||
val binding: VideoRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root)
|
||||
|
@ -1,146 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="8dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="15dp"
|
||||
app:cardCornerRadius="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thumbnailImage"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="83dp"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/durationContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:visibility="gone"
|
||||
app:cardBackgroundColor="@color/duration_background_color"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/thumbnailImage"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thumbnail_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:paddingVertical="2dp"
|
||||
android:textColor="@color/duration_text_color"
|
||||
android:textSize="11sp"
|
||||
tools:text="05:36" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<View
|
||||
android:id="@+id/watch_progress"
|
||||
style="@style/WatchProgress"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible"
|
||||
tools:layout_width="20dp" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/downloadOverlay"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="83dp"
|
||||
android:background="#BF000000"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:indeterminateOnly="false"
|
||||
android:progressDrawable="@drawable/circular_progress"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/resumePauseBtn"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_download"
|
||||
app:layout_constraintBottom_toBottomOf="@id/progressBar"
|
||||
app:layout_constraintLeft_toLeftOf="@id/progressBar"
|
||||
app:layout_constraintRight_toRightOf="@id/progressBar"
|
||||
app:layout_constraintTop_toTopOf="@id/progressBar" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/uploaderName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="2dp"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/videoInfo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fileSize"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="13sp"
|
||||
tools:text="13.13MB" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -66,6 +66,37 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/downloadOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#BF000000"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:indeterminateOnly="false"
|
||||
android:progressDrawable="@drawable/circular_progress"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/resumePauseBtn"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_download"
|
||||
app:layout_constraintBottom_toBottomOf="@id/progressBar"
|
||||
app:layout_constraintLeft_toLeftOf="@id/progressBar"
|
||||
app:layout_constraintRight_toRightOf="@id/progressBar"
|
||||
app:layout_constraintTop_toTopOf="@id/progressBar" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
@ -108,7 +139,9 @@
|
||||
android:id="@+id/channel_image_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="13.5dp">
|
||||
app:cardCornerRadius="13.5dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/channel_image"
|
||||
@ -122,10 +155,22 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="8dp"
|
||||
android:ellipsize="end"
|
||||
tools:text="Uploader name"
|
||||
android:maxLines="1" />
|
||||
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/file_size"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
tools:text="55MB/2050MB"
|
||||
tools:visibility="visible"
|
||||
android:textAlignment="viewEnd" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user