Replaced Serializable with Parcelable everywhere
This commit is contained in:
parent
c5b5460e01
commit
5bdd763248
21 changed files with 413 additions and 175 deletions
|
|
@ -93,7 +93,7 @@ public class AlbumCoverPagerAdapter extends CustomFragmentStatePagerAdapter {
|
|||
public static AlbumCoverFragment newInstance(final Song song) {
|
||||
AlbumCoverFragment frag = new AlbumCoverFragment();
|
||||
final Bundle args = new Bundle();
|
||||
args.putSerializable(SONG_ARG, song);
|
||||
args.putParcelable(SONG_ARG, song);
|
||||
frag.setArguments(args);
|
||||
return frag;
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ public class AlbumCoverPagerAdapter extends CustomFragmentStatePagerAdapter {
|
|||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
song = (Song) getArguments().getSerializable(SONG_ARG);
|
||||
song = (Song) getArguments().getParcelable(SONG_ARG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public class ArtistSongAdapter extends ArrayAdapter<Song> implements MaterialCab
|
|||
|
||||
final int size = checked.size();
|
||||
if (size <= 0) cab.finish();
|
||||
else if (size == 1) cab.setTitle(checked.get(0).toString());
|
||||
else if (size == 1) cab.setTitle(checked.get(0).title);
|
||||
else if (size > 1) cab.setTitle(String.valueOf(size));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class AddToPlaylistDialog extends LeakDetectDialogFragment {
|
|||
public static AddToPlaylistDialog create(ArrayList<Song> songs) {
|
||||
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("songs", songs);
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ public class AddToPlaylistDialog extends LeakDetectDialogFragment {
|
|||
@Override
|
||||
public void onSelection(@NonNull MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> songs = (ArrayList<Song>) getArguments().getSerializable("songs");
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
if (songs == null) return;
|
||||
if (i == 0) {
|
||||
materialDialog.dismiss();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class ClearSmartPlaylistDialog extends LeakDetectDialogFragment {
|
|||
public static ClearSmartPlaylistDialog create(AbsSmartPlaylist playlist) {
|
||||
ClearSmartPlaylistDialog dialog = new ClearSmartPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("playlist", playlist);
|
||||
args.putParcelable("playlist", playlist);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ public class ClearSmartPlaylistDialog extends LeakDetectDialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final AbsSmartPlaylist playlist = (AbsSmartPlaylist) getArguments().getSerializable("playlist");
|
||||
final AbsSmartPlaylist playlist = (AbsSmartPlaylist) getArguments().getParcelable("playlist");
|
||||
int title = R.string.clear_playlist_title;
|
||||
//noinspection ConstantConditions
|
||||
CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class CreatePlaylistDialog extends LeakDetectDialogFragment {
|
|||
public static CreatePlaylistDialog create(ArrayList<Song> songs) {
|
||||
CreatePlaylistDialog dialog = new CreatePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("songs", songs);
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public class CreatePlaylistDialog extends LeakDetectDialogFragment {
|
|||
final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), charSequence.toString());
|
||||
if (playlistId != -1 && getActivity() != null) {
|
||||
//noinspection unchecked
|
||||
ArrayList<Song> songs = (ArrayList<Song>) getArguments().getSerializable("songs");
|
||||
ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
if (songs != null) {
|
||||
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class DeletePlaylistDialog extends LeakDetectDialogFragment {
|
|||
public static DeletePlaylistDialog create(ArrayList<Playlist> playlists) {
|
||||
DeletePlaylistDialog dialog = new DeletePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("playlists", playlists);
|
||||
args.putParcelableArrayList("playlists", playlists);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ public class DeletePlaylistDialog extends LeakDetectDialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Playlist> playlists = (ArrayList<Playlist>) getArguments().getSerializable("playlists");
|
||||
final ArrayList<Playlist> playlists = getArguments().getParcelableArrayList("playlists");
|
||||
int title;
|
||||
CharSequence content;
|
||||
//noinspection ConstantConditions
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class DeleteSongsDialog extends LeakDetectDialogFragment {
|
|||
public static DeleteSongsDialog create(ArrayList<Song> songs) {
|
||||
DeleteSongsDialog dialog = new DeleteSongsDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("songs", songs);
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ public class DeleteSongsDialog extends LeakDetectDialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> songs = (ArrayList<Song>) getArguments().getSerializable("songs");
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
int title;
|
||||
CharSequence content;
|
||||
if (songs.size() > 1) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PlayingQueueDialog extends LeakDetectDialogFragment {
|
|||
final ArrayList<Song> playingQueue = MusicPlayerRemote.getPlayingQueue();
|
||||
PlayingQueueDialog dialog = new PlayingQueueDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("queue", playingQueue);
|
||||
args.putParcelableArrayList("queue", playingQueue);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -44,14 +44,14 @@ public class PlayingQueueDialog extends LeakDetectDialogFragment {
|
|||
if (getActivity() == null)
|
||||
return;
|
||||
//noinspection unchecked
|
||||
ArrayList<Song> playingQueue = (ArrayList<Song>) getArguments().getSerializable("queue");
|
||||
ArrayList<Song> playingQueue = getArguments().getParcelableArrayList("queue");
|
||||
AddToPlaylistDialog.create(playingQueue).show(getActivity().getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> playingQueue = (ArrayList<Song>) getArguments().getSerializable("queue");
|
||||
final ArrayList<Song> playingQueue = getArguments().getParcelableArrayList("queue");
|
||||
final DragSortListView dragSortListView = (DragSortListView) dialog.getCustomView().findViewById(R.id.dragSortListView);
|
||||
final PlayingQueueAdapterDeprecated playingQueueAdapterDeprecated =
|
||||
new PlayingQueueAdapterDeprecated((AppCompatActivity) getActivity(), playingQueue);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class RemoveFromPlaylistDialog extends LeakDetectDialogFragment {
|
|||
public static RemoveFromPlaylistDialog create(ArrayList<PlaylistSong> songs) {
|
||||
RemoveFromPlaylistDialog dialog = new RemoveFromPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("songs", songs);
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ public class RemoveFromPlaylistDialog extends LeakDetectDialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<PlaylistSong> songs = (ArrayList<PlaylistSong>) getArguments().getSerializable("songs");
|
||||
final ArrayList<PlaylistSong> songs = getArguments().getParcelableArrayList("songs");
|
||||
int title;
|
||||
CharSequence content;
|
||||
if (songs.size() > 1) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class SongDetailDialog extends LeakDetectDialogFragment {
|
|||
public static SongDetailDialog create(Song song) {
|
||||
SongDetailDialog dialog = new SongDetailDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("song", song);
|
||||
args.putParcelable("song", song);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class SongDetailDialog extends LeakDetectDialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Activity context = getActivity();
|
||||
final Song song = (Song) getArguments().getSerializable("song");
|
||||
final Song song = (Song) getArguments().getParcelable("song");
|
||||
|
||||
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
||||
.customView(R.layout.dialog_file_details, true)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class SongShareDialog extends LeakDetectDialogFragment {
|
|||
public static SongShareDialog create(final Song song) {
|
||||
final SongShareDialog dialog = new SongShareDialog();
|
||||
final Bundle args = new Bundle();
|
||||
args.putSerializable("song", song);
|
||||
args.putParcelable("song", song);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ public class SongShareDialog extends LeakDetectDialogFragment {
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Song song = (Song) getArguments().getSerializable("song");
|
||||
final Song song = (Song) getArguments().getParcelable("song");
|
||||
final String currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName);
|
||||
return new MaterialDialog.Builder(getActivity())
|
||||
.title(R.string.what_do_you_want_to_share)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class Album {
|
||||
|
||||
public class Album implements Parcelable {
|
||||
public final int id;
|
||||
public final int artistId;
|
||||
public final String title;
|
||||
|
|
@ -34,47 +33,77 @@ public class Album {
|
|||
year = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Album album = (Album) o;
|
||||
|
||||
if (id != album.id) return false;
|
||||
if (artistId != album.artistId) return false;
|
||||
if (songCount != album.songCount) return false;
|
||||
if (year != album.year) return false;
|
||||
if (title != null ? !title.equals(album.title) : album.title != null) return false;
|
||||
return artistName != null ? artistName.equals(album.artistName) : album.artistName == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + id;
|
||||
result = prime * result + (title == null ? 0 : title.hashCode());
|
||||
result = prime * result + (artistName == null ? 0 : artistName.hashCode());
|
||||
result = prime * result + songCount;
|
||||
result = prime * result + year;
|
||||
int result = id;
|
||||
result = 31 * result + artistId;
|
||||
result = 31 * result + (title != null ? title.hashCode() : 0);
|
||||
result = 31 * result + (artistName != null ? artistName.hashCode() : 0);
|
||||
result = 31 * result + songCount;
|
||||
result = 31 * result + year;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Album other = (Album) obj;
|
||||
if (id != other.id) {
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.equals(title, other.title)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.equals(artistName, other.artistName)) {
|
||||
return false;
|
||||
}
|
||||
if (songCount != other.songCount) {
|
||||
return false;
|
||||
}
|
||||
return year == other.year;
|
||||
public String toString() {
|
||||
return "Album{" +
|
||||
"id=" + id +
|
||||
", artistId=" + artistId +
|
||||
", title='" + title + '\'' +
|
||||
", artistName='" + artistName + '\'' +
|
||||
", songCount=" + songCount +
|
||||
", year=" + year +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeInt(this.artistId);
|
||||
dest.writeString(this.title);
|
||||
dest.writeString(this.artistName);
|
||||
dest.writeInt(this.songCount);
|
||||
dest.writeInt(this.year);
|
||||
}
|
||||
|
||||
protected Album(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.artistId = in.readInt();
|
||||
this.title = in.readString();
|
||||
this.artistName = in.readString();
|
||||
this.songCount = in.readInt();
|
||||
this.year = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Album> CREATOR = new Parcelable.Creator<Album>() {
|
||||
public Album createFromParcel(Parcel source) {
|
||||
return new Album(source);
|
||||
}
|
||||
|
||||
public Album[] newArray(int size) {
|
||||
return new Album[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class Artist {
|
||||
public class Artist implements Parcelable {
|
||||
public final int id;
|
||||
public final String name;
|
||||
public final int albumCount;
|
||||
|
|
@ -26,43 +26,67 @@ public class Artist {
|
|||
albumCount = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Artist artist = (Artist) o;
|
||||
|
||||
if (id != artist.id) return false;
|
||||
if (albumCount != artist.albumCount) return false;
|
||||
if (songCount != artist.songCount) return false;
|
||||
return name != null ? name.equals(artist.name) : artist.name == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + albumCount;
|
||||
result = prime * result + id;
|
||||
result = prime * result + (name == null ? 0 : name.hashCode());
|
||||
result = prime * result + songCount;
|
||||
int result = id;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + albumCount;
|
||||
result = 31 * result + songCount;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Artist other = (Artist) obj;
|
||||
if (albumCount != other.albumCount) {
|
||||
return false;
|
||||
}
|
||||
if (id != other.id) {
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.equals(name, other.name)) {
|
||||
return false;
|
||||
}
|
||||
return songCount == other.songCount;
|
||||
public String toString() {
|
||||
return "Artist{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", albumCount=" + albumCount +
|
||||
", songCount=" + songCount +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeString(this.name);
|
||||
dest.writeInt(this.albumCount);
|
||||
dest.writeInt(this.songCount);
|
||||
}
|
||||
|
||||
protected Artist(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.name = in.readString();
|
||||
this.albumCount = in.readInt();
|
||||
this.songCount = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Artist> CREATOR = new Parcelable.Creator<Artist>() {
|
||||
public Artist createFromParcel(Parcel source) {
|
||||
return new Artist(source);
|
||||
}
|
||||
|
||||
public Artist[] newArray(int size) {
|
||||
return new Artist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class Playlist implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3013703495354856981L;
|
||||
|
||||
public class Playlist implements Parcelable {
|
||||
public final int id;
|
||||
public final String name;
|
||||
|
||||
|
|
@ -25,35 +20,48 @@ public class Playlist implements Serializable {
|
|||
this.name = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Playlist playlist = (Playlist) o;
|
||||
|
||||
if (id != playlist.id) return false;
|
||||
return name != null ? name.equals(playlist.name) : playlist.name == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + id;
|
||||
result = prime * result + (name == null ? 0 : name.hashCode());
|
||||
int result = id;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Playlist other = (Playlist) obj;
|
||||
if (id != other.id) {
|
||||
return false;
|
||||
}
|
||||
return TextUtils.equals(name, other.name);
|
||||
public String toString() {
|
||||
return "Playlist{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeString(this.name);
|
||||
}
|
||||
|
||||
protected Playlist(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.name = in.readString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
public class PlaylistSong extends Song {
|
||||
import android.os.Parcel;
|
||||
|
||||
private static final long serialVersionUID = 1098600801627571043L;
|
||||
public class PlaylistSong extends Song {
|
||||
|
||||
public final int playlistId;
|
||||
public final int idInPlayList;
|
||||
|
|
@ -20,21 +20,62 @@ public class PlaylistSong extends Song {
|
|||
idInPlayList = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
PlaylistSong that = (PlaylistSong) o;
|
||||
|
||||
if (playlistId != that.playlistId) return false;
|
||||
return idInPlayList == that.idInPlayList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + playlistId;
|
||||
result = prime * result + idInPlayList;
|
||||
result = 31 * result + playlistId;
|
||||
result = 31 * result + idInPlayList;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
final PlaylistSong other = (PlaylistSong) obj;
|
||||
return playlistId == other.playlistId && idInPlayList == other.idInPlayList;
|
||||
}
|
||||
return false;
|
||||
public String toString() {
|
||||
return super.toString() +
|
||||
"PlaylistSong{" +
|
||||
"playlistId=" + playlistId +
|
||||
", idInPlayList=" + idInPlayList +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(this.playlistId);
|
||||
dest.writeInt(this.idInPlayList);
|
||||
}
|
||||
|
||||
protected PlaylistSong(Parcel in) {
|
||||
super(in);
|
||||
this.playlistId = in.readInt();
|
||||
this.idInPlayList = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator<PlaylistSong> CREATOR = new Creator<PlaylistSong>() {
|
||||
public PlaylistSong createFromParcel(Parcel source) {
|
||||
return new PlaylistSong(source);
|
||||
}
|
||||
|
||||
public PlaylistSong[] newArray(int size) {
|
||||
return new PlaylistSong[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class Song implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3720703366054566981L;
|
||||
|
||||
public class Song implements Parcelable {
|
||||
public final int id;
|
||||
public final int albumId;
|
||||
public final int artistId;
|
||||
|
|
@ -47,47 +42,94 @@ public class Song implements Serializable {
|
|||
this.data = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Song song = (Song) o;
|
||||
|
||||
if (id != song.id) return false;
|
||||
if (albumId != song.albumId) return false;
|
||||
if (artistId != song.artistId) return false;
|
||||
if (duration != song.duration) return false;
|
||||
if (trackNumber != song.trackNumber) return false;
|
||||
if (title != null ? !title.equals(song.title) : song.title != null) return false;
|
||||
if (artistName != null ? !artistName.equals(song.artistName) : song.artistName != null)
|
||||
return false;
|
||||
if (albumName != null ? !albumName.equals(song.albumName) : song.albumName != null)
|
||||
return false;
|
||||
return data != null ? data.equals(song.data) : song.data == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (albumName == null ? 0 : albumName.hashCode());
|
||||
result = prime * result + (artistName == null ? 0 : artistName.hashCode());
|
||||
result = prime * result + (int) duration;
|
||||
result = prime * result + id;
|
||||
result = prime * result + (title == null ? 0 : title.hashCode());
|
||||
int result = id;
|
||||
result = 31 * result + albumId;
|
||||
result = 31 * result + artistId;
|
||||
result = 31 * result + (title != null ? title.hashCode() : 0);
|
||||
result = 31 * result + (artistName != null ? artistName.hashCode() : 0);
|
||||
result = 31 * result + (albumName != null ? albumName.hashCode() : 0);
|
||||
result = 31 * result + (int) (duration ^ (duration >>> 32));
|
||||
result = 31 * result + trackNumber;
|
||||
result = 31 * result + (data != null ? data.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Song other = (Song) obj;
|
||||
if (id != other.id) {
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.equals(albumName, other.albumName)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.equals(artistName, other.artistName)) {
|
||||
return false;
|
||||
}
|
||||
if (duration != other.duration) {
|
||||
return false;
|
||||
}
|
||||
return TextUtils.equals(title, other.title);
|
||||
public String toString() {
|
||||
return "Song{" +
|
||||
"id=" + id +
|
||||
", albumId=" + albumId +
|
||||
", artistId=" + artistId +
|
||||
", title='" + title + '\'' +
|
||||
", artistName='" + artistName + '\'' +
|
||||
", albumName='" + albumName + '\'' +
|
||||
", duration=" + duration +
|
||||
", trackNumber=" + trackNumber +
|
||||
", data='" + data + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeInt(this.albumId);
|
||||
dest.writeInt(this.artistId);
|
||||
dest.writeString(this.title);
|
||||
dest.writeString(this.artistName);
|
||||
dest.writeString(this.albumName);
|
||||
dest.writeLong(this.duration);
|
||||
dest.writeInt(this.trackNumber);
|
||||
dest.writeString(this.data);
|
||||
}
|
||||
|
||||
protected Song(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.albumId = in.readInt();
|
||||
this.artistId = in.readInt();
|
||||
this.title = in.readString();
|
||||
this.artistName = in.readString();
|
||||
this.albumName = in.readString();
|
||||
this.duration = in.readLong();
|
||||
this.trackNumber = in.readInt();
|
||||
this.data = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<Song> CREATOR = new Creator<Song>() {
|
||||
public Song createFromParcel(Parcel source) {
|
||||
return new Song(source);
|
||||
}
|
||||
|
||||
public Song[] newArray(int size) {
|
||||
return new Song[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
|
|
@ -14,8 +15,6 @@ import java.util.ArrayList;
|
|||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public abstract class AbsSmartPlaylist extends Playlist {
|
||||
private static final long serialVersionUID = 3013701295356403681L;
|
||||
|
||||
@DrawableRes
|
||||
public final int iconRes;
|
||||
|
||||
|
|
@ -52,4 +51,21 @@ public abstract class AbsSmartPlaylist extends Playlist {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(this.iconRes);
|
||||
}
|
||||
|
||||
protected AbsSmartPlaylist(Parcel in) {
|
||||
super(in);
|
||||
this.iconRes = in.readInt();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
@ -29,4 +30,29 @@ public class HistoryPlaylist extends AbsSmartPlaylist {
|
|||
public void clear(@NonNull Context context) {
|
||||
HistoryStore.getInstance(context).clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
protected HistoryPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<HistoryPlaylist> CREATOR = new Creator<HistoryPlaylist>() {
|
||||
public HistoryPlaylist createFromParcel(Parcel source) {
|
||||
return new HistoryPlaylist(source);
|
||||
}
|
||||
|
||||
public HistoryPlaylist[] newArray(int size) {
|
||||
return new HistoryPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
@ -29,4 +30,29 @@ public class LastAddedPlaylist extends AbsSmartPlaylist {
|
|||
public void clear(@NonNull Context context) {
|
||||
PreferenceUtil.getInstance(context).setLastAddedCutoffTimestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
protected LastAddedPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<LastAddedPlaylist> CREATOR = new Creator<LastAddedPlaylist>() {
|
||||
public LastAddedPlaylist createFromParcel(Parcel source) {
|
||||
return new LastAddedPlaylist(source);
|
||||
}
|
||||
|
||||
public LastAddedPlaylist[] newArray(int size) {
|
||||
return new LastAddedPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
@ -29,4 +30,29 @@ public class MyTopTracksPlaylist extends AbsSmartPlaylist {
|
|||
public void clear(@NonNull Context context) {
|
||||
SongPlayCountStore.getInstance(context).clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
protected MyTopTracksPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<MyTopTracksPlaylist> CREATOR = new Creator<MyTopTracksPlaylist>() {
|
||||
public MyTopTracksPlaylist createFromParcel(Parcel source) {
|
||||
return new MyTopTracksPlaylist(source);
|
||||
}
|
||||
|
||||
public MyTopTracksPlaylist[] newArray(int size) {
|
||||
return new MyTopTracksPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ public class PlaylistDetailActivity extends AbsSlidingMusicPanelActivity impleme
|
|||
private void getIntentExtras() {
|
||||
Bundle intentExtras = getIntent().getExtras();
|
||||
try {
|
||||
playlist = (Playlist) intentExtras.getSerializable(EXTRA_PLAYLIST);
|
||||
playlist = (Playlist) intentExtras.getParcelable(EXTRA_PLAYLIST);
|
||||
} catch (ClassCastException ignored) {
|
||||
}
|
||||
if (playlist == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue