Adapters refactoring

This commit is contained in:
Antonio Cappiello 2020-11-28 14:50:15 +01:00
parent 18fae806a6
commit ae23d268cd
34 changed files with 341 additions and 100 deletions

View file

@ -54,6 +54,7 @@ dependencies {
implementation "androidx.room:room-runtime:2.2.5" implementation "androidx.room:room-runtime:2.2.5"
implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.paging:paging-runtime:2.1.2'
// Android Material // Android Material
implementation 'com.google.android.material:material:1.2.1' implementation 'com.google.android.material:material:1.2.1'

View file

@ -16,21 +16,21 @@ import com.cappielloantonio.play.model.Album;
import java.util.List; import java.util.List;
public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder> { public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder> {
private static final String TAG = "RecentMusicAdapter"; private static final String TAG = "AlbumAdapter";
private List<Album> albums; private List<Album> albums;
private LayoutInflater mInflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public AlbumAdapter(Context context, List<Album> albums) { public AlbumAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.albums = albums;
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_library_album, parent, false); View view = inflater.inflate(R.layout.item_library_album, parent, false);
return new ViewHolder(view); return new ViewHolder(view);
} }
@ -69,7 +69,8 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition()); if (itemClickListener != null)
itemClickListener.onItemClick(view, getAdapterPosition());
} }
} }

View file

@ -17,20 +17,20 @@ import java.util.List;
public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPageAdapter.ViewHolder> { public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPageAdapter.ViewHolder> {
private static final String TAG = "AlbumArtistPageAdapter"; private static final String TAG = "AlbumArtistPageAdapter";
private List<Album> albums; private List<Album> albums;
private LayoutInflater mInflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public AlbumArtistPageAdapter(Context context, List<Album> albums) { public AlbumArtistPageAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.albums = albums;
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_artist_page_album, parent, false); View view = inflater.inflate(R.layout.item_artist_page_album, parent, false);
return new ViewHolder(view); return new ViewHolder(view);
} }

View file

@ -16,21 +16,21 @@ import com.cappielloantonio.play.model.Album;
import java.util.List; import java.util.List;
public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAdapter.ViewHolder> { public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAdapter.ViewHolder> {
private static final String TAG = "AlbumAdapter"; private static final String TAG = "AlbumCatalogueAdapter";
private List<Album> albums; private List<Album> albums;
private LayoutInflater mInflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public AlbumCatalogueAdapter(Context context, List<Album> albums) { public AlbumCatalogueAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.albums = albums;
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_library_catalogue_album, parent, false); View view = inflater.inflate(R.layout.item_library_catalogue_album, parent, false);
return new ViewHolder(view); return new ViewHolder(view);
} }
@ -70,7 +70,8 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition()); if (itemClickListener != null)
itemClickListener.onItemClick(view, getAdapterPosition());
} }
} }

View file

@ -17,20 +17,20 @@ import java.util.List;
public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder> { public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder> {
private static final String TAG = "ArtistAdapter"; private static final String TAG = "ArtistAdapter";
private List<Artist> artists; private List<Artist> artists;
private LayoutInflater mInflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public ArtistAdapter(Context context, List<Artist> artists) { public ArtistAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.artists = artists;
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_library_artist, parent, false); View view = inflater.inflate(R.layout.item_library_artist, parent, false);
return new ViewHolder(view); return new ViewHolder(view);
} }

View file

@ -16,21 +16,21 @@ import com.cappielloantonio.play.model.Artist;
import java.util.List; import java.util.List;
public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> { public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> {
private static final String TAG = "ArtistAdapter"; private static final String TAG = "ArtistCatalogueAdapter";
private List<Artist> artists; private List<Artist> artists;
private LayoutInflater mInflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public ArtistCatalogueAdapter(Context context, List<Artist> artists) { public ArtistCatalogueAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.artists = artists;
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_library_catalogue_artist, parent, false); View view = inflater.inflate(R.layout.item_library_catalogue_artist, parent, false);
return new ViewHolder(view); return new ViewHolder(view);
} }

View file

@ -21,18 +21,18 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
private static final String TAG = "DiscoverSongAdapter"; private static final String TAG = "DiscoverSongAdapter";
private List<Song> songs; private List<Song> songs;
private LayoutInflater layoutInflater; private LayoutInflater inflater;
private Context context; private Context context;
public DiscoverSongAdapter(Context context, List<Song> songs) { public DiscoverSongAdapter(Context context, List<Song> songs) {
this.context = context; this.context = context;
this.layoutInflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.songs = songs; this.songs = songs;
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = layoutInflater.inflate(R.layout.item_home_discover_song, parent, false); View view = inflater.inflate(R.layout.item_home_discover_song, parent, false);
return new ViewHolder(view); return new ViewHolder(view);
} }

View file

@ -15,18 +15,17 @@ import java.util.List;
public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder> { public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder> {
private static final String TAG = "GenreAdapter"; private static final String TAG = "GenreAdapter";
private List<Genre> genres; private List<Genre> genres;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public GenreAdapter(Context context, List<Genre> genres) { public GenreAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.genres = genres;
} }
// inflates the row layout from xml when needed
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_library_genre, parent, false); View view = mInflater.inflate(R.layout.item_library_genre, parent, false);
@ -58,7 +57,8 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition()); if (itemClickListener != null)
itemClickListener.onItemClick(view, getAdapterPosition());
} }
} }

View file

@ -1,7 +1,6 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Parcelable;
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,16 +14,16 @@ import com.cappielloantonio.play.model.Genre;
import java.util.List; import java.util.List;
public class GenreCatalogueAdapter extends RecyclerView.Adapter<GenreCatalogueAdapter.ViewHolder> { public class GenreCatalogueAdapter extends RecyclerView.Adapter<GenreCatalogueAdapter.ViewHolder> {
private static final String TAG = "GenreAdapter"; private static final String TAG = "GenreCatalogueAdapter";
private List<Genre> genres; private List<Genre> genres;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public GenreCatalogueAdapter(Context context, List<Genre> genres) { public GenreCatalogueAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.genres = genres;
} }
// inflates the row layout from xml when needed // inflates the row layout from xml when needed

View file

@ -9,22 +9,21 @@ 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.Playlist; import com.cappielloantonio.play.model.Playlist;
import java.util.List; import java.util.List;
public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHolder> { public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHolder> {
private static final String TAG = "PlaylistAdapter"; private static final String TAG = "PlaylistAdapter";
private List<Playlist> playlists; private List<Playlist> playlists;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public PlaylistAdapter(Context context, List<Playlist> playlists) { public PlaylistAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.playlists = playlists;
} }
@Override @Override
@ -58,7 +57,8 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition()); if (itemClickListener != null)
itemClickListener.onItemClick(view, getAdapterPosition());
} }
} }

View file

@ -22,14 +22,14 @@ import java.util.List;
*/ */
public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.ViewHolder> { public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.ViewHolder> {
private static final String TAG = "RecentMusicAdapter"; private static final String TAG = "RecentMusicAdapter";
private List<Song> songs; private List<Song> songs;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
public RecentMusicAdapter(Context context, List<Song> songs) { public RecentMusicAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.songs = songs;
} }
@Override @Override
@ -46,7 +46,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
holder.textAlbum.setText(song.getAlbumName()); holder.textAlbum.setText(song.getAlbumName());
CustomGlideRequest.Builder CustomGlideRequest.Builder
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY) .from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
.build() .build()
.into(holder.cover); .into(holder.cover);
} }

View file

@ -9,22 +9,21 @@ 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.Playlist;
import com.cappielloantonio.play.model.RecentSearch; import com.cappielloantonio.play.model.RecentSearch;
import java.util.List; import java.util.List;
public class RecentSearchAdapter extends RecyclerView.Adapter<RecentSearchAdapter.ViewHolder> { public class RecentSearchAdapter extends RecyclerView.Adapter<RecentSearchAdapter.ViewHolder> {
private static final String TAG = "GenreAdapter"; private static final String TAG = "RecentSearchAdapter";
private List<RecentSearch> searches; private List<RecentSearch> searches;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public RecentSearchAdapter(Context context, List<RecentSearch> searches) { public RecentSearchAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.searches = searches;
} }
@Override @Override

View file

@ -23,14 +23,14 @@ import java.util.List;
*/ */
public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSearchAdapter.ViewHolder> { public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSearchAdapter.ViewHolder> {
private static final String TAG = "SongResultSearchAdapter"; private static final String TAG = "SongResultSearchAdapter";
private List<Song> songs; private List<Song> songs;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
public SongResultSearchAdapter(Context context, List<Song> songs) { public SongResultSearchAdapter(Context context) {
this.context = context; this.context = context;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.songs = songs;
} }
@Override @Override
@ -48,7 +48,7 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
holder.songDuration.setText(Util.getReadableDurationString(song.getDuration())); holder.songDuration.setText(Util.getReadableDurationString(song.getDuration()));
CustomGlideRequest.Builder CustomGlideRequest.Builder
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY) .from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
.build() .build()
.into(holder.cover); .into(holder.cover);
} }

View file

@ -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 java.util.List;
public class YearAdapter extends RecyclerView.Adapter<YearAdapter.ViewHolder> {
private static final String TAG = "YearAdapter";
private List<Integer> years;
private LayoutInflater mInflater;
private Context context;
private ItemClickListener itemClickListener;
public YearAdapter(Context context, List<Integer> years) {
this.context = context;
this.mInflater = LayoutInflater.from(context);
this.years = years;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.item_home_year, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
int year = years.get(position);
holder.textYear.setText(Integer.toString(year));
}
@Override
public int getItemCount() {
return years.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView textYear;
ViewHolder(View itemView) {
super(itemView);
textYear = itemView.findViewById(R.id.year_label);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
}
}
public Integer getItem(int position) {
return years.get(position);
}
public void setItems(List<Integer> years) {
this.years = years;
notifyDataSetChanged();
}
public void setClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
}

View file

@ -24,9 +24,6 @@ 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 added DESC LIMIT :number") @Query("SELECT * FROM song ORDER BY added DESC LIMIT :number")
LiveData<List<Song>> getRecentlyAddedSample(int number); LiveData<List<Song>> getRecentlyAddedSample(int number);
@ -74,4 +71,10 @@ public interface SongDao {
@Query("SELECT title FROM song WHERE title LIKE :query || '%' OR title like '% ' || :query || '%' GROUP BY title LIMIT :number") @Query("SELECT title FROM song WHERE title LIKE :query || '%' OR title like '% ' || :query || '%' GROUP BY title LIMIT :number")
List<String> searchSuggestions(String query, int number); List<String> searchSuggestions(String query, int number);
@Query("SELECT year FROM song WHERE year != 0 GROUP BY year")
List<Integer> getYearList();
@Query("SELECT * FROM song WHERE year = :year")
LiveData<List<Song>> getSongsByYear(int year);
} }

View file

@ -93,14 +93,14 @@ public class CustomGlideRequest {
break; break;
} }
case MEDIUM_QUALITY: { case MEDIUM_QUALITY: {
options.setQuality(80); options.setQuality(100);
options.setMaxHeight(500); options.setMaxHeight(600);
options.setEnableImageEnhancers(true); options.setEnableImageEnhancers(true);
break; break;
} }
case LOW_QUALITY: { case LOW_QUALITY: {
options.setQuality(60); options.setQuality(100);
options.setMaxHeight(300); options.setMaxHeight(400);
options.setEnableImageEnhancers(true); options.setEnableImageEnhancers(true);
break; break;
} }

View file

@ -37,6 +37,9 @@ public class Song implements Parcelable {
@Ignore @Ignore
public static final String BY_ARTIST = "BY_ARTIST"; public static final String BY_ARTIST = "BY_ARTIST";
@Ignore
public static final String BY_YEAR = "BY_YEAR";
@NonNull @NonNull
@PrimaryKey @PrimaryKey
@ColumnInfo(name = "id") @ColumnInfo(name = "id")

View file

@ -24,6 +24,7 @@ public class SongRepository {
private LiveData<List<Song>> listLiveAlbumSongs; private LiveData<List<Song>> listLiveAlbumSongs;
private LiveData<List<Song>> listLiveSongByGenre; private LiveData<List<Song>> listLiveSongByGenre;
private LiveData<List<Song>> listLiveFilteredSongs; private LiveData<List<Song>> listLiveFilteredSongs;
private LiveData<List<Song>> listLiveSongByYear;
public SongRepository(Application application) { public SongRepository(Application application) {
@ -115,6 +116,28 @@ public class SongRepository {
return catalogue; return catalogue;
} }
public List<Integer> getYearList() {
List<Integer> years = new ArrayList<>();
GetYearListThreadSafe getYearListThreadSafe = new GetYearListThreadSafe(songDao);
Thread thread = new Thread(getYearListThreadSafe);
thread.start();
try {
thread.join();
years = getYearListThreadSafe.getYearList();
} catch (InterruptedException e) {
e.printStackTrace();
}
return years;
}
public LiveData<List<Song>> getSongByYearListLive(int year) {
listLiveSongByYear = songDao.getSongsByYear(year);
return listLiveSongByYear;
}
public boolean exist(Song song) { public boolean exist(Song song) {
boolean exist = false; boolean exist = false;
@ -383,4 +406,33 @@ public class SongRepository {
songGenreCrossDao.deleteAll(); songGenreCrossDao.deleteAll();
} }
} }
private static class GetYearListThreadSafe implements Runnable {
private SongDao songDao;
private List<Integer> years = new ArrayList<>();
private List<Integer> decades = new ArrayList<>();
public GetYearListThreadSafe(SongDao songDao) {
this.songDao = songDao;
}
@Override
public void run() {
years = songDao.getYearList();
for(int year : years) {
if(!decades.contains(year - year % 10)) {
decades.add(year);
}
}
}
public List<Integer> getYearList() {
return years;
}
public List<Integer> getDecadeList() {
return decades;
}
}
} }

View file

@ -16,8 +16,6 @@ import com.cappielloantonio.play.helper.recyclerview.ItemDecoration;
import com.cappielloantonio.play.ui.activities.MainActivity; import com.cappielloantonio.play.ui.activities.MainActivity;
import com.cappielloantonio.play.viewmodel.AlbumCatalogueViewModel; import com.cappielloantonio.play.viewmodel.AlbumCatalogueViewModel;
import java.util.ArrayList;
public class AlbumCatalogueFragment extends Fragment { public class AlbumCatalogueFragment extends Fragment {
private static final String TAG = "ArtistCatalogueFragment"; private static final String TAG = "ArtistCatalogueFragment";
@ -51,7 +49,7 @@ public class AlbumCatalogueFragment extends Fragment {
bind.albumCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.albumCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false));
bind.albumCatalogueRecyclerView.setHasFixedSize(true); bind.albumCatalogueRecyclerView.setHasFixedSize(true);
albumAdapter = new AlbumCatalogueAdapter(requireContext(), new ArrayList<>()); albumAdapter = new AlbumCatalogueAdapter(requireContext());
albumAdapter.setClickListener((view, position) -> { albumAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumAdapter.getItem(position)); bundle.putParcelable("album_object", albumAdapter.getItem(position));

View file

@ -16,8 +16,6 @@ import com.cappielloantonio.play.helper.recyclerview.ItemDecoration;
import com.cappielloantonio.play.ui.activities.MainActivity; import com.cappielloantonio.play.ui.activities.MainActivity;
import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel; import com.cappielloantonio.play.viewmodel.ArtistCatalogueViewModel;
import java.util.ArrayList;
public class ArtistCatalogueFragment extends Fragment { public class ArtistCatalogueFragment extends Fragment {
private static final String TAG = "ArtistCatalogueFragment"; private static final String TAG = "ArtistCatalogueFragment";
@ -51,7 +49,7 @@ public class ArtistCatalogueFragment extends Fragment {
bind.artistCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.artistCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false));
bind.artistCatalogueRecyclerView.setHasFixedSize(true); bind.artistCatalogueRecyclerView.setHasFixedSize(true);
artistAdapter = new ArtistCatalogueAdapter(requireContext(), new ArrayList<>()); artistAdapter = new ArtistCatalogueAdapter(requireContext());
artistAdapter.setClickListener((view, position) -> { artistAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artistAdapter.getItem(position)); bundle.putParcelable("artist_object", artistAdapter.getItem(position));

View file

@ -83,7 +83,7 @@ public class ArtistPageFragment extends Fragment {
bind.albumsRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)); bind.albumsRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
bind.albumsRecyclerView.setHasFixedSize(true); bind.albumsRecyclerView.setHasFixedSize(true);
albumArtistPageAdapter = new AlbumArtistPageAdapter(requireContext(), new ArrayList<>()); albumArtistPageAdapter = new AlbumArtistPageAdapter(requireContext());
albumArtistPageAdapter.setClickListener((view, position) -> { albumArtistPageAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumArtistPageAdapter.getItem(position)); bundle.putParcelable("album_object", albumArtistPageAdapter.getItem(position));

View file

@ -17,8 +17,6 @@ import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.ui.activities.MainActivity; import com.cappielloantonio.play.ui.activities.MainActivity;
import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel; import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel;
import java.util.ArrayList;
public class GenreCatalogueFragment extends Fragment { public class GenreCatalogueFragment extends Fragment {
private static final String TAG = "GenreCatalogueFragment";; private static final String TAG = "GenreCatalogueFragment";;
@ -57,7 +55,7 @@ public class GenreCatalogueFragment extends Fragment {
bind.genreCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 16, false)); bind.genreCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 16, false));
bind.genreCatalogueRecyclerView.setHasFixedSize(true); bind.genreCatalogueRecyclerView.setHasFixedSize(true);
genreCatalogueAdapter = new GenreCatalogueAdapter(requireContext(), new ArrayList<>()); genreCatalogueAdapter = new GenreCatalogueAdapter(requireContext());
genreCatalogueAdapter.setClickListener((view, position) -> { genreCatalogueAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Song.BY_GENRE, Song.BY_GENRE); bundle.putString(Song.BY_GENRE, Song.BY_GENRE);

View file

@ -16,14 +16,13 @@ import androidx.viewpager2.widget.ViewPager2;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
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.adapter.YearAdapter;
import com.cappielloantonio.play.databinding.FragmentHomeBinding; import com.cappielloantonio.play.databinding.FragmentHomeBinding;
import com.cappielloantonio.play.model.Song; 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;
public class HomeFragment extends Fragment { public class HomeFragment extends Fragment {
private static final String TAG = "CategoriesFragment"; private static final String TAG = "CategoriesFragment";
@ -33,6 +32,7 @@ public class HomeFragment extends Fragment {
private DiscoverSongAdapter discoverSongAdapter; private DiscoverSongAdapter discoverSongAdapter;
private RecentMusicAdapter recentlyAddedMusicAdapter; private RecentMusicAdapter recentlyAddedMusicAdapter;
private YearAdapter yearAdapter;
private RecentMusicAdapter recentlyPlayedMusicAdapter; private RecentMusicAdapter recentlyPlayedMusicAdapter;
private RecentMusicAdapter mostPlayedMusicAdapter; private RecentMusicAdapter mostPlayedMusicAdapter;
@ -48,6 +48,7 @@ public class HomeFragment extends Fragment {
init(); init();
initDiscoverSongSlideView(); initDiscoverSongSlideView();
initRecentAddedSongView(); initRecentAddedSongView();
initYearSongView();
initRecentPlayedSongView(); initRecentPlayedSongView();
initMostPlayedSongView(); initMostPlayedSongView();
@ -99,16 +100,30 @@ public class HomeFragment extends Fragment {
bind.recentlyAddedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)); bind.recentlyAddedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
bind.recentlyAddedTracksRecyclerView.setHasFixedSize(true); bind.recentlyAddedTracksRecyclerView.setHasFixedSize(true);
recentlyAddedMusicAdapter = new RecentMusicAdapter(requireContext(), new ArrayList<>()); recentlyAddedMusicAdapter = new RecentMusicAdapter(requireContext());
bind.recentlyAddedTracksRecyclerView.setAdapter(recentlyAddedMusicAdapter); bind.recentlyAddedTracksRecyclerView.setAdapter(recentlyAddedMusicAdapter);
homeViewModel.getRecentlyAddedSongList().observe(requireActivity(), songs -> recentlyAddedMusicAdapter.setItems(songs)); homeViewModel.getRecentlyAddedSongList().observe(requireActivity(), songs -> recentlyAddedMusicAdapter.setItems(songs));
} }
private void initYearSongView() {
bind.yearsRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
bind.yearsRecyclerView.setHasFixedSize(true);
yearAdapter = new YearAdapter(requireContext(), homeViewModel.getYearList());
yearAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putString(Song.BY_YEAR, Song.BY_YEAR);
bundle.putInt("year_object", yearAdapter.getItem(position));
activity.navController.navigate(R.id.action_homeFragment_to_songListPageFragment, bundle);
});
bind.yearsRecyclerView.setAdapter(yearAdapter);
}
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);
recentlyPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), new ArrayList<>()); recentlyPlayedMusicAdapter = new RecentMusicAdapter(requireContext());
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyPlayedMusicAdapter); bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyPlayedMusicAdapter);
homeViewModel.getRecentlyPlayedSongList().observe(requireActivity(), songs -> recentlyPlayedMusicAdapter.setItems(songs)); homeViewModel.getRecentlyPlayedSongList().observe(requireActivity(), songs -> recentlyPlayedMusicAdapter.setItems(songs));
} }
@ -117,7 +132,7 @@ public class HomeFragment extends Fragment {
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(), new ArrayList<>()); mostPlayedMusicAdapter = new RecentMusicAdapter(requireContext());
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter); bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs)); homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs));
} }

View file

@ -25,8 +25,6 @@ import com.cappielloantonio.play.ui.activities.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil; import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.viewmodel.LibraryViewModel; import com.cappielloantonio.play.viewmodel.LibraryViewModel;
import java.util.ArrayList;
public class LibraryFragment extends Fragment { public class LibraryFragment extends Fragment {
private static final String TAG = "LibraryFragment"; private static final String TAG = "LibraryFragment";
@ -75,7 +73,7 @@ public class LibraryFragment extends Fragment {
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(), new ArrayList<>()); albumAdapter = new AlbumAdapter(requireContext());
albumAdapter.setClickListener((view, position) -> { albumAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumAdapter.getItem(position)); bundle.putParcelable("album_object", albumAdapter.getItem(position));
@ -89,7 +87,7 @@ public class LibraryFragment extends Fragment {
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(), new ArrayList<>()); artistAdapter = new ArtistAdapter(requireContext());
artistAdapter.setClickListener((view, position) -> { artistAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artistAdapter.getItem(position)); bundle.putParcelable("artist_object", artistAdapter.getItem(position));
@ -103,7 +101,7 @@ public class LibraryFragment extends Fragment {
bind.genreRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 3, GridLayoutManager.HORIZONTAL, false)); bind.genreRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 3, GridLayoutManager.HORIZONTAL, false));
bind.genreRecyclerView.setHasFixedSize(true); bind.genreRecyclerView.setHasFixedSize(true);
genreAdapter = new GenreAdapter(requireContext(), new ArrayList<>()); genreAdapter = new GenreAdapter(requireContext());
genreAdapter.setClickListener((view, position) -> { genreAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Song.BY_GENRE, Song.BY_GENRE); bundle.putString(Song.BY_GENRE, Song.BY_GENRE);
@ -118,7 +116,7 @@ public class LibraryFragment extends Fragment {
bind.playlistRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); bind.playlistRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
bind.playlistRecyclerView.setHasFixedSize(true); bind.playlistRecyclerView.setHasFixedSize(true);
playlistAdapter = new PlaylistAdapter(requireContext(), new ArrayList<>()); playlistAdapter = new PlaylistAdapter(requireContext());
playlistAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Playlist: " + position, Toast.LENGTH_SHORT).show()); playlistAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Playlist: " + position, Toast.LENGTH_SHORT).show());
bind.playlistRecyclerView.setAdapter(playlistAdapter); bind.playlistRecyclerView.setAdapter(playlistAdapter);
libraryViewModel.getPlaylistList().observe(requireActivity(), playlists -> playlistAdapter.setItems(playlists)); libraryViewModel.getPlaylistList().observe(requireActivity(), playlists -> playlistAdapter.setItems(playlists));

View file

@ -72,7 +72,7 @@ public class SearchFragment extends Fragment {
bind.recentlySearchedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext())); bind.recentlySearchedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
bind.recentlySearchedTracksRecyclerView.setHasFixedSize(true); bind.recentlySearchedTracksRecyclerView.setHasFixedSize(true);
recentSearchAdapter = new RecentSearchAdapter(requireContext(), new ArrayList<>()); recentSearchAdapter = new RecentSearchAdapter(requireContext());
recentSearchAdapter.setClickListener((view, position) -> { recentSearchAdapter.setClickListener((view, position) -> {
RecentSearch search = recentSearchAdapter.getItem(position); RecentSearch search = recentSearchAdapter.getItem(position);
search(search.getSearch()); search(search.getSearch());
@ -95,7 +95,7 @@ public class SearchFragment extends Fragment {
bind.searchResultAlbumRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.searchResultAlbumRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false));
bind.searchResultAlbumRecyclerView.setHasFixedSize(true); bind.searchResultAlbumRecyclerView.setHasFixedSize(true);
albumResultSearchAdapter = new AlbumCatalogueAdapter(requireContext(), new ArrayList<>()); albumResultSearchAdapter = new AlbumCatalogueAdapter(requireContext());
albumResultSearchAdapter.setClickListener((view, position) -> { albumResultSearchAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumResultSearchAdapter.getItem(position)); bundle.putParcelable("album_object", albumResultSearchAdapter.getItem(position));
@ -108,7 +108,7 @@ public class SearchFragment extends Fragment {
bind.searchResultArtistRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.searchResultArtistRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false));
bind.searchResultArtistRecyclerView.setHasFixedSize(true); bind.searchResultArtistRecyclerView.setHasFixedSize(true);
artistResultSearchAdapter = new ArtistCatalogueAdapter(requireContext(), new ArrayList<>()); artistResultSearchAdapter = new ArtistCatalogueAdapter(requireContext());
artistResultSearchAdapter.setClickListener((view, position) -> { artistResultSearchAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artistResultSearchAdapter.getItem(position)); bundle.putParcelable("artist_object", artistResultSearchAdapter.getItem(position));

View file

@ -74,6 +74,11 @@ public class SongListPageFragment extends Fragment {
songListPageViewModel.filterNames = getArguments().getStringArrayList("filter_name_list"); songListPageViewModel.filterNames = getArguments().getStringArrayList("filter_name_list");
bind.pageTitleLabel.setText(songListPageViewModel.getFiltersTitle()); bind.pageTitleLabel.setText(songListPageViewModel.getFiltersTitle());
} }
else if(getArguments().getString(Song.BY_YEAR) != null) {
songListPageViewModel.title = Song.BY_YEAR;
songListPageViewModel.year = getArguments().getInt("year_object");
bind.pageTitleLabel.setText("Year " + songListPageViewModel.year);
}
} }
private void initSongListView() { private void initSongListView() {

View file

@ -7,16 +7,13 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.repository.AlbumRepository; import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.repository.ArtistRepository;
import java.util.List; import java.util.List;
public class AlbumCatalogueViewModel extends AndroidViewModel { public class AlbumCatalogueViewModel extends AndroidViewModel {
private AlbumRepository albumRepository; private AlbumRepository albumRepository;
public LiveData<List<Album>> albumList;
private LiveData<List<Album>> albumList;
public AlbumCatalogueViewModel(@NonNull Application application) { public AlbumCatalogueViewModel(@NonNull Application application) {
super(application); super(application);

View file

@ -1,6 +1,7 @@
package com.cappielloantonio.play.viewmodel; package com.cappielloantonio.play.viewmodel;
import android.app.Application; import android.app.Application;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
@ -19,6 +20,7 @@ public class HomeViewModel extends AndroidViewModel {
private LiveData<List<Song>> recentlyPlayedSongSample; private LiveData<List<Song>> recentlyPlayedSongSample;
private LiveData<List<Song>> recentlyAddedSongSample; private LiveData<List<Song>> recentlyAddedSongSample;
private LiveData<List<Song>> mostPlayedSongSample; private LiveData<List<Song>> mostPlayedSongSample;
private List<Integer> years;
public HomeViewModel(@NonNull Application application) { public HomeViewModel(@NonNull Application application) {
super(application); super(application);
@ -29,6 +31,7 @@ public class HomeViewModel extends AndroidViewModel {
recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong(20); recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong(20);
recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong(20); recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong(20);
mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong(20); mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong(20);
years = songRepository.getYearList();
} }
@ -51,4 +54,9 @@ public class HomeViewModel extends AndroidViewModel {
public LiveData<List<Song>> getMostPlayedSongList() { public LiveData<List<Song>> getMostPlayedSongList() {
return mostPlayedSongSample; return mostPlayedSongSample;
} }
public List<Integer> getYearList() {
Log.d(TAG, "getYearList: " + years.toString());
return years;
}
} }

View file

@ -25,6 +25,7 @@ public class SongListPageViewModel extends AndroidViewModel {
public Artist artist; public Artist artist;
public ArrayList<String> filters = new ArrayList<>(); public ArrayList<String> filters = new ArrayList<>();
public ArrayList<String> filterNames = new ArrayList<>(); public ArrayList<String> filterNames = new ArrayList<>();
public int year = 0;
public SongListPageViewModel(@NonNull Application application) { public SongListPageViewModel(@NonNull Application application) {
super(application); super(application);
@ -52,6 +53,9 @@ public class SongListPageViewModel extends AndroidViewModel {
case Song.BY_GENRES: case Song.BY_GENRES:
songList = songRepository.getFilteredListLiveSong(filters); songList = songRepository.getFilteredListLiveSong(filters);
break; break;
case Song.BY_YEAR:
songList = songRepository.getSongByYearListLive(year);
break;
} }
return songList; return songList;

View file

@ -3,7 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:paddingTop="20dp">
<ProgressBar <ProgressBar
android:id="@+id/loading_progress_bar" android:id="@+id/loading_progress_bar"
@ -12,7 +13,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:minWidth="128dp" android:minWidth="128dp"
android:layout_centerInParent="true"/> android:layout_centerInParent="true"
android:visibility="visible"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/album_catalogue_container" android:id="@+id/album_catalogue_container"

View file

@ -4,7 +4,8 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:paddingTop="20dp">
<ProgressBar <ProgressBar
android:id="@+id/loading_progress_bar" android:id="@+id/loading_progress_bar"

View file

@ -25,7 +25,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="20dp" android:paddingTop="20dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:text="Discover Music" android:text="Music discovery"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />
@ -63,7 +63,7 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="Recently added tracks" android:text="Recently added"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />
@ -96,6 +96,38 @@
android:paddingBottom="8dp" /> android:paddingBottom="8dp" />
</LinearLayout> </LinearLayout>
<!-- Recently added tracks -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Label and button -->
<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="Flashback"
android:textColor="@color/titleTextColor"
android:textSize="22sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/years_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="8dp"
android:paddingBottom="8dp" />
</LinearLayout>
<!-- Recently played tracks --> <!-- Recently played tracks -->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -119,7 +151,7 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="Recently played tracks" android:text="Last played"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />
@ -175,7 +207,7 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="Most played tracks" android:text="Most played"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />

View file

@ -41,7 +41,7 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="My Albums" android:text="Albums"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />
@ -104,7 +104,7 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="My Artists" android:text="Artists"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />
@ -167,7 +167,7 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:text="Music by genre" android:text="Genres"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingEnd="12dp"
android:paddingBottom="8dp">
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="172dp"
android:layout_height="72dp"
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/year_label"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:fontFamily="@font/open_sans_font_family"
android:paddingStart="8dp"
android:text="@string/label_placeholder"
android:textColor="@color/titleTextColor"
android:textSize="14sp"
android:textStyle="bold"
android:textAlignment="gravity"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>