kotlin conversion
This commit is contained in:
parent
8e6ab40d93
commit
b2c15ef186
316 changed files with 13055 additions and 22983 deletions
|
@ -1,103 +0,0 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class Album implements Parcelable {
|
||||
|
||||
public static final Creator<Album> CREATOR = new Creator<Album>() {
|
||||
public Album createFromParcel(Parcel source) {
|
||||
return new Album(source);
|
||||
}
|
||||
|
||||
public Album[] newArray(int size) {
|
||||
return new Album[size];
|
||||
}
|
||||
};
|
||||
public final ArrayList<Song> songs;
|
||||
|
||||
public Album(ArrayList<Song> songs) {
|
||||
this.songs = songs;
|
||||
}
|
||||
|
||||
public Album() {
|
||||
this.songs = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected Album(Parcel in) {
|
||||
this.songs = in.createTypedArrayList(Song.CREATOR);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return safeGetFirstSong().albumId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return safeGetFirstSong().albumName;
|
||||
}
|
||||
|
||||
public int getArtistId() {
|
||||
return safeGetFirstSong().artistId;
|
||||
}
|
||||
|
||||
public String getArtistName() {
|
||||
return safeGetFirstSong().artistName;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return safeGetFirstSong().year;
|
||||
}
|
||||
|
||||
public long getDateModified() {
|
||||
return safeGetFirstSong().dateModified;
|
||||
}
|
||||
|
||||
public int getSongCount() {
|
||||
return songs.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Song safeGetFirstSong() {
|
||||
return songs.isEmpty() ? Song.EMPTY_SONG : songs.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Album that = (Album) o;
|
||||
|
||||
return songs != null ? songs.equals(that.songs) : that.songs == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return songs != null ? songs.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Album{" +
|
||||
"songs=" + songs +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeTypedList(songs);
|
||||
}
|
||||
}
|
41
app/src/main/java/code/name/monkey/retromusic/model/Album.kt
Normal file
41
app/src/main/java/code/name/monkey/retromusic/model/Album.kt
Normal file
|
@ -0,0 +1,41 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
import java.util.*
|
||||
|
||||
|
||||
class Album {
|
||||
val songs: ArrayList<Song>?
|
||||
|
||||
val id: Int
|
||||
get() = safeGetFirstSong().albumId
|
||||
|
||||
val title: String?
|
||||
get() = safeGetFirstSong().albumName
|
||||
|
||||
val artistId: Int
|
||||
get() = safeGetFirstSong().artistId
|
||||
|
||||
val artistName: String?
|
||||
get() = safeGetFirstSong().artistName
|
||||
|
||||
val year: Int
|
||||
get() = safeGetFirstSong().year
|
||||
|
||||
val dateModified: Long
|
||||
get() = safeGetFirstSong().dateModified
|
||||
|
||||
val songCount: Int
|
||||
get() = songs!!.size
|
||||
|
||||
constructor(songs: ArrayList<Song>) {
|
||||
this.songs = songs
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.songs = ArrayList()
|
||||
}
|
||||
|
||||
fun safeGetFirstSong(): Song {
|
||||
return if (songs!!.isEmpty()) Song.EMPTY_SONG else songs[0]
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import code.name.monkey.retromusic.util.MusicUtil;
|
||||
|
||||
|
||||
public class Artist implements Parcelable {
|
||||
public static final String UNKNOWN_ARTIST_DISPLAY_NAME = "Unknown Artist";
|
||||
public final ArrayList<Album> albums;
|
||||
|
||||
public Artist(ArrayList<Album> albums) {
|
||||
this.albums = albums;
|
||||
}
|
||||
|
||||
public Artist() {
|
||||
this.albums = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return safeGetFirstAlbum().getArtistId();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = safeGetFirstAlbum().getArtistName();
|
||||
if (MusicUtil.isArtistNameUnknown(name)) {
|
||||
return UNKNOWN_ARTIST_DISPLAY_NAME;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getSongCount() {
|
||||
int songCount = 0;
|
||||
for (Album album : albums) {
|
||||
songCount += album.getSongCount();
|
||||
}
|
||||
return songCount;
|
||||
}
|
||||
|
||||
public int getAlbumCount() {
|
||||
return albums.size();
|
||||
}
|
||||
|
||||
public ArrayList<Song> getSongs() {
|
||||
ArrayList<Song> songs = new ArrayList<>();
|
||||
for (Album album : albums) {
|
||||
songs.addAll(album.songs);
|
||||
}
|
||||
return songs;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Album safeGetFirstAlbum() {
|
||||
return albums.isEmpty() ? new Album() : albums.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Artist artist = (Artist) o;
|
||||
|
||||
return albums != null ? albums.equals(artist.albums) : artist.albums == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return albums != null ? albums.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Artist{" +
|
||||
"albums=" + albums +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeTypedList(this.albums);
|
||||
}
|
||||
|
||||
protected Artist(Parcel in) {
|
||||
this.albums = in.createTypedArrayList(Album.CREATOR);
|
||||
}
|
||||
|
||||
public static final Creator<Artist> CREATOR = new Creator<Artist>() {
|
||||
@Override
|
||||
public Artist createFromParcel(Parcel source) {
|
||||
return new Artist(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artist[] newArray(int size) {
|
||||
return new Artist[size];
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import java.util.*
|
||||
|
||||
|
||||
class Artist {
|
||||
val albums: ArrayList<Album>?
|
||||
|
||||
val id: Int
|
||||
get() = safeGetFirstAlbum().artistId
|
||||
|
||||
val name: String
|
||||
get() {
|
||||
val name = safeGetFirstAlbum().artistName
|
||||
return if (MusicUtil.isArtistNameUnknown(name)) {
|
||||
UNKNOWN_ARTIST_DISPLAY_NAME
|
||||
} else name!!
|
||||
}
|
||||
|
||||
val songCount: Int
|
||||
get() {
|
||||
var songCount = 0
|
||||
for (album in albums!!) {
|
||||
songCount += album.songCount
|
||||
}
|
||||
return songCount
|
||||
}
|
||||
|
||||
val albumCount: Int
|
||||
get() = albums!!.size
|
||||
|
||||
val songs: ArrayList<Song>
|
||||
get() {
|
||||
val songs = ArrayList<Song>()
|
||||
for (album in albums!!) {
|
||||
songs.addAll(album.songs!!)
|
||||
}
|
||||
return songs
|
||||
}
|
||||
|
||||
constructor(albums: ArrayList<Album>) {
|
||||
this.albums = albums
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.albums = ArrayList()
|
||||
}
|
||||
|
||||
fun safeGetFirstAlbum(): Album {
|
||||
return if (albums!!.isEmpty()) Album() else albums[0]
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val UNKNOWN_ARTIST_DISPLAY_NAME = "Unknown Artist"
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
public class Contributor {
|
||||
private String name;
|
||||
private String summary;
|
||||
private String link;
|
||||
private String profile_image;
|
||||
|
||||
public Contributor() {
|
||||
}
|
||||
|
||||
public Contributor(String name, String summary, String link, String profile_image) {
|
||||
this.name = name;
|
||||
this.summary = summary;
|
||||
this.link = link;
|
||||
this.profile_image = profile_image;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public String getProfileImage() {
|
||||
return profile_image;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
class Contributor(val name: String, val summary: String, val link: String, val profileImage: String)
|
|
@ -1,86 +0,0 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
public class Genre implements Parcelable {
|
||||
|
||||
public static final Creator<Genre> CREATOR = new Creator<Genre>() {
|
||||
@Override
|
||||
public Genre createFromParcel(Parcel in) {
|
||||
return new Genre(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Genre[] newArray(int size) {
|
||||
return new Genre[size];
|
||||
}
|
||||
};
|
||||
public final int id;
|
||||
public final String name;
|
||||
public final int songCount;
|
||||
|
||||
public Genre(final int id, final String name, int songCount) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.songCount = songCount;
|
||||
}
|
||||
|
||||
|
||||
// For unknown genre
|
||||
public Genre(final String name, final int songCount) {
|
||||
this.id = -1;
|
||||
this.name = name;
|
||||
this.songCount = songCount;
|
||||
}
|
||||
|
||||
protected Genre(Parcel in) {
|
||||
id = in.readInt();
|
||||
name = in.readString();
|
||||
songCount = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(id);
|
||||
dest.writeString(name);
|
||||
dest.writeInt(songCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Genre genre = (Genre) o;
|
||||
|
||||
if (id != genre.id) return false;
|
||||
return name != null ? name.equals(genre.name) : genre.name == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Genre{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
}
|
26
app/src/main/java/code/name/monkey/retromusic/model/Genre.kt
Normal file
26
app/src/main/java/code/name/monkey/retromusic/model/Genre.kt
Normal file
|
@ -0,0 +1,26 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
class Genre : Serializable {
|
||||
val id: Int
|
||||
val name: String?
|
||||
val songCount: Int
|
||||
|
||||
constructor(id: Int, name: String, songCount: Int) {
|
||||
this.id = id
|
||||
this.name = name
|
||||
this.songCount = songCount
|
||||
}
|
||||
|
||||
// For unknown genre
|
||||
constructor(name: String, songCount: Int) {
|
||||
this.id = -1
|
||||
this.name = name
|
||||
this.songCount = songCount
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Created by BlackFootSanji on 5/22/2017.
|
||||
*/
|
||||
|
||||
public class Home {
|
||||
|
||||
private int sectionTitle;
|
||||
private ArrayList list;
|
||||
|
||||
public Home(@StringRes int sectionTitle, ArrayList list) {
|
||||
this.sectionTitle = sectionTitle;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public int getSectionTitle() {
|
||||
return sectionTitle;
|
||||
}
|
||||
|
||||
public ArrayList getList() {
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
|
||||
public class Song implements Parcelable {
|
||||
public static final Song EMPTY_SONG = new Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "");
|
||||
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];
|
||||
}
|
||||
};
|
||||
public final int id;
|
||||
public final String title;
|
||||
public final int trackNumber;
|
||||
public final int year;
|
||||
public final long duration;
|
||||
public final String data;
|
||||
public final long dateModified;
|
||||
public final int albumId;
|
||||
public final String albumName;
|
||||
public final int artistId;
|
||||
public final String artistName;
|
||||
|
||||
public Song(int id, String title, int trackNumber, int year, long duration, String data, long dateModified, int albumId, String albumName, int artistId, String artistName) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.trackNumber = trackNumber;
|
||||
this.year = year;
|
||||
this.duration = duration;
|
||||
this.data = data;
|
||||
this.dateModified = dateModified;
|
||||
this.albumId = albumId;
|
||||
this.albumName = albumName;
|
||||
this.artistId = artistId;
|
||||
this.artistName = artistName;
|
||||
}
|
||||
|
||||
protected Song(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.title = in.readString();
|
||||
this.trackNumber = in.readInt();
|
||||
this.year = in.readInt();
|
||||
this.duration = in.readLong();
|
||||
this.data = in.readString();
|
||||
this.dateModified = in.readLong();
|
||||
this.albumId = in.readInt();
|
||||
this.albumName = in.readString();
|
||||
this.artistId = in.readInt();
|
||||
this.artistName = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeString(this.title);
|
||||
dest.writeInt(this.trackNumber);
|
||||
dest.writeInt(this.year);
|
||||
dest.writeLong(this.duration);
|
||||
dest.writeString(this.data);
|
||||
dest.writeLong(this.dateModified);
|
||||
dest.writeInt(this.albumId);
|
||||
dest.writeString(this.albumName);
|
||||
dest.writeInt(this.artistId);
|
||||
dest.writeString(this.artistName);
|
||||
}
|
||||
}
|
79
app/src/main/java/code/name/monkey/retromusic/model/Song.kt
Normal file
79
app/src/main/java/code/name/monkey/retromusic/model/Song.kt
Normal file
|
@ -0,0 +1,79 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
|
||||
open class Song : Parcelable {
|
||||
val id: Int
|
||||
val title: String?
|
||||
val trackNumber: Int
|
||||
val year: Int
|
||||
val duration: Long
|
||||
val data: String?
|
||||
val dateModified: Long
|
||||
val albumId: Int
|
||||
val albumName: String?
|
||||
val artistId: Int
|
||||
val artistName: String?
|
||||
|
||||
constructor(id: Int, title: String, trackNumber: Int, year: Int, duration: Long, data: String, dateModified: Long, albumId: Int, albumName: String, artistId: Int, artistName: String) {
|
||||
this.id = id
|
||||
this.title = title
|
||||
this.trackNumber = trackNumber
|
||||
this.year = year
|
||||
this.duration = duration
|
||||
this.data = data
|
||||
this.dateModified = dateModified
|
||||
this.albumId = albumId
|
||||
this.albumName = albumName
|
||||
this.artistId = artistId
|
||||
this.artistName = artistName
|
||||
}
|
||||
|
||||
protected constructor(`in`: Parcel) {
|
||||
this.id = `in`.readInt()
|
||||
this.title = `in`.readString()
|
||||
this.trackNumber = `in`.readInt()
|
||||
this.year = `in`.readInt()
|
||||
this.duration = `in`.readLong()
|
||||
this.data = `in`.readString()
|
||||
this.dateModified = `in`.readLong()
|
||||
this.albumId = `in`.readInt()
|
||||
this.albumName = `in`.readString()
|
||||
this.artistId = `in`.readInt()
|
||||
this.artistName = `in`.readString()
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeInt(this.id)
|
||||
dest.writeString(this.title)
|
||||
dest.writeInt(this.trackNumber)
|
||||
dest.writeInt(this.year)
|
||||
dest.writeLong(this.duration)
|
||||
dest.writeString(this.data)
|
||||
dest.writeLong(this.dateModified)
|
||||
dest.writeInt(this.albumId)
|
||||
dest.writeString(this.albumName)
|
||||
dest.writeInt(this.artistId)
|
||||
dest.writeString(this.artistName)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY_SONG = Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "")
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<Song> = object : Parcelable.Creator<Song> {
|
||||
override fun createFromParcel(source: Parcel): Song {
|
||||
return Song(source)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Song> {
|
||||
return emptyArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ public class HistoryPlaylist extends AbsSmartPlaylist {
|
|||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(context);
|
||||
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getRecentlyPlayedTracks(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public class LastAddedPlaylist extends AbsSmartPlaylist {
|
|||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return LastAddedSongsLoader.getLastAddedSongs(context);
|
||||
return LastAddedSongsLoader.INSTANCE.getLastAddedSongs(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public class MyTopTracksPlaylist extends AbsSmartPlaylist implements Parcelable
|
|||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return TopAndRecentlyPlayedTracksLoader.getTopTracks(context);
|
||||
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getTopTracks(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ShuffleAllPlaylist extends AbsSmartPlaylist {
|
|||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return SongLoader.Companion.getAllSongs(context);
|
||||
return SongLoader.INSTANCE.getAllSongs(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue