blob: d3ee08546c73a03b1c282adb9804eed2321855b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package de.danoeh.antennapod.adapter;
import android.content.res.Resources;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.util.Converter;
/**
* Utility methods for adapters
*/
public class AdapterUtils {
private AdapterUtils() {
}
/**
* Updates the contents of the TextView that shows the current playback position and the ProgressBar.
*/
public static void updateEpisodePlaybackProgress(FeedItem item, Resources res, TextView txtvPos, ProgressBar episodeProgress) {
FeedMedia media = item.getMedia();
episodeProgress.setVisibility(View.GONE);
if (media == null) {
txtvPos.setVisibility(View.GONE);
return;
} else {
txtvPos.setVisibility(View.VISIBLE);
}
FeedItem.State state = item.getState();
if (state == FeedItem.State.PLAYING
|| state == FeedItem.State.IN_PROGRESS) {
if (media.getDuration() > 0) {
episodeProgress.setVisibility(View.VISIBLE);
episodeProgress.setProgress((int) (((double) media
.getPosition()) / media.getDuration() * 100));
txtvPos.setText(Converter.getDurationStringLong(media.getDuration()
- media.getPosition()));
}
} else if (!media.isDownloaded()) {
if(media.getSize() > 0) {
txtvPos.setText(Converter.byteToString(media.getSize()));
} else {
txtvPos.setText("");
}
} else {
txtvPos.setText(Converter.getDurationStringLong(media.getDuration()));
}
}
}
|