mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Added starred tracks, starred albums and starred artists view
This commit is contained in:
parent
9495fbd83d
commit
7742cbdd08
23 changed files with 752 additions and 171 deletions
|
|
@ -0,0 +1,125 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AlbumHorizontalAdapter extends RecyclerView.Adapter<AlbumHorizontalAdapter.ViewHolder> {
|
||||
private static final String TAG = "AlbumHorizontalAdapter";
|
||||
|
||||
private List<Album> albums;
|
||||
private LayoutInflater mInflater;
|
||||
private MainActivity mainActivity;
|
||||
private Context context;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public AlbumHorizontalAdapter(MainActivity mainActivity, Context context, FragmentManager fragmentManager) {
|
||||
this.mainActivity = mainActivity;
|
||||
this.context = context;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.albums = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.item_horizontal_album, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Album album = albums.get(position);
|
||||
|
||||
holder.albumTitle.setText(album.getTitle());
|
||||
holder.albumArtist.setText(album.getArtistName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return albums.size();
|
||||
}
|
||||
|
||||
public void setItems(List<Album> albums) {
|
||||
this.albums = albums;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Album getItem(int id) {
|
||||
return albums.get(id);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView albumTitle;
|
||||
TextView albumArtist;
|
||||
ImageView more;
|
||||
ImageView cover;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
albumTitle = itemView.findViewById(R.id.album_title_text_view);
|
||||
albumArtist = itemView.findViewById(R.id.album_artist_text_view);
|
||||
more = itemView.findViewById(R.id.album_more_button);
|
||||
cover = itemView.findViewById(R.id.album_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
||||
more.setOnClickListener(v -> {
|
||||
openMore(v);
|
||||
});
|
||||
|
||||
albumTitle.setSelected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getBindingAdapterPosition()));
|
||||
|
||||
if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.homeFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_homeFragment_to_albumPageFragment, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
openMore(v);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openMore(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getBindingAdapterPosition()));
|
||||
Navigation.findNavController(view).navigate(R.id.albumBottomSheetDialog, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArtistHorizontalAdapter extends RecyclerView.Adapter<ArtistHorizontalAdapter.ViewHolder> {
|
||||
private static final String TAG = "ArtistHorizontalAdapter";
|
||||
|
||||
private List<Artist> artists;
|
||||
private LayoutInflater mInflater;
|
||||
private MainActivity mainActivity;
|
||||
private Context context;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public ArtistHorizontalAdapter(MainActivity mainActivity, Context context, FragmentManager fragmentManager) {
|
||||
this.mainActivity = mainActivity;
|
||||
this.context = context;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.artists = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.item_horizontal_artist, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Artist artist = artists.get(position);
|
||||
|
||||
holder.artistName.setText(artist.getName());
|
||||
holder.artistInfo.setText("--");
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, artist.getPrimary(), artist.getPrimaryBlurHash(), CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return artists.size();
|
||||
}
|
||||
|
||||
public void setItems(List<Artist> artists) {
|
||||
this.artists = artists;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Artist getItem(int id) {
|
||||
return artists.get(id);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView artistName;
|
||||
TextView artistInfo;
|
||||
|
||||
ImageView more;
|
||||
ImageView cover;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
artistName = itemView.findViewById(R.id.artist_name_text_view);
|
||||
artistInfo = itemView.findViewById(R.id.artist_info_text_view);
|
||||
more = itemView.findViewById(R.id.artist_more_button);
|
||||
cover = itemView.findViewById(R.id.artist_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
||||
more.setOnClickListener(v -> {
|
||||
openMore(v);
|
||||
});
|
||||
|
||||
artistName.setSelected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artists.get(getBindingAdapterPosition()));
|
||||
|
||||
if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.homeFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_homeFragment_to_artistPageFragment, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
openMore(v);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openMore(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("song_object", artists.get(getBindingAdapterPosition()));
|
||||
Navigation.findNavController(view).navigate(R.id.songBottomSheetDialog, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,21 +20,19 @@ import com.cappielloantonio.play.repository.QueueRepository;
|
|||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSearchAdapter.ViewHolder> {
|
||||
private static final String TAG = "SongResultSearchAdapter";
|
||||
|
||||
public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAdapter.ViewHolder> {
|
||||
private static final String TAG = "SongHorizontalAdapter";
|
||||
private List<Song> songs;
|
||||
private LayoutInflater mInflater;
|
||||
private MainActivity mainActivity;
|
||||
private Context context;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public SongResultSearchAdapter(MainActivity mainActivity, Context context, FragmentManager fragmentManager) {
|
||||
public SongHorizontalAdapter(MainActivity mainActivity, Context context, FragmentManager fragmentManager) {
|
||||
this.mainActivity = mainActivity;
|
||||
this.context = context;
|
||||
this.fragmentManager = fragmentManager;
|
||||
|
|
@ -44,7 +42,7 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
|
|||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.item_search_result_song, parent, false);
|
||||
View view = mInflater.inflate(R.layout.item_horizontal_track, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +92,7 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
|
|||
super(itemView);
|
||||
|
||||
songTitle = itemView.findViewById(R.id.search_result_song_title_text_view);
|
||||
songArtist = itemView.findViewById(R.id.search_result_song_artist_text_view);
|
||||
songArtist = itemView.findViewById(R.id.album_artist_text_view);
|
||||
songDuration = itemView.findViewById(R.id.search_result_song_duration_text_view);
|
||||
downloadIndicator = itemView.findViewById(R.id.search_result_dowanload_indicator_image_view);
|
||||
more = itemView.findViewById(R.id.search_result_song_more_button);
|
||||
Loading…
Add table
Add a link
Reference in a new issue