Optimized imports

This commit is contained in:
CappielloAntonio 2021-08-01 11:48:18 +02:00
parent 8d517ae3e0
commit 0827fc10a9
80 changed files with 130 additions and 269 deletions

View file

@ -15,7 +15,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -15,7 +15,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -19,7 +19,6 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -13,15 +13,10 @@ import androidx.fragment.app.FragmentManager;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.App;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.MusicUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -15,7 +15,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -19,7 +19,6 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -13,15 +13,10 @@ import androidx.fragment.app.FragmentManager;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.App;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.MusicUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -14,9 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -20,8 +20,6 @@ import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.repository.SongRepository; import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote; import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.util.SyncUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -12,7 +12,6 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.service.MusicPlayerRemote; import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -16,7 +16,6 @@ import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.service.MusicPlayerRemote; import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.fragment.PlayerBottomSheetFragment; import com.cappielloantonio.play.ui.fragment.PlayerBottomSheetFragment;
import com.cappielloantonio.play.util.MusicUtil; import com.cappielloantonio.play.util.MusicUtil;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -1,6 +1,5 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
@ -17,7 +16,6 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Playlist; import com.cappielloantonio.play.model.Playlist;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -19,7 +19,6 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Playlist; import com.cappielloantonio.play.model.Playlist;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -20,7 +20,6 @@ import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.QueueRepository; import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote; import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -12,7 +12,6 @@ import com.cappielloantonio.play.database.dao.RecentSearchDao;
import com.cappielloantonio.play.model.Download; import com.cappielloantonio.play.model.Download;
import com.cappielloantonio.play.model.Queue; import com.cappielloantonio.play.model.Queue;
import com.cappielloantonio.play.model.RecentSearch; import com.cappielloantonio.play.model.RecentSearch;
import com.cappielloantonio.play.model.Song;
@Database(entities = {Queue.class, RecentSearch.class, Download.class}, version = 5, exportSchema = false) @Database(entities = {Queue.class, RecentSearch.class, Download.class}, version = 5, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase { public abstract class AppDatabase extends RoomDatabase {

View file

@ -7,7 +7,6 @@ import androidx.room.OnConflictStrategy;
import androidx.room.Query; import androidx.room.Query;
import com.cappielloantonio.play.model.Queue; import com.cappielloantonio.play.model.Queue;
import com.cappielloantonio.play.model.Song;
import java.util.List; import java.util.List;

View file

@ -4,7 +4,6 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;

View file

@ -1,7 +1,5 @@
package com.cappielloantonio.play.interfaces; package com.cappielloantonio.play.interfaces;
import java.util.List;
public interface SystemCallback { public interface SystemCallback {
void onError(Exception exception); void onError(Exception exception);

View file

@ -4,10 +4,6 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.cappielloantonio.play.subsonic.models.AlbumID3; import com.cappielloantonio.play.subsonic.models.AlbumID3;
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3; import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3;

View file

@ -4,9 +4,6 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
public class Genre implements Parcelable { public class Genre implements Parcelable {
public String id; public String id;

View file

@ -3,11 +3,6 @@ package com.cappielloantonio.play.model;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
public class Playlist implements Parcelable { public class Playlist implements Parcelable {
public String id; public String id;
public String name; public String name;

View file

@ -4,12 +4,6 @@ import android.annotation.SuppressLint;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.cappielloantonio.play.subsonic.models.Child; import com.cappielloantonio.play.subsonic.models.Child;
import java.time.Instant; import java.time.Instant;

View file

@ -8,7 +8,6 @@ import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.subsonic.models.ResponseStatus; import com.cappielloantonio.play.subsonic.models.ResponseStatus;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;

View file

@ -260,7 +260,7 @@ public class ArtistRepository {
if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) { if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) {
List<Album> albums = new ArrayList<>(MappingUtil.mapAlbum(response.body().getArtist().getAlbums())); List<Album> albums = new ArrayList<>(MappingUtil.mapAlbum(response.body().getArtist().getAlbums()));
if(albums.size() > 0) { if (albums.size() > 0) {
AlbumRepository albumRepository = new AlbumRepository(App.getInstance()); AlbumRepository albumRepository = new AlbumRepository(App.getInstance());
for (int index = 0; index < albums.size(); index++) { for (int index = 0; index < albums.size(); index++) {

View file

@ -7,12 +7,7 @@ import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.database.AppDatabase; import com.cappielloantonio.play.database.AppDatabase;
import com.cappielloantonio.play.database.dao.DownloadDao; import com.cappielloantonio.play.database.dao.DownloadDao;
import com.cappielloantonio.play.database.dao.QueueDao;
import com.cappielloantonio.play.model.Download; import com.cappielloantonio.play.model.Download;
import com.cappielloantonio.play.model.Queue;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.util.MappingUtil;
import com.cappielloantonio.play.util.QueueUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -39,14 +39,13 @@ public class GenreRepository {
if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) { if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) {
List<Genre> genreList = new ArrayList<>(MappingUtil.mapGenre(response.body().getGenres().getGenres())); List<Genre> genreList = new ArrayList<>(MappingUtil.mapGenre(response.body().getGenres().getGenres()));
if(random) { if (random) {
Collections.shuffle(genreList); Collections.shuffle(genreList);
} }
if(size != -1) { if (size != -1) {
genres.setValue(genreList.subList(0, Math.min(size, genreList.size()))); genres.setValue(genreList.subList(0, Math.min(size, genreList.size())));
} } else {
else {
genres.setValue(genreList); genres.setValue(genreList);
} }
} }

View file

@ -5,7 +5,6 @@ import android.app.Application;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Playlist; import com.cappielloantonio.play.model.Playlist;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.subsonic.models.ResponseStatus; import com.cappielloantonio.play.subsonic.models.ResponseStatus;

View file

@ -206,7 +206,7 @@ public class SongRepository {
public MutableLiveData<List<Song>> getSongsByGenres(ArrayList<String> genresId) { public MutableLiveData<List<Song>> getSongsByGenres(ArrayList<String> genresId) {
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>(new ArrayList<>()); MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>(new ArrayList<>());
for(String id: genresId) for (String id : genresId)
App.getSubsonicClientInstance(application, false) App.getSubsonicClientInstance(application, false)
.getAlbumSongListClient() .getAlbumSongListClient()

View file

@ -4,7 +4,6 @@ import android.app.Application;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.interfaces.SystemCallback; import com.cappielloantonio.play.interfaces.SystemCallback;
import com.cappielloantonio.play.subsonic.api.system.SystemClient;
import com.cappielloantonio.play.subsonic.models.ResponseStatus; import com.cappielloantonio.play.subsonic.models.ResponseStatus;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;

View file

@ -9,7 +9,6 @@ import androidx.annotation.Nullable;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.DownloadRepository; import com.cappielloantonio.play.repository.DownloadRepository;
import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.util.MappingUtil; import com.cappielloantonio.play.util.MappingUtil;
import com.cappielloantonio.play.util.MusicUtil; import com.cappielloantonio.play.util.MusicUtil;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;

View file

@ -37,15 +37,11 @@ import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.ui.notification.PlayingNotification; import com.cappielloantonio.play.ui.notification.PlayingNotification;
import com.cappielloantonio.play.util.PreferenceUtil; import com.cappielloantonio.play.util.PreferenceUtil;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO; import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED; import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED;
@ -799,7 +795,8 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
public void handleMessage(@NonNull final Message msg) { public void handleMessage(@NonNull final Message msg) {
switch (msg.what) { switch (msg.what) {
case TRACK_STARTED: case TRACK_STARTED:
case TRACK_CHANGED: break; case TRACK_CHANGED:
break;
case TRACK_ENDED: case TRACK_ENDED:
} }
} }

View file

@ -8,7 +8,6 @@ import com.cappielloantonio.play.subsonic.api.playlist.PlaylistClient;
import com.cappielloantonio.play.subsonic.api.searching.SearchingClient; import com.cappielloantonio.play.subsonic.api.searching.SearchingClient;
import com.cappielloantonio.play.subsonic.api.system.SystemClient; import com.cappielloantonio.play.subsonic.api.system.SystemClient;
import com.cappielloantonio.play.subsonic.base.Version; import com.cappielloantonio.play.subsonic.base.Version;
import com.cappielloantonio.play.subsonic.models.Playlist;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View file

@ -39,8 +39,9 @@ public class SubsonicPreferences {
} }
public void setAuthentication(String password, String token, String salt) { public void setAuthentication(String password, String token, String salt) {
if(password != null) this.authentication = new SubsonicAuthentication(password); if (password != null) this.authentication = new SubsonicAuthentication(password);
if(token != null && salt != null) this.authentication = new SubsonicAuthentication(token, salt); if (token != null && salt != null)
this.authentication = new SubsonicAuthentication(token, salt);
} }
public static class SubsonicAuthentication { public static class SubsonicAuthentication {

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -4,7 +4,6 @@ import android.util.Log;
import com.cappielloantonio.play.subsonic.Subsonic; import com.cappielloantonio.play.subsonic.Subsonic;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory; import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;

View file

@ -1,6 +1,6 @@
package com.cappielloantonio.play.subsonic.base; package com.cappielloantonio.play.subsonic.base;
public class SubsonicIncompatibilityException extends RuntimeException{ public class SubsonicIncompatibilityException extends RuntimeException {
private final Version serverApiVersion; private final Version serverApiVersion;
private final Version minClientApiVersion; private final Version minClientApiVersion;

View file

@ -4,7 +4,6 @@ import com.tickaroo.tikxml.annotation.Attribute;
import com.tickaroo.tikxml.annotation.Xml; import com.tickaroo.tikxml.annotation.Xml;
import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter; import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
@Xml(name = "album") @Xml(name = "album")

View file

@ -4,7 +4,6 @@ import com.tickaroo.tikxml.annotation.Attribute;
import com.tickaroo.tikxml.annotation.Xml; import com.tickaroo.tikxml.annotation.Xml;
import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter; import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
@Xml(name = "artist") @Xml(name = "artist")

View file

@ -1,11 +1,9 @@
package com.cappielloantonio.play.subsonic.models; package com.cappielloantonio.play.subsonic.models;
import com.tickaroo.tikxml.annotation.Attribute; import com.tickaroo.tikxml.annotation.Attribute;
import com.tickaroo.tikxml.annotation.Element;
import com.tickaroo.tikxml.annotation.Xml; import com.tickaroo.tikxml.annotation.Xml;
import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter; import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View file

@ -3,7 +3,6 @@ package com.cappielloantonio.play.ui.fragment;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;

View file

@ -10,20 +10,11 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.cappielloantonio.play.App;
import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter; import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
import com.cappielloantonio.play.databinding.FragmentAlbumListPageBinding; import com.cappielloantonio.play.databinding.FragmentAlbumListPageBinding;
import com.cappielloantonio.play.databinding.FragmentSongListPageBinding;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.viewmodel.AlbumListPageViewModel; import com.cappielloantonio.play.viewmodel.AlbumListPageViewModel;
import com.cappielloantonio.play.viewmodel.SongListPageViewModel;
import java.util.Collections;
public class AlbumListPageFragment extends Fragment { public class AlbumListPageFragment extends Fragment {
private FragmentAlbumListPageBinding bind; private FragmentAlbumListPageBinding bind;
@ -61,19 +52,16 @@ public class AlbumListPageFragment extends Fragment {
} }
private void init() { private void init() {
if(getArguments().getString(Album.RECENTLY_PLAYED) != null) { if (getArguments().getString(Album.RECENTLY_PLAYED) != null) {
albumListPageViewModel.title = Album.RECENTLY_PLAYED; albumListPageViewModel.title = Album.RECENTLY_PLAYED;
bind.pageTitleLabel.setText("Recently played albums"); bind.pageTitleLabel.setText("Recently played albums");
} } else if (getArguments().getString(Album.MOST_PLAYED) != null) {
else if(getArguments().getString(Album.MOST_PLAYED) != null) {
albumListPageViewModel.title = Album.MOST_PLAYED; albumListPageViewModel.title = Album.MOST_PLAYED;
bind.pageTitleLabel.setText("Most played albums"); bind.pageTitleLabel.setText("Most played albums");
} } else if (getArguments().getString(Album.RECENTLY_ADDED) != null) {
else if(getArguments().getString(Album.RECENTLY_ADDED) != null) {
albumListPageViewModel.title = Album.RECENTLY_ADDED; albumListPageViewModel.title = Album.RECENTLY_ADDED;
bind.pageTitleLabel.setText("Recently added albums"); bind.pageTitleLabel.setText("Recently added albums");
} } else if (getArguments().getString(Album.STARRED) != null) {
else if(getArguments().getString(Album.STARRED) != null) {
albumListPageViewModel.title = Album.STARRED; albumListPageViewModel.title = Album.STARRED;
bind.pageTitleLabel.setText("Starred albums"); bind.pageTitleLabel.setText("Starred albums");
} }

View file

@ -21,21 +21,13 @@ import com.cappielloantonio.play.adapter.AlbumArtistPageOrSimilarAdapter;
import com.cappielloantonio.play.adapter.SongHorizontalAdapter; import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
import com.cappielloantonio.play.databinding.FragmentAlbumPageBinding; import com.cappielloantonio.play.databinding.FragmentAlbumPageBinding;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.repository.QueueRepository; import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.DownloadUtil; import com.cappielloantonio.play.util.DownloadUtil;
import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.util.SyncUtil;
import com.cappielloantonio.play.viewmodel.AlbumPageViewModel; import com.cappielloantonio.play.viewmodel.AlbumPageViewModel;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List;
public class AlbumPageFragment extends Fragment { public class AlbumPageFragment extends Fragment {
private static final String TAG = "AlbumPageFragment"; private static final String TAG = "AlbumPageFragment";
@ -133,12 +125,12 @@ public class AlbumPageFragment extends Fragment {
private void initAlbumInfoTextButton() { private void initAlbumInfoTextButton() {
bind.albumArtistLabel.setOnClickListener(v -> { bind.albumArtistLabel.setOnClickListener(v -> {
albumPageViewModel.getArtist().observe(requireActivity(), artist -> { albumPageViewModel.getArtist().observe(requireActivity(), artist -> {
if(artist != null) { if (artist != null) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artist); bundle.putParcelable("artist_object", artist);
activity.navController.navigate(R.id.action_albumPageFragment_to_artistPageFragment, bundle); activity.navController.navigate(R.id.action_albumPageFragment_to_artistPageFragment, bundle);
} } else
else Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show(); Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
}); });
}); });
@ -152,7 +144,7 @@ public class AlbumPageFragment extends Fragment {
private void initMusicButton() { private void initMusicButton() {
albumPageViewModel.getAlbumSongLiveList().observe(requireActivity(), songs -> { albumPageViewModel.getAlbumSongLiveList().observe(requireActivity(), songs -> {
if(bind != null) { if (bind != null) {
bind.albumPagePlayButton.setOnClickListener(v -> { bind.albumPagePlayButton.setOnClickListener(v -> {
QueueRepository queueRepository = new QueueRepository(App.getInstance()); QueueRepository queueRepository = new QueueRepository(App.getInstance());
queueRepository.insertAllAndStartNew(songs); queueRepository.insertAllAndStartNew(songs);

View file

@ -26,7 +26,6 @@ import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter;
import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding; import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding;
import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration; import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.viewmodel.AlbumCatalogueViewModel;
import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel; import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel;
public class ArtistCatalogueFragment extends Fragment { public class ArtistCatalogueFragment extends Fragment {

View file

@ -10,13 +10,10 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
import com.cappielloantonio.play.adapter.ArtistHorizontalAdapter; import com.cappielloantonio.play.adapter.ArtistHorizontalAdapter;
import com.cappielloantonio.play.databinding.FragmentAlbumListPageBinding;
import com.cappielloantonio.play.databinding.FragmentArtistListPageBinding; import com.cappielloantonio.play.databinding.FragmentArtistListPageBinding;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.viewmodel.AlbumListPageViewModel;
import com.cappielloantonio.play.viewmodel.ArtistListPageViewModel; import com.cappielloantonio.play.viewmodel.ArtistListPageViewModel;
public class ArtistListPageFragment extends Fragment { public class ArtistListPageFragment extends Fragment {
@ -55,7 +52,7 @@ public class ArtistListPageFragment extends Fragment {
} }
private void init() { private void init() {
if(getArguments().getString(Album.STARRED) != null) { if (getArguments().getString(Album.STARRED) != null) {
artistListPageViewModel.title = Album.STARRED; artistListPageViewModel.title = Album.STARRED;
bind.pageTitleLabel.setText("Starred artists"); bind.pageTitleLabel.setText("Starred artists");
} }

View file

@ -3,7 +3,6 @@ package com.cappielloantonio.play.ui.fragment;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.BlendMode; import android.graphics.BlendMode;
import android.graphics.BlendModeColorFilter; import android.graphics.BlendModeColorFilter;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,7 +11,6 @@ import android.view.ViewGroup;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
@ -20,21 +18,17 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.AlbumAdapter;
import com.cappielloantonio.play.adapter.AlbumArtistPageOrSimilarAdapter; import com.cappielloantonio.play.adapter.AlbumArtistPageOrSimilarAdapter;
import com.cappielloantonio.play.adapter.ArtistSimilarAdapter; import com.cappielloantonio.play.adapter.ArtistSimilarAdapter;
import com.cappielloantonio.play.adapter.SongHorizontalAdapter; import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
import com.cappielloantonio.play.databinding.FragmentArtistPageBinding; import com.cappielloantonio.play.databinding.FragmentArtistPageBinding;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.repository.ArtistRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.ArtistRepository;
import com.cappielloantonio.play.repository.QueueRepository; import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.util.SyncUtil;
import com.cappielloantonio.play.viewmodel.ArtistPageViewModel; import com.cappielloantonio.play.viewmodel.ArtistPageViewModel;
import java.util.ArrayList; import java.util.ArrayList;
@ -191,7 +185,8 @@ public class ArtistPageFragment extends Fragment {
artistSimilarAdapter = new ArtistSimilarAdapter(requireContext()); artistSimilarAdapter = new ArtistSimilarAdapter(requireContext());
bind.similarArtistsRecyclerView.setAdapter(artistSimilarAdapter); bind.similarArtistsRecyclerView.setAdapter(artistSimilarAdapter);
artistPageViewModel.getArtistInfo(artistPageViewModel.getArtist().getId()).observe(requireActivity(), artist -> { artistPageViewModel.getArtistInfo(artistPageViewModel.getArtist().getId()).observe(requireActivity(), artist -> {
if(bind != null) bind.similarArtistSector.setVisibility(!artist.getSimilarArtists().isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.similarArtistSector.setVisibility(!artist.getSimilarArtists().isEmpty() ? View.VISIBLE : View.GONE);
artistSimilarAdapter.setItems(artist.getSimilarArtists()); artistSimilarAdapter.setItems(artist.getSimilarArtists());
}); });
} }

View file

@ -60,8 +60,10 @@ public class FilterFragment extends Fragment {
bundle.putStringArrayList("filters_list", filterViewModel.getFilters()); bundle.putStringArrayList("filters_list", filterViewModel.getFilters());
bundle.putStringArrayList("filter_name_list", filterViewModel.getFilterNames()); bundle.putStringArrayList("filter_name_list", filterViewModel.getFilterNames());
bind.finishFilteringTextViewClickable.setOnClickListener(v -> { bind.finishFilteringTextViewClickable.setOnClickListener(v -> {
if(filterViewModel.getFilters().size() > 1) activity.navController.navigate(R.id.action_filterFragment_to_songListPageFragment, bundle); if (filterViewModel.getFilters().size() > 1)
else Toast.makeText(requireContext(), "Select two or more filters", Toast.LENGTH_SHORT).show(); activity.navController.navigate(R.id.action_filterFragment_to_songListPageFragment, bundle);
else
Toast.makeText(requireContext(), "Select two or more filters", Toast.LENGTH_SHORT).show();
}); });
} }
@ -96,8 +98,10 @@ public class FilterFragment extends Fragment {
chip.setText(genre.getName()); chip.setText(genre.getName());
chip.setChecked(filterViewModel.getFilters().contains(genre.getId())); chip.setChecked(filterViewModel.getFilters().contains(genre.getId()));
chip.setOnCheckedChangeListener((buttonView, isChecked) -> { chip.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(isChecked) filterViewModel.addFilter(genre.getId(), buttonView.getText().toString()); if (isChecked)
else filterViewModel.removeFilter(genre.getId(), buttonView.getText().toString()); filterViewModel.addFilter(genre.getId(), buttonView.getText().toString());
else
filterViewModel.removeFilter(genre.getId(), buttonView.getText().toString());
}); });
bind.filtersChipsGroup.addView(chip); bind.filtersChipsGroup.addView(chip);
} }

View file

@ -30,7 +30,8 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel; import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel;
public class GenreCatalogueFragment extends Fragment { public class GenreCatalogueFragment extends Fragment {
private static final String TAG = "GenreCatalogueFragment";; private static final String TAG = "GenreCatalogueFragment";
;
private FragmentGenreCatalogueBinding bind; private FragmentGenreCatalogueBinding bind;
private MainActivity activity; private MainActivity activity;

View file

@ -159,8 +159,9 @@ public class HomeFragment extends Fragment {
mostPlayedAlbumAdapter = new AlbumAdapter(requireContext()); mostPlayedAlbumAdapter = new AlbumAdapter(requireContext());
bind.mostPlayedAlbumsRecyclerView.setAdapter(mostPlayedAlbumAdapter); bind.mostPlayedAlbumsRecyclerView.setAdapter(mostPlayedAlbumAdapter);
homeViewModel.getMostPlayedAlbums().observe(requireActivity(), albums -> { homeViewModel.getMostPlayedAlbums().observe(requireActivity(), albums -> {
if(albums.size() < 10) reorder(); if (albums.size() < 10) reorder();
if(bind != null) bind.homeMostPlayedAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeMostPlayedAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
mostPlayedAlbumAdapter.setItems(albums); mostPlayedAlbumAdapter.setItems(albums);
}); });
} }
@ -172,13 +173,15 @@ public class HomeFragment extends Fragment {
recentlyPlayedAlbumAdapter = new AlbumAdapter(requireContext()); recentlyPlayedAlbumAdapter = new AlbumAdapter(requireContext());
bind.recentlyPlayedAlbumsRecyclerView.setAdapter(recentlyPlayedAlbumAdapter); bind.recentlyPlayedAlbumsRecyclerView.setAdapter(recentlyPlayedAlbumAdapter);
homeViewModel.getRecentlyPlayedAlbumList().observe(requireActivity(), albums -> { homeViewModel.getRecentlyPlayedAlbumList().observe(requireActivity(), albums -> {
if(bind != null) bind.homeRecentlyPlayedAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeRecentlyPlayedAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
recentlyPlayedAlbumAdapter.setItems(albums); recentlyPlayedAlbumAdapter.setItems(albums);
}); });
} }
private void initYearSongView() { private void initYearSongView() {
if(bind != null) bind.homeFlashbackSector.setVisibility(!homeViewModel.getYearList().isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeFlashbackSector.setVisibility(!homeViewModel.getYearList().isEmpty() ? View.VISIBLE : View.GONE);
bind.yearsRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)); bind.yearsRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
bind.yearsRecyclerView.setHasFixedSize(true); bind.yearsRecyclerView.setHasFixedSize(true);
@ -199,7 +202,8 @@ public class HomeFragment extends Fragment {
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager()); starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter); bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
homeViewModel.getStarredTracks().observe(requireActivity(), songs -> { homeViewModel.getStarredTracks().observe(requireActivity(), songs -> {
if(bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false)); bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
starredSongAdapter.setItems(songs); starredSongAdapter.setItems(songs);
}); });
@ -214,7 +218,8 @@ public class HomeFragment extends Fragment {
starredAlbumAdapter = new AlbumHorizontalAdapter(activity, requireContext(), getChildFragmentManager()); starredAlbumAdapter = new AlbumHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter); bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter);
homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> { homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> {
if(bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false)); bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
starredAlbumAdapter.setItems(albums); starredAlbumAdapter.setItems(albums);
}); });
@ -229,7 +234,8 @@ public class HomeFragment extends Fragment {
starredArtistAdapter = new ArtistHorizontalAdapter(activity, requireContext(), getChildFragmentManager()); starredArtistAdapter = new ArtistHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter); bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
homeViewModel.getStarredArtists().observe(requireActivity(), artists -> { homeViewModel.getStarredArtists().observe(requireActivity(), artists -> {
if(bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false)); bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
starredArtistAdapter.setItems(artists); starredArtistAdapter.setItems(artists);
}); });
@ -256,7 +262,8 @@ public class HomeFragment extends Fragment {
dowanloadedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager()); dowanloadedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
bind.downloadedTracksRecyclerView.setAdapter(dowanloadedMusicAdapter); bind.downloadedTracksRecyclerView.setAdapter(dowanloadedMusicAdapter);
homeViewModel.getDownloaded().observe(requireActivity(), downloads -> { homeViewModel.getDownloaded().observe(requireActivity(), downloads -> {
if(bind != null) bind.homeDownloadedTracksSector.setVisibility(!downloads.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.homeDownloadedTracksSector.setVisibility(!downloads.isEmpty() ? View.VISIBLE : View.GONE);
dowanloadedMusicAdapter.setItems(MappingUtil.mapDownload(downloads)); dowanloadedMusicAdapter.setItems(MappingUtil.mapDownload(downloads));
}); });
} }
@ -284,7 +291,7 @@ public class HomeFragment extends Fragment {
* - Discovery - Recently_added - Year - Favorite - Downloaded - Most_played - Last_played * - Discovery - Recently_added - Year - Favorite - Downloaded - Most_played - Last_played
*/ */
public void reorder() { public void reorder() {
if(bind != null) { if (bind != null) {
bind.homeLinearLayoutContainer.removeAllViews(); bind.homeLinearLayoutContainer.removeAllViews();
bind.homeLinearLayoutContainer.addView(bind.homeDiscoverSector); bind.homeLinearLayoutContainer.addView(bind.homeDiscoverSector);
bind.homeLinearLayoutContainer.addView(bind.homeRecentlyAddedAlbumsSector); bind.homeLinearLayoutContainer.addView(bind.homeRecentlyAddedAlbumsSector);

View file

@ -7,7 +7,6 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
@ -18,13 +17,11 @@ import androidx.viewpager2.widget.ViewPager2;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.AlbumAdapter; import com.cappielloantonio.play.adapter.AlbumAdapter;
import com.cappielloantonio.play.adapter.ArtistAdapter; import com.cappielloantonio.play.adapter.ArtistAdapter;
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
import com.cappielloantonio.play.adapter.GenreAdapter; import com.cappielloantonio.play.adapter.GenreAdapter;
import com.cappielloantonio.play.adapter.PlaylistAdapter; import com.cappielloantonio.play.adapter.PlaylistAdapter;
import com.cappielloantonio.play.databinding.FragmentLibraryBinding; import com.cappielloantonio.play.databinding.FragmentLibraryBinding;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.viewmodel.LibraryViewModel; import com.cappielloantonio.play.viewmodel.LibraryViewModel;
public class LibraryFragment extends Fragment { public class LibraryFragment extends Fragment {
@ -89,7 +86,8 @@ public class LibraryFragment extends Fragment {
albumAdapter = new AlbumAdapter(requireContext()); albumAdapter = new AlbumAdapter(requireContext());
bind.albumRecyclerView.setAdapter(albumAdapter); bind.albumRecyclerView.setAdapter(albumAdapter);
libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> { libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> {
if(bind != null) bind.libraryAlbumSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.libraryAlbumSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
albumAdapter.setItems(albums); albumAdapter.setItems(albums);
}); });
} }
@ -101,7 +99,8 @@ public class LibraryFragment extends Fragment {
artistAdapter = new ArtistAdapter(requireContext()); artistAdapter = new ArtistAdapter(requireContext());
bind.artistRecyclerView.setAdapter(artistAdapter); bind.artistRecyclerView.setAdapter(artistAdapter);
libraryViewModel.getArtistSample().observe(requireActivity(), artists -> { libraryViewModel.getArtistSample().observe(requireActivity(), artists -> {
if(bind != null) bind.libraryArtistSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.libraryArtistSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
artistAdapter.setItems(artists); artistAdapter.setItems(artists);
}); });
} }
@ -119,7 +118,8 @@ public class LibraryFragment extends Fragment {
}); });
bind.genreRecyclerView.setAdapter(genreAdapter); bind.genreRecyclerView.setAdapter(genreAdapter);
libraryViewModel.getGenreSample().observe(requireActivity(), genres -> { libraryViewModel.getGenreSample().observe(requireActivity(), genres -> {
if(bind != null) bind.libraryGenresSector.setVisibility(!genres.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.libraryGenresSector.setVisibility(!genres.isEmpty() ? View.VISIBLE : View.GONE);
genreAdapter.setItems(genres); genreAdapter.setItems(genres);
}); });
} }
@ -131,7 +131,8 @@ public class LibraryFragment extends Fragment {
bind.playlistViewPager.setAdapter(playlistAdapter); bind.playlistViewPager.setAdapter(playlistAdapter);
bind.playlistViewPager.setOffscreenPageLimit(3); bind.playlistViewPager.setOffscreenPageLimit(3);
libraryViewModel.getPlaylistSample().observe(requireActivity(), playlists -> { libraryViewModel.getPlaylistSample().observe(requireActivity(), playlists -> {
if(bind != null) bind.libraryPlaylistSector.setVisibility(!playlists.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.libraryPlaylistSector.setVisibility(!playlists.isEmpty() ? View.VISIBLE : View.GONE);
playlistAdapter.setItems(playlists); playlistAdapter.setItems(playlists);
}); });

View file

@ -22,10 +22,10 @@ import com.cappielloantonio.play.adapter.PlayerNowPlayingSongAdapter;
import com.cappielloantonio.play.adapter.PlayerSongQueueAdapter; import com.cappielloantonio.play.adapter.PlayerSongQueueAdapter;
import com.cappielloantonio.play.databinding.FragmentPlayerBottomSheetBinding; import com.cappielloantonio.play.databinding.FragmentPlayerBottomSheetBinding;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.helper.MusicProgressViewUpdateHelper; import com.cappielloantonio.play.helper.MusicProgressViewUpdateHelper;
import com.cappielloantonio.play.interfaces.MusicServiceEventListener; import com.cappielloantonio.play.interfaces.MusicServiceEventListener;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.MappingUtil; import com.cappielloantonio.play.util.MappingUtil;
import com.cappielloantonio.play.util.MusicUtil; import com.cappielloantonio.play.util.MusicUtil;
@ -150,7 +150,8 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
@Override @Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
if(originalPosition == -1) originalPosition = viewHolder.getBindingAdapterPosition(); if (originalPosition == -1)
originalPosition = viewHolder.getBindingAdapterPosition();
fromPosition = viewHolder.getBindingAdapterPosition(); fromPosition = viewHolder.getBindingAdapterPosition();
toPosition = target.getBindingAdapterPosition(); toPosition = target.getBindingAdapterPosition();
@ -191,13 +192,12 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
@Override @Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
if(!(viewHolder.getBindingAdapterPosition() == MusicPlayerRemote.getPosition()) && !(MusicPlayerRemote.getPlayingQueue().size() <= 1)) { if (!(viewHolder.getBindingAdapterPosition() == MusicPlayerRemote.getPosition()) && !(MusicPlayerRemote.getPlayingQueue().size() <= 1)) {
MusicPlayerRemote.removeFromQueue(viewHolder.getBindingAdapterPosition()); MusicPlayerRemote.removeFromQueue(viewHolder.getBindingAdapterPosition());
playerBottomSheetViewModel.removeSong(viewHolder.getBindingAdapterPosition()); playerBottomSheetViewModel.removeSong(viewHolder.getBindingAdapterPosition());
bind.playerBodyLayout.playerQueueRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition()); bind.playerBodyLayout.playerQueueRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
bind.playerBodyLayout.playerSongCoverViewPager.setCurrentItem(MusicPlayerRemote.getPosition(), false); bind.playerBodyLayout.playerSongCoverViewPager.setCurrentItem(MusicPlayerRemote.getPosition(), false);
} } else {
else {
bind.playerBodyLayout.playerQueueRecyclerView.getAdapter().notifyDataSetChanged(); bind.playerBodyLayout.playerQueueRecyclerView.getAdapter().notifyDataSetChanged();
} }
} }

View file

@ -24,11 +24,11 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.PlaylistCatalogueAdapter; import com.cappielloantonio.play.adapter.PlaylistCatalogueAdapter;
import com.cappielloantonio.play.databinding.FragmentPlaylistCatalogueBinding; import com.cappielloantonio.play.databinding.FragmentPlaylistCatalogueBinding;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel;
import com.cappielloantonio.play.viewmodel.PlaylistCatalogueViewModel; import com.cappielloantonio.play.viewmodel.PlaylistCatalogueViewModel;
public class PlaylistCatalogueFragment extends Fragment { public class PlaylistCatalogueFragment extends Fragment {
private static final String TAG = "GenreCatalogueFragment";; private static final String TAG = "GenreCatalogueFragment";
;
private FragmentPlaylistCatalogueBinding bind; private FragmentPlaylistCatalogueBinding bind;
private MainActivity activity; private MainActivity activity;

View file

@ -121,7 +121,7 @@ public class PlaylistPageFragment extends Fragment {
private void initMusicButton() { private void initMusicButton() {
playlistPageViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> { playlistPageViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> {
if(bind != null) { if (bind != null) {
bind.playlistPagePlayButton.setOnClickListener(v -> { bind.playlistPagePlayButton.setOnClickListener(v -> {
QueueRepository queueRepository = new QueueRepository(App.getInstance()); QueueRepository queueRepository = new QueueRepository(App.getInstance());
queueRepository.insertAllAndStartNew(songs); queueRepository.insertAllAndStartNew(songs);

View file

@ -10,17 +10,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.AlbumAdapter; import com.cappielloantonio.play.adapter.AlbumAdapter;
import com.cappielloantonio.play.adapter.ArtistAdapter; import com.cappielloantonio.play.adapter.ArtistAdapter;
import com.cappielloantonio.play.adapter.GenreCatalogueAdapter;
import com.cappielloantonio.play.adapter.SongHorizontalAdapter; import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
import com.cappielloantonio.play.databinding.FragmentSearchBinding; import com.cappielloantonio.play.databinding.FragmentSearchBinding;
import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.viewmodel.SearchViewModel; import com.cappielloantonio.play.viewmodel.SearchViewModel;
import com.paulrybitskyi.persistentsearchview.adapters.model.SuggestionItem; import com.paulrybitskyi.persistentsearchview.adapters.model.SuggestionItem;
@ -127,8 +122,7 @@ public class SearchFragment extends Fragment {
if (isQueryValid(query)) { if (isQueryValid(query)) {
searchView.collapse(); searchView.collapse();
search(query); search(query);
} } else {
else {
Toast.makeText(requireContext(), "Enter at least three characters", Toast.LENGTH_SHORT).show(); Toast.makeText(requireContext(), "Enter at least three characters", Toast.LENGTH_SHORT).show();
} }
}); });
@ -161,15 +155,18 @@ public class SearchFragment extends Fragment {
private void performSearch(String query) { private void performSearch(String query) {
searchViewModel.searchSong(query).observe(requireActivity(), songs -> { searchViewModel.searchSong(query).observe(requireActivity(), songs -> {
if(bind != null) bind.searchSongSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.searchSongSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
songHorizontalAdapter.setItems(songs); songHorizontalAdapter.setItems(songs);
}); });
searchViewModel.searchAlbum(query).observe(requireActivity(), albums -> { searchViewModel.searchAlbum(query).observe(requireActivity(), albums -> {
if(bind != null) bind.searchAlbumSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.searchAlbumSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
albumAdapter.setItems(albums); albumAdapter.setItems(albums);
}); });
searchViewModel.searchArtist(query).observe(requireActivity(), artists -> { searchViewModel.searchArtist(query).observe(requireActivity(), artists -> {
if(bind != null) bind.searchArtistSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE); if (bind != null)
bind.searchArtistSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
artistAdapter.setItems(artists); artistAdapter.setItems(artists);
}); });
@ -181,7 +178,7 @@ public class SearchFragment extends Fragment {
} }
private void inputFocus() { private void inputFocus() {
if(!isQueryValid(searchViewModel.getQuery())) { if (!isQueryValid(searchViewModel.getQuery())) {
bind.persistentSearchView.expand(); bind.persistentSearchView.expand();
} }
} }

View file

@ -5,16 +5,12 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.helper.ThemeHelper; import com.cappielloantonio.play.helper.ThemeHelper;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.util.SyncUtil;
public class SettingsFragment extends PreferenceFragmentCompat { public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = "SettingsFragment"; private static final String TAG = "SettingsFragment";
@ -27,7 +23,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
View view = super.onCreateView(inflater, container, savedInstanceState); View view = super.onCreateView(inflater, container, savedInstanceState);
if(view != null) { if (view != null) {
getListView().setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.global_padding_bottom)); getListView().setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.global_padding_bottom));
} }

View file

@ -58,44 +58,36 @@ public class SongListPageFragment extends Fragment {
} }
private void init() { private void init() {
if(getArguments().getString(Song.RECENTLY_PLAYED) != null) { if (getArguments().getString(Song.RECENTLY_PLAYED) != null) {
songListPageViewModel.title = Song.RECENTLY_PLAYED; songListPageViewModel.title = Song.RECENTLY_PLAYED;
bind.pageTitleLabel.setText("Recently played tracks"); bind.pageTitleLabel.setText("Recently played tracks");
} } else if (getArguments().getString(Song.MOST_PLAYED) != null) {
else if(getArguments().getString(Song.MOST_PLAYED) != null) {
songListPageViewModel.title = Song.MOST_PLAYED; songListPageViewModel.title = Song.MOST_PLAYED;
bind.pageTitleLabel.setText("Most played tracks"); bind.pageTitleLabel.setText("Most played tracks");
} } else if (getArguments().getString(Song.RECENTLY_ADDED) != null) {
else if(getArguments().getString(Song.RECENTLY_ADDED) != null) {
songListPageViewModel.title = Song.RECENTLY_ADDED; songListPageViewModel.title = Song.RECENTLY_ADDED;
bind.pageTitleLabel.setText("Recently added tracks"); bind.pageTitleLabel.setText("Recently added tracks");
} } else if (getArguments().getString(Song.BY_GENRE) != null) {
else if(getArguments().getString(Song.BY_GENRE) != null) {
songListPageViewModel.title = Song.BY_GENRE; songListPageViewModel.title = Song.BY_GENRE;
songListPageViewModel.genre = getArguments().getParcelable("genre_object"); songListPageViewModel.genre = getArguments().getParcelable("genre_object");
bind.pageTitleLabel.setText(songListPageViewModel.genre.getName() + ": all tracks"); bind.pageTitleLabel.setText(songListPageViewModel.genre.getName() + ": all tracks");
} } else if (getArguments().getString(Song.BY_ARTIST) != null) {
else if(getArguments().getString(Song.BY_ARTIST) != null) {
songListPageViewModel.title = Song.BY_ARTIST; songListPageViewModel.title = Song.BY_ARTIST;
songListPageViewModel.artist = getArguments().getParcelable("artist_object"); songListPageViewModel.artist = getArguments().getParcelable("artist_object");
bind.pageTitleLabel.setText(songListPageViewModel.artist.getName() + "'s top tracks"); bind.pageTitleLabel.setText(songListPageViewModel.artist.getName() + "'s top tracks");
} } else if (getArguments().getString(Song.BY_GENRES) != null) {
else if(getArguments().getString(Song.BY_GENRES) != null) {
songListPageViewModel.title = Song.BY_GENRES; songListPageViewModel.title = Song.BY_GENRES;
songListPageViewModel.filters = getArguments().getStringArrayList("filters_list"); songListPageViewModel.filters = getArguments().getStringArrayList("filters_list");
songListPageViewModel.filterNames = getArguments().getStringArrayList("filter_name_list"); songListPageViewModel.filterNames = getArguments().getStringArrayList("filter_name_list");
bind.pageTitleLabel.setText(songListPageViewModel.getFiltersTitle()); bind.pageTitleLabel.setText(songListPageViewModel.getFiltersTitle());
} } else if (getArguments().getString(Song.BY_YEAR) != null) {
else if(getArguments().getString(Song.BY_YEAR) != null) {
songListPageViewModel.title = Song.BY_YEAR; songListPageViewModel.title = Song.BY_YEAR;
songListPageViewModel.year = getArguments().getInt("year_object"); songListPageViewModel.year = getArguments().getInt("year_object");
bind.pageTitleLabel.setText("Year " + songListPageViewModel.year); bind.pageTitleLabel.setText("Year " + songListPageViewModel.year);
} } else if (getArguments().getString(Song.STARRED) != null) {
else if(getArguments().getString(Song.STARRED) != null) {
songListPageViewModel.title = Song.STARRED; songListPageViewModel.title = Song.STARRED;
bind.pageTitleLabel.setText("Starred tracks"); bind.pageTitleLabel.setText("Starred tracks");
} } else if (getArguments().getString(Song.DOWNLOADED) != null) {
else if(getArguments().getString(Song.DOWNLOADED) != null) {
songListPageViewModel.title = Song.DOWNLOADED; songListPageViewModel.title = Song.DOWNLOADED;
bind.pageTitleLabel.setText("Downloaded"); bind.pageTitleLabel.setText("Downloaded");
} }
@ -124,7 +116,7 @@ public class SongListPageFragment extends Fragment {
private void initButtons() { private void initButtons() {
songListPageViewModel.getSongList().observe(requireActivity(), songs -> { songListPageViewModel.getSongList().observe(requireActivity(), songs -> {
if(bind != null) { if (bind != null) {
bind.songListShuffleImageView.setOnClickListener(v -> { bind.songListShuffleImageView.setOnClickListener(v -> {
Collections.shuffle(songs); Collections.shuffle(songs);

View file

@ -4,14 +4,8 @@ import android.content.Context;
import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Playlist; import com.cappielloantonio.play.model.Playlist;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.subsonic.models.AlbumID3;
import com.cappielloantonio.play.subsonic.models.ArtistID3;
import com.cappielloantonio.play.subsonic.models.Genre;
import com.cappielloantonio.play.util.DownloadUtil;
import com.cappielloantonio.play.util.SyncUtil; import com.cappielloantonio.play.util.SyncUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SyncFragment { public class SyncFragment {

View file

@ -22,7 +22,6 @@ import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.AlbumRepository; import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.repository.QueueRepository; import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote; import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.DownloadUtil; import com.cappielloantonio.play.util.DownloadUtil;
@ -104,7 +103,7 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements
@Override @Override
public void onLoadMedia(List<?> media) { public void onLoadMedia(List<?> media) {
if(media.size() > 0) { if (media.size() > 0) {
QueueRepository queueRepository = new QueueRepository(App.getInstance()); QueueRepository queueRepository = new QueueRepository(App.getInstance());
queueRepository.insertAllAndStartNew((ArrayList<Song>) media); queueRepository.insertAllAndStartNew((ArrayList<Song>) media);

View file

@ -22,7 +22,6 @@ import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.service.MusicService; import com.cappielloantonio.play.service.MusicService;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil;
import static android.content.Context.NOTIFICATION_SERVICE; import static android.content.Context.NOTIFICATION_SERVICE;
import static com.cappielloantonio.play.service.MusicService.ACTION_REWIND; import static com.cappielloantonio.play.service.MusicService.ACTION_REWIND;

View file

@ -6,8 +6,7 @@ public class UIUtil {
if (itemSize / maxSpan > 0) { if (itemSize / maxSpan > 0) {
return maxSpan; return maxSpan;
} } else {
else {
return itemSize % maxSpan; return itemSize % maxSpan;
} }
} }

View file

@ -11,7 +11,6 @@ import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.repository.AlbumRepository; import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.subsonic.models.AlbumID3; import com.cappielloantonio.play.subsonic.models.AlbumID3;
import com.cappielloantonio.play.subsonic.models.ResponseStatus; import com.cappielloantonio.play.subsonic.models.ResponseStatus;

View file

@ -1,7 +1,6 @@
package com.cappielloantonio.play.viewmodel; package com.cappielloantonio.play.viewmodel;
import android.app.Application; import android.app.Application;
import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@ -10,13 +9,8 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Genre;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.AlbumRepository; import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.repository.DownloadRepository;
import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.util.MappingUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -7,7 +7,6 @@ import androidx.lifecycle.AndroidViewModel;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.repository.AlbumRepository; import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.repository.ArtistRepository;
public class ArtistBottomSheetViewModel extends AndroidViewModel { public class ArtistBottomSheetViewModel extends AndroidViewModel {
private AlbumRepository albumRepository; private AlbumRepository albumRepository;

View file

@ -9,11 +9,8 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.repository.ArtistRepository; import com.cappielloantonio.play.repository.ArtistRepository;
import com.cappielloantonio.play.subsonic.models.AlbumID3;
import com.cappielloantonio.play.subsonic.models.ArtistID3; import com.cappielloantonio.play.subsonic.models.ArtistID3;
import com.cappielloantonio.play.subsonic.models.IndexID3; import com.cappielloantonio.play.subsonic.models.IndexID3;
import com.cappielloantonio.play.subsonic.models.ResponseStatus; import com.cappielloantonio.play.subsonic.models.ResponseStatus;

View file

@ -3,15 +3,12 @@ package com.cappielloantonio.play.viewmodel;
import android.app.Application; import android.app.Application;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.repository.ArtistRepository; import com.cappielloantonio.play.repository.ArtistRepository;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -5,7 +5,6 @@ import android.app.Application;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
@ -16,7 +15,6 @@ import com.cappielloantonio.play.repository.ArtistRepository;
import com.cappielloantonio.play.repository.GenreRepository; import com.cappielloantonio.play.repository.GenreRepository;
import com.cappielloantonio.play.repository.PlaylistRepository; import com.cappielloantonio.play.repository.PlaylistRepository;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class LibraryViewModel extends AndroidViewModel { public class LibraryViewModel extends AndroidViewModel {

View file

@ -9,11 +9,8 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Playlist; import com.cappielloantonio.play.model.Playlist;
import com.cappielloantonio.play.repository.PlaylistRepository; import com.cappielloantonio.play.repository.PlaylistRepository;
import com.cappielloantonio.play.subsonic.models.ArtistID3;
import com.cappielloantonio.play.subsonic.models.IndexID3;
import com.cappielloantonio.play.subsonic.models.ResponseStatus; import com.cappielloantonio.play.subsonic.models.ResponseStatus;
import com.cappielloantonio.play.subsonic.models.SubsonicResponse; import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
import com.cappielloantonio.play.util.MappingUtil; import com.cappielloantonio.play.util.MappingUtil;

View file

@ -4,7 +4,6 @@ import android.app.Application;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.model.Playlist; import com.cappielloantonio.play.model.Playlist;

View file

@ -1,7 +1,6 @@
package com.cappielloantonio.play.viewmodel; package com.cappielloantonio.play.viewmodel;
import android.app.Application; import android.app.Application;
import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
@ -20,7 +19,6 @@ import com.cappielloantonio.play.repository.SearchingRepository;
import com.cappielloantonio.play.repository.SongRepository; import com.cappielloantonio.play.repository.SongRepository;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
public class SearchViewModel extends AndroidViewModel { public class SearchViewModel extends AndroidViewModel {

View file

@ -1,18 +1,14 @@
package com.cappielloantonio.play.viewmodel; package com.cappielloantonio.play.viewmodel;
import android.app.Application; import android.app.Application;
import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.play.App;
import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Download;
import com.cappielloantonio.play.model.Genre; import com.cappielloantonio.play.model.Genre;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.DownloadRepository; import com.cappielloantonio.play.repository.DownloadRepository;