Merge pull request #1020 from mfietz/feature/queue-information
Queue shows number of episodes and total duration
This commit is contained in:
commit
d1ef7f63ff
|
@ -47,6 +47,7 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||||
|
import de.danoeh.antennapod.core.util.Converter;
|
||||||
import de.danoeh.antennapod.core.util.LongList;
|
import de.danoeh.antennapod.core.util.LongList;
|
||||||
import de.danoeh.antennapod.core.util.QueueSorter;
|
import de.danoeh.antennapod.core.util.QueueSorter;
|
||||||
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
|
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
|
||||||
|
@ -66,6 +67,7 @@ public class QueueFragment extends Fragment {
|
||||||
EventDistributor.DOWNLOAD_QUEUED |
|
EventDistributor.DOWNLOAD_QUEUED |
|
||||||
EventDistributor.PLAYER_STATUS_UPDATE;
|
EventDistributor.PLAYER_STATUS_UPDATE;
|
||||||
|
|
||||||
|
private TextView infoBar;
|
||||||
private DragSortListView listView;
|
private DragSortListView listView;
|
||||||
private QueueListAdapter listAdapter;
|
private QueueListAdapter listAdapter;
|
||||||
private TextView txtvEmpty;
|
private TextView txtvEmpty;
|
||||||
|
@ -363,6 +365,7 @@ public class QueueFragment extends Fragment {
|
||||||
((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.queue_label);
|
((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.queue_label);
|
||||||
|
|
||||||
View root = inflater.inflate(R.layout.queue_fragment, container, false);
|
View root = inflater.inflate(R.layout.queue_fragment, container, false);
|
||||||
|
infoBar = (TextView) root.findViewById(R.id.info_bar);
|
||||||
listView = (DragSortListView) root.findViewById(android.R.id.list);
|
listView = (DragSortListView) root.findViewById(android.R.id.list);
|
||||||
txtvEmpty = (TextView) root.findViewById(android.R.id.empty);
|
txtvEmpty = (TextView) root.findViewById(android.R.id.empty);
|
||||||
progLoading = (ProgressBar) root.findViewById(R.id.progLoading);
|
progLoading = (ProgressBar) root.findViewById(R.id.progLoading);
|
||||||
|
@ -469,6 +472,20 @@ public class QueueFragment extends Fragment {
|
||||||
// we need to refresh the options menu because it sometimes
|
// we need to refresh the options menu because it sometimes
|
||||||
// needs data that may have just been loaded.
|
// needs data that may have just been loaded.
|
||||||
getActivity().supportInvalidateOptionsMenu();
|
getActivity().supportInvalidateOptionsMenu();
|
||||||
|
|
||||||
|
// refresh information bar
|
||||||
|
String info = queue.size() + getString(R.string.episodes_suffix);
|
||||||
|
if(queue.size() > 0) {
|
||||||
|
int duration = 0;
|
||||||
|
for(FeedItem item : queue) {
|
||||||
|
if(item.getMedia() != null) {
|
||||||
|
duration += item.getMedia().getDuration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info += " \u2022 ";
|
||||||
|
info += Converter.getDurationStringLocalized(getActivity(), duration);
|
||||||
|
}
|
||||||
|
infoBar.setText(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() {
|
private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() {
|
||||||
|
|
|
@ -1,18 +1,33 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:dslv="http://schemas.android.com/apk/res-auto"
|
xmlns:dslv="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/info_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:text="42 episodes \u2022 5 hours 17 minutes"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_below="@id/info_bar"
|
||||||
|
android:background="?android:attr/listDivider"/>
|
||||||
|
|
||||||
<com.mobeta.android.dslv.DragSortListView
|
<com.mobeta.android.dslv.DragSortListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="@dimen/list_vertical_padding"
|
|
||||||
android:paddingTop="@dimen/list_vertical_padding"
|
|
||||||
android:scrollbarStyle="outsideOverlay"
|
android:scrollbarStyle="outsideOverlay"
|
||||||
|
android:layout_below="@+id/divider"
|
||||||
dslv:collapsed_height="2dp"
|
dslv:collapsed_height="2dp"
|
||||||
dslv:drag_enabled="true"
|
dslv:drag_enabled="true"
|
||||||
dslv:drag_handle_id="@id/drag_handle"
|
dslv:drag_handle_id="@id/drag_handle"
|
||||||
|
@ -31,7 +46,7 @@
|
||||||
android:id="@id/android:empty"
|
android:id="@id/android:empty"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_centerInParent="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/no_items_label" />
|
android:text="@string/no_items_label" />
|
||||||
|
|
||||||
|
@ -39,12 +54,13 @@
|
||||||
android:id="@+id/progLoading"
|
android:id="@+id/progLoading"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_centerInParent="true"
|
||||||
android:indeterminateOnly="true"
|
android:indeterminateOnly="true"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/undobar"
|
android:id="@+id/undobar"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
style="@style/UndoBar">
|
style="@style/UndoBar">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -57,4 +73,4 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package de.danoeh.antennapod.core.util;
|
package de.danoeh.antennapod.core.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.R;
|
||||||
|
|
||||||
/** Provides methods for converting various units. */
|
/** Provides methods for converting various units. */
|
||||||
public final class Converter {
|
public final class Converter {
|
||||||
/** Class shall not be instantiated. */
|
/** Class shall not be instantiated. */
|
||||||
|
@ -99,5 +102,21 @@ public final class Converter {
|
||||||
return Integer.valueOf(parts[0]) * 3600 * 1000 +
|
return Integer.valueOf(parts[0]) * 3600 * 1000 +
|
||||||
Integer.valueOf(parts[1]) * 1000 * 60;
|
Integer.valueOf(parts[1]) * 1000 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Converts milliseconds to a localized string containing hours and minutes */
|
||||||
|
public static String getDurationStringLocalized(Context context, int duration) {
|
||||||
|
int h = duration / HOURS_MIL;
|
||||||
|
int rest = duration - h * HOURS_MIL;
|
||||||
|
int m = rest / MINUTES_MIL;
|
||||||
|
|
||||||
|
String result = "";
|
||||||
|
if(h > 0) {
|
||||||
|
String hours = context.getString(R.string.time_unit_hours);
|
||||||
|
result += h + " " + hours + " ";
|
||||||
|
}
|
||||||
|
String minutes = context.getString(R.string.time_unit_minutes);
|
||||||
|
result += m + " " + minutes;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue