Merge pull request #1580 from mfietz/issue/1278-update-widget
Widget: Update playback position every second
This commit is contained in:
commit
bb78f0805a
|
@ -128,7 +128,7 @@ public class PlayerWidgetService extends Service {
|
||||||
|
|
||||||
views.setTextViewText(R.id.txtvTitle, media.getEpisodeTitle());
|
views.setTextViewText(R.id.txtvTitle, media.getEpisodeTitle());
|
||||||
|
|
||||||
String progressString = getProgressString(media);
|
String progressString = getProgressString();
|
||||||
if (progressString != null) {
|
if (progressString != null) {
|
||||||
views.setViewVisibility(R.id.txtvProgress, View.VISIBLE);
|
views.setViewVisibility(R.id.txtvProgress, View.VISIBLE);
|
||||||
views.setTextViewText(R.id.txtvProgress, progressString);
|
views.setTextViewText(R.id.txtvProgress, progressString);
|
||||||
|
@ -181,9 +181,9 @@ public class PlayerWidgetService extends Service {
|
||||||
return PendingIntent.getBroadcast(this, 0, startingIntent, 0);
|
return PendingIntent.getBroadcast(this, 0, startingIntent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProgressString(Playable media) {
|
private String getProgressString() {
|
||||||
int position = media.getPosition();
|
int position = playbackService.getCurrentPosition();
|
||||||
int duration = media.getDuration();
|
int duration = playbackService.getDuration();
|
||||||
if (position > 0 && duration > 0) {
|
if (position > 0 && duration > 0) {
|
||||||
return Converter.getDurationStringLong(position) + " / "
|
return Converter.getDurationStringLong(position) + " / "
|
||||||
+ Converter.getDurationStringLong(duration);
|
+ Converter.getDurationStringLong(duration);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class PlaybackServiceTaskManager {
|
||||||
/**
|
/**
|
||||||
* Notification interval of widget updater in milliseconds.
|
* Notification interval of widget updater in milliseconds.
|
||||||
*/
|
*/
|
||||||
public static final int WIDGET_UPDATER_NOTIFICATION_INTERVAL = 1500;
|
public static final int WIDGET_UPDATER_NOTIFICATION_INTERVAL = 1000;
|
||||||
|
|
||||||
private static final int SCHED_EX_POOL_SIZE = 2;
|
private static final int SCHED_EX_POOL_SIZE = 2;
|
||||||
private final ScheduledThreadPoolExecutor schedExecutor;
|
private final ScheduledThreadPoolExecutor schedExecutor;
|
||||||
|
|
Loading…
Reference in New Issue