diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-09-03 22:13:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 22:13:50 +0200 |
commit | 18b63dd75cedd0d0a78c5503f3a07cb08ded85d1 (patch) | |
tree | 05011c21fa6584d177106252faaf1ec24c113924 | |
parent | 2ad713772dd1de7ea8463fc54744d1bcc7d786d3 (diff) | |
download | AntennaPod-18b63dd75cedd0d0a78c5503f3a07cb08ded85d1.zip |
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.
4 files changed, 22 insertions, 1 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java index 951e5affb..d474b108d 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java @@ -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; diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java index 06de7803a..3d00bf392 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java @@ -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); diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java index 09f060f81..e1d4051d2 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/EpisodesSurpriseSection.java @@ -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; @@ -124,6 +125,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) { return; diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java index 634f1ecfe..4e1b49e03 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java @@ -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"); |