- Added duration to video list

This commit is contained in:
Stefan Schüller 2019-01-06 03:23:18 +01:00
parent d0d3f6c634
commit a397822c23
3 changed files with 25 additions and 2 deletions

View File

@ -85,9 +85,12 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
.into(holder.avatar); .into(holder.avatar);
} }
// set Name
holder.name.setText(videoList.get(position).getName()); holder.name.setText(videoList.get(position).getName());
// set duration
holder.videoDuration.setText( MetaDataHelper.getDuration(videoList.get(position).getDuration().longValue()));
// set age and view count // set age and view count
holder.videoMeta.setText( holder.videoMeta.setText(
MetaDataHelper.getMetaString(videoList.get(position).getCreatedAt(), MetaDataHelper.getMetaString(videoList.get(position).getCreatedAt(),
@ -153,7 +156,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
class VideoViewHolder extends RecyclerView.ViewHolder { class VideoViewHolder extends RecyclerView.ViewHolder {
TextView name, videoMeta, videoOwner, moreButton; TextView name, videoMeta, videoOwner, moreButton, videoDuration;
ImageView thumb, avatar; ImageView thumb, avatar;
View mView; View mView;
@ -165,6 +168,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
videoMeta = itemView.findViewById(R.id.videoMeta); videoMeta = itemView.findViewById(R.id.videoMeta);
videoOwner = itemView.findViewById(R.id.videoOwner); videoOwner = itemView.findViewById(R.id.videoOwner);
moreButton = itemView.findViewById(R.id.moreButton); moreButton = itemView.findViewById(R.id.moreButton);
videoDuration = itemView.findViewById(R.id.video_duration);
mView = itemView; mView = itemView;
} }
} }

View File

@ -20,6 +20,9 @@ package net.schueller.peertube.helper;
import android.content.Context; import android.content.Context;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import net.schueller.peertube.R; import net.schueller.peertube.R;
import java.time.Duration;
import java.time.Period;
import java.util.Date; import java.util.Date;
public class MetaDataHelper { public class MetaDataHelper {
@ -37,4 +40,7 @@ public class MetaDataHelper {
serverHost; serverHost;
} }
public static String getDuration(Long duration) {
return DateUtils.formatElapsedTime(duration);
}
} }

View File

@ -24,6 +24,19 @@
android:maxHeight="300dp" android:maxHeight="300dp"
android:scaleType="fitXY" /> android:scaleType="fitXY" />
<TextView
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:layout_margin="2dp"
android:text=""
android:layout_above="@+id/avatar"
android:gravity="bottom|end"
android:layout_alignParentEnd="true"
android:id="@+id/video_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"/>
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="72dp" android:layout_width="72dp"