From acf065b7cd54e065c8ee0eb105aa6286e95ff952 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sat, 15 Apr 2017 14:32:33 +0200 Subject: Added duration to chapters list Closes #2174 --- .../de/danoeh/antennapod/adapter/ChaptersListAdapter.java | 12 ++++++++++++ app/src/main/res/layout/simplechapter_item.xml | 10 ++++++++++ 2 files changed, 22 insertions(+) (limited to 'app') diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java index 37e00ab74..d7bebb672 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java @@ -60,6 +60,7 @@ public class ChaptersListAdapter extends ArrayAdapter { defaultTextColor = holder.title.getTextColors().getDefaultColor(); holder.start = (TextView) convertView.findViewById(R.id.txtvStart); holder.link = (TextView) convertView.findViewById(R.id.txtvLink); + holder.duration = (TextView) convertView.findViewById(R.id.txtvDuration); holder.butPlayChapter = (ImageButton) convertView.findViewById(R.id.butPlayChapter); convertView.setTag(holder); } else { @@ -70,6 +71,16 @@ public class ChaptersListAdapter extends ArrayAdapter { holder.title.setText(sc.getTitle()); holder.start.setText(Converter.getDurationStringLong((int) sc .getStart())); + + long duration; + if (position + 1 < media.getChapters().size()) { + duration = media.getChapters().get(position + 1).getStart() - sc.getStart(); + } else { + duration = media.getDuration() - sc.getStart(); + } + holder.duration.setText(getContext().getString(R.string.chapter_duration, + Converter.getDurationStringLong((int) duration))); + if (sc.getLink() != null) { holder.link.setVisibility(View.VISIBLE); holder.link.setText(sc.getLink()); @@ -155,6 +166,7 @@ public class ChaptersListAdapter extends ArrayAdapter { TextView title; TextView start; TextView link; + TextView duration; ImageButton butPlayChapter; } diff --git a/app/src/main/res/layout/simplechapter_item.xml b/app/src/main/res/layout/simplechapter_item.xml index fae6bac8c..21bbc9545 100644 --- a/app/src/main/res/layout/simplechapter_item.xml +++ b/app/src/main/res/layout/simplechapter_item.xml @@ -53,6 +53,16 @@ tools:text="Link" tools:background="@android:color/holo_green_dark" /> + + -- cgit v1.2.3