Tell player fragments to refresh

This commit is contained in:
Martin Fietz 2016-01-26 11:50:12 +01:00
parent b41aaff2dd
commit 59129c6c88
4 changed files with 26 additions and 12 deletions

View File

@ -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 {

View File

@ -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) {

View File

@ -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();
}

View File

@ -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();