mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Add bottomsheet everywhere
This commit is contained in:
parent
01bdbf49b2
commit
9af0afa441
41 changed files with 866 additions and 359 deletions
|
|
@ -1,12 +1,14 @@
|
|||
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.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
|
|
@ -22,7 +24,6 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
private List<Album> albums;
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
private ItemClickListener itemClickListener;
|
||||
|
||||
public AlbumAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -54,7 +55,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
return albums.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textAlbumName;
|
||||
TextView textArtistName;
|
||||
ImageView cover;
|
||||
|
|
@ -67,12 +68,22 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
cover = itemView.findViewById(R.id.album_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (itemClickListener != null)
|
||||
itemClickListener.onItemClick(view, getAdapterPosition());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getAdapterPosition()));
|
||||
Navigation.findNavController(view).navigate(R.id.action_libraryFragment_to_albumPageFragment, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getAdapterPosition()));
|
||||
Navigation.findNavController(v).navigate(R.id.albumBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,12 +95,4 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
this.albums = albums;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setClickListener(ItemClickListener itemClickListener) {
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
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.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
|
|
@ -22,7 +24,6 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
|
|||
private List<Album> albums;
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
private ItemClickListener itemClickListener;
|
||||
|
||||
public AlbumArtistPageAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -53,7 +54,7 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
|
|||
return albums.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textAlbumName;
|
||||
ImageView cover;
|
||||
|
||||
|
|
@ -64,11 +65,22 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
|
|||
cover = itemView.findViewById(R.id.artist_page_album_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getAdapterPosition()));
|
||||
Navigation.findNavController(view).navigate(R.id.action_artistPageFragment_to_albumPageFragment, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getAdapterPosition()));
|
||||
Navigation.findNavController(v).navigate(R.id.albumBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,12 +92,4 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
|
|||
this.albums = albums;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setClickListener(ItemClickListener itemClickListener) {
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
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.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
|
|
@ -15,6 +17,7 @@ import com.cappielloantonio.play.model.Album;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAdapter.ViewHolder> {
|
||||
private static final String TAG = "AlbumCatalogueAdapter";
|
||||
|
|
@ -22,7 +25,6 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
|
|||
private List<Album> albums;
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
private ItemClickListener itemClickListener;
|
||||
|
||||
public AlbumCatalogueAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -55,7 +57,7 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
|
|||
return albums.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textAlbumName;
|
||||
TextView textArtistName;
|
||||
ImageView cover;
|
||||
|
|
@ -68,12 +70,31 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
|
|||
cover = itemView.findViewById(R.id.album_catalogue_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (itemClickListener != null)
|
||||
itemClickListener.onItemClick(view, getAdapterPosition());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getAdapterPosition()));
|
||||
|
||||
if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.searchFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_searchFragment_to_albumPageFragment, bundle);
|
||||
}
|
||||
else if(Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.libraryFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_libraryFragment_to_albumPageFragment, bundle);
|
||||
}
|
||||
else if(Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.albumCatalogueFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_albumCatalogueFragment_to_albumPageFragment, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", albums.get(getAdapterPosition()));
|
||||
Navigation.findNavController(v).navigate(R.id.albumBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,12 +106,4 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
|
|||
this.albums = albums;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setClickListener(ItemClickListener itemClickListener) {
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
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.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
|
|
@ -22,7 +24,6 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
|||
private List<Artist> artists;
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
private ItemClickListener itemClickListener;
|
||||
|
||||
public ArtistAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -53,7 +54,7 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
|||
return artists.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textArtistName;
|
||||
ImageView cover;
|
||||
|
||||
|
|
@ -64,11 +65,22 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
|||
cover = itemView.findViewById(R.id.artist_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artists.get(getAdapterPosition()));
|
||||
Navigation.findNavController(view).navigate(R.id.action_libraryFragment_to_artistPageFragment, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artists.get(getAdapterPosition()));
|
||||
Navigation.findNavController(v).navigate(R.id.artistBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,12 +92,4 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
|||
this.artists = artists;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setClickListener(ItemClickListener itemClickListener) {
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
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.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
|
|
@ -15,6 +17,7 @@ import com.cappielloantonio.play.model.Artist;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> {
|
||||
private static final String TAG = "ArtistCatalogueAdapter";
|
||||
|
|
@ -22,7 +25,6 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
|
|||
private List<Artist> artists;
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
private ItemClickListener itemClickListener;
|
||||
|
||||
public ArtistCatalogueAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -53,7 +55,7 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
|
|||
return artists.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textArtistName;
|
||||
ImageView cover;
|
||||
|
||||
|
|
@ -64,11 +66,31 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
|
|||
cover = itemView.findViewById(R.id.artist_catalogue_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (itemClickListener != null) itemClickListener.onItemClick(view, getAdapterPosition());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artists.get(getAdapterPosition()));
|
||||
|
||||
if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.searchFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_searchFragment_to_artistPageFragment, bundle);
|
||||
}
|
||||
else if(Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.libraryFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_libraryFragment_to_artistPageFragment, bundle);
|
||||
}
|
||||
else if(Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.artistCatalogueFragment) {
|
||||
Navigation.findNavController(view).navigate(R.id.action_artistCatalogueFragment_to_artistPageFragment, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artists.get(getAdapterPosition()));
|
||||
Navigation.findNavController(v).navigate(R.id.artistBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,12 +102,4 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
|
|||
this.artists = artists;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setClickListener(ItemClickListener itemClickListener) {
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
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;
|
||||
|
|
@ -27,9 +30,11 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
|||
private List<Song> songs;
|
||||
private LayoutInflater mInflater;
|
||||
private Context context;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public RecentMusicAdapter(Context context) {
|
||||
public RecentMusicAdapter(Context context, FragmentManager fragmentManager) {
|
||||
this.context = context;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.songs = new ArrayList<>();
|
||||
}
|
||||
|
|
@ -58,7 +63,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
|||
return songs.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textTitle;
|
||||
TextView textAlbum;
|
||||
ImageView cover;
|
||||
|
|
@ -71,6 +76,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
|||
cover = itemView.findViewById(R.id.track_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -78,6 +84,14 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
|||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
songRepository.increasePlayCount(songs.get(getAdapterPosition()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("song_object", songs.get(getAdapterPosition()));
|
||||
Navigation.findNavController(view).navigate(R.id.songBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
|
@ -8,6 +9,7 @@ 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;
|
||||
|
|
@ -15,7 +17,6 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.ui.fragment.bottomsheetdialog.SongBottomSheetDialog;
|
||||
import com.cappielloantonio.play.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -90,8 +91,9 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
|
|||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
SongBottomSheetDialog songBottomSheetDialog = new SongBottomSheetDialog(songs.get(getAdapterPosition()));
|
||||
songBottomSheetDialog.show(fragmentManager, null);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("song_object", songs.get(getAdapterPosition()));
|
||||
Navigation.findNavController(v).navigate(R.id.songBottomSheetDialog, bundle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue