diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index 21c81f9e4..0ec24134d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -169,7 +169,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe } if(mPagerAdapter != null && controller != null && controller.getMedia() != media) { media = controller.getMedia(); - mPagerAdapter.notifyDataSetChanged(); + mPagerAdapter.onMediaChanged(media); } @@ -281,16 +281,18 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe } if(controller.getMedia() != media) { media = controller.getMedia(); - mPagerAdapter.notifyDataSetChanged(); + mPagerAdapter.onMediaChanged(media); } return true; } public void notifyMediaPositionChanged() { - ListFragment chapterFragment = (ListFragment) mPagerAdapter.getItem(POS_CHAPTERS); - ChaptersListAdapter adapter = (ChaptersListAdapter) chapterFragment.getListAdapter(); - if(adapter != null) { - adapter.notifyDataSetChanged(); + ChaptersFragment chaptersFragment = mPagerAdapter.getChaptersFragment(); + if(chaptersFragment != null) { + ChaptersListAdapter adapter = (ChaptersListAdapter) chaptersFragment.getListAdapter(); + if (adapter != null) { + adapter.notifyDataSetChanged(); + } } } @@ -526,7 +528,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe }; public interface AudioplayerContentFragment { - void onDataSetChanged(Playable media); + void onMediaChanged(Playable media); } private class AudioplayerPagerAdapter extends FragmentStatePagerAdapter { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ChaptersFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ChaptersFragment.java index 513e2f449..51e4d801a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ChaptersFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ChaptersFragment.java @@ -61,7 +61,11 @@ public class ChaptersFragment extends ListFragment implements AudioplayerContent } @Override - public void onDataSetChanged(Playable media) { + public void onMediaChanged(Playable media) { + if(this.media == media) { + return; + } + this.media = media; adapter.setMedia(media); adapter.notifyDataSetChanged(); if(media.getChapters() == null) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java index e1265d2d3..a851358a0 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java @@ -19,8 +19,8 @@ import de.danoeh.antennapod.core.util.playback.Playable; /** * Displays the cover and the title of a FeedItem. */ -public class CoverFragment extends Fragment implements - AudioplayerContentFragment { +public class CoverFragment extends Fragment implements AudioplayerContentFragment { + private static final String TAG = "CoverFragment"; private static final String ARG_PLAYABLE = "arg.playable"; @@ -97,12 +97,17 @@ public class CoverFragment extends Fragment implements } @Override - public void onDataSetChanged(Playable media) { public void onDestroy() { super.onDestroy(); // prevent memory leaks root = null; } + + @Override + public void onMediaChanged(Playable media) { + if(this.media == media) { + return; + } this.media = media; loadMediaInfo(); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java index 9790e66b3..1bfba4632 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java @@ -384,7 +384,10 @@ public class ItemDescriptionFragment extends Fragment implements AudioplayerCont } @Override - public void onDataSetChanged(Playable media) { + public void onMediaChanged(Playable media) { + if(this.media == media) { + return; + } this.media = media; this.shownotesProvider = media; load();