mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Fix artist cover visualization
This commit is contained in:
parent
80f30aa41a
commit
c55f639368
21 changed files with 157 additions and 334 deletions
|
|
@ -58,8 +58,6 @@ public class CustomGlideRequest {
|
|||
"&c=" + params.get("c") +
|
||||
"&id=" + item;
|
||||
|
||||
Log.d(TAG, "--- createUrl() - " + sb);
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,44 +11,17 @@ import androidx.room.PrimaryKey;
|
|||
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
|
||||
@Entity(tableName = "album")
|
||||
public class Album implements Parcelable {
|
||||
private static final String TAG = "Album";
|
||||
|
||||
@NonNull
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "id")
|
||||
public String id;
|
||||
|
||||
@ColumnInfo(name = "title")
|
||||
public String title;
|
||||
|
||||
@ColumnInfo(name = "year")
|
||||
public int year;
|
||||
|
||||
@ColumnInfo(name = "artistId")
|
||||
public String artistId;
|
||||
|
||||
@ColumnInfo(name = "artistName")
|
||||
public String artistName;
|
||||
|
||||
@ColumnInfo(name = "primary")
|
||||
public String primary;
|
||||
|
||||
@ColumnInfo(name = "blurHash")
|
||||
public String blurHash;
|
||||
|
||||
public Album(@NonNull String id, String title, int year, String artistId, String artistName, String primary, String blurHash) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.year = year;
|
||||
this.artistId = artistId;
|
||||
this.artistName = artistName;
|
||||
this.primary = primary;
|
||||
this.blurHash = blurHash;
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public Album(AlbumID3 albumID3) {
|
||||
this.id = albumID3.getId();
|
||||
this.title = albumID3.getName();
|
||||
|
|
@ -57,13 +30,11 @@ public class Album implements Parcelable {
|
|||
this.artistName = albumID3.getArtist();
|
||||
this.primary = albumID3.getCoverArtId();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(@NonNull String id) {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
package com.cappielloantonio.play.model;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "album_artist_cross")
|
||||
public class AlbumArtistCross {
|
||||
@NonNull
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
private int id;
|
||||
|
||||
@ColumnInfo(name = "album_id")
|
||||
private String albumId;
|
||||
|
||||
@ColumnInfo(name = "artist_id")
|
||||
private String artistId;
|
||||
|
||||
@ColumnInfo(name = "is_producer")
|
||||
private boolean isProducer;
|
||||
|
||||
public AlbumArtistCross(String albumId, String artistId, boolean isProducer) {
|
||||
this.albumId = albumId;
|
||||
this.artistId = artistId;
|
||||
this.isProducer = isProducer;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAlbumId() {
|
||||
return albumId;
|
||||
}
|
||||
|
||||
public void setAlbumId(String albumId) {
|
||||
this.albumId = albumId;
|
||||
}
|
||||
|
||||
public String getArtistId() {
|
||||
return artistId;
|
||||
}
|
||||
|
||||
public void setArtistId(String artistId) {
|
||||
this.artistId = artistId;
|
||||
}
|
||||
|
||||
public boolean isProducer() {
|
||||
return isProducer;
|
||||
}
|
||||
|
||||
public void setProducer(boolean producer) {
|
||||
isProducer = producer;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.cappielloantonio.play.model;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.Html;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
|
|
@ -10,11 +11,12 @@ import androidx.room.Ignore;
|
|||
import androidx.room.PrimaryKey;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistID3;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity(tableName = "artist")
|
||||
public class Artist implements Parcelable {
|
||||
private static final String TAG = "Artist";
|
||||
|
||||
|
|
@ -33,11 +35,20 @@ public class Artist implements Parcelable {
|
|||
public Artist(ArtistID3 artistID3) {
|
||||
this.id = artistID3.getId();
|
||||
this.name = artistID3.getName();
|
||||
this.primary = artistID3.getCoverArtId() != null ? artistID3.getCoverArtId() : artistID3.getId();
|
||||
this.primary = artistID3.getCoverArtId();
|
||||
this.backdrop = artistID3.getCoverArtId();
|
||||
this.albumCount = artistID3.getAlbumCount();
|
||||
}
|
||||
|
||||
public Artist(ArtistWithAlbumsID3 artistWithAlbumsID3) {
|
||||
this.id = artistWithAlbumsID3.getId();
|
||||
this.name = artistWithAlbumsID3.getName();
|
||||
this.primary = artistWithAlbumsID3.getCoverArtId();
|
||||
this.backdrop = artistWithAlbumsID3.getCoverArtId();
|
||||
this.albumCount = artistWithAlbumsID3.getAlbumCount();
|
||||
this.albums = MappingUtil.mapAlbum(artistWithAlbumsID3.getAlbums());
|
||||
}
|
||||
|
||||
public Artist(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
|
@ -99,6 +110,14 @@ public class Artist implements Parcelable {
|
|||
this.albumCount = albumCount;
|
||||
}
|
||||
|
||||
public List<Album> getAlbums() {
|
||||
return albums;
|
||||
}
|
||||
|
||||
public void setAlbums(List<Album> albums) {
|
||||
this.albums = albums;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
package com.cappielloantonio.play.model;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "playlist_song_cross", primaryKeys = {"playlist_id","song_id"})
|
||||
public class PlaylistSongCross {
|
||||
@NonNull
|
||||
@ColumnInfo(name = "playlist_id")
|
||||
private String playlistId;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = "song_id")
|
||||
private String songId;
|
||||
|
||||
@ColumnInfo(name = "item_number")
|
||||
private int itemNumber;
|
||||
|
||||
public PlaylistSongCross(String playlistId, String songId, int itemNumber) {
|
||||
this.playlistId = playlistId;
|
||||
this.songId = songId;
|
||||
this.itemNumber = itemNumber;
|
||||
}
|
||||
|
||||
public String getPlaylistId() {
|
||||
return playlistId;
|
||||
}
|
||||
|
||||
public void setPlaylistId(String playlistId) {
|
||||
this.playlistId = playlistId;
|
||||
}
|
||||
|
||||
public String getSongId() {
|
||||
return songId;
|
||||
}
|
||||
|
||||
public void setSongId(String songId) {
|
||||
this.songId = songId;
|
||||
}
|
||||
|
||||
public int getItemNumber() { return itemNumber; }
|
||||
|
||||
public void setItemNumber(int itemNumber) { this.itemNumber = itemNumber; }
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
package com.cappielloantonio.play.model;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "song_artist_cross")
|
||||
public class SongArtistCross {
|
||||
@NonNull
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
private int id;
|
||||
|
||||
@ColumnInfo(name = "song_id")
|
||||
private String songId;
|
||||
|
||||
@ColumnInfo(name = "artist_id")
|
||||
private String artistId;
|
||||
|
||||
public SongArtistCross(String songId, String artistId) {
|
||||
this.songId = songId;
|
||||
this.artistId = artistId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSongId() {
|
||||
return songId;
|
||||
}
|
||||
|
||||
public void setSongId(String songId) {
|
||||
this.songId = songId;
|
||||
}
|
||||
|
||||
public String getArtistId() {
|
||||
return artistId;
|
||||
}
|
||||
|
||||
public void setArtistId(String artistId) {
|
||||
this.artistId = artistId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
package com.cappielloantonio.play.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "song_genre_cross")
|
||||
public class SongGenreCross implements Parcelable {
|
||||
@NonNull
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
private int id;
|
||||
|
||||
@ColumnInfo(name = "song_id")
|
||||
private String songId;
|
||||
|
||||
@ColumnInfo(name = "genre_id")
|
||||
private String genreId;
|
||||
|
||||
public SongGenreCross(String songId, String genreId) {
|
||||
this.songId = songId;
|
||||
this.genreId = genreId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSongId() {
|
||||
return songId;
|
||||
}
|
||||
|
||||
public void setSongId(String songId) {
|
||||
this.songId = songId;
|
||||
}
|
||||
|
||||
public String getGenreId() {
|
||||
return genreId;
|
||||
}
|
||||
|
||||
public void setGenreId(String genreId) {
|
||||
this.genreId = genreId;
|
||||
}
|
||||
|
||||
protected SongGenreCross(Parcel in) {
|
||||
id = in.readInt();
|
||||
songId = in.readString();
|
||||
genreId = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(id);
|
||||
dest.writeString(songId);
|
||||
dest.writeString(genreId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<SongGenreCross> CREATOR = new Creator<SongGenreCross>() {
|
||||
@Override
|
||||
public SongGenreCross createFromParcel(Parcel in) {
|
||||
return new SongGenreCross(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SongGenreCross[] newArray(int size) {
|
||||
return new SongGenreCross[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -26,13 +26,15 @@ public class AlbumRepository {
|
|||
private MutableLiveData<List<Album>> listLiveRecentlyAddedAlbums = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Album>> listLiveMostPlayedAlbums = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Album>> listLiveRecentlyPlayedAlbums = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Album>> listLiveRandomAlbums = new MutableLiveData<>();
|
||||
|
||||
public AlbumRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public LiveData<List<Album>> getListLiveAlbums(String type, int size) {
|
||||
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||
public LiveData<List<Album>> getAlbums(String type, int size) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getAlbumSongListClient()
|
||||
.getAlbumList2(type, size, 0)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
@ -49,6 +51,9 @@ public class AlbumRepository {
|
|||
case "recent":
|
||||
listLiveRecentlyPlayedAlbums.setValue(albums);
|
||||
break;
|
||||
case "random":
|
||||
listLiveRandomAlbums.setValue(albums);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +70,8 @@ public class AlbumRepository {
|
|||
return listLiveMostPlayedAlbums;
|
||||
case "recent":
|
||||
return listLiveRecentlyPlayedAlbums;
|
||||
case "random":
|
||||
return listLiveRandomAlbums;
|
||||
default:
|
||||
return new MutableLiveData<>();
|
||||
}
|
||||
|
|
@ -73,7 +80,8 @@ public class AlbumRepository {
|
|||
public MutableLiveData<List<Album>> getStarredAlbums() {
|
||||
MutableLiveData<List<Album>> starredAlbums = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
||||
import com.cappielloantonio.play.subsonic.models.IndexID3;
|
||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
|
|
@ -20,21 +23,24 @@ import retrofit2.Response;
|
|||
public class ArtistRepository {
|
||||
private Application application;
|
||||
|
||||
private MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>(new ArrayList<>());
|
||||
private MutableLiveData<List<Artist>> listLiveRandomArtists = new MutableLiveData<>(new ArrayList<>());
|
||||
private MutableLiveData<List<Artist>> listLiveArtists = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
public ArtistRepository(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Artist>> getStarredArtists() {
|
||||
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) {
|
||||
List<Artist> artists = new ArrayList<>(MappingUtil.mapArtist(response.body().getStarred2().getArtists()));
|
||||
starredArtists.setValue(artists);
|
||||
getArtistInfo(artists, starredArtists);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,4 +51,61 @@ public class ArtistRepository {
|
|||
|
||||
return starredArtists;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Artist>> getArtists(boolean random, int size) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getArtists()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) {
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
|
||||
for (IndexID3 index : response.body().getArtists().getIndices()) {
|
||||
artists.addAll(MappingUtil.mapArtist(index.getArtists()));
|
||||
}
|
||||
|
||||
listLiveArtists.setValue(artists);
|
||||
Collections.shuffle(artists);
|
||||
getArtistInfo(artists.subList(0, artists.size() / size > 0 ? size : artists.size()), listLiveRandomArtists);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
}
|
||||
});
|
||||
|
||||
if (random) {
|
||||
return listLiveRandomArtists;
|
||||
} else {
|
||||
return listLiveArtists;
|
||||
}
|
||||
}
|
||||
|
||||
public void getArtistInfo(List<Artist> artists, MutableLiveData<List<Artist>> list) {
|
||||
for (Artist artist : artists) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(artist.getId())
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
addToMutableLiveData(list, MappingUtil.mapArtistWithAlbum(response.body().getArtist()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void addToMutableLiveData(MutableLiveData<List<Artist>> liveData, Artist artist) {
|
||||
List<Artist> liveArtists = liveData.getValue();
|
||||
liveArtists.add(artist);
|
||||
liveData.setValue(liveArtists);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import com.cappielloantonio.play.model.RecentSearch;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecentSearchRepository {
|
||||
public class SearchingRepository {
|
||||
private RecentSearchDao recentSearchDao;
|
||||
|
||||
public RecentSearchRepository(Application application) {
|
||||
public SearchingRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
recentSearchDao = database.recentSearchDao();
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Xml
|
||||
@Xml(name = "artist")
|
||||
public class ArtistID3 {
|
||||
@Attribute
|
||||
protected String id;
|
||||
|
|
|
|||
|
|
@ -1,35 +1,24 @@
|
|||
package com.cappielloantonio.play.subsonic.models;
|
||||
|
||||
import com.tickaroo.tikxml.annotation.Element;
|
||||
import com.tickaroo.tikxml.annotation.Xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Xml
|
||||
public class ArtistWithAlbumsID3 extends ArtistID3 {
|
||||
@Element(name = "album")
|
||||
protected List<AlbumID3> albums;
|
||||
|
||||
/**
|
||||
* Gets the value of the albums property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the albums property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getAlbums().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link AlbumID3 }
|
||||
*/
|
||||
public List<AlbumID3> getAlbums() {
|
||||
if (albums == null) {
|
||||
albums = new ArrayList<AlbumID3>();
|
||||
albums = new ArrayList<>();
|
||||
}
|
||||
return this.albums;
|
||||
}
|
||||
|
||||
public void setAlbums(List<AlbumID3> albums) {
|
||||
this.albums = albums;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class SubsonicResponse {
|
|||
private Child song;
|
||||
@Element(name = "album")
|
||||
private AlbumWithSongsID3 album;
|
||||
@Element(name = "artist")
|
||||
private ArtistWithAlbumsID3 artist;
|
||||
@Element(name = "artists")
|
||||
private ArtistsID3 artists;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
|||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -198,7 +199,7 @@ public class HomeFragment extends Fragment {
|
|||
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
||||
homeViewModel.getStarredTracks().observe(requireActivity(), songs -> {
|
||||
if(bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), (songs.size() / 5) > 0 ? 5 : songs.size() % 5, GridLayoutManager.HORIZONTAL, false));
|
||||
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
starredSongAdapter.setItems(songs);
|
||||
});
|
||||
|
||||
|
|
@ -213,7 +214,7 @@ public class HomeFragment extends Fragment {
|
|||
bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter);
|
||||
homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> {
|
||||
if(bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), (albums.size() / 5) > 0 ? 5 : albums.size() % 5, GridLayoutManager.HORIZONTAL, false));
|
||||
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
starredAlbumAdapter.setItems(albums);
|
||||
});
|
||||
|
||||
|
|
@ -228,7 +229,7 @@ public class HomeFragment extends Fragment {
|
|||
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
|
||||
homeViewModel.getStarredArtists().observe(requireActivity(), artists -> {
|
||||
if(bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), (artists.size() / 5) > 0 ? 5 : artists.size() % 5, GridLayoutManager.HORIZONTAL, false));
|
||||
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
starredArtistAdapter.setItems(artists);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.cappielloantonio.play.model.Queue;
|
|||
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.ArtistWithAlbumsID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -32,16 +33,20 @@ public class MappingUtil {
|
|||
return albums;
|
||||
}
|
||||
|
||||
public static ArrayList<Artist> mapArtist(List<ArtistID3> albumID3List) {
|
||||
public static ArrayList<Artist> mapArtist(List<ArtistID3> artistID3List) {
|
||||
ArrayList<Artist> artists = new ArrayList();
|
||||
|
||||
for(ArtistID3 artistID3 : albumID3List){
|
||||
for(ArtistID3 artistID3 : artistID3List){
|
||||
artists.add(new Artist(artistID3));
|
||||
}
|
||||
|
||||
return artists;
|
||||
}
|
||||
|
||||
public static Artist mapArtistWithAlbum(ArtistWithAlbumsID3 artistWithAlbumsID3) {
|
||||
return new Artist(artistWithAlbumsID3);
|
||||
}
|
||||
|
||||
public static ArrayList<Song> mapQueue(List<Queue> queueList) {
|
||||
ArrayList<Song> songs = new ArrayList();
|
||||
|
||||
|
|
|
|||
14
app/src/main/java/com/cappielloantonio/play/util/UIUtil.java
Normal file
14
app/src/main/java/com/cappielloantonio/play/util/UIUtil.java
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package com.cappielloantonio.play.util;
|
||||
|
||||
public class UIUtil {
|
||||
public static int getSpanCount(int itemCount, int maxSpan) {
|
||||
int itemSize = itemCount == 0 ? 1 : itemCount;
|
||||
|
||||
if (itemSize / maxSpan > 0) {
|
||||
return maxSpan;
|
||||
}
|
||||
else {
|
||||
return itemSize % maxSpan;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.cappielloantonio.play.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class Util {
|
||||
public static String getDate() {
|
||||
String pattern = "EEEE, MMMM d";
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
|
||||
String date = simpleDateFormat.format(new Date());
|
||||
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
package com.cappielloantonio.play.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
|
|
@ -54,9 +52,9 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
downloadedSongSample = new MutableLiveData<>();
|
||||
years = new ArrayList<>();
|
||||
|
||||
mostPlayedAlbumSample = albumRepository.getListLiveAlbums("frequent", 20);
|
||||
recentlyAddedAlbumSample = albumRepository.getListLiveAlbums("newest", 20);
|
||||
recentlyPlayedAlbumSample = albumRepository.getListLiveAlbums("recent", 20);
|
||||
mostPlayedAlbumSample = albumRepository.getAlbums("frequent", 20);
|
||||
recentlyAddedAlbumSample = albumRepository.getAlbums("newest", 20);
|
||||
recentlyPlayedAlbumSample = albumRepository.getAlbums("recent", 20);
|
||||
|
||||
starredTracks = songRepository.getStarredSongs();
|
||||
starredAlbums = albumRepository.getStarredAlbums();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.app.Application;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
|
|
@ -15,6 +16,7 @@ import com.cappielloantonio.play.repository.ArtistRepository;
|
|||
import com.cappielloantonio.play.repository.GenreRepository;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryViewModel extends AndroidViewModel {
|
||||
|
|
@ -42,6 +44,11 @@ public class LibraryViewModel extends AndroidViewModel {
|
|||
// sampleArtist = artistRepository.getListLiveSampleArtist();
|
||||
// sampleGenres = genreRepository.getListLiveSampleGenre();
|
||||
// playlistSample = playlistRepository.getRandomSample(5);
|
||||
|
||||
sampleAlbum = albumRepository.getAlbums("random", 20);
|
||||
sampleArtist = artistRepository.getArtists(true, 20);
|
||||
sampleGenres = new MutableLiveData<>();
|
||||
playlistSample = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<Playlist> getPlaylistSample() {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@ import com.cappielloantonio.play.model.Song;
|
|||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.GenreRepository;
|
||||
import com.cappielloantonio.play.repository.RecentSearchRepository;
|
||||
import com.cappielloantonio.play.repository.SearchingRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
|
|
@ -32,7 +31,7 @@ public class SearchViewModel extends AndroidViewModel {
|
|||
private AlbumRepository albumRepository;
|
||||
private ArtistRepository artistRepository;
|
||||
private GenreRepository genreRepository;
|
||||
private RecentSearchRepository recentSearchRepository;
|
||||
private SearchingRepository searchingRepository;
|
||||
|
||||
private LiveData<List<Song>> searchSong;
|
||||
private LiveData<List<Album>> searchAlbum;
|
||||
|
|
@ -46,7 +45,7 @@ public class SearchViewModel extends AndroidViewModel {
|
|||
albumRepository = new AlbumRepository(application);
|
||||
artistRepository = new ArtistRepository(application);
|
||||
genreRepository = new GenreRepository(application);
|
||||
recentSearchRepository = new RecentSearchRepository(application);
|
||||
searchingRepository = new SearchingRepository(application);
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
|
|
@ -82,11 +81,11 @@ public class SearchViewModel extends AndroidViewModel {
|
|||
}
|
||||
|
||||
public void insertNewSearch(String search) {
|
||||
recentSearchRepository.insert(new RecentSearch(search));
|
||||
searchingRepository.insert(new RecentSearch(search));
|
||||
}
|
||||
|
||||
public void deleteRecentSearch(String search) {
|
||||
recentSearchRepository.delete(new RecentSearch(search));
|
||||
searchingRepository.delete(new RecentSearch(search));
|
||||
}
|
||||
|
||||
public List<String> getSearchSuggestion(String query) {
|
||||
|
|
@ -104,7 +103,7 @@ public class SearchViewModel extends AndroidViewModel {
|
|||
|
||||
public List<String> getRecentSearchSuggestion() {
|
||||
ArrayList<String> suggestions = new ArrayList<>();
|
||||
suggestions.addAll(recentSearchRepository.getRecentSearchSuggestion(5));
|
||||
suggestions.addAll(searchingRepository.getRecentSearchSuggestion(5));
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@
|
|||
app:errorEnabled="true"
|
||||
app:hintTextColor="?android:textColorSecondary">
|
||||
|
||||
<!-- Navidrome android:text="!$4EBXhSPUi4$E#oagvAisCA" -->
|
||||
<!-- Gonic android:text="hYP3%yD!rx@GBf95B2wbRUk8" -->
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/password_text_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue