Info text has smaller font, conversion moved utility class
This commit is contained in:
parent
35dcabd103
commit
76393e1e7c
|
@ -47,6 +47,7 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||
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.QueueSorter;
|
||||
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
|
||||
|
@ -475,19 +476,14 @@ public class QueueFragment extends Fragment {
|
|||
// refresh information bar
|
||||
String info = queue.size() + getString(R.string.episodes_suffix);
|
||||
if(queue.size() > 0) {
|
||||
int durationSec = 0;
|
||||
int duration = 0;
|
||||
for(FeedItem item : queue) {
|
||||
if(item.getMedia() != null) {
|
||||
durationSec += item.getMedia().getDuration() / 1000;
|
||||
duration += item.getMedia().getDuration();
|
||||
}
|
||||
}
|
||||
int hours = durationSec / 3600;
|
||||
int minutes = (durationSec % 3600) / 60;
|
||||
info += " \u2022 ";
|
||||
if (hours > 0) {
|
||||
info += hours + " " + getString(R.string.time_unit_hours) + " ";
|
||||
}
|
||||
info += minutes + " " + getString(R.string.time_unit_minutes);
|
||||
info += Converter.getDurationStringLocalized(getActivity(), duration);
|
||||
}
|
||||
infoBar.setText(info);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
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
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
|
||||
/** Provides methods for converting various units. */
|
||||
public final class Converter {
|
||||
/** Class shall not be instantiated. */
|
||||
|
@ -100,4 +103,20 @@ public final class Converter {
|
|||
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