mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Code decontextualization
This commit is contained in:
parent
f16650a74b
commit
a4b31a9c02
108 changed files with 569 additions and 952 deletions
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
|
|
@ -11,7 +9,6 @@ import com.cappielloantonio.play.interfaces.MediaCallback;
|
|||
import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
|
@ -26,16 +23,10 @@ import retrofit2.Response;
|
|||
public class AlbumRepository {
|
||||
private static final String TAG = "AlbumRepository";
|
||||
|
||||
private final Application application;
|
||||
|
||||
public AlbumRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<AlbumID3>> getAlbums(String type, int size, Integer fromYear, Integer toYear) {
|
||||
MutableLiveData<List<AlbumID3>> listLiveAlbums = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getAlbumList2(type, size, 0, fromYear, toYear)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -58,7 +49,7 @@ public class AlbumRepository {
|
|||
public MutableLiveData<List<AlbumID3>> getStarredAlbums(boolean random, int size) {
|
||||
MutableLiveData<List<AlbumID3>> starredAlbums = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -86,7 +77,7 @@ public class AlbumRepository {
|
|||
}
|
||||
|
||||
public void star(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.star(null, id, null)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -103,7 +94,7 @@ public class AlbumRepository {
|
|||
}
|
||||
|
||||
public void unstar(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.unstar(null, id, null)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -120,7 +111,7 @@ public class AlbumRepository {
|
|||
}
|
||||
|
||||
public void setRating(String id, int rating) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.setRating(id, rating)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -139,7 +130,7 @@ public class AlbumRepository {
|
|||
public MutableLiveData<List<Child>> getAlbumTracks(String id) {
|
||||
MutableLiveData<List<Child>> albumTracks = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getAlbum(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -166,7 +157,7 @@ public class AlbumRepository {
|
|||
public MutableLiveData<List<AlbumID3>> getArtistAlbums(String id) {
|
||||
MutableLiveData<List<AlbumID3>> artistsAlbum = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -191,7 +182,7 @@ public class AlbumRepository {
|
|||
public MutableLiveData<AlbumID3> getAlbum(String id) {
|
||||
MutableLiveData<AlbumID3> album = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getAlbum(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -212,7 +203,7 @@ public class AlbumRepository {
|
|||
}
|
||||
|
||||
public void getInstantMix(AlbumID3 album, int count, MediaCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getSimilarSongs2(album.getId(), count)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -257,7 +248,7 @@ public class AlbumRepository {
|
|||
}
|
||||
|
||||
private void getFirstAlbum(DecadesCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getAlbumList2("byYear", 1, 0, 1900, Calendar.getInstance().get(Calendar.YEAR))
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -276,7 +267,7 @@ public class AlbumRepository {
|
|||
}
|
||||
|
||||
private void getLastAlbum(DecadesCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getAlbumList2("byYear", 1, 0, Calendar.getInstance().get(Calendar.YEAR), 1900)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
|
@ -23,16 +21,10 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class ArtistRepository {
|
||||
private final Application application;
|
||||
|
||||
public ArtistRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<ArtistID3>> getStarredArtists(boolean random, int size) {
|
||||
MutableLiveData<List<ArtistID3>> starredArtists = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -62,7 +54,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<List<ArtistID3>> getArtists(boolean random, int size) {
|
||||
MutableLiveData<List<ArtistID3>> listLiveArtists = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtists()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -101,7 +93,7 @@ public class ArtistRepository {
|
|||
list.setValue(liveArtists);
|
||||
|
||||
for (ArtistID3 artist : artists) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(artist.getId())
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -123,7 +115,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<ArtistID3> getArtistInfo(String id) {
|
||||
MutableLiveData<ArtistID3> artist = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -149,7 +141,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<ArtistInfo2> getArtistFullInfo(String id) {
|
||||
MutableLiveData<ArtistInfo2> artistFullInfo = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtistInfo2(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -170,7 +162,7 @@ public class ArtistRepository {
|
|||
}
|
||||
|
||||
public void star(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.star(null, null, id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -187,7 +179,7 @@ public class ArtistRepository {
|
|||
}
|
||||
|
||||
public void unstar(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.unstar(null, null, id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -204,7 +196,7 @@ public class ArtistRepository {
|
|||
}
|
||||
|
||||
public void setRating(String id, int rating) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.setRating(id, rating)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -223,7 +215,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<ArtistID3> getArtist(String id) {
|
||||
MutableLiveData<ArtistID3> artist = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -246,7 +238,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<List<Child>> getInstantMix(ArtistID3 artist, int count) {
|
||||
MutableLiveData<List<Child>> instantMix = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getSimilarSongs2(artist.getId(), count)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -269,7 +261,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<ArrayList<Child>> getArtistRandomSong(LifecycleOwner owner, ArtistID3 artist, int count) {
|
||||
MutableLiveData<ArrayList<Child>> randomSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(artist.getId())
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -279,7 +271,7 @@ public class ArtistRepository {
|
|||
List<AlbumID3> albums = response.body().getSubsonicResponse().getArtist().getAlbums();
|
||||
|
||||
if (albums.size() > 0) {
|
||||
AlbumRepository albumRepository = new AlbumRepository(App.getInstance());
|
||||
AlbumRepository albumRepository = new AlbumRepository();
|
||||
|
||||
for (int index = 0; index < albums.size(); index++) {
|
||||
albumRepository.getAlbumTracks(albums.get(index).getId()).observe(owner, songs -> {
|
||||
|
|
@ -306,7 +298,7 @@ public class ArtistRepository {
|
|||
public MutableLiveData<List<Child>> getTopSongs(String artistName, int count) {
|
||||
MutableLiveData<List<Child>> topSongs = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getTopSongs(artistName, count)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
|
|
@ -12,14 +10,7 @@ import java.util.Calendar;
|
|||
import java.util.List;
|
||||
|
||||
public class ChronologyRepository {
|
||||
private static final String TAG = "ChronologyRepository";
|
||||
|
||||
private final ChronologyDao chronologyDao;
|
||||
|
||||
public ChronologyRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
chronologyDao = database.chronologyDao();
|
||||
}
|
||||
private final ChronologyDao chronologyDao = AppDatabase.getInstance().chronologyDao();
|
||||
|
||||
public LiveData<List<Chronology>> getThisWeek(String server) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
|
|
@ -11,12 +9,7 @@ import com.cappielloantonio.play.model.Download;
|
|||
import java.util.List;
|
||||
|
||||
public class DownloadRepository {
|
||||
private final DownloadDao downloadDao;
|
||||
|
||||
public DownloadRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
downloadDao = database.downloadDao();
|
||||
}
|
||||
private final DownloadDao downloadDao = AppDatabase.getInstance().downloadDao();
|
||||
|
||||
public LiveData<List<Download>> getLiveDownload() {
|
||||
return downloadDao.getAll();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.Genre;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -18,18 +15,10 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class GenreRepository {
|
||||
private static final String TAG = "GenreRepository";
|
||||
|
||||
private final Application application;
|
||||
|
||||
public GenreRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Genre>> getGenres(boolean random, int size) {
|
||||
MutableLiveData<List<Genre>> genres = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getGenres()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -23,20 +22,12 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class PlaylistRepository {
|
||||
private final Application application;
|
||||
private final PlaylistDao playlistDao;
|
||||
|
||||
public PlaylistRepository(Application application) {
|
||||
this.application = application;
|
||||
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
this.playlistDao = database.playlistDao();
|
||||
}
|
||||
private final PlaylistDao playlistDao = AppDatabase.getInstance().playlistDao();
|
||||
|
||||
public MutableLiveData<List<Playlist>> getPlaylists(boolean random, int size) {
|
||||
MutableLiveData<List<Playlist>> listLivePlaylists = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPlaylistClient()
|
||||
.getPlaylists()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -65,7 +56,7 @@ public class PlaylistRepository {
|
|||
public MutableLiveData<List<Child>> getPlaylistSongs(String id) {
|
||||
MutableLiveData<List<Child>> listLivePlaylistSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPlaylistClient()
|
||||
.getPlaylist(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -86,7 +77,7 @@ public class PlaylistRepository {
|
|||
}
|
||||
|
||||
public void addSongToPlaylist(String playlistId, ArrayList<String> songsId) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPlaylistClient()
|
||||
.updatePlaylist(playlistId, null, true, songsId, null)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -103,7 +94,7 @@ public class PlaylistRepository {
|
|||
}
|
||||
|
||||
public void createPlaylist(String playlistId, String name, ArrayList<String> songsId) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPlaylistClient()
|
||||
.createPlaylist(playlistId, name, songsId)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -120,7 +111,7 @@ public class PlaylistRepository {
|
|||
}
|
||||
|
||||
public void updatePlaylist(String playlistId, String name, boolean isPublic, ArrayList<String> songIdToAdd, ArrayList<Integer> songIndexToRemove) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPlaylistClient()
|
||||
.updatePlaylist(playlistId, name, isPublic, songIdToAdd, songIndexToRemove)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -137,7 +128,7 @@ public class PlaylistRepository {
|
|||
}
|
||||
|
||||
public void deletePlaylist(String playlistId) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPlaylistClient()
|
||||
.deletePlaylist(playlistId)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -10,7 +9,6 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastChannel;
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastEpisode;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -19,18 +17,12 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class PodcastRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
||||
private final Application application;
|
||||
|
||||
public PodcastRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
private static final String TAG = "PodcastRepository";
|
||||
|
||||
public MutableLiveData<List<PodcastChannel>> getPodcastChannels(boolean includeEpisodes, String channelId) {
|
||||
MutableLiveData<List<PodcastChannel>> livePodcastChannel = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPodcastClient()
|
||||
.getPodcasts(includeEpisodes, channelId)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -53,7 +45,7 @@ public class PodcastRepository {
|
|||
public MutableLiveData<List<PodcastEpisode>> getNewestPodcastEpisodes(int count) {
|
||||
MutableLiveData<List<PodcastEpisode>> liveNewestPodcastEpisodes = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPodcastClient()
|
||||
.getNewestPodcasts(count)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -74,7 +66,7 @@ public class PodcastRepository {
|
|||
}
|
||||
|
||||
public void refreshPodcasts() {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getPodcastClient()
|
||||
.refreshPodcasts()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.media3.common.MediaItem;
|
||||
|
||||
|
|
@ -18,12 +16,7 @@ import java.util.stream.Collectors;
|
|||
public class QueueRepository {
|
||||
private static final String TAG = "QueueRepository";
|
||||
|
||||
private final QueueDao queueDao;
|
||||
|
||||
public QueueRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
queueDao = database.queueDao();
|
||||
}
|
||||
private final QueueDao queueDao = AppDatabase.getInstance().queueDao();
|
||||
|
||||
public LiveData<List<Queue>> getLiveQueue() {
|
||||
return queueDao.getAll();
|
||||
|
|
@ -205,11 +198,7 @@ public class QueueRepository {
|
|||
|
||||
if (mediaItem.mediaId.equals(lastMediaPlayed.getId())) {
|
||||
|
||||
if (System.currentTimeMillis() > lastMediaPlayed.getLastPlay() + lastMediaPlayed.getDuration() * 1000) {
|
||||
isPlausible = true;
|
||||
} else {
|
||||
isPlausible = false;
|
||||
}
|
||||
isPlausible = System.currentTimeMillis() > lastMediaPlayed.getLastPlay() + lastMediaPlayed.getDuration() * 1000;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -1,28 +1,17 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.interfaces.ScanCallback;
|
||||
import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
public class ScanRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
||||
private final Application application;
|
||||
|
||||
public ScanRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public void startScan(ScanCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaLibraryScanningClient()
|
||||
.startScan()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -41,7 +30,7 @@ public class ScanRepository {
|
|||
}
|
||||
|
||||
public void getScanStatus(ScanCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaLibraryScanningClient()
|
||||
.startScan()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
|
|
@ -14,7 +12,6 @@ import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
|||
import com.cappielloantonio.play.subsonic.models.ArtistID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.subsonic.models.SearchResult3;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
|
|
@ -25,20 +22,12 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class SearchingRepository {
|
||||
private final RecentSearchDao recentSearchDao;
|
||||
private final Application application;
|
||||
|
||||
public SearchingRepository(Application application) {
|
||||
this.application = application;
|
||||
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
recentSearchDao = database.recentSearchDao();
|
||||
}
|
||||
private final RecentSearchDao recentSearchDao = AppDatabase.getInstance().recentSearchDao();
|
||||
|
||||
public MutableLiveData<SearchResult3> search(String query) {
|
||||
MutableLiveData<SearchResult3> result = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getSearchingClient()
|
||||
.search3(query, 20, 20, 20)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -59,7 +48,7 @@ public class SearchingRepository {
|
|||
public MutableLiveData<List<String>> getSuggestions(String query) {
|
||||
MutableLiveData<List<String>> suggestions = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getSearchingClient()
|
||||
.search3(query, 5, 5, 5)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -68,19 +57,19 @@ public class SearchingRepository {
|
|||
List<String> newSuggestions = new ArrayList();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
if(response.body().getSubsonicResponse().getSearchResult3().getArtists() != null) {
|
||||
if (response.body().getSubsonicResponse().getSearchResult3().getArtists() != null) {
|
||||
for (ArtistID3 artistID3 : response.body().getSubsonicResponse().getSearchResult3().getArtists()) {
|
||||
newSuggestions.add(artistID3.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if(response.body().getSubsonicResponse().getSearchResult3().getAlbums() != null) {
|
||||
if (response.body().getSubsonicResponse().getSearchResult3().getAlbums() != null) {
|
||||
for (AlbumID3 albumID3 : response.body().getSubsonicResponse().getSearchResult3().getAlbums()) {
|
||||
newSuggestions.add(albumID3.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if(response.body().getSubsonicResponse().getSearchResult3().getSongs() != null) {
|
||||
if (response.body().getSubsonicResponse().getSearchResult3().getSongs() != null) {
|
||||
for (Child song : response.body().getSubsonicResponse().getSearchResult3().getSongs()) {
|
||||
newSuggestions.add(song.getTitle());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
|
|
@ -13,12 +11,7 @@ import java.util.List;
|
|||
public class ServerRepository {
|
||||
private static final String TAG = "QueueRepository";
|
||||
|
||||
private final ServerDao serverDao;
|
||||
|
||||
public ServerRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
serverDao = database.serverDao();
|
||||
}
|
||||
private final ServerDao serverDao = AppDatabase.getInstance().serverDao();
|
||||
|
||||
public LiveData<List<Server>> getLiveServer() {
|
||||
return serverDao.getAll();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -11,13 +10,10 @@ import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
|||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import kotlin.collections.EmptyList;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
|
@ -25,16 +21,10 @@ import retrofit2.Response;
|
|||
public class SongRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
||||
private final Application application;
|
||||
|
||||
public SongRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Child>> getStarredSongs(boolean random, int size) {
|
||||
MutableLiveData<List<Child>> starredSongs = new MutableLiveData<>(Collections.EMPTY_LIST);
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -66,7 +56,7 @@ public class SongRepository {
|
|||
public MutableLiveData<List<Child>> getInstantMix(Child song, int count) {
|
||||
MutableLiveData<List<Child>> instantMix = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getSimilarSongs2(song.getId(), count)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -89,7 +79,7 @@ public class SongRepository {
|
|||
public MutableLiveData<List<Child>> getRandomSample(int number, Integer fromYear, Integer toYear) {
|
||||
MutableLiveData<List<Child>> randomSongsSample = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getRandomSongs(number, fromYear, toYear)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -114,7 +104,7 @@ public class SongRepository {
|
|||
}
|
||||
|
||||
public void scrobble(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.scrobble(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -131,7 +121,7 @@ public class SongRepository {
|
|||
}
|
||||
|
||||
public void star(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.star(id, null, null)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -148,7 +138,7 @@ public class SongRepository {
|
|||
}
|
||||
|
||||
public void unstar(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.unstar(id, null, null)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -165,7 +155,7 @@ public class SongRepository {
|
|||
}
|
||||
|
||||
public void setRating(String id, int rating) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaAnnotationClient()
|
||||
.setRating(id, rating)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -184,7 +174,7 @@ public class SongRepository {
|
|||
public MutableLiveData<List<Child>> getSongsByGenre(String id) {
|
||||
MutableLiveData<List<Child>> songsByGenre = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getSongsByGenre(id, 500, 0)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -218,7 +208,7 @@ public class SongRepository {
|
|||
MutableLiveData<List<Child>> songsByGenre = new MutableLiveData<>();
|
||||
|
||||
for (String id : genresId)
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getAlbumSongListClient()
|
||||
.getSongsByGenre(id, 500, 0)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -245,7 +235,7 @@ public class SongRepository {
|
|||
public MutableLiveData<Child> getSong(String id) {
|
||||
MutableLiveData<Child> song = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getBrowsingClient()
|
||||
.getSong(id)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -268,7 +258,7 @@ public class SongRepository {
|
|||
public MutableLiveData<String> getSongLyrics(Child song) {
|
||||
MutableLiveData<String> lyrics = new MutableLiveData<>(null);
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getMediaRetrievalClient()
|
||||
.getLyrics(song.getArtist(), song.getTitle())
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
|
|
@ -9,23 +7,14 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.interfaces.SystemCallback;
|
||||
import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class SystemRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
||||
private final Application application;
|
||||
|
||||
public SystemRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public void checkUserCredential(SystemCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getSystemClient()
|
||||
.ping()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -57,7 +46,7 @@ public class SystemRepository {
|
|||
public MutableLiveData<Boolean> ping() {
|
||||
MutableLiveData<Boolean> pingResult = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
App.getSubsonicClientInstance(false)
|
||||
.getSystemClient()
|
||||
.ping()
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue