Open the downloaded artist detail in ArtistListPageFragment

This commit is contained in:
CappielloAntonio 2021-08-31 13:04:22 +02:00
parent ef645143e0
commit 8cef75c763
6 changed files with 17 additions and 14 deletions

View file

@ -102,7 +102,7 @@ public class AlbumHorizontalAdapter extends RecyclerView.Adapter<AlbumHorizontal
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.albumListPageFragment) {
Navigation.findNavController(view).navigate(R.id.action_albumListPageFragment_to_albumPageFragment, bundle);
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.downloadFragment) {
Navigation.findNavController(view).navigate(R.id.action_downloadFragment_to_songListPageFragment, bundle);
Navigation.findNavController(view).navigate(R.id.action_downloadFragment_to_albumPageFragment, bundle);
}
}

View file

@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -10,9 +9,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView;
@ -20,7 +16,6 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.MusicUtil;
import java.util.ArrayList;
@ -33,11 +28,13 @@ public class ArtistHorizontalAdapter extends RecyclerView.Adapter<ArtistHorizont
private List<Artist> artists;
private final LayoutInflater mInflater;
private final Context context;
private final boolean isDownloaded;
public ArtistHorizontalAdapter(Context context) {
public ArtistHorizontalAdapter(Context context, boolean isDownloaded) {
this.context = context;
this.mInflater = LayoutInflater.from(context);
this.artists = new ArrayList<>();
this.isDownloaded = isDownloaded;
}
@NonNull
@ -53,10 +50,9 @@ public class ArtistHorizontalAdapter extends RecyclerView.Adapter<ArtistHorizont
holder.artistName.setText(MusicUtil.getReadableString(artist.getName()));
if(artist.getAlbumCount() > 0) {
if (artist.getAlbumCount() > 0) {
holder.artistInfo.setText("Album count: " + String.valueOf(artist.getAlbumCount()));
}
else {
} else {
holder.artistInfo.setVisibility(View.GONE);
}
@ -114,7 +110,8 @@ public class ArtistHorizontalAdapter extends RecyclerView.Adapter<ArtistHorizont
if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.homeFragment) {
Navigation.findNavController(view).navigate(R.id.action_homeFragment_to_artistPageFragment, bundle);
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.artistListPageFragment) {
Navigation.findNavController(view).navigate(R.id.action_artistListPageFragment_to_artistPageFragment, bundle);
if (!isDownloaded) Navigation.findNavController(view).navigate(R.id.action_artistListPageFragment_to_artistPageFragment, bundle);
else Navigation.findNavController(view).navigate(R.id.action_artistListPageFragment_to_albumListPageFragment, bundle);
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.downloadFragment) {
Navigation.findNavController(view).navigate(R.id.action_downloadFragment_to_albumListPageFragment, bundle);
}

View file

@ -88,7 +88,7 @@ public class ArtistListPageFragment extends Fragment {
bind.artistListRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
bind.artistListRecyclerView.setHasFixedSize(true);
artistHorizontalAdapter = new ArtistHorizontalAdapter(requireContext());
artistHorizontalAdapter = new ArtistHorizontalAdapter(requireContext(), artistListPageViewModel.title.equals(Artist.DOWNLOADED));
bind.artistListRecyclerView.setAdapter(artistHorizontalAdapter);
artistListPageViewModel.getArtistList(requireActivity()).observe(requireActivity(), artists -> artistHorizontalAdapter.setItems(artists));
}

View file

@ -148,7 +148,7 @@ public class DownloadFragment extends Fragment {
private void initDownloadedArtistView() {
bind.downloadedArtistRecyclerView.setHasFixedSize(true);
downloadedArtistAdapter = new ArtistHorizontalAdapter(requireContext());
downloadedArtistAdapter = new ArtistHorizontalAdapter(requireContext(), false);
bind.downloadedArtistRecyclerView.setAdapter(downloadedArtistAdapter);
downloadViewModel.getDownloadedArtists(requireActivity(), 20).observe(requireActivity(), artists -> {
if (artists == null) {

View file

@ -398,7 +398,7 @@ public class HomeFragment extends Fragment {
private void initStarredArtistsView() {
bind.starredArtistsRecyclerView.setHasFixedSize(true);
starredArtistAdapter = new ArtistHorizontalAdapter(requireContext());
starredArtistAdapter = new ArtistHorizontalAdapter(requireContext(), false);
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
homeViewModel.getStarredArtists(requireActivity()).observe(requireActivity(), artists -> {
if (artists == null) {

View file

@ -104,6 +104,9 @@
<action
android:id="@+id/action_downloadFragment_to_songListPageFragment"
app:destination="@id/songListPageFragment" />
<action
android:id="@+id/action_downloadFragment_to_albumPageFragment"
app:destination="@id/albumPageFragment" />
<action
android:id="@+id/action_downloadFragment_to_albumListPageFragment"
app:destination="@id/albumListPageFragment" />
@ -238,6 +241,9 @@
<action
android:id="@+id/action_artistListPageFragment_to_artistPageFragment"
app:destination="@id/artistPageFragment" />
<action
android:id="@+id/action_artistListPageFragment_to_albumListPageFragment"
app:destination="@id/albumListPageFragment" />
</fragment>
<fragment
android:id="@+id/playlistPageFragment"