add empty constructor for song model
This commit is contained in:
parent
295df08a46
commit
632061bb7f
7 changed files with 21 additions and 15 deletions
|
|
@ -90,7 +90,7 @@ public abstract class AbsOffsetSongAdapter extends SongAdapter {
|
||||||
@Override
|
@Override
|
||||||
protected Song getSong() {
|
protected Song getSong() {
|
||||||
// return empty song just to be safe
|
// return empty song just to be safe
|
||||||
if (getItemViewType() == OFFSET_ITEM) return Song.EMPTY_SONG;
|
if (getItemViewType() == OFFSET_ITEM) return Song.EMPTY;
|
||||||
return dataSet.get(getAdapterPosition() - 1);
|
return dataSet.get(getAdapterPosition() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ public class MusicPlayerRemote {
|
||||||
return musicService.getCurrentSong();
|
return musicService.getCurrentSong();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Song.EMPTY_SONG;
|
return Song.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPosition() {
|
public static int getPosition() {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class SongLoader {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
song = getSongFromCursorImpl(cursor);
|
song = getSongFromCursorImpl(cursor);
|
||||||
} else {
|
} else {
|
||||||
song = Song.EMPTY_SONG;
|
song = Song.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,20 @@ import org.jellyfin.apiclient.model.dto.MediaSourceInfo;
|
||||||
import org.jellyfin.apiclient.model.entities.ImageType;
|
import org.jellyfin.apiclient.model.entities.ImageType;
|
||||||
import org.jellyfin.apiclient.model.entities.MediaStream;
|
import org.jellyfin.apiclient.model.entities.MediaStream;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Song implements Parcelable {
|
public class Song implements Parcelable {
|
||||||
public static final Song EMPTY_SONG = new Song(null, "", -1, -1, -1, -1, null, "", null, "", null, false);
|
public static final Song EMPTY = new Song();
|
||||||
|
|
||||||
public final String id;
|
public String id;
|
||||||
public final String title;
|
public String title;
|
||||||
public final int trackNumber;
|
public int trackNumber;
|
||||||
public final int discNumber;
|
public int discNumber;
|
||||||
public final int year;
|
public int year;
|
||||||
public final long duration;
|
public long duration;
|
||||||
|
|
||||||
public final String albumId;
|
public String albumId;
|
||||||
public final String albumName;
|
public String albumName;
|
||||||
|
|
||||||
public String artistId;
|
public String artistId;
|
||||||
public String artistName;
|
public String artistName;
|
||||||
|
|
@ -41,6 +43,10 @@ public class Song implements Parcelable {
|
||||||
public int bitDepth;
|
public int bitDepth;
|
||||||
public int channels;
|
public int channels;
|
||||||
|
|
||||||
|
public Song() {
|
||||||
|
this.id = UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
public Song(BaseItemDto itemDto) {
|
public Song(BaseItemDto itemDto) {
|
||||||
this.id = itemDto.getId();
|
this.id = itemDto.getId();
|
||||||
this.title = itemDto.getName();
|
this.title = itemDto.getName();
|
||||||
|
|
|
||||||
|
|
@ -623,7 +623,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
if (position >= 0 && position < getPlayingQueue().size()) {
|
if (position >= 0 && position < getPlayingQueue().size()) {
|
||||||
return getPlayingQueue().get(position);
|
return getPlayingQueue().get(position);
|
||||||
} else {
|
} else {
|
||||||
return Song.EMPTY_SONG;
|
return Song.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
private static class PortraitImpl extends BaseImpl {
|
private static class PortraitImpl extends BaseImpl {
|
||||||
MediaEntryViewHolder currentSongViewHolder;
|
MediaEntryViewHolder currentSongViewHolder;
|
||||||
Song currentSong = Song.EMPTY_SONG;
|
Song currentSong = Song.EMPTY;
|
||||||
|
|
||||||
public PortraitImpl(CardPlayerFragment fragment, FragmentCardPlayerBinding binding) {
|
public PortraitImpl(CardPlayerFragment fragment, FragmentCardPlayerBinding binding) {
|
||||||
super(fragment, binding);
|
super(fragment, binding);
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
private static class PortraitImpl extends BaseImpl {
|
private static class PortraitImpl extends BaseImpl {
|
||||||
MediaEntryViewHolder currentSongViewHolder;
|
MediaEntryViewHolder currentSongViewHolder;
|
||||||
Song currentSong = Song.EMPTY_SONG;
|
Song currentSong = Song.EMPTY;
|
||||||
|
|
||||||
public PortraitImpl(FlatPlayerFragment fragment, FragmentFlatPlayerBinding binding) {
|
public PortraitImpl(FlatPlayerFragment fragment, FragmentFlatPlayerBinding binding) {
|
||||||
super(fragment, binding);
|
super(fragment, binding);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue