Merge pull request #2096 from domingos86/fix-cover-fragment

fix cover fragment onMediaChanged
This commit is contained in:
Martin Fietz 2016-10-02 23:33:48 +02:00 committed by GitHub
commit 8da8bf6af6
3 changed files with 24 additions and 23 deletions

View File

@ -69,10 +69,11 @@ public class ChaptersFragment extends ListFragment implements MediaplayerInfoCon
@Override
public void onMediaChanged(Playable media) {
if(this.media == media || adapter == null) {
if(this.media == media) {
return;
}
this.media = media;
if (adapter != null) {
adapter.setMedia(media);
adapter.notifyDataSetChanged();
if(media == null || media.getChapters() == null || media.getChapters().size() == 0) {
@ -81,6 +82,7 @@ public class ChaptersFragment extends ListFragment implements MediaplayerInfoCon
setEmptyText(null);
}
}
}
public void setController(PlaybackController controller) {
this.controller = controller;

View File

@ -33,22 +33,15 @@ public class CoverFragment extends Fragment implements MediaplayerInfoContentFra
public static CoverFragment newInstance(Playable item) {
CoverFragment f = new CoverFragment();
if (item != null) {
Bundle args = new Bundle();
args.putParcelable(ARG_PLAYABLE, item);
f.setArguments(args);
}
f.media = item;
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null) {
media = args.getParcelable(ARG_PLAYABLE);
} else {
Log.e(TAG, TAG + " was called with invalid arguments");
if (media == null) {
Log.e(TAG, TAG + " was called without media");
}
}
@ -98,11 +91,13 @@ public class CoverFragment extends Fragment implements MediaplayerInfoContentFra
@Override
public void onMediaChanged(Playable media) {
if(!isAdded() || this.media == media) {
if(this.media == media) {
return;
}
this.media = media;
if (isAdded()) {
loadMediaInfo();
}
}
}

View File

@ -185,8 +185,10 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
super.onViewCreated(view, savedInstanceState);
Bundle args = getArguments();
if (args.containsKey(ARG_PLAYABLE)) {
if (media == null) {
media = args.getParcelable(ARG_PLAYABLE);
shownotesProvider = media;
}
load();
} else if (args.containsKey(ARG_FEEDITEM_ID)) {
long id = getArguments().getLong(ARG_FEEDITEM_ID);
@ -377,12 +379,14 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
@Override
public void onMediaChanged(Playable media) {
if(this.media == media || webvDescription == null) {
if(this.media == media) {
return;
}
this.media = media;
this.shownotesProvider = media;
if (webvDescription != null) {
load();
}
}
}