Fix several item update events not being handled (#7377)
This lead to inconsistent display state. Also, users were able to access items that no longer exist.
This commit is contained in:
parent
2ad713772d
commit
18b63dd75c
|
@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
@ -171,6 +172,11 @@ public class ItemPagerFragment extends Fragment implements MaterialToolbar.OnMen
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(UnreadItemsUpdateEvent event) {
|
||||
refreshToolbarState();
|
||||
}
|
||||
|
||||
private void openPodcast() {
|
||||
if (item == null) {
|
||||
return;
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
|
||||
import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter;
|
||||
import de.danoeh.antennapod.event.DownloadLogEvent;
|
||||
import de.danoeh.antennapod.ui.MenuItemUtils;
|
||||
|
@ -111,6 +112,11 @@ public class DownloadsSection extends HomeSection {
|
|||
loadItems();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onUnreadItemsUpdateEvent(UnreadItemsUpdateEvent event) {
|
||||
loadItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSectionTitle() {
|
||||
return getString(R.string.home_downloads_title);
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.event.FeedListUpdateEvent;
|
||||
import de.danoeh.antennapod.ui.episodeslist.HorizontalItemListAdapter;
|
||||
import de.danoeh.antennapod.ui.MenuItemUtils;
|
||||
import de.danoeh.antennapod.storage.database.DBReader;
|
||||
|
@ -123,6 +124,11 @@ public class EpisodesSurpriseSection extends HomeSection {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(FeedListUpdateEvent event) {
|
||||
loadItems();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(PlaybackPositionEvent event) {
|
||||
if (listAdapter == null) {
|
||||
|
|
|
@ -362,7 +362,10 @@ public class AudioPlayerFragment extends Fragment implements
|
|||
int currentPosition = converter.convert(event.getPosition());
|
||||
int duration = converter.convert(event.getDuration());
|
||||
int remainingTime = converter.convert(Math.max(event.getDuration() - event.getPosition(), 0));
|
||||
currentChapterIndex = Chapter.getAfterPosition(controller.getMedia().getChapters(), currentPosition);
|
||||
@Nullable Playable media = controller.getMedia();
|
||||
if (media != null) {
|
||||
currentChapterIndex = Chapter.getAfterPosition(media.getChapters(), currentPosition);
|
||||
}
|
||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
||||
if (currentPosition == Playable.INVALID_TIME || duration == Playable.INVALID_TIME) {
|
||||
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||
|
|
Loading…
Reference in New Issue