mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Add catalogues
This commit is contained in:
parent
8c889f7a38
commit
8b7e383dc2
45 changed files with 1084 additions and 136 deletions
|
|
@ -54,6 +54,9 @@ dependencies {
|
||||||
implementation "androidx.room:room-runtime:2.2.5"
|
implementation "androidx.room:room-runtime:2.2.5"
|
||||||
implementation 'com.github.jellyfin.jellyfin-apiclient-java:android:0.7.7'
|
implementation 'com.github.jellyfin.jellyfin-apiclient-java:android:0.7.7'
|
||||||
implementation "androidx.cardview:cardview:1.0.0"
|
implementation "androidx.cardview:cardview:1.0.0"
|
||||||
|
|
||||||
|
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||||
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
||||||
testImplementation 'junit:junit:4.13.1'
|
testImplementation 'junit:junit:4.13.1'
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
import com.cappielloantonio.play.model.Album;
|
import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.model.Genre;
|
import com.cappielloantonio.play.util.Util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.cappielloantonio.play.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.R;
|
||||||
|
import com.cappielloantonio.play.model.Album;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAdapter.ViewHolder> {
|
||||||
|
private static final String TAG = "AlbumAdapter";
|
||||||
|
private List<Album> albums;
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
private Context context;
|
||||||
|
private ItemClickListener itemClickListener;
|
||||||
|
|
||||||
|
public AlbumCatalogueAdapter(Context context, List<Album> albums) {
|
||||||
|
this.context = context;
|
||||||
|
this.mInflater = LayoutInflater.from(context);
|
||||||
|
this.albums = albums;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
View view = mInflater.inflate(R.layout.item_library_catalogue_album, parent, false);
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
|
Album album = albums.get(position);
|
||||||
|
|
||||||
|
holder.textAlbumName.setText(album.getTitle());
|
||||||
|
holder.textArtistName.setText(album.getArtistName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return albums.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
TextView textAlbumName;
|
||||||
|
TextView textArtistName;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
textAlbumName = itemView.findViewById(R.id.album_name_label);
|
||||||
|
textArtistName = itemView.findViewById(R.id.artist_name_label);
|
||||||
|
|
||||||
|
itemView.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<Album> albums) {
|
||||||
|
this.albums = albums;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClickListener(ItemClickListener itemClickListener) {
|
||||||
|
this.itemClickListener = itemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ItemClickListener {
|
||||||
|
void onItemClick(View view, int position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,8 +9,8 @@ import android.widget.TextView;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
import com.cappielloantonio.play.model.Album;
|
|
||||||
import com.cappielloantonio.play.model.Artist;
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
import com.cappielloantonio.play.util.Util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.cappielloantonio.play.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.R;
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> {
|
||||||
|
private static final String TAG = "ArtistAdapter";
|
||||||
|
private List<Artist> artists;
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
private Context context;
|
||||||
|
private ItemClickListener itemClickListener;
|
||||||
|
|
||||||
|
public ArtistCatalogueAdapter(Context context, List<Artist> artists) {
|
||||||
|
this.context = context;
|
||||||
|
this.mInflater = LayoutInflater.from(context);
|
||||||
|
this.artists = artists;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
View view = mInflater.inflate(R.layout.item_library_catalogue_artist, parent, false);
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
|
Artist artist = artists.get(position);
|
||||||
|
|
||||||
|
holder.textArtistName.setText(artist.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return artists.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
TextView textArtistName;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
textArtistName = itemView.findViewById(R.id.artist_name_label);
|
||||||
|
|
||||||
|
itemView.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<Artist> artists) {
|
||||||
|
this.artists = artists;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClickListener(ItemClickListener itemClickListener) {
|
||||||
|
this.itemClickListener = itemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ItemClickListener {
|
||||||
|
void onItemClick(View view, int position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
|
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -57,6 +58,11 @@ public class DiscoverSongAdapter extends PagerAdapter {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItems(List<Song> songs) {
|
||||||
|
this.songs = songs;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||||
container.removeView((View)object);
|
container.removeView((View)object);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.cappielloantonio.play.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.R;
|
||||||
|
import com.cappielloantonio.play.model.Genre;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GenreCatalogueAdapter extends RecyclerView.Adapter<GenreCatalogueAdapter.ViewHolder> {
|
||||||
|
private static final String TAG = "GenreAdapter";
|
||||||
|
private List<Genre> genres;
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
private Context context;
|
||||||
|
private ItemClickListener itemClickListener;
|
||||||
|
|
||||||
|
public GenreCatalogueAdapter(Context context, List<Genre> genres) {
|
||||||
|
this.context = context;
|
||||||
|
this.mInflater = LayoutInflater.from(context);
|
||||||
|
this.genres = genres;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inflates the row layout from xml when needed
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
View view = mInflater.inflate(R.layout.item_library_catalogue_genre, parent, false);
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
|
Genre genre = genres.get(position);
|
||||||
|
|
||||||
|
holder.textGenre.setText(genre.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return genres.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
TextView textGenre;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
textGenre = itemView.findViewById(R.id.genre_label);
|
||||||
|
|
||||||
|
itemView.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<Genre> genres) {
|
||||||
|
this.genres = genres;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClickListener(ItemClickListener itemClickListener) {
|
||||||
|
this.itemClickListener = itemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ItemClickListener {
|
||||||
|
void onItemClick(View view, int position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,9 @@ import android.widget.TextView;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
|
import com.cappielloantonio.play.util.Util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -67,6 +69,11 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItems(List<Song> songs) {
|
||||||
|
this.songs = songs;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public void setClickListener(ItemClickListener itemClickListener) {
|
public void setClickListener(ItemClickListener itemClickListener) {
|
||||||
this.itemClickListener = itemClickListener;
|
this.itemClickListener = itemClickListener;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ public interface AlbumDao {
|
||||||
@Query("SELECT * FROM album")
|
@Query("SELECT * FROM album")
|
||||||
LiveData<List<Album>> getAll();
|
LiveData<List<Album>> getAll();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM album ORDER BY RANDOM() LIMIT :number;")
|
||||||
|
LiveData<List<Album>> getSample(int number);
|
||||||
|
|
||||||
@Query("SELECT EXISTS(SELECT * FROM album WHERE id = :id)")
|
@Query("SELECT EXISTS(SELECT * FROM album WHERE id = :id)")
|
||||||
boolean exist(String id);
|
boolean exist(String id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ public interface ArtistDao {
|
||||||
@Query("SELECT * FROM artist")
|
@Query("SELECT * FROM artist")
|
||||||
LiveData<List<Artist>> getAll();
|
LiveData<List<Artist>> getAll();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM artist ORDER BY RANDOM() LIMIT :number;")
|
||||||
|
LiveData<List<Artist>> getSample(int number);
|
||||||
|
|
||||||
@Query("SELECT EXISTS(SELECT * FROM artist WHERE id = :id)")
|
@Query("SELECT EXISTS(SELECT * FROM artist WHERE id = :id)")
|
||||||
boolean exist(String id);
|
boolean exist(String id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import androidx.room.Insert;
|
||||||
import androidx.room.OnConflictStrategy;
|
import androidx.room.OnConflictStrategy;
|
||||||
import androidx.room.Query;
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.model.Artist;
|
import com.cappielloantonio.play.model.Artist;
|
||||||
import com.cappielloantonio.play.model.Genre;
|
import com.cappielloantonio.play.model.Genre;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,9 @@ public interface GenreDao {
|
||||||
@Query("SELECT * FROM genre")
|
@Query("SELECT * FROM genre")
|
||||||
LiveData<List<Genre>> getAll();
|
LiveData<List<Genre>> getAll();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM genre ORDER BY RANDOM() LIMIT :number;")
|
||||||
|
LiveData<List<Genre>> getSample(int number);
|
||||||
|
|
||||||
@Query("SELECT EXISTS(SELECT * FROM genre WHERE id = :id)")
|
@Query("SELECT EXISTS(SELECT * FROM genre WHERE id = :id)")
|
||||||
boolean exist(String id);
|
boolean exist(String id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,18 @@ public interface SongDao {
|
||||||
@Query("SELECT * FROM song WHERE title LIKE '%' || :title || '%'")
|
@Query("SELECT * FROM song WHERE title LIKE '%' || :title || '%'")
|
||||||
LiveData<List<Song>> searchSong(String title);
|
LiveData<List<Song>> searchSong(String title);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
|
||||||
|
LiveData<List<Song>> getDiscoverSample(int number);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
|
||||||
|
LiveData<List<Song>> getRecentlyAddedSample(int number);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
|
||||||
|
LiveData<List<Song>> getRecentlyPlayedSample(int number);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
|
||||||
|
LiveData<List<Song>> getMostPlayedSample(int number);
|
||||||
|
|
||||||
@Query("SELECT EXISTS(SELECT * FROM song WHERE id = :id)")
|
@Query("SELECT EXISTS(SELECT * FROM song WHERE id = :id)")
|
||||||
boolean exist(String id);
|
boolean exist(String id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,23 @@ import java.util.List;
|
||||||
public class AlbumRepository {
|
public class AlbumRepository {
|
||||||
private AlbumDao albumDao;
|
private AlbumDao albumDao;
|
||||||
private LiveData<List<Album>> listLiveAlbums;
|
private LiveData<List<Album>> listLiveAlbums;
|
||||||
|
private LiveData<List<Album>> listLiveSampleAlbum;
|
||||||
|
|
||||||
public AlbumRepository(Application application) {
|
public AlbumRepository(Application application) {
|
||||||
AppDatabase database = AppDatabase.getInstance(application);
|
AppDatabase database = AppDatabase.getInstance(application);
|
||||||
albumDao = database.albumDao();
|
albumDao = database.albumDao();
|
||||||
listLiveAlbums = albumDao.getAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Album>> getListLiveAlbums() {
|
public LiveData<List<Album>> getListLiveAlbums() {
|
||||||
|
listLiveAlbums = albumDao.getAll();
|
||||||
return listLiveAlbums;
|
return listLiveAlbums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Album>> getListLiveSampleAlbum() {
|
||||||
|
listLiveSampleAlbum = albumDao.getSample(10);
|
||||||
|
return listLiveSampleAlbum;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exist(Album album) {
|
public boolean exist(Album album) {
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
import com.cappielloantonio.play.database.AppDatabase;
|
import com.cappielloantonio.play.database.AppDatabase;
|
||||||
import com.cappielloantonio.play.database.dao.ArtistDao;
|
import com.cappielloantonio.play.database.dao.ArtistDao;
|
||||||
|
import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.model.Artist;
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -14,17 +15,23 @@ import java.util.List;
|
||||||
public class ArtistRepository {
|
public class ArtistRepository {
|
||||||
private ArtistDao artistDao;
|
private ArtistDao artistDao;
|
||||||
private LiveData<List<Artist>> listLiveArtists;
|
private LiveData<List<Artist>> listLiveArtists;
|
||||||
|
private LiveData<List<Artist>> listLiveSampleArtist;
|
||||||
|
|
||||||
public ArtistRepository(Application application) {
|
public ArtistRepository(Application application) {
|
||||||
AppDatabase database = AppDatabase.getInstance(application);
|
AppDatabase database = AppDatabase.getInstance(application);
|
||||||
artistDao = database.artistDao();
|
artistDao = database.artistDao();
|
||||||
listLiveArtists = artistDao.getAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Artist>> getListLiveArtists() {
|
public LiveData<List<Artist>> getListLiveArtists() {
|
||||||
|
listLiveArtists = artistDao.getAll();
|
||||||
return listLiveArtists;
|
return listLiveArtists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Artist>> getListLiveSampleArtist() {
|
||||||
|
listLiveSampleArtist = artistDao.getSample(10);
|
||||||
|
return listLiveSampleArtist;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exist(Artist artist) {
|
public boolean exist(Artist artist) {
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
import com.cappielloantonio.play.database.AppDatabase;
|
import com.cappielloantonio.play.database.AppDatabase;
|
||||||
import com.cappielloantonio.play.database.dao.GenreDao;
|
import com.cappielloantonio.play.database.dao.GenreDao;
|
||||||
|
import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.model.Genre;
|
import com.cappielloantonio.play.model.Genre;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -14,17 +15,23 @@ import java.util.List;
|
||||||
public class GenreRepository {
|
public class GenreRepository {
|
||||||
private GenreDao genreDao;
|
private GenreDao genreDao;
|
||||||
private LiveData<List<Genre>> listLiveGenres;
|
private LiveData<List<Genre>> listLiveGenres;
|
||||||
|
private LiveData<List<Genre>> listLiveAlbumGenre;
|
||||||
|
|
||||||
public GenreRepository(Application application) {
|
public GenreRepository(Application application) {
|
||||||
AppDatabase database = AppDatabase.getInstance(application);
|
AppDatabase database = AppDatabase.getInstance(application);
|
||||||
genreDao = database.genreDao();
|
genreDao = database.genreDao();
|
||||||
listLiveGenres = genreDao.getAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Genre>> getListLiveGenres() {
|
public LiveData<List<Genre>> getListLiveGenres() {
|
||||||
|
listLiveGenres = genreDao.getAll();
|
||||||
return listLiveGenres;
|
return listLiveGenres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Genre>> getListLiveSampleGenre() {
|
||||||
|
listLiveAlbumGenre = genreDao.getSample(6 * 3);
|
||||||
|
return listLiveAlbumGenre;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exist(Genre genre) {
|
public boolean exist(Genre genre) {
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
import com.cappielloantonio.play.database.AppDatabase;
|
import com.cappielloantonio.play.database.AppDatabase;
|
||||||
import com.cappielloantonio.play.database.dao.SongDao;
|
import com.cappielloantonio.play.database.dao.SongDao;
|
||||||
|
import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -15,22 +16,42 @@ public class SongRepository {
|
||||||
private SongDao songDao;
|
private SongDao songDao;
|
||||||
private LiveData<List<Song>> listLiveSongs;
|
private LiveData<List<Song>> listLiveSongs;
|
||||||
private LiveData<List<Song>> searchListLiveSongs;
|
private LiveData<List<Song>> searchListLiveSongs;
|
||||||
|
private LiveData<List<Song>> listLiveSampleDiscoverSongs;
|
||||||
|
private LiveData<List<Song>> listLiveSampleRecentlyAddedSongs;
|
||||||
|
private LiveData<List<Song>> listLiveSampleRecentlyPlayedSongs;
|
||||||
|
private LiveData<List<Song>> listLiveSampleMostPlayedSongs;
|
||||||
|
|
||||||
|
|
||||||
public SongRepository(Application application) {
|
public SongRepository(Application application) {
|
||||||
AppDatabase database = AppDatabase.getInstance(application);
|
AppDatabase database = AppDatabase.getInstance(application);
|
||||||
songDao = database.songDao();
|
songDao = database.songDao();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Song>> getListLiveSongs() {
|
public LiveData<List<Song>> searchListLiveSong(String title) {
|
||||||
listLiveSongs = songDao.getAll();
|
|
||||||
return listLiveSongs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<List<Song>> searchListLiveSongs(String title) {
|
|
||||||
searchListLiveSongs = songDao.searchSong(title);
|
searchListLiveSongs = songDao.searchSong(title);
|
||||||
return searchListLiveSongs;
|
return searchListLiveSongs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Song>> getListLiveDiscoverSampleSong() {
|
||||||
|
listLiveSampleDiscoverSongs = songDao.getDiscoverSample(5);
|
||||||
|
return listLiveSampleDiscoverSongs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Song>> getListLiveRecentlyAddedSampleSong() {
|
||||||
|
listLiveSampleRecentlyAddedSongs = songDao.getRecentlyAddedSample(20);
|
||||||
|
return listLiveSampleRecentlyAddedSongs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Song>> getListLiveRecentlyPlayedSampleSong() {
|
||||||
|
listLiveSampleRecentlyPlayedSongs = songDao.getRecentlyPlayedSample(20);
|
||||||
|
return listLiveSampleRecentlyPlayedSongs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Song>> getListLiveMostPlayedSampleSong() {
|
||||||
|
listLiveSampleMostPlayedSongs = songDao.getMostPlayedSample(20);
|
||||||
|
return listLiveSampleMostPlayedSongs;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exist(Song song) {
|
public boolean exist(Song song) {
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.cappielloantonio.play.ui.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.adapter.AlbumCatalogueAdapter;
|
||||||
|
import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter;
|
||||||
|
import com.cappielloantonio.play.databinding.FragmentAlbumCatalogueBinding;
|
||||||
|
import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding;
|
||||||
|
import com.cappielloantonio.play.viewmodel.AlbumCatalogueViewModel;
|
||||||
|
import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class AlbumCatalogueFragment extends Fragment {
|
||||||
|
private static final String TAG = "ArtistCatalogueFragment";
|
||||||
|
|
||||||
|
private FragmentAlbumCatalogueBinding bind;
|
||||||
|
private AlbumCatalogueViewModel albumCatalogueViewModel;
|
||||||
|
|
||||||
|
private AlbumCatalogueAdapter albumAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
bind = FragmentAlbumCatalogueBinding.inflate(inflater, container, false);
|
||||||
|
View view = bind.getRoot();
|
||||||
|
albumCatalogueViewModel = new ViewModelProvider(requireActivity()).get(AlbumCatalogueViewModel.class);
|
||||||
|
|
||||||
|
initAlbumCatalogueView();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
bind = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAlbumCatalogueView() {
|
||||||
|
bind.albumCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
|
||||||
|
bind.albumCatalogueRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
|
albumAdapter = new AlbumCatalogueAdapter(requireContext(), new ArrayList<>());
|
||||||
|
albumAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Click: " + position, Toast.LENGTH_SHORT).show());
|
||||||
|
bind.albumCatalogueRecyclerView.setAdapter(albumAdapter);
|
||||||
|
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> {
|
||||||
|
bind.loadingProgressBar.setVisibility(View.GONE);
|
||||||
|
bind.albumCatalogueContainer.setVisibility(View.VISIBLE);
|
||||||
|
albumAdapter.setItems(albums);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.cappielloantonio.play.ui.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.R;
|
||||||
|
import com.cappielloantonio.play.adapter.ArtistAdapter;
|
||||||
|
import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter;
|
||||||
|
import com.cappielloantonio.play.adapter.RecentMusicAdapter;
|
||||||
|
import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding;
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||||
|
import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ArtistCatalogueFragment extends Fragment {
|
||||||
|
private static final String TAG = "ArtistCatalogueFragment";
|
||||||
|
|
||||||
|
private FragmentArtistCatalogueBinding bind;
|
||||||
|
private ArtistCatalogueViewModel artistCatalogueViewModel;
|
||||||
|
|
||||||
|
private ArtistCatalogueAdapter artistAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
bind = FragmentArtistCatalogueBinding.inflate(inflater, container, false);
|
||||||
|
View view = bind.getRoot();
|
||||||
|
artistCatalogueViewModel = new ViewModelProvider(requireActivity()).get(ArtistCatalogueViewModel.class);
|
||||||
|
|
||||||
|
initArtistCatalogueView();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
bind = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initArtistCatalogueView() {
|
||||||
|
bind.artistCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
|
||||||
|
bind.artistCatalogueRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
|
artistAdapter = new ArtistCatalogueAdapter(requireContext(), new ArrayList<>());
|
||||||
|
artistAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Click: " + position, Toast.LENGTH_SHORT).show());
|
||||||
|
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
|
||||||
|
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artists -> {
|
||||||
|
bind.loadingProgressBar.setVisibility(View.GONE);
|
||||||
|
bind.artistCatalogueContainer.setVisibility(View.VISIBLE);
|
||||||
|
artistAdapter.setItems(artists);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.cappielloantonio.play.ui.fragment;
|
package com.cappielloantonio.play.ui.fragment;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -15,26 +14,22 @@ import androidx.lifecycle.ViewModelProvider;
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
import com.cappielloantonio.play.databinding.FragmentFilterBinding;
|
import com.cappielloantonio.play.databinding.FragmentFilterBinding;
|
||||||
import com.cappielloantonio.play.model.Genre;
|
import com.cappielloantonio.play.model.Genre;
|
||||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
import com.cappielloantonio.play.viewmodel.FilterViewModel;
|
||||||
import com.cappielloantonio.play.viewmodel.SearchViewModel;
|
|
||||||
import com.google.android.material.chip.Chip;
|
import com.google.android.material.chip.Chip;
|
||||||
|
|
||||||
public class FilterFragment extends Fragment {
|
public class FilterFragment extends Fragment {
|
||||||
private static final String TAG = "FilterFragment";
|
private static final String TAG = "FilterFragment";
|
||||||
|
|
||||||
private MainActivity activity;
|
|
||||||
private FragmentFilterBinding bind;
|
private FragmentFilterBinding bind;
|
||||||
private SearchViewModel searchViewModel;
|
private FilterViewModel filterViewModel;
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
activity = (MainActivity) getActivity();
|
|
||||||
|
|
||||||
bind = FragmentFilterBinding.inflate(inflater, container, false);
|
bind = FragmentFilterBinding.inflate(inflater, container, false);
|
||||||
View view = bind.getRoot();
|
View view = bind.getRoot();
|
||||||
searchViewModel = new ViewModelProvider(requireActivity()).get(SearchViewModel.class);
|
filterViewModel = new ViewModelProvider(requireActivity()).get(FilterViewModel.class);
|
||||||
|
|
||||||
setFilterChips();
|
setFilterChips();
|
||||||
return view;
|
return view;
|
||||||
|
|
@ -47,7 +42,7 @@ public class FilterFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFilterChips() {
|
private void setFilterChips() {
|
||||||
searchViewModel.getGenreList().observe(requireActivity(), genres -> {
|
filterViewModel.getGenreList().observe(requireActivity(), genres -> {
|
||||||
bind.loadingProgressBar.setVisibility(View.GONE);
|
bind.loadingProgressBar.setVisibility(View.GONE);
|
||||||
for (Genre genre : genres) {
|
for (Genre genre : genres) {
|
||||||
Chip mChip = (Chip) requireActivity().getLayoutInflater().inflate(R.layout.chip_search_filter_genre, null, false);
|
Chip mChip = (Chip) requireActivity().getLayoutInflater().inflate(R.layout.chip_search_filter_genre, null, false);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.cappielloantonio.play.ui.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter;
|
||||||
|
import com.cappielloantonio.play.adapter.GenreAdapter;
|
||||||
|
import com.cappielloantonio.play.adapter.GenreCatalogueAdapter;
|
||||||
|
import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding;
|
||||||
|
import com.cappielloantonio.play.databinding.FragmentGenreCatalogueBinding;
|
||||||
|
import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel;
|
||||||
|
import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GenreCatalogueFragment extends Fragment {
|
||||||
|
private static final String TAG = "GenreCatalogueFragment";;
|
||||||
|
|
||||||
|
private FragmentGenreCatalogueBinding bind;
|
||||||
|
private GenreCatalogueViewModel genreCatalogueViewModel;
|
||||||
|
|
||||||
|
private GenreCatalogueAdapter genreCatalogueAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
bind = FragmentGenreCatalogueBinding.inflate(inflater, container, false);
|
||||||
|
View view = bind.getRoot();
|
||||||
|
genreCatalogueViewModel = new ViewModelProvider(requireActivity()).get(GenreCatalogueViewModel.class);
|
||||||
|
|
||||||
|
initArtistCatalogueView();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
bind = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initArtistCatalogueView() {
|
||||||
|
bind.genreCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
|
||||||
|
bind.genreCatalogueRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
|
genreCatalogueAdapter = new GenreCatalogueAdapter(requireContext(), new ArrayList<>());
|
||||||
|
genreCatalogueAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Click: " + position, Toast.LENGTH_SHORT).show());
|
||||||
|
bind.genreCatalogueRecyclerView.setAdapter(genreCatalogueAdapter);
|
||||||
|
genreCatalogueViewModel.getGenreList().observe(requireActivity(), genres -> {
|
||||||
|
bind.loadingProgressBar.setVisibility(View.GONE);
|
||||||
|
bind.genreCatalogueContainer.setVisibility(View.VISIBLE);
|
||||||
|
genreCatalogueAdapter.setItems(genres);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,16 +9,21 @@ import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
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.Observer;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
|
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
|
||||||
import com.cappielloantonio.play.adapter.RecentMusicAdapter;
|
import com.cappielloantonio.play.adapter.RecentMusicAdapter;
|
||||||
import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
||||||
|
import com.cappielloantonio.play.model.Song;
|
||||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemClickListener {
|
public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemClickListener {
|
||||||
private static final String TAG = "CategoriesFragment";
|
private static final String TAG = "CategoriesFragment";
|
||||||
|
|
||||||
|
|
@ -27,7 +32,7 @@ public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemCli
|
||||||
private HomeViewModel homeViewModel;
|
private HomeViewModel homeViewModel;
|
||||||
|
|
||||||
private DiscoverSongAdapter discoverSongAdapter;
|
private DiscoverSongAdapter discoverSongAdapter;
|
||||||
private RecentMusicAdapter recentMusicAdapter;
|
private RecentMusicAdapter recentlyAddedMusicAdapter;
|
||||||
private RecentMusicAdapter mostPlayedMusicAdapter;
|
private RecentMusicAdapter mostPlayedMusicAdapter;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -61,27 +66,30 @@ public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemCli
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDiscoverSongSlideView() {
|
private void initDiscoverSongSlideView() {
|
||||||
discoverSongAdapter = new DiscoverSongAdapter(requireContext(), homeViewModel.getDiscoverSongList());
|
discoverSongAdapter = new DiscoverSongAdapter(requireContext(), new ArrayList<>());
|
||||||
bind.discoverSongViewPager.setAdapter(discoverSongAdapter);
|
bind.discoverSongViewPager.setAdapter(discoverSongAdapter);
|
||||||
bind.discoverSongViewPager.setPageMargin(20);
|
bind.discoverSongViewPager.setPageMargin(20);
|
||||||
|
homeViewModel.getDiscoverSongList().observe(requireActivity(), songs -> discoverSongAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initRecentPlayedSongView() {
|
private void initRecentPlayedSongView() {
|
||||||
bind.recentlyPlayedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
bind.recentlyPlayedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||||
bind.recentlyPlayedTracksRecyclerView.setHasFixedSize(true);
|
bind.recentlyPlayedTracksRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
recentMusicAdapter = new RecentMusicAdapter(requireContext(), homeViewModel.getRecentSongList());
|
recentlyAddedMusicAdapter = new RecentMusicAdapter(requireContext(), new ArrayList<>());
|
||||||
recentMusicAdapter.setClickListener(this);
|
recentlyAddedMusicAdapter.setClickListener(this);
|
||||||
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentMusicAdapter);
|
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyAddedMusicAdapter);
|
||||||
|
homeViewModel.getRecentlyAddedSongList().observe(requireActivity(), songs -> recentlyAddedMusicAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMostPlayedSongView() {
|
private void initMostPlayedSongView() {
|
||||||
bind.mostPlayedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
bind.mostPlayedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||||
bind.mostPlayedTracksRecyclerView.setHasFixedSize(true);
|
bind.mostPlayedTracksRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
mostPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), homeViewModel.getMostPlayedSongList());
|
mostPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), new ArrayList<>());
|
||||||
mostPlayedMusicAdapter.setClickListener(this);
|
mostPlayedMusicAdapter.setClickListener(this);
|
||||||
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
|
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
|
||||||
|
homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.cappielloantonio.play.ui.fragment;
|
package com.cappielloantonio.play.ui.fragment;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -14,11 +15,14 @@ import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
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.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.Album;
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
import com.cappielloantonio.play.model.Genre;
|
import com.cappielloantonio.play.model.Genre;
|
||||||
import com.cappielloantonio.play.model.Playlist;
|
import com.cappielloantonio.play.model.Playlist;
|
||||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||||
|
|
@ -48,6 +52,7 @@ public class LibraryFragment extends Fragment {
|
||||||
View view = bind.getRoot();
|
View view = bind.getRoot();
|
||||||
libraryViewModel = new ViewModelProvider(requireActivity()).get(LibraryViewModel.class);
|
libraryViewModel = new ViewModelProvider(requireActivity()).get(LibraryViewModel.class);
|
||||||
|
|
||||||
|
init();
|
||||||
initAlbumView();
|
initAlbumView();
|
||||||
initArtistView();
|
initArtistView();
|
||||||
initGenreView();
|
initGenreView();
|
||||||
|
|
@ -62,22 +67,30 @@ public class LibraryFragment extends Fragment {
|
||||||
bind = null;
|
bind = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
bind.albumCatalogueTextViewClickable.setOnClickListener(v -> activity.navController.navigate(R.id.action_libraryFragment_to_albumCatalogueFragment));
|
||||||
|
bind.artistCatalogueTextViewClickable.setOnClickListener(v -> activity.navController.navigate(R.id.action_libraryFragment_to_artistCatalogueFragment));
|
||||||
|
bind.genreCatalogueTextViewClickable.setOnClickListener(v -> activity.navController.navigate(R.id.action_libraryFragment_to_genreCatalogueFragment));
|
||||||
|
}
|
||||||
|
|
||||||
private void initAlbumView() {
|
private void initAlbumView() {
|
||||||
bind.albumRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
bind.albumRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||||
bind.albumRecyclerView.setHasFixedSize(true);
|
bind.albumRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
albumAdapter = new AlbumAdapter(requireContext(), libraryViewModel.getAlbumSample());
|
albumAdapter = new AlbumAdapter(requireContext(), new ArrayList<>());
|
||||||
albumAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Album: " + position, Toast.LENGTH_SHORT).show());
|
albumAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Album: " + position, Toast.LENGTH_SHORT).show());
|
||||||
bind.albumRecyclerView.setAdapter(albumAdapter);
|
bind.albumRecyclerView.setAdapter(albumAdapter);
|
||||||
|
libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> albumAdapter.setItems(albums));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initArtistView() {
|
private void initArtistView() {
|
||||||
bind.artistRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
bind.artistRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||||
bind.artistRecyclerView.setHasFixedSize(true);
|
bind.artistRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
artistAdapter = new ArtistAdapter(requireContext(), libraryViewModel.getArtistSample());
|
artistAdapter = new ArtistAdapter(requireContext(), new ArrayList<>());
|
||||||
artistAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Artist: " + position, Toast.LENGTH_SHORT).show());
|
artistAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Artist: " + position, Toast.LENGTH_SHORT).show());
|
||||||
bind.artistRecyclerView.setAdapter(artistAdapter);
|
bind.artistRecyclerView.setAdapter(artistAdapter);
|
||||||
|
libraryViewModel.getArtistSample().observe(requireActivity(), artists -> artistAdapter.setItems(artists));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGenreView() {
|
private void initGenreView() {
|
||||||
|
|
@ -87,7 +100,7 @@ public class LibraryFragment extends Fragment {
|
||||||
genreAdapter = new GenreAdapter(requireContext(), new ArrayList<>());
|
genreAdapter = new GenreAdapter(requireContext(), new ArrayList<>());
|
||||||
genreAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Genre: " + position, Toast.LENGTH_SHORT).show());
|
genreAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Genre: " + position, Toast.LENGTH_SHORT).show());
|
||||||
bind.genreRecyclerView.setAdapter(genreAdapter);
|
bind.genreRecyclerView.setAdapter(genreAdapter);
|
||||||
libraryViewModel.getGenreList().observe(requireActivity(), genres -> genreAdapter.setItems(genres));
|
libraryViewModel.getGenreSample().observe(requireActivity(), genres -> genreAdapter.setItems(genres));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPlaylistView() {
|
private void initPlaylistView() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.cappielloantonio.play.viewmodel;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.model.Album;
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||||
|
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AlbumCatalogueViewModel extends AndroidViewModel {
|
||||||
|
private AlbumRepository albumRepository;
|
||||||
|
|
||||||
|
private LiveData<List<Album>> albumList;
|
||||||
|
|
||||||
|
public AlbumCatalogueViewModel(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
|
||||||
|
albumRepository = new AlbumRepository(application);
|
||||||
|
|
||||||
|
albumList = albumRepository.getListLiveAlbums();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Album>> getAlbumList() {
|
||||||
|
return albumList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.cappielloantonio.play.viewmodel;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ArtistCatalogueViewModel extends AndroidViewModel {
|
||||||
|
private ArtistRepository artistRepository;
|
||||||
|
|
||||||
|
private LiveData<List<Artist>> artistList;
|
||||||
|
|
||||||
|
public ArtistCatalogueViewModel(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
|
||||||
|
artistRepository = new ArtistRepository(application);
|
||||||
|
|
||||||
|
artistList = artistRepository.getListLiveArtists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Artist>> getArtistList() {
|
||||||
|
return artistList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.cappielloantonio.play.viewmodel;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.model.Genre;
|
||||||
|
import com.cappielloantonio.play.model.RecentSearch;
|
||||||
|
import com.cappielloantonio.play.model.Song;
|
||||||
|
import com.cappielloantonio.play.repository.GenreRepository;
|
||||||
|
import com.cappielloantonio.play.repository.RecentSearchRepository;
|
||||||
|
import com.cappielloantonio.play.repository.SongRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FilterViewModel extends AndroidViewModel {
|
||||||
|
private GenreRepository genreRepository;
|
||||||
|
|
||||||
|
private LiveData<List<Genre>> allGenres;
|
||||||
|
|
||||||
|
public FilterViewModel(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
|
||||||
|
genreRepository = new GenreRepository(application);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Genre>> getGenreList() {
|
||||||
|
allGenres = genreRepository.getListLiveGenres();
|
||||||
|
return allGenres;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.cappielloantonio.play.viewmodel;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.model.Artist;
|
||||||
|
import com.cappielloantonio.play.model.Genre;
|
||||||
|
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||||
|
import com.cappielloantonio.play.repository.GenreRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GenreCatalogueViewModel extends AndroidViewModel {
|
||||||
|
private GenreRepository genreRepository;
|
||||||
|
|
||||||
|
private LiveData<List<Genre>> genreList;
|
||||||
|
|
||||||
|
public GenreCatalogueViewModel(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
|
||||||
|
genreRepository = new GenreRepository(application);
|
||||||
|
|
||||||
|
genreList = genreRepository.getListLiveGenres();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Genre>> getGenreList() {
|
||||||
|
return genreList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,41 +1,51 @@
|
||||||
package com.cappielloantonio.play.viewmodel;
|
package com.cappielloantonio.play.viewmodel;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
|
import com.cappielloantonio.play.repository.SongRepository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HomeViewModel extends ViewModel {
|
public class HomeViewModel extends AndroidViewModel {
|
||||||
|
private SongRepository songRepository;
|
||||||
|
|
||||||
public List<Song> getDiscoverSongList() {
|
private LiveData<List<Song>> dicoverSongSample;
|
||||||
List<Song> discover_songs = new ArrayList<>();
|
private LiveData<List<Song>> recentlyPlayedSongSample;
|
||||||
discover_songs.add(new Song("Holiday", "American Idiot"));
|
private LiveData<List<Song>> recentlyAddedSongSample;
|
||||||
discover_songs.add(new Song("Brioschi", "Stanza Singola"));
|
private LiveData<List<Song>> mostPlayedSongSample;
|
||||||
discover_songs.add(new Song("HappySad", "Ceri Singles"));
|
|
||||||
discover_songs.add(new Song("Falling back to Earth", "Haken"));
|
|
||||||
|
|
||||||
return discover_songs;
|
public HomeViewModel(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
|
||||||
|
songRepository = new SongRepository(application);
|
||||||
|
|
||||||
|
dicoverSongSample = songRepository.getListLiveDiscoverSampleSong();
|
||||||
|
recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong();
|
||||||
|
recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong();
|
||||||
|
mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Song> getRecentSongList() {
|
|
||||||
List<Song> recent_songs = new ArrayList<>();
|
|
||||||
recent_songs.add(new Song("Holiday", "American Idiot"));
|
|
||||||
recent_songs.add(new Song("Brioschi", "Stanza Singola"));
|
|
||||||
recent_songs.add(new Song("HappySad", "Ceri Singles"));
|
|
||||||
recent_songs.add(new Song("Falling back to Earth", "Haken"));
|
|
||||||
|
|
||||||
return recent_songs;
|
public LiveData<List<Song>> getDiscoverSongList() {
|
||||||
|
return dicoverSongSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Song> getMostPlayedSongList() {
|
public LiveData<List<Song>> getRecentlyAddedSongList() {
|
||||||
List<Song> most_played_songs = new ArrayList<>();
|
return recentlyAddedSongSample;
|
||||||
most_played_songs.add(new Song("Holiday", "American Idiot"));
|
}
|
||||||
most_played_songs.add(new Song("Brioschi", "Stanza Singola"));
|
|
||||||
most_played_songs.add(new Song("HappySad", "Ceri Singles"));
|
|
||||||
most_played_songs.add(new Song("Falling back to Earth", "Haken"));
|
|
||||||
|
|
||||||
return most_played_songs;
|
public LiveData<List<Song>> getRecentlyPlayedSongList() {
|
||||||
|
return recentlyPlayedSongSample;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Song>> getMostPlayedSongList() {
|
||||||
|
return mostPlayedSongSample;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,54 +10,53 @@ import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.model.Artist;
|
import com.cappielloantonio.play.model.Artist;
|
||||||
import com.cappielloantonio.play.model.Genre;
|
import com.cappielloantonio.play.model.Genre;
|
||||||
import com.cappielloantonio.play.model.Playlist;
|
import com.cappielloantonio.play.model.Playlist;
|
||||||
|
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||||
|
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||||
import com.cappielloantonio.play.repository.GenreRepository;
|
import com.cappielloantonio.play.repository.GenreRepository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LibraryViewModel extends AndroidViewModel {
|
public class LibraryViewModel extends AndroidViewModel {
|
||||||
|
private AlbumRepository albumRepository;
|
||||||
|
private ArtistRepository artistRepository;
|
||||||
private GenreRepository genreRepository;
|
private GenreRepository genreRepository;
|
||||||
|
|
||||||
|
private LiveData<List<Album>> sampleAlbum;
|
||||||
|
private LiveData<List<Artist>> sampleArtist;
|
||||||
|
private LiveData<List<Genre>> sampleGenres;
|
||||||
|
|
||||||
private LiveData<List<Genre>> allGenres;
|
private LiveData<List<Genre>> allGenres;
|
||||||
|
|
||||||
public LibraryViewModel(@NonNull Application application) {
|
public LibraryViewModel(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
|
|
||||||
|
albumRepository = new AlbumRepository(application);
|
||||||
|
artistRepository = new ArtistRepository(application);
|
||||||
genreRepository = new GenreRepository(application);
|
genreRepository = new GenreRepository(application);
|
||||||
allGenres = genreRepository.getListLiveGenres();
|
|
||||||
|
// Inizializzate all'interno del costruttore, in modo da rimanere immutabili per tutto il
|
||||||
|
// ciclo di vita dell'applicazione
|
||||||
|
sampleAlbum = albumRepository.getListLiveSampleAlbum();
|
||||||
|
sampleArtist = artistRepository.getListLiveSampleArtist();
|
||||||
|
sampleGenres = genreRepository.getListLiveSampleGenre();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Genre>> getGenreList() {
|
public LiveData<List<Genre>> getGenreList() {
|
||||||
|
allGenres = genreRepository.getListLiveGenres();
|
||||||
return allGenres;
|
return allGenres;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Album> getAlbumSample() {
|
public LiveData<List<Album>> getAlbumSample() {
|
||||||
ArrayList<Album> albums = new ArrayList<>();
|
return sampleAlbum;
|
||||||
albums.add(new Album("1", "aaaa", 1, "1", "qqqq", "", ""));
|
|
||||||
albums.add(new Album("2", "ssss", 1, "2", "wwww", "", ""));
|
|
||||||
albums.add(new Album("3", "dddd", 1, "3", "eeee", "", ""));
|
|
||||||
albums.add(new Album("4", "ffff", 1, "4", "rrrr", "", ""));
|
|
||||||
albums.add(new Album("5", "gggg", 1, "5", "tttt", "", ""));
|
|
||||||
albums.add(new Album("6", "hhhh", 1, "6", "yyyy", "", ""));
|
|
||||||
albums.add(new Album("7", "jjjj", 1, "7", "uuuu", "", ""));
|
|
||||||
albums.add(new Album("8", "kkkk", 1, "8", "iiii", "", ""));
|
|
||||||
albums.add(new Album("9", "llll", 1, "9", "oooo", "", ""));
|
|
||||||
|
|
||||||
return albums;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Artist> getArtistSample() {
|
public LiveData<List<Artist>> getArtistSample() {
|
||||||
ArrayList<Artist> artists = new ArrayList<>();
|
return sampleArtist;
|
||||||
artists.add(new Artist("1", "dhgr", "", ""));
|
}
|
||||||
artists.add(new Artist("2", "kdnu", "", ""));
|
|
||||||
artists.add(new Artist("3", "wfty", "", ""));
|
|
||||||
artists.add(new Artist("4", "hfds", "", ""));
|
|
||||||
artists.add(new Artist("5", "jgab", "", ""));
|
|
||||||
artists.add(new Artist("6", "iudg", "", ""));
|
|
||||||
artists.add(new Artist("7", "istr", "", ""));
|
|
||||||
artists.add(new Artist("8", "dger", "", ""));
|
|
||||||
artists.add(new Artist("9", "jhjk", "", ""));
|
|
||||||
|
|
||||||
return artists;
|
public LiveData<List<Genre>> getGenreSample() {
|
||||||
|
return sampleGenres;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Playlist> getPlaylist() {
|
public ArrayList<Playlist> getPlaylist() {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class SearchViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Song>> searchSong(String title) {
|
public LiveData<List<Song>> searchSong(String title) {
|
||||||
searchSong = songRepository.searchListLiveSongs(title);
|
searchSong = songRepository.searchListLiveSong(title);
|
||||||
return searchSong;
|
return searchSong;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
package com.cappielloantonio.play.viewmodel;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.lifecycle.AndroidViewModel;
|
|
||||||
import androidx.lifecycle.LiveData;
|
|
||||||
|
|
||||||
import com.cappielloantonio.play.model.Song;
|
|
||||||
import com.cappielloantonio.play.repository.SongRepository;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SongViewModel extends AndroidViewModel {
|
|
||||||
private SongRepository repository;
|
|
||||||
private LiveData<List<Song>> allSongs;
|
|
||||||
|
|
||||||
public SongViewModel(@NonNull Application application) {
|
|
||||||
super(application);
|
|
||||||
|
|
||||||
repository = new SongRepository(application);
|
|
||||||
allSongs = repository.getListLiveSongs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean exist(Song song) {
|
|
||||||
return repository.exist(song);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insert(Song song) {
|
|
||||||
repository.insert(song);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete(Song song) {
|
|
||||||
repository.delete(song);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<List<Song>> getAllSongs() {
|
|
||||||
return allSongs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
57
app/src/main/res/layout/fragment_album_catalogue.xml
Normal file
57
app/src/main/res/layout/fragment_album_catalogue.xml
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading_progress_bar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:minWidth="128dp"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:id="@+id/album_catalogue_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="Album Catalogue"
|
||||||
|
android:textColor="@color/titleTextColor"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/album_catalogue_recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
57
app/src/main/res/layout/fragment_artist_catalogue.xml
Normal file
57
app/src/main/res/layout/fragment_artist_catalogue.xml
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading_progress_bar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:minWidth="128dp"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:id="@+id/artist_catalogue_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="Artist Catalogue"
|
||||||
|
android:textColor="@color/titleTextColor"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/artist_catalogue_recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
@ -35,5 +35,4 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:singleSelection="false" />
|
app:singleSelection="false" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
57
app/src/main/res/layout/fragment_genre_catalogue.xml
Normal file
57
app/src/main/res/layout/fragment_genre_catalogue.xml
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading_progress_bar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:minWidth="128dp"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:id="@+id/genre_catalogue_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="Genre Catalogue"
|
||||||
|
android:textColor="@color/titleTextColor"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/genre_catalogue_recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recently_played_tracks_recycler_view"
|
android:id="@+id/recently_played_tracks_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
|
@ -167,7 +167,7 @@
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/most_played_tracks_recycler_view"
|
android:id="@+id/most_played_tracks_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/album_catalogue_text_view_clickable"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
|
@ -109,6 +110,7 @@
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/artist_catalogue_text_view_clickable"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
|
@ -171,6 +173,7 @@
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/genre_catalogue_text_view_clickable"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="156dp">
|
android:layout_height="172dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title_discover_song_label"
|
android:id="@+id/title_discover_song_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginTop="18dp"
|
android:layout_marginTop="18dp"
|
||||||
android:text="@string/label_placeholder"
|
android:text="@string/label_placeholder"
|
||||||
android:textColor="@color/titleTextColor"
|
android:textColor="@color/titleTextColor"
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="180dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingEnd="8dp">
|
android:paddingEnd="8dp">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/card_view"
|
android:id="@+id/card_view"
|
||||||
android:layout_width="156dp"
|
android:layout_width="172dp"
|
||||||
android:layout_height="156dp"
|
android:layout_height="172dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:backgroundTint="@color/cardColor"
|
android:backgroundTint="@color/cardColor"
|
||||||
card_view:cardCornerRadius="4dp"
|
card_view:cardCornerRadius="4dp"
|
||||||
|
|
@ -21,9 +21,10 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:text="@string/label_placeholder"
|
android:singleLine="false"
|
||||||
android:textColor="@color/titleTextColor"
|
android:textColor="@color/titleTextColor"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
@ -34,7 +35,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:text="@string/label_placeholder"
|
|
||||||
android:textColor="@color/titleTextColor"
|
android:textColor="@color/titleTextColor"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/card_view"
|
android:id="@+id/card_view"
|
||||||
android:layout_width="156dp"
|
android:layout_width="172dp"
|
||||||
android:layout_height="156dp"
|
android:layout_height="172dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:backgroundTint="@color/cardColor"
|
android:backgroundTint="@color/cardColor"
|
||||||
card_view:cardCornerRadius="4dp"
|
card_view:cardCornerRadius="4dp"
|
||||||
|
|
@ -21,8 +21,10 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
|
android:singleLine="false"
|
||||||
android:text="@string/label_placeholder"
|
android:text="@string/label_placeholder"
|
||||||
android:textColor="@color/titleTextColor"
|
android:textColor="@color/titleTextColor"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
|
@ -33,7 +35,9 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
|
android:singleLine="false"
|
||||||
android:text="@string/label_placeholder"
|
android:text="@string/label_placeholder"
|
||||||
android:textColor="@color/titleTextColor"
|
android:textColor="@color/titleTextColor"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/card_view"
|
android:id="@+id/card_view"
|
||||||
android:layout_width="156dp"
|
android:layout_width="172dp"
|
||||||
android:layout_height="156dp"
|
android:layout_height="172dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:backgroundTint="@color/cardColor"
|
android:backgroundTint="@color/cardColor"
|
||||||
card_view:cardCornerRadius="4dp"
|
card_view:cardCornerRadius="4dp"
|
||||||
|
|
@ -21,8 +21,10 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/open_sans_font_family"
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
|
android:singleLine="false"
|
||||||
android:text="@string/label_placeholder"
|
android:text="@string/label_placeholder"
|
||||||
android:textColor="@color/titleTextColor"
|
android:textColor="@color/titleTextColor"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
|
|
||||||
52
app/src/main/res/layout/item_library_catalogue_album.xml
Normal file
52
app/src/main/res/layout/item_library_catalogue_album.xml
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/card_view"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:backgroundTint="@color/cardColor"
|
||||||
|
app:layout_constraintDimensionRatio="W, 1:1"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
card_view:cardCornerRadius="4dp"
|
||||||
|
card_view:cardElevation="2dp"
|
||||||
|
card_view:cardPreventCornerOverlap="false"
|
||||||
|
card_view:cardUseCompatPadding="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/album_name_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:singleLine="false"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:textColor="@color/titleTextColor"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/card_view" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/artist_name_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:singleLine="false"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:textColor="@color/subtitleTextColor"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/album_name_label" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
38
app/src/main/res/layout/item_library_catalogue_artist.xml
Normal file
38
app/src/main/res/layout/item_library_catalogue_artist.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/card_view"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:backgroundTint="@color/cardColor"
|
||||||
|
app:layout_constraintDimensionRatio="W, 1:1"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
card_view:cardCornerRadius="4dp"
|
||||||
|
card_view:cardElevation="2dp"
|
||||||
|
card_view:cardPreventCornerOverlap="false"
|
||||||
|
card_view:cardUseCompatPadding="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/artist_name_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:maxWidth="172dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:singleLine="false"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:textColor="@color/titleTextColor"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/card_view" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
44
app/src/main/res/layout/item_library_catalogue_genre.xml
Normal file
44
app/src/main/res/layout/item_library_catalogue_genre.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="54dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginBottom="4dp">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/card_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:backgroundTint="@color/cardColor"
|
||||||
|
card_view:cardCornerRadius="4dp"
|
||||||
|
card_view:cardElevation="2dp"
|
||||||
|
card_view:cardPreventCornerOverlap="false"
|
||||||
|
card_view:cardUseCompatPadding="true">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="6dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/colorAccent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/genre_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fontFamily="@font/open_sans_font_family"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:textAlignment="gravity"
|
||||||
|
android:textColor="@color/titleTextColor"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -6,9 +6,10 @@
|
||||||
android:paddingEnd="12dp"
|
android:paddingEnd="12dp"
|
||||||
android:paddingBottom="8dp">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
<androidx.cardview.widget.CardView
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/card_view"
|
android:id="@+id/card_view"
|
||||||
android:layout_width="172dp"
|
android:layout_width="196dp"
|
||||||
android:layout_height="54dp"
|
android:layout_height="54dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:backgroundTint="@color/cardColor"
|
android:backgroundTint="@color/cardColor"
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,17 @@
|
||||||
android:id="@+id/libraryFragment"
|
android:id="@+id/libraryFragment"
|
||||||
android:name="com.cappielloantonio.play.ui.fragment.LibraryFragment"
|
android:name="com.cappielloantonio.play.ui.fragment.LibraryFragment"
|
||||||
android:label="LibraryFragment"
|
android:label="LibraryFragment"
|
||||||
tools:layout="@layout/fragment_library"/>
|
tools:layout="@layout/fragment_library">
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_libraryFragment_to_artistCatalogueFragment"
|
||||||
|
app:destination="@id/artistCatalogueFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_libraryFragment_to_albumCatalogueFragment"
|
||||||
|
app:destination="@id/albumCatalogueFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_libraryFragment_to_genreCatalogueFragment"
|
||||||
|
app:destination="@id/genreCatalogueFragment" />
|
||||||
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/settingsFragment"
|
android:id="@+id/settingsFragment"
|
||||||
android:name="com.cappielloantonio.play.ui.fragment.SettingsFragment"
|
android:name="com.cappielloantonio.play.ui.fragment.SettingsFragment"
|
||||||
|
|
@ -84,12 +94,26 @@
|
||||||
tools:layout="@layout/fragment_search">
|
tools:layout="@layout/fragment_search">
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_searchFragment_to_filterFragment"
|
android:id="@+id/action_searchFragment_to_filterFragment"
|
||||||
app:destination="@id/filterFragment"
|
app:destination="@id/filterFragment" />
|
||||||
app:launchSingleTop="true" />
|
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/filterFragment"
|
android:id="@+id/filterFragment"
|
||||||
android:name="com.cappielloantonio.play.ui.fragment.FilterFragment"
|
android:name="com.cappielloantonio.play.ui.fragment.FilterFragment"
|
||||||
android:label="FilterFragment"
|
android:label="FilterFragment"
|
||||||
tools:layout="@layout/fragment_filter" />
|
tools:layout="@layout/fragment_filter" />
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/artistCatalogueFragment"
|
||||||
|
android:name="com.cappielloantonio.play.ui.fragment.ArtistCatalogueFragment"
|
||||||
|
android:label="ArtistCatalogueFragment"
|
||||||
|
tools:layout="@layout/fragment_artist_catalogue"/>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/albumCatalogueFragment"
|
||||||
|
android:name="com.cappielloantonio.play.ui.fragment.AlbumCatalogueFragment"
|
||||||
|
android:label="AlbumCatalogueFragment"
|
||||||
|
tools:layout="@layout/fragment_album_catalogue"/>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/genreCatalogueFragment"
|
||||||
|
android:name="com.cappielloantonio.play.ui.fragment.GenreCatalogueFragment"
|
||||||
|
android:label="GenreCatalogueFragment"
|
||||||
|
tools:layout="@layout/fragment_genre_catalogue"/>
|
||||||
</navigation>
|
</navigation>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue