Update playback position in feed details list
This commit is contained in:
parent
8c1e6206da
commit
7bdc0b3ddd
|
@ -13,15 +13,18 @@ import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.adapter.actionbutton.ItemActionButton;
|
import de.danoeh.antennapod.adapter.actionbutton.ItemActionButton;
|
||||||
|
import de.danoeh.antennapod.core.event.PlaybackPositionEvent;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
import de.danoeh.antennapod.core.feed.MediaType;
|
||||||
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.DateUtils;
|
import de.danoeh.antennapod.core.util.DateUtils;
|
||||||
import de.danoeh.antennapod.core.util.LongList;
|
import de.danoeh.antennapod.core.util.LongList;
|
||||||
import de.danoeh.antennapod.core.util.ThemeUtils;
|
import de.danoeh.antennapod.core.util.ThemeUtils;
|
||||||
|
@ -39,6 +42,8 @@ public class FeedItemlistAdapter extends BaseAdapter {
|
||||||
private final int playingBackGroundColor;
|
private final int playingBackGroundColor;
|
||||||
private final int normalBackGroundColor;
|
private final int normalBackGroundColor;
|
||||||
|
|
||||||
|
private int currentlyPlayingItem = -1;
|
||||||
|
|
||||||
public FeedItemlistAdapter(Context context,
|
public FeedItemlistAdapter(Context context,
|
||||||
ItemAccess itemAccess,
|
ItemAccess itemAccess,
|
||||||
boolean showFeedtitle,
|
boolean showFeedtitle,
|
||||||
|
@ -176,8 +181,9 @@ public class FeedItemlistAdapter extends BaseAdapter {
|
||||||
}
|
}
|
||||||
typeDrawables.recycle();
|
typeDrawables.recycle();
|
||||||
|
|
||||||
if(media.isCurrentlyPlaying()) {
|
if (media.isCurrentlyPlaying()) {
|
||||||
holder.container.setBackgroundColor(playingBackGroundColor);
|
holder.container.setBackgroundColor(playingBackGroundColor);
|
||||||
|
currentlyPlayingItem = position;
|
||||||
} else {
|
} else {
|
||||||
holder.container.setBackgroundColor(normalBackGroundColor);
|
holder.container.setBackgroundColor(normalBackGroundColor);
|
||||||
}
|
}
|
||||||
|
@ -195,6 +201,19 @@ public class FeedItemlistAdapter extends BaseAdapter {
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void notifyCurrentlyPlayingItemChanged(PlaybackPositionEvent event, ListView listView) {
|
||||||
|
if (currentlyPlayingItem != -1 && currentlyPlayingItem < getCount()) {
|
||||||
|
View view = listView.getChildAt(currentlyPlayingItem
|
||||||
|
- listView.getFirstVisiblePosition() + listView.getHeaderViewsCount());
|
||||||
|
if (view == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Holder holder = (Holder) view.getTag();
|
||||||
|
holder.episodeProgress.setProgress((int) (100.0 * event.getPosition() / event.getDuration()));
|
||||||
|
holder.lenSize.setText(Converter.getDurationStringLong(event.getDuration() - event.getPosition()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class Holder {
|
static class Holder {
|
||||||
LinearLayout container;
|
LinearLayout container;
|
||||||
TextView title;
|
TextView title;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.joanzapata.iconify.Iconify;
|
import com.joanzapata.iconify.Iconify;
|
||||||
import com.joanzapata.iconify.widget.IconTextView;
|
import com.joanzapata.iconify.widget.IconTextView;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.event.PlaybackPositionEvent;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
@ -398,6 +399,13 @@ public class FeedItemlistFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onEventMainThread(PlaybackPositionEvent event) {
|
||||||
|
if (adapter != null) {
|
||||||
|
adapter.notifyCurrentlyPlayingItemChanged(event, getListView());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
private final EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue