mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Add catalogues
This commit is contained in:
parent
8c889f7a38
commit
8b7e383dc2
45 changed files with 1084 additions and 136 deletions
|
|
@ -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;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -15,26 +14,22 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.databinding.FragmentFilterBinding;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.SearchViewModel;
|
||||
import com.cappielloantonio.play.viewmodel.FilterViewModel;
|
||||
import com.google.android.material.chip.Chip;
|
||||
|
||||
public class FilterFragment extends Fragment {
|
||||
private static final String TAG = "FilterFragment";
|
||||
|
||||
private MainActivity activity;
|
||||
private FragmentFilterBinding bind;
|
||||
private SearchViewModel searchViewModel;
|
||||
private FilterViewModel filterViewModel;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
activity = (MainActivity) getActivity();
|
||||
|
||||
bind = FragmentFilterBinding.inflate(inflater, container, false);
|
||||
View view = bind.getRoot();
|
||||
searchViewModel = new ViewModelProvider(requireActivity()).get(SearchViewModel.class);
|
||||
filterViewModel = new ViewModelProvider(requireActivity()).get(FilterViewModel.class);
|
||||
|
||||
setFilterChips();
|
||||
return view;
|
||||
|
|
@ -47,7 +42,7 @@ public class FilterFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void setFilterChips() {
|
||||
searchViewModel.getGenreList().observe(requireActivity(), genres -> {
|
||||
filterViewModel.getGenreList().observe(requireActivity(), genres -> {
|
||||
bind.loadingProgressBar.setVisibility(View.GONE);
|
||||
for (Genre genre : genres) {
|
||||
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.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
|
||||
import com.cappielloantonio.play.adapter.RecentMusicAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemClickListener {
|
||||
private static final String TAG = "CategoriesFragment";
|
||||
|
||||
|
|
@ -27,7 +32,7 @@ public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemCli
|
|||
private HomeViewModel homeViewModel;
|
||||
|
||||
private DiscoverSongAdapter discoverSongAdapter;
|
||||
private RecentMusicAdapter recentMusicAdapter;
|
||||
private RecentMusicAdapter recentlyAddedMusicAdapter;
|
||||
private RecentMusicAdapter mostPlayedMusicAdapter;
|
||||
|
||||
@Nullable
|
||||
|
|
@ -61,27 +66,30 @@ public class HomeFragment extends Fragment implements RecentMusicAdapter.ItemCli
|
|||
}
|
||||
|
||||
private void initDiscoverSongSlideView() {
|
||||
discoverSongAdapter = new DiscoverSongAdapter(requireContext(), homeViewModel.getDiscoverSongList());
|
||||
discoverSongAdapter = new DiscoverSongAdapter(requireContext(), new ArrayList<>());
|
||||
bind.discoverSongViewPager.setAdapter(discoverSongAdapter);
|
||||
bind.discoverSongViewPager.setPageMargin(20);
|
||||
homeViewModel.getDiscoverSongList().observe(requireActivity(), songs -> discoverSongAdapter.setItems(songs));
|
||||
}
|
||||
|
||||
private void initRecentPlayedSongView() {
|
||||
bind.recentlyPlayedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
bind.recentlyPlayedTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
recentMusicAdapter = new RecentMusicAdapter(requireContext(), homeViewModel.getRecentSongList());
|
||||
recentMusicAdapter.setClickListener(this);
|
||||
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentMusicAdapter);
|
||||
recentlyAddedMusicAdapter = new RecentMusicAdapter(requireContext(), new ArrayList<>());
|
||||
recentlyAddedMusicAdapter.setClickListener(this);
|
||||
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyAddedMusicAdapter);
|
||||
homeViewModel.getRecentlyAddedSongList().observe(requireActivity(), songs -> recentlyAddedMusicAdapter.setItems(songs));
|
||||
}
|
||||
|
||||
private void initMostPlayedSongView() {
|
||||
bind.mostPlayedTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
bind.mostPlayedTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
mostPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), homeViewModel.getMostPlayedSongList());
|
||||
mostPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), new ArrayList<>());
|
||||
mostPlayedMusicAdapter.setClickListener(this);
|
||||
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
|
||||
homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -14,11 +15,14 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.AlbumAdapter;
|
||||
import com.cappielloantonio.play.adapter.ArtistAdapter;
|
||||
import com.cappielloantonio.play.adapter.GenreAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistAdapter;
|
||||
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.Playlist;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
|
|
@ -48,6 +52,7 @@ public class LibraryFragment extends Fragment {
|
|||
View view = bind.getRoot();
|
||||
libraryViewModel = new ViewModelProvider(requireActivity()).get(LibraryViewModel.class);
|
||||
|
||||
init();
|
||||
initAlbumView();
|
||||
initArtistView();
|
||||
initGenreView();
|
||||
|
|
@ -62,22 +67,30 @@ public class LibraryFragment extends Fragment {
|
|||
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() {
|
||||
bind.albumRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
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());
|
||||
bind.albumRecyclerView.setAdapter(albumAdapter);
|
||||
libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> albumAdapter.setItems(albums));
|
||||
}
|
||||
|
||||
private void initArtistView() {
|
||||
bind.artistRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
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());
|
||||
bind.artistRecyclerView.setAdapter(artistAdapter);
|
||||
libraryViewModel.getArtistSample().observe(requireActivity(), artists -> artistAdapter.setItems(artists));
|
||||
}
|
||||
|
||||
private void initGenreView() {
|
||||
|
|
@ -87,7 +100,7 @@ public class LibraryFragment extends Fragment {
|
|||
genreAdapter = new GenreAdapter(requireContext(), new ArrayList<>());
|
||||
genreAdapter.setClickListener((view, position) -> Toast.makeText(requireContext(), "Genre: " + position, Toast.LENGTH_SHORT).show());
|
||||
bind.genreRecyclerView.setAdapter(genreAdapter);
|
||||
libraryViewModel.getGenreList().observe(requireActivity(), genres -> genreAdapter.setItems(genres));
|
||||
libraryViewModel.getGenreSample().observe(requireActivity(), genres -> genreAdapter.setItems(genres));
|
||||
}
|
||||
|
||||
private void initPlaylistView() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue