clean-arc
This commit is contained in:
parent
1d423fc7bd
commit
5ee566c09a
62 changed files with 477 additions and 937 deletions
|
@ -15,27 +15,20 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.reactivex.Observable;
|
||||
import kotlinx.android.parcel.Parcelize;
|
||||
|
||||
|
||||
@Parcelize
|
||||
public abstract class AbsCustomPlaylist extends Playlist {
|
||||
public AbsCustomPlaylist(int id, String name) {
|
||||
public AbsCustomPlaylist(int id, @NonNull String name) {
|
||||
super(id, name);
|
||||
}
|
||||
|
||||
public AbsCustomPlaylist() {
|
||||
}
|
||||
|
||||
public AbsCustomPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Observable<ArrayList<Song>> getSongs(Context context);
|
||||
public abstract Observable<ArrayList<Song>> getSongs(@NonNull Context context);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,6 @@ class Album {
|
|||
}
|
||||
|
||||
fun safeGetFirstSong(): Song {
|
||||
return if (songs!!.isEmpty()) Song.EMPTY_SONG else songs[0]
|
||||
return if (songs!!.isEmpty()) Song.emptySong else songs[0]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
}
|
25
app/src/main/java/code/name/monkey/retromusic/model/Genre.kt
Normal file
25
app/src/main/java/code/name/monkey/retromusic/model/Genre.kt
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
@Parcelize
|
||||
class Genre(val id: Int = -1, val name: String, val songCount: Int) : Parcelable
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.StringRes;
|
||||
import code.name.monkey.retromusic.ui.adapter.HomeAdapter.Companion.HomeSection;
|
||||
|
||||
public class Home {
|
||||
@StringRes
|
||||
int title;
|
||||
@StringRes
|
||||
int subtitle;
|
||||
@HomeSection
|
||||
int homeSection;
|
||||
@DrawableRes
|
||||
int icon;
|
||||
|
||||
ArrayList arrayList;
|
||||
|
||||
public Home(int title, int subtitle, ArrayList arrayList, @HomeSection int homeSection, @DrawableRes int icon) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.arrayList = arrayList;
|
||||
this.homeSection = homeSection;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@HomeSection
|
||||
public int getHomeSection() {
|
||||
return homeSection;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public ArrayList getArrayList() {
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
}
|
31
app/src/main/java/code/name/monkey/retromusic/model/Home.kt
Normal file
31
app/src/main/java/code/name/monkey/retromusic/model/Home.kt
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import code.name.monkey.retromusic.ui.adapter.HomeAdapter.Companion.HomeSection
|
||||
|
||||
/**
|
||||
* Created by hemanths on 3/4/19
|
||||
*/
|
||||
|
||||
class Home(@StringRes val title: Int,
|
||||
@StringRes val subTitle: Int,
|
||||
val arrayList: ArrayList<*>,
|
||||
@HomeSection
|
||||
val homeSection: Int,
|
||||
@DrawableRes
|
||||
val icon: Int)
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
|
||||
public class Playlist implements Parcelable {
|
||||
public static final Creator<Playlist> CREATOR = new Creator<Playlist>() {
|
||||
public Playlist createFromParcel(Parcel source) {
|
||||
return new Playlist(source);
|
||||
}
|
||||
|
||||
public Playlist[] newArray(int size) {
|
||||
return new Playlist[size];
|
||||
}
|
||||
};
|
||||
public final int id;
|
||||
public final String name;
|
||||
|
||||
public Playlist(final int id, final String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Playlist() {
|
||||
this.id = -1;
|
||||
this.name = "";
|
||||
}
|
||||
|
||||
protected Playlist(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.name = in.readString();
|
||||
}
|
||||
|
||||
@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() {
|
||||
int result = id;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Playlist{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeString(this.name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
open class Playlist(val id: Int = -1, val name: String = "") : Parcelable
|
|
@ -14,72 +14,42 @@
|
|||
|
||||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import kotlinx.android.parcel.Parcelize;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 3/4/19
|
||||
*/
|
||||
@Parcelize
|
||||
public class PlaylistSong extends Song {
|
||||
public static final Creator<PlaylistSong> CREATOR = new Creator<PlaylistSong>() {
|
||||
public PlaylistSong createFromParcel(Parcel source) {
|
||||
return new PlaylistSong(source);
|
||||
}
|
||||
final int playlistId;
|
||||
final int idInPlayList;
|
||||
|
||||
public PlaylistSong[] newArray(int size) {
|
||||
return new PlaylistSong[size];
|
||||
}
|
||||
};
|
||||
public final int playlistId;
|
||||
public final int idInPlayList;
|
||||
|
||||
public PlaylistSong(int id, String title, int trackNumber, int year, long duration, String data, int dateModified, int albumId, String albumName, int artistId, String artistName, final int playlistId, final int idInPlayList, String composer) {
|
||||
public PlaylistSong(int id,
|
||||
@NotNull String title,
|
||||
int trackNumber,
|
||||
int year,
|
||||
long duration,
|
||||
@NotNull String data,
|
||||
long dateModified,
|
||||
int albumId,
|
||||
@NotNull String albumName,
|
||||
int artistId,
|
||||
@NotNull String artistName,
|
||||
int playlistId,
|
||||
int idInPlayList,
|
||||
@NotNull String composer) {
|
||||
super(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, composer);
|
||||
this.playlistId = playlistId;
|
||||
this.idInPlayList = idInPlayList;
|
||||
}
|
||||
|
||||
protected PlaylistSong(Parcel in) {
|
||||
super(in);
|
||||
this.playlistId = in.readInt();
|
||||
this.idInPlayList = in.readInt();
|
||||
public int getPlaylistId() {
|
||||
return playlistId;
|
||||
}
|
||||
|
||||
@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() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + playlistId;
|
||||
result = 31 * result + idInPlayList;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
public int getIdInPlayList() {
|
||||
return idInPlayList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
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 final String composer;
|
||||
|
||||
public Song(int id, String title, int trackNumber, int year, long duration, String data, long dateModified, int albumId, String albumName, int artistId, String artistName, String composer) {
|
||||
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;
|
||||
this.composer = composer;
|
||||
}
|
||||
|
||||
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();
|
||||
this.composer = 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);
|
||||
dest.writeString(this.composer);
|
||||
}
|
||||
}
|
31
app/src/main/java/code/name/monkey/retromusic/model/Song.kt
Normal file
31
app/src/main/java/code/name/monkey/retromusic/model/Song.kt
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
package code.name.monkey.retromusic.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
@Parcelize
|
||||
open class Song(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, val composer: String?) : Parcelable {
|
||||
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val emptySong = Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", "")
|
||||
}
|
||||
}
|
|
@ -15,27 +15,29 @@
|
|||
package code.name.monkey.retromusic.model.lyrics;
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
|
||||
public class Lyrics {
|
||||
private static final ArrayList<Class<? extends Lyrics>> FORMATS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
Lyrics.FORMATS.add(SynchronizedLyricsLRC.class);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Song song;
|
||||
@NonNull
|
||||
public String data;
|
||||
|
||||
protected boolean parsed = false;
|
||||
protected boolean valid = false;
|
||||
|
||||
public Lyrics setData(Song song, String data) {
|
||||
this.song = song;
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Lyrics parse(Song song, String data) {
|
||||
@NonNull
|
||||
public static Lyrics parse(@NonNull Song song, @NonNull String data) {
|
||||
for (Class<? extends Lyrics> format : Lyrics.FORMATS) {
|
||||
try {
|
||||
Lyrics lyrics = format.newInstance().setData(song, data);
|
||||
|
@ -47,7 +49,7 @@ public class Lyrics {
|
|||
return new Lyrics().setData(song, data).parse(false);
|
||||
}
|
||||
|
||||
public static boolean isSynchronized(String data) {
|
||||
public static boolean isSynchronized(@NonNull String data) {
|
||||
for (Class<? extends Lyrics> format : Lyrics.FORMATS) {
|
||||
try {
|
||||
Lyrics lyrics = format.newInstance().setData(null, data);
|
||||
|
@ -59,6 +61,13 @@ public class Lyrics {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Lyrics setData(@NonNull Song song, @NonNull String data) {
|
||||
this.song = song;
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Lyrics parse(boolean check) {
|
||||
this.valid = true;
|
||||
this.parsed = true;
|
||||
|
@ -74,11 +83,8 @@ public class Lyrics {
|
|||
return this.valid;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getText() {
|
||||
return this.data.trim().replaceAll("(\r?\n){3,}", "\r\n\r\n");
|
||||
}
|
||||
|
||||
static {
|
||||
Lyrics.FORMATS.add(SynchronizedLyricsLRC.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,63 +15,22 @@
|
|||
package code.name.monkey.retromusic.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import androidx.annotation.NonNull;
|
||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist;
|
||||
import kotlinx.android.parcel.Parcelize;
|
||||
|
||||
|
||||
@Parcelize
|
||||
public abstract class AbsSmartPlaylist extends AbsCustomPlaylist {
|
||||
@DrawableRes
|
||||
public final int iconRes;
|
||||
|
||||
public AbsSmartPlaylist(final String name, final int iconRes) {
|
||||
public AbsSmartPlaylist(final @NonNull String name, final int iconRes) {
|
||||
super(-Math.abs(31 * name.hashCode() + (iconRes * name.hashCode() * 31 * 31)), name);
|
||||
this.iconRes = iconRes;
|
||||
}
|
||||
|
||||
public AbsSmartPlaylist() {
|
||||
super();
|
||||
this.iconRes = R.drawable.ic_playlist_play_white_24dp;
|
||||
}
|
||||
public abstract void clear(@NonNull Context context);
|
||||
|
||||
protected AbsSmartPlaylist(Parcel in) {
|
||||
super(in);
|
||||
this.iconRes = in.readInt();
|
||||
}
|
||||
|
||||
public abstract void clear(Context context);
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + iconRes;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable final Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AbsSmartPlaylist other = (AbsSmartPlaylist) obj;
|
||||
return iconRes == other.iconRes;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(this.iconRes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.providers.HistoryStore;
|
||||
import io.reactivex.Observable;
|
||||
|
||||
|
||||
public class HistoryPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public static final Parcelable.Creator<HistoryPlaylist> CREATOR = new Parcelable.Creator<HistoryPlaylist>() {
|
||||
public HistoryPlaylist createFromParcel(Parcel source) {
|
||||
return new HistoryPlaylist(source);
|
||||
}
|
||||
|
||||
public HistoryPlaylist[] newArray(int size) {
|
||||
return new HistoryPlaylist[size];
|
||||
}
|
||||
};
|
||||
|
||||
public HistoryPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp);
|
||||
}
|
||||
|
||||
protected HistoryPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getRecentlyPlayedTracks(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist
|
||||
|
||||
import android.content.Context
|
||||
|
||||
import java.util.ArrayList
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.providers.HistoryStore
|
||||
import io.reactivex.Observable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
class HistoryPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp) {
|
||||
|
||||
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||
return TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(context)
|
||||
}
|
||||
|
||||
override fun clear(context: Context) {
|
||||
HistoryStore.getInstance(context).clear()
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.loaders.LastAddedSongsLoader;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
|
||||
public class LastAddedPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public static final Parcelable.Creator<LastAddedPlaylist> CREATOR = new Parcelable.Creator<LastAddedPlaylist>() {
|
||||
public LastAddedPlaylist createFromParcel(Parcel source) {
|
||||
return new LastAddedPlaylist(source);
|
||||
}
|
||||
|
||||
public LastAddedPlaylist[] newArray(int size) {
|
||||
return new LastAddedPlaylist[size];
|
||||
}
|
||||
};
|
||||
|
||||
public LastAddedPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp);
|
||||
}
|
||||
|
||||
protected LastAddedPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return LastAddedSongsLoader.INSTANCE.getLastAddedSongs(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(@NonNull Context context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist
|
||||
|
||||
import android.content.Context
|
||||
|
||||
import java.util.ArrayList
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.loaders.LastAddedSongsLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import io.reactivex.Observable
|
||||
|
||||
class LastAddedPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp) {
|
||||
|
||||
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||
return LastAddedSongsLoader.getLastAddedSongs(context)
|
||||
}
|
||||
|
||||
override fun clear(context: Context) {}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.providers.SongPlayCountStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
|
||||
public class MyTopTracksPlaylist extends AbsSmartPlaylist implements Parcelable {
|
||||
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];
|
||||
}
|
||||
};
|
||||
|
||||
public MyTopTracksPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp);
|
||||
}
|
||||
|
||||
protected MyTopTracksPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getTopTracks(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist
|
||||
|
||||
import android.content.Context
|
||||
|
||||
import java.util.ArrayList
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.providers.SongPlayCountStore
|
||||
import io.reactivex.Observable
|
||||
|
||||
|
||||
class MyTopTracksPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp) {
|
||||
|
||||
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||
return TopAndRecentlyPlayedTracksLoader.getTopTracks(context)
|
||||
}
|
||||
|
||||
override fun clear(context: Context) {
|
||||
SongPlayCountStore.getInstance(context).clear()
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.loaders.SongLoader;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public class ShuffleAllPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public static final Parcelable.Creator<ShuffleAllPlaylist> CREATOR = new Parcelable.Creator<ShuffleAllPlaylist>() {
|
||||
public ShuffleAllPlaylist createFromParcel(Parcel source) {
|
||||
return new ShuffleAllPlaylist(source);
|
||||
}
|
||||
|
||||
public ShuffleAllPlaylist[] newArray(int size) {
|
||||
return new ShuffleAllPlaylist[size];
|
||||
}
|
||||
};
|
||||
|
||||
public ShuffleAllPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp);
|
||||
}
|
||||
|
||||
protected ShuffleAllPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
|
||||
return SongLoader.INSTANCE.getAllSongs(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(@NonNull Context context) {
|
||||
// Shuffle all is not a real "Smart Playlist"
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.model.smartplaylist
|
||||
|
||||
import android.content.Context
|
||||
|
||||
import java.util.ArrayList
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.loaders.SongLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import io.reactivex.Observable
|
||||
|
||||
class ShuffleAllPlaylist(context: Context) : AbsSmartPlaylist(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp) {
|
||||
|
||||
|
||||
override fun getSongs(context: Context): Observable<ArrayList<Song>> {
|
||||
return SongLoader.getAllSongs(context)
|
||||
}
|
||||
|
||||
override fun clear(context: Context) {
|
||||
// Shuffle all is not a real "Smart Playlist"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue