Skip to content

Commit 9f5c81c

Browse files
committed
item: When Android specific, abstract the class.
This refactors the work from 3fdfe1b in a more sensable way, so Android code can cleanly be added as necessary. This should make adding Android specific code to JMPDComm cleaner.
1 parent 3f02495 commit 9f5c81c

File tree

20 files changed

+361
-143
lines changed

20 files changed

+361
-143
lines changed

.idea/scopes/JMPDComm.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/AlbumParcelable.java JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/Album.java

+24-6
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@
3030
import android.os.Parcel;
3131
import android.os.Parcelable;
3232

33-
/** A class to put org.a0z.mpd.item.Album in a Parcelable wrapper. */
34-
public class AlbumParcelable extends Album implements Parcelable {
33+
/**
34+
* This is the Android backend {@code Album} item.
35+
*
36+
* @see org.a0z.mpd.item.AbstractAlbum For generic {@code Album} code.
37+
*/
38+
public class Album extends AbstractAlbum implements Parcelable {
3539

3640
public static final Creator<Album> CREATOR = new Creator<Album>() {
3741
@Override
3842
public Album createFromParcel(final Parcel source) {
39-
return new AlbumParcelable(source);
43+
return new Album(source);
4044
}
4145

4246
@Override
@@ -45,11 +49,25 @@ public Album[] newArray(final int size) {
4549
}
4650
};
4751

48-
public AlbumParcelable(final Album album) {
49-
super(album);
52+
public Album(final Album otherAlbum) {
53+
super(otherAlbum);
54+
}
55+
56+
public Album(final String name, final Artist artist) {
57+
super(name, artist, false, 0L, 0L, 0L, null);
58+
}
59+
60+
public Album(final String name, final Artist artist, final boolean hasAlbumArtist) {
61+
super(name, artist, hasAlbumArtist, 0L, 0L, 0L, null);
62+
}
63+
64+
public Album(final String name, final Artist artist, final boolean hasAlbumArtist,
65+
final long songCount, final long duration,
66+
final long year, final String path) {
67+
super(name, artist, hasAlbumArtist, songCount, duration, year, path);
5068
}
5169

52-
protected AlbumParcelable(final Parcel in) {
70+
protected Album(final Parcel in) {
5371
super(in.readString(), /** name */
5472
new Artist(in.readString()), /** artist */
5573
in.readInt() > 0, /** hasAlbumArtist */

JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/ArtistParcelable.java JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/Artist.java

+17-5
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,19 @@
3030
import android.os.Parcel;
3131
import android.os.Parcelable;
3232

33-
/** A class to put org.a0z.mpd.item.Artist in a Parcelable wrapper. */
34-
public class ArtistParcelable extends Artist implements Parcelable {
33+
/**
34+
* This is the Android backend {@code Artist} item.
35+
*
36+
* @see org.a0z.mpd.item.AbstractArtist For generic {@code Artist} code.
37+
*/
38+
public class Artist extends AbstractArtist implements Parcelable {
3539

3640
public static final Creator<Artist> CREATOR =
3741
new Creator<Artist>() {
3842

3943
@Override
4044
public Artist createFromParcel(final Parcel source) {
41-
return new ArtistParcelable(source);
45+
return new Artist(source);
4246
}
4347

4448
@Override
@@ -47,11 +51,19 @@ public Artist[] newArray(final int size) {
4751
}
4852
};
4953

50-
public ArtistParcelable(final Artist artist) {
54+
public Artist(final Artist artist) {
5155
super(artist);
5256
}
5357

54-
protected ArtistParcelable(final Parcel in) {
58+
public Artist(final String name) {
59+
super(name);
60+
}
61+
62+
protected Artist(final String name, final String sort) {
63+
super(name, sort);
64+
}
65+
66+
protected Artist(final Parcel in) {
5567
super(in.readString(), /** name */
5668
in.readString()); /** sort */
5769
}

JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/GenreParcelable.java JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/Genre.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@
3030
import android.os.Parcel;
3131
import android.os.Parcelable;
3232

33-
/** A class to put org.a0z.mpd.item.Genre in a Parcelable wrapper. */
34-
public class GenreParcelable extends Genre implements Parcelable {
33+
/**
34+
* This is the Android backend {@code Genre} item.
35+
*
36+
* @see org.a0z.mpd.item.AbstractGenre For generic {@code Genre} code.
37+
*/
38+
public class Genre extends AbstractGenre implements Parcelable {
3539

3640
public static final Creator<Genre> CREATOR = new Creator<Genre>() {
3741
@Override
3842
public Genre createFromParcel(final Parcel source) {
39-
return new GenreParcelable(source);
43+
return new Genre(source);
4044
}
4145

4246
@Override
@@ -45,11 +49,15 @@ public Genre[] newArray(final int size) {
4549
}
4650
};
4751

48-
public GenreParcelable(final Genre genre) {
52+
public Genre(final Genre genre) {
4953
super(genre);
5054
}
5155

52-
protected GenreParcelable(final Parcel in) {
56+
public Genre(final String name) {
57+
super(name);
58+
}
59+
60+
protected Genre(final Parcel in) {
5361
super(in.readString()); /** name */
5462
}
5563

JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/MusicParcelable.java JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/Music.java

+22-12
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,48 @@
3030
import android.os.Parcel;
3131
import android.os.Parcelable;
3232

33-
/** A class to put org.a0z.mpd.item.Music in a Parcelable wrapper. */
34-
public class MusicParcelable extends Music implements Parcelable {
33+
/**
34+
* This is the Android backend {@code Music} item.
35+
*
36+
* @see org.a0z.mpd.item.AbstractMusic For generic {@code Music} code.
37+
*/
38+
public class Music extends AbstractMusic implements Parcelable {
3539

3640
public static final Creator<Music> CREATOR = new Creator<Music>() {
3741
@Override
3842
public Music createFromParcel(final Parcel source) {
39-
return new MusicParcelable(source);
43+
return new Music(source);
4044
}
4145

4246
@Override
4347
public Music[] newArray(final int size) {
44-
return new MusicParcelable[size];
48+
return new Music[size];
4549
}
4650
};
4751

48-
/**
49-
* Public constructor, used to encapsulate a {@link org.a0z.mpd.item.Music} into this {@link
50-
* android.os.Parcelable}
51-
*
52-
* @param music The target {@link org.a0z.mpd.item.Music} object
53-
*/
54-
public MusicParcelable(final Music music) {
52+
public Music() {
53+
super();
54+
}
55+
56+
protected Music(final Music music) {
5557
super(music);
5658
}
5759

60+
protected Music(final String album, final String artist, final String albumArtist,
61+
final String composer, final String fullPath, final int disc, final long date,
62+
final String genre, final long time, final String title, final int totalTracks,
63+
final int track, final int songId, final int songPos, final String name) {
64+
super(album, artist, albumArtist, composer, fullPath, disc, date, genre, time, title,
65+
totalTracks, track, songId, songPos, name);
66+
}
67+
5868
/**
5969
* Protected constructor, used by the Android framework when reconstructing the object from a
6070
* {@link android.os.Parcel}<br />
6171
*
6272
* @param in The {@link android.os.Parcel} that contains our object
6373
*/
64-
protected MusicParcelable(final Parcel in) {
74+
protected Music(final Parcel in) {
6575
super(in.readString(), in.readString(), in.readString(), in.readString(), in.readString(),
6676
in.readInt(), in.readLong(), in.readString(), in.readLong(), in.readString(),
6777
in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (C) 2004 Felipe Gustavo de Almeida
3+
* Copyright (C) 2010-2014 The MPDroid Project
4+
*
5+
* All Rights Reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice,this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package org.a0z.mpd.item;
29+
30+
/**
31+
* This is the Java backend {@code Album} item.
32+
*
33+
* @see org.a0z.mpd.item.AbstractAlbum For generic {@code Album} code.
34+
*/
35+
public class Album extends AbstractAlbum {
36+
37+
public Album(final Album otherAlbum) {
38+
super(otherAlbum);
39+
}
40+
41+
public Album(final String name, final Artist artist) {
42+
super(name, artist, false, 0L, 0L, 0L, null);
43+
}
44+
45+
public Album(final String name, final Artist artist, final boolean hasAlbumArtist) {
46+
super(name, artist, hasAlbumArtist, 0L, 0L, 0L, null);
47+
}
48+
49+
public Album(final String name, final Artist artist, final boolean hasAlbumArtist,
50+
final long songCount, final long duration,
51+
final long year, final String path) {
52+
super(name, artist, hasAlbumArtist, songCount, duration, year, path);
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2004 Felipe Gustavo de Almeida
3+
* Copyright (C) 2010-2014 The MPDroid Project
4+
*
5+
* All Rights Reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice,this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package org.a0z.mpd.item;
29+
30+
/**
31+
* This is the Java backend {@code Artist} item.
32+
*
33+
* @see org.a0z.mpd.item.AbstractArtist For generic {@code Artist} code.
34+
*/
35+
public class Artist extends AbstractArtist {
36+
37+
public Artist(final Artist artist) {
38+
super(artist);
39+
}
40+
41+
public Artist(final String name) {
42+
super(name);
43+
}
44+
45+
protected Artist(final String name, final String sort) {
46+
super(name, sort);
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2004 Felipe Gustavo de Almeida
3+
* Copyright (C) 2010-2014 The MPDroid Project
4+
*
5+
* All Rights Reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice,this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package org.a0z.mpd.item;
29+
30+
/**
31+
* This is the Java backend {@code Genre} item.
32+
*
33+
* @see org.a0z.mpd.item.AbstractGenre For generic {@code Genre} code.
34+
*/
35+
public class Genre extends AbstractGenre {
36+
37+
public Genre(final Genre genre) {
38+
super(genre);
39+
}
40+
41+
public Genre(final String name) {
42+
super(name);
43+
}
44+
}

0 commit comments

Comments
 (0)