fix cover fragment onMediaChanged

This commit is contained in:
Domingos Lopes 2016-08-06 22:47:02 -04:00
parent 4a1e728ac5
commit 2babfa2bc6
1 changed files with 7 additions and 12 deletions

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