Add bottomsheet everywhere

This commit is contained in:
Antonio Cappiello 2020-12-01 20:04:54 +01:00
parent 01bdbf49b2
commit 9af0afa441
41 changed files with 866 additions and 359 deletions

View file

@ -1,12 +1,14 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
@ -22,7 +24,6 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
private List<Album> albums; private List<Album> albums;
private LayoutInflater inflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener;
public AlbumAdapter(Context context) { public AlbumAdapter(Context context) {
this.context = context; this.context = context;
@ -54,7 +55,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
return albums.size(); 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 textAlbumName;
TextView textArtistName; TextView textArtistName;
ImageView cover; ImageView cover;
@ -67,12 +68,22 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
cover = itemView.findViewById(R.id.album_cover_image_view); cover = itemView.findViewById(R.id.album_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (itemClickListener != null) Bundle bundle = new Bundle();
itemClickListener.onItemClick(view, getAdapterPosition()); 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; this.albums = albums;
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
} }

View file

@ -1,12 +1,14 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
@ -22,7 +24,6 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
private List<Album> albums; private List<Album> albums;
private LayoutInflater inflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener;
public AlbumArtistPageAdapter(Context context) { public AlbumArtistPageAdapter(Context context) {
this.context = context; this.context = context;
@ -53,7 +54,7 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
return albums.size(); 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 textAlbumName;
ImageView cover; ImageView cover;
@ -64,11 +65,22 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
cover = itemView.findViewById(R.id.artist_page_album_cover_image_view); cover = itemView.findViewById(R.id.artist_page_album_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
@Override @Override
public void onClick(View view) { 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; this.albums = albums;
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
} }

View file

@ -1,12 +1,14 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
@ -15,6 +17,7 @@ import com.cappielloantonio.play.model.Album;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAdapter.ViewHolder> { public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAdapter.ViewHolder> {
private static final String TAG = "AlbumCatalogueAdapter"; private static final String TAG = "AlbumCatalogueAdapter";
@ -22,7 +25,6 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
private List<Album> albums; private List<Album> albums;
private LayoutInflater inflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener;
public AlbumCatalogueAdapter(Context context) { public AlbumCatalogueAdapter(Context context) {
this.context = context; this.context = context;
@ -55,7 +57,7 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
return albums.size(); 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 textAlbumName;
TextView textArtistName; TextView textArtistName;
ImageView cover; ImageView cover;
@ -68,12 +70,31 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
cover = itemView.findViewById(R.id.album_catalogue_cover_image_view); cover = itemView.findViewById(R.id.album_catalogue_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (itemClickListener != null) Bundle bundle = new Bundle();
itemClickListener.onItemClick(view, getAdapterPosition()); 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; this.albums = albums;
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
} }

View file

@ -1,12 +1,14 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
@ -22,7 +24,6 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
private List<Artist> artists; private List<Artist> artists;
private LayoutInflater inflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener;
public ArtistAdapter(Context context) { public ArtistAdapter(Context context) {
this.context = context; this.context = context;
@ -53,7 +54,7 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
return artists.size(); 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; TextView textArtistName;
ImageView cover; ImageView cover;
@ -64,11 +65,22 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
cover = itemView.findViewById(R.id.artist_cover_image_view); cover = itemView.findViewById(R.id.artist_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
@Override @Override
public void onClick(View view) { 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; this.artists = artists;
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
} }

View file

@ -1,12 +1,14 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
@ -15,6 +17,7 @@ import com.cappielloantonio.play.model.Artist;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> { public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> {
private static final String TAG = "ArtistCatalogueAdapter"; private static final String TAG = "ArtistCatalogueAdapter";
@ -22,7 +25,6 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
private List<Artist> artists; private List<Artist> artists;
private LayoutInflater inflater; private LayoutInflater inflater;
private Context context; private Context context;
private ItemClickListener itemClickListener;
public ArtistCatalogueAdapter(Context context) { public ArtistCatalogueAdapter(Context context) {
this.context = context; this.context = context;
@ -53,7 +55,7 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
return artists.size(); 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; TextView textArtistName;
ImageView cover; ImageView cover;
@ -64,11 +66,31 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
cover = itemView.findViewById(R.id.artist_catalogue_cover_image_view); cover = itemView.findViewById(R.id.artist_catalogue_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
@Override @Override
public void onClick(View view) { 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; this.artists = artists;
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
public interface ItemClickListener {
void onItemClick(View view, int position);
}
} }

View file

@ -1,12 +1,15 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
@ -27,9 +30,11 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
private List<Song> songs; private List<Song> songs;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private Context context; private Context context;
private FragmentManager fragmentManager;
public RecentMusicAdapter(Context context) { public RecentMusicAdapter(Context context, FragmentManager fragmentManager) {
this.context = context; this.context = context;
this.fragmentManager = fragmentManager;
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.songs = new ArrayList<>(); this.songs = new ArrayList<>();
} }
@ -58,7 +63,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
return songs.size(); 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 textTitle;
TextView textAlbum; TextView textAlbum;
ImageView cover; ImageView cover;
@ -71,6 +76,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
cover = itemView.findViewById(R.id.track_cover_image_view); cover = itemView.findViewById(R.id.track_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
@Override @Override
@ -78,6 +84,14 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
SongRepository songRepository = new SongRepository(App.getInstance()); SongRepository songRepository = new SongRepository(App.getInstance());
songRepository.increasePlayCount(songs.get(getAdapterPosition())); 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) { public void setItems(List<Song> songs) {

View file

@ -1,6 +1,7 @@
package com.cappielloantonio.play.adapter; package com.cappielloantonio.play.adapter;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -8,6 +9,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
@ -15,7 +17,6 @@ import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.SongRepository; import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.ui.fragment.bottomsheetdialog.SongBottomSheetDialog;
import com.cappielloantonio.play.util.Util; import com.cappielloantonio.play.util.Util;
import java.util.ArrayList; import java.util.ArrayList;
@ -90,8 +91,9 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
SongBottomSheetDialog songBottomSheetDialog = new SongBottomSheetDialog(songs.get(getAdapterPosition())); Bundle bundle = new Bundle();
songBottomSheetDialog.show(fragmentManager, null); bundle.putParcelable("song_object", songs.get(getAdapterPosition()));
Navigation.findNavController(v).navigate(R.id.songBottomSheetDialog, bundle);
return true; return true;
} }
} }

View file

@ -42,4 +42,7 @@ public interface AlbumDao {
@Query("DELETE FROM album") @Query("DELETE FROM album")
void deleteAll(); void deleteAll();
@Query("SELECT * FROM album WHERE id = :id")
Album getAlbumByID(String id);
} }

View file

@ -39,4 +39,7 @@ public interface ArtistDao {
@Query("DELETE FROM artist") @Query("DELETE FROM artist")
void deleteAll(); void deleteAll();
@Query("SELECT * FROM artist WHERE id = :id")
Artist getArtistByID(String id);
} }

View file

@ -1,111 +0,0 @@
package com.cappielloantonio.play.helper;
import android.util.Log;
import org.jellyfin.apiclient.interaction.ApiClient;
import org.jellyfin.apiclient.interaction.ApiEventListener;
import org.jellyfin.apiclient.model.apiclient.RemoteLogoutReason;
import org.jellyfin.apiclient.model.apiclient.SessionUpdatesEventArgs;
import org.jellyfin.apiclient.model.dto.UserDto;
import org.jellyfin.apiclient.model.entities.LibraryUpdateInfo;
import org.jellyfin.apiclient.model.session.BrowseRequest;
import org.jellyfin.apiclient.model.session.GeneralCommand;
import org.jellyfin.apiclient.model.session.MessageCommand;
import org.jellyfin.apiclient.model.session.PlayRequest;
import org.jellyfin.apiclient.model.session.PlaystateRequest;
import org.jellyfin.apiclient.model.session.SessionInfoDto;
import org.jellyfin.apiclient.model.session.UserDataChangeInfo;
public class EventListenerHelper extends ApiEventListener {
private static final String TAG = "EventListenerHelper";
@Override
public void onRemoteLoggedOut(ApiClient client, RemoteLogoutReason reason) {
Log.i(TAG, "onRemoteLoggedOut: " + reason);
}
@Override
public void onUserUpdated(ApiClient client, UserDto userDto) {
Log.i(TAG, "onUserUpdated: " + userDto.getName());
}
@Override
public void onLibraryChanged(ApiClient client, LibraryUpdateInfo info) {
Log.i(TAG, "onLibraryChanged");
}
@Override
public void onUserConfigurationUpdated(ApiClient client, UserDto userDto) {
Log.i(TAG, "onUserConfigurationUpdated");
}
@Override
public void onBrowseCommand(ApiClient client, BrowseRequest command) {
Log.i(TAG, "onBrowseCommand: " + command.getItemName());
}
@Override
public void onPlayCommand(ApiClient client, PlayRequest command) {
Log.i(TAG, "onPlayCommand: " + command.getPlayCommand());
}
@Override
public void onPlaystateCommand(ApiClient client, PlaystateRequest command) {
Log.i(TAG, "onPlayStateCommand");
}
@Override
public void onMessageCommand(ApiClient client, MessageCommand command) {
Log.i(TAG, "onMessageCommand");
}
@Override
public void onGeneralCommand(ApiClient client, GeneralCommand command) {
Log.i(TAG, "onGeneralCommand: " + command.getName());
}
@Override
public void onSendStringCommand(ApiClient client, String value) {
Log.i(TAG, "onSendStringCommand");
}
@Override
public void onSetVolumeCommand(ApiClient client, int value) {
Log.i(TAG, "onSetVolumeCommand");
}
@Override
public void onSetAudioStreamIndexCommand(ApiClient client, int value) {
Log.i(TAG, "onSetAudioStreamIndexCommand");
}
@Override
public void onSetSubtitleStreamIndexCommand(ApiClient client, int value) {
Log.i(TAG, "onSetSubtitleStreamIndexCommand");
}
@Override
public void onUserDataChanged(ApiClient client, UserDataChangeInfo info) {
Log.i(TAG, "onUserDataChanged");
}
@Override
public void onSessionsUpdated(ApiClient client, SessionUpdatesEventArgs args) {
Log.i(TAG, "onSessionsUpdated");
}
@Override
public void onPlaybackStart(ApiClient client, SessionInfoDto info) {
Log.i(TAG, "onPlaybackStart");
}
@Override
public void onPlaybackStopped(ApiClient client, SessionInfoDto info) {
Log.i(TAG, "onPlaybackStopped");
}
@Override
public void onSessionEnded(ApiClient client, SessionInfoDto info) {
Log.i(TAG, "onSessionEnded");
}
}

View file

@ -5,12 +5,12 @@ import android.view.View;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
public class ItemDecoration extends RecyclerView.ItemDecoration { public class GridItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount; private int spanCount;
private int spacing; private int spacing;
private boolean includeEdge; private boolean includeEdge;
public ItemDecoration(int spanCount, int spacing, boolean includeEdge) { public GridItemDecoration(int spanCount, int spacing, boolean includeEdge) {
this.spanCount = spanCount; this.spanCount = spanCount;
this.spacing = spacing; this.spacing = spacing;
this.includeEdge = includeEdge; this.includeEdge = includeEdge;

View file

@ -104,6 +104,23 @@ public class AlbumRepository {
thread.start(); thread.start();
} }
public Album getAlbumByID(String id) {
Album album = null;
GetAlbumByIDThreadSafe getAlbum = new GetAlbumByIDThreadSafe(albumDao, id);
Thread thread = new Thread(getAlbum);
thread.start();
try {
thread.join();
album = getAlbum.getAlbum();
} catch (InterruptedException e) {
e.printStackTrace();
}
return album;
}
private static class ExistThreadSafe implements Runnable { private static class ExistThreadSafe implements Runnable {
private AlbumDao albumDao; private AlbumDao albumDao;
private Album album; private Album album;
@ -204,4 +221,24 @@ public class AlbumRepository {
albumDao.deleteAll(); albumDao.deleteAll();
} }
} }
private static class GetAlbumByIDThreadSafe implements Runnable {
private Album album;
private AlbumDao albumDao;
private String id;
public GetAlbumByIDThreadSafe(AlbumDao albumDao, String id) {
this.albumDao = albumDao;
this.id = id;
}
@Override
public void run() {
album = albumDao.getAlbumByID(id);
}
public Album getAlbum() {
return album;
}
}
} }

View file

@ -97,6 +97,23 @@ public class ArtistRepository {
thread.start(); thread.start();
} }
public Artist getArtistByID(String id) {
Artist artist = null;
GetArtistByIDThreadSafe getArtist = new GetArtistByIDThreadSafe(artistDao, id);
Thread thread = new Thread(getArtist);
thread.start();
try {
thread.join();
artist = getArtist.getArtist();
} catch (InterruptedException e) {
e.printStackTrace();
}
return artist;
}
private static class ExistThreadSafe implements Runnable { private static class ExistThreadSafe implements Runnable {
private ArtistDao artistDao; private ArtistDao artistDao;
private Artist artist; private Artist artist;
@ -197,4 +214,24 @@ public class ArtistRepository {
artistDao.deleteAll(); artistDao.deleteAll();
} }
} }
private static class GetArtistByIDThreadSafe implements Runnable {
private Artist artist;
private ArtistDao artistDao;
private String id;
public GetArtistByIDThreadSafe(ArtistDao artistDao, String id) {
this.artistDao = artistDao;
this.id = id;
}
@Override
public void run() {
artist = artistDao.getArtistByID(id);
}
public Artist getArtist() {
return artist;
}
}
} }

View file

@ -9,10 +9,9 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.AlbumCatalogueAdapter; import com.cappielloantonio.play.adapter.AlbumCatalogueAdapter;
import com.cappielloantonio.play.databinding.FragmentAlbumCatalogueBinding; import com.cappielloantonio.play.databinding.FragmentAlbumCatalogueBinding;
import com.cappielloantonio.play.helper.recyclerview.ItemDecoration; import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
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;
@ -52,15 +51,10 @@ public class AlbumCatalogueFragment extends Fragment {
private void initAlbumCatalogueView() { private void initAlbumCatalogueView() {
bind.albumCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); bind.albumCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
bind.albumCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.albumCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false));
bind.albumCatalogueRecyclerView.setHasFixedSize(true); bind.albumCatalogueRecyclerView.setHasFixedSize(true);
albumAdapter = new AlbumCatalogueAdapter(requireContext()); albumAdapter = new AlbumCatalogueAdapter(requireContext());
albumAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumAdapter.getItem(position));
activity.navController.navigate(R.id.action_albumCatalogueFragment_to_albumPageFragment, bundle);
});
bind.albumCatalogueRecyclerView.setAdapter(albumAdapter); bind.albumCatalogueRecyclerView.setAdapter(albumAdapter);
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> { albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> {
bind.loadingProgressBar.setVisibility(View.GONE); bind.loadingProgressBar.setVisibility(View.GONE);

View file

@ -13,7 +13,6 @@ import com.cappielloantonio.play.adapter.SongResultSearchAdapter;
import com.cappielloantonio.play.databinding.FragmentAlbumPageBinding; import com.cappielloantonio.play.databinding.FragmentAlbumPageBinding;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.ui.activities.MainActivity; import com.cappielloantonio.play.ui.activities.MainActivity;
import com.cappielloantonio.play.ui.fragment.bottomsheetdialog.AlbumBottomSheetDialog;
import com.cappielloantonio.play.viewmodel.AlbumPageViewModel; import com.cappielloantonio.play.viewmodel.AlbumPageViewModel;
public class AlbumPageFragment extends Fragment { public class AlbumPageFragment extends Fragment {
@ -33,7 +32,6 @@ public class AlbumPageFragment extends Fragment {
albumPageViewModel = new ViewModelProvider(requireActivity()).get(AlbumPageViewModel.class); albumPageViewModel = new ViewModelProvider(requireActivity()).get(AlbumPageViewModel.class);
init(); init();
initBottomSheetDialog();
initBackCover(); initBackCover();
initSongsView(); initSongsView();
@ -65,13 +63,6 @@ public class AlbumPageFragment extends Fragment {
bind.albumTitleLabel.setText(albumPageViewModel.getAlbum().getTitle()); bind.albumTitleLabel.setText(albumPageViewModel.getAlbum().getTitle());
} }
private void initBottomSheetDialog() {
bind.albumSettingsImageButton.setOnClickListener(v -> {
AlbumBottomSheetDialog albumBottomSheetDialog = new AlbumBottomSheetDialog(albumPageViewModel.getAlbum());
albumBottomSheetDialog.show(this.getChildFragmentManager(), null);
});
}
private void initSongsView() { private void initSongsView() {
bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext())); bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
bind.songRecyclerView.setHasFixedSize(true); bind.songRecyclerView.setHasFixedSize(true);

View file

@ -9,10 +9,9 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter; import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter;
import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding; import com.cappielloantonio.play.databinding.FragmentArtistCatalogueBinding;
import com.cappielloantonio.play.helper.recyclerview.ItemDecoration; import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
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;
@ -52,15 +51,10 @@ public class ArtistCatalogueFragment extends Fragment {
private void initArtistCatalogueView() { private void initArtistCatalogueView() {
bind.artistCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); bind.artistCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
bind.artistCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.artistCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false));
bind.artistCatalogueRecyclerView.setHasFixedSize(true); bind.artistCatalogueRecyclerView.setHasFixedSize(true);
artistAdapter = new ArtistCatalogueAdapter(requireContext()); artistAdapter = new ArtistCatalogueAdapter(requireContext());
artistAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artistAdapter.getItem(position));
activity.navController.navigate(R.id.action_artistCatalogueFragment_to_artistPageFragment, bundle);
});
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter); bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artists -> { artistCatalogueViewModel.getArtistList().observe(requireActivity(), artists -> {
bind.loadingProgressBar.setVisibility(View.GONE); bind.loadingProgressBar.setVisibility(View.GONE);

View file

@ -89,11 +89,6 @@ public class ArtistPageFragment extends Fragment {
bind.albumsRecyclerView.setHasFixedSize(true); bind.albumsRecyclerView.setHasFixedSize(true);
albumArtistPageAdapter = new AlbumArtistPageAdapter(requireContext()); albumArtistPageAdapter = new AlbumArtistPageAdapter(requireContext());
albumArtistPageAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumArtistPageAdapter.getItem(position));
activity.navController.navigate(R.id.action_artistPageFragment_to_albumPageFragment, bundle);
});
bind.albumsRecyclerView.setAdapter(albumArtistPageAdapter); bind.albumsRecyclerView.setAdapter(albumArtistPageAdapter);
artistPageViewModel.getAlbumList().observe(requireActivity(), songs -> albumArtistPageAdapter.setItems(songs)); artistPageViewModel.getAlbumList().observe(requireActivity(), songs -> albumArtistPageAdapter.setItems(songs));
} }

View file

@ -12,7 +12,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.GenreCatalogueAdapter; import com.cappielloantonio.play.adapter.GenreCatalogueAdapter;
import com.cappielloantonio.play.databinding.FragmentGenreCatalogueBinding; import com.cappielloantonio.play.databinding.FragmentGenreCatalogueBinding;
import com.cappielloantonio.play.helper.recyclerview.ItemDecoration; import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
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.viewmodel.GenreCatalogueViewModel; import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel;
@ -58,7 +58,7 @@ public class GenreCatalogueFragment extends Fragment {
private void initArtistCatalogueView() { private void initArtistCatalogueView() {
bind.genreCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); bind.genreCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
bind.genreCatalogueRecyclerView.addItemDecoration(new ItemDecoration(2, 16, false)); bind.genreCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(2, 16, false));
bind.genreCatalogueRecyclerView.setHasFixedSize(true); bind.genreCatalogueRecyclerView.setHasFixedSize(true);
genreCatalogueAdapter = new GenreCatalogueAdapter(requireContext()); genreCatalogueAdapter = new GenreCatalogueAdapter(requireContext());

View file

@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.viewpager2.widget.ViewPager2; import androidx.viewpager2.widget.ViewPager2;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
@ -129,7 +130,7 @@ 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()); recentlyAddedMusicAdapter = new RecentMusicAdapter(requireContext(), getChildFragmentManager());
bind.recentlyAddedTracksRecyclerView.setAdapter(recentlyAddedMusicAdapter); bind.recentlyAddedTracksRecyclerView.setAdapter(recentlyAddedMusicAdapter);
homeViewModel.getRecentlyAddedSongList().observe(requireActivity(), songs -> recentlyAddedMusicAdapter.setItems(songs)); homeViewModel.getRecentlyAddedSongList().observe(requireActivity(), songs -> recentlyAddedMusicAdapter.setItems(songs));
} }
@ -149,19 +150,22 @@ public class HomeFragment extends Fragment {
} }
private void initFavoritesSongView() { private void initFavoritesSongView() {
bind.favoritesTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 3, GridLayoutManager.HORIZONTAL, false)); bind.favoritesTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 5, GridLayoutManager.HORIZONTAL, false));
bind.favoritesTracksRecyclerView.setHasFixedSize(true); bind.favoritesTracksRecyclerView.setHasFixedSize(true);
favoriteSongAdapter = new SongResultSearchAdapter(requireContext(), getChildFragmentManager()); favoriteSongAdapter = new SongResultSearchAdapter(requireContext(), getChildFragmentManager());
bind.favoritesTracksRecyclerView.setAdapter(favoriteSongAdapter); bind.favoritesTracksRecyclerView.setAdapter(favoriteSongAdapter);
homeViewModel.getFavorites().observe(requireActivity(), songs -> favoriteSongAdapter.setItems(songs)); homeViewModel.getFavorites().observe(requireActivity(), songs -> favoriteSongAdapter.setItems(songs));
PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
pagerSnapHelper.attachToRecyclerView(bind.favoritesTracksRecyclerView);
} }
private void initMostPlayedSongView() { private void initMostPlayedSongView() {
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()); mostPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), getChildFragmentManager());
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter); bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs)); homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs));
} }
@ -170,7 +174,7 @@ public class HomeFragment extends Fragment {
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()); recentlyPlayedMusicAdapter = new RecentMusicAdapter(requireContext(), getChildFragmentManager());
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyPlayedMusicAdapter); bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyPlayedMusicAdapter);
homeViewModel.getRecentlyPlayedSongList().observe(requireActivity(), songs -> recentlyPlayedMusicAdapter.setItems(songs)); homeViewModel.getRecentlyPlayedSongList().observe(requireActivity(), songs -> recentlyPlayedMusicAdapter.setItems(songs));
} }

View file

@ -79,11 +79,6 @@ public class LibraryFragment extends Fragment {
bind.albumRecyclerView.setHasFixedSize(true); bind.albumRecyclerView.setHasFixedSize(true);
albumAdapter = new AlbumAdapter(requireContext()); albumAdapter = new AlbumAdapter(requireContext());
albumAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumAdapter.getItem(position));
activity.navController.navigate(R.id.action_libraryFragment_to_albumPageFragment, bundle);
});
bind.albumRecyclerView.setAdapter(albumAdapter); bind.albumRecyclerView.setAdapter(albumAdapter);
libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> albumAdapter.setItems(albums)); libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> albumAdapter.setItems(albums));
} }
@ -93,11 +88,6 @@ public class LibraryFragment extends Fragment {
bind.artistRecyclerView.setHasFixedSize(true); bind.artistRecyclerView.setHasFixedSize(true);
artistAdapter = new ArtistAdapter(requireContext()); artistAdapter = new ArtistAdapter(requireContext());
artistAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artistAdapter.getItem(position));
activity.navController.navigate(R.id.action_libraryFragment_to_artistPageFragment, bundle);
});
bind.artistRecyclerView.setAdapter(artistAdapter); bind.artistRecyclerView.setAdapter(artistAdapter);
libraryViewModel.getArtistSample().observe(requireActivity(), artists -> artistAdapter.setItems(artists)); libraryViewModel.getArtistSample().observe(requireActivity(), artists -> artistAdapter.setItems(artists));
} }

View file

@ -13,13 +13,12 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.cappielloantonio.play.R;
import com.cappielloantonio.play.adapter.AlbumCatalogueAdapter; import com.cappielloantonio.play.adapter.AlbumCatalogueAdapter;
import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter; import com.cappielloantonio.play.adapter.ArtistCatalogueAdapter;
import com.cappielloantonio.play.adapter.RecentSearchAdapter; import com.cappielloantonio.play.adapter.RecentSearchAdapter;
import com.cappielloantonio.play.adapter.SongResultSearchAdapter; import com.cappielloantonio.play.adapter.SongResultSearchAdapter;
import com.cappielloantonio.play.databinding.FragmentSearchBinding; import com.cappielloantonio.play.databinding.FragmentSearchBinding;
import com.cappielloantonio.play.helper.recyclerview.ItemDecoration; import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
import com.cappielloantonio.play.model.RecentSearch; import com.cappielloantonio.play.model.RecentSearch;
import com.cappielloantonio.play.ui.activities.MainActivity; import com.cappielloantonio.play.ui.activities.MainActivity;
import com.cappielloantonio.play.viewmodel.SearchViewModel; import com.cappielloantonio.play.viewmodel.SearchViewModel;
@ -98,28 +97,18 @@ public class SearchFragment extends Fragment {
// Albums // Albums
bind.searchResultAlbumRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); bind.searchResultAlbumRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
bind.searchResultAlbumRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.searchResultAlbumRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false));
bind.searchResultAlbumRecyclerView.setHasFixedSize(true); bind.searchResultAlbumRecyclerView.setHasFixedSize(true);
albumResultSearchAdapter = new AlbumCatalogueAdapter(requireContext()); albumResultSearchAdapter = new AlbumCatalogueAdapter(requireContext());
albumResultSearchAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("album_object", albumResultSearchAdapter.getItem(position));
activity.navController.navigate(R.id.action_searchFragment_to_albumPageFragment, bundle);
});
bind.searchResultAlbumRecyclerView.setAdapter(albumResultSearchAdapter); bind.searchResultAlbumRecyclerView.setAdapter(albumResultSearchAdapter);
// Artist // Artist
bind.searchResultArtistRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); bind.searchResultArtistRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
bind.searchResultArtistRecyclerView.addItemDecoration(new ItemDecoration(2, 20, false)); bind.searchResultArtistRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false));
bind.searchResultArtistRecyclerView.setHasFixedSize(true); bind.searchResultArtistRecyclerView.setHasFixedSize(true);
artistResultSearchAdapter = new ArtistCatalogueAdapter(requireContext()); artistResultSearchAdapter = new ArtistCatalogueAdapter(requireContext());
artistResultSearchAdapter.setClickListener((view, position) -> {
Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artistResultSearchAdapter.getItem(position));
activity.navController.navigate(R.id.action_searchFragment_to_artistPageFragment, bundle);
});
bind.searchResultArtistRecyclerView.setAdapter(artistResultSearchAdapter); bind.searchResultArtistRecyclerView.setAdapter(artistResultSearchAdapter);
} }

View file

@ -4,51 +4,123 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.fragment.NavHostFragment;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.viewmodel.AlbumBottomSheetViewModel;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener { public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
private static final String TAG = "AlbumBottomSheetDialog"; private static final String TAG = "AlbumBottomSheetDialog";
private AlbumBottomSheetViewModel albumBottomSheetViewModel;
private Album album; private Album album;
public AlbumBottomSheetDialog(Album album) { private ImageView coverAlbum;
this.album = album; private TextView titleAlbum;
} private TextView artistAlbum;
private TextView playRadio;
private TextView playRandom;
private TextView playNext;
private TextView addToQueue;
private TextView Download;
private TextView addToPlaylist;
private TextView goToArtist;
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_sheet_album_dialog, container, false); View view = inflater.inflate(R.layout.bottom_sheet_album_dialog, container, false);
album = this.getArguments().getParcelable("album_object");
albumBottomSheetViewModel = new ViewModelProvider(requireActivity()).get(AlbumBottomSheetViewModel.class);
albumBottomSheetViewModel.setAlbum(album);
init(view); init(view);
return view; return view;
} }
private void init(View view) { private void init(View view) {
Button button1 = view.findViewById(R.id.button1); coverAlbum = view.findViewById(R.id.album_cover_image_view);
Button button2 = view.findViewById(R.id.button2); CustomGlideRequest.Builder
.from(requireContext(), albumBottomSheetViewModel.getAlbum().getPrimary(), albumBottomSheetViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
.build()
.into(coverAlbum);
button1.setOnClickListener(v -> { titleAlbum = view.findViewById(R.id.album_title_text_view);
Toast.makeText(requireContext(), album.getTitle(), Toast.LENGTH_SHORT).show(); titleAlbum.setText(albumBottomSheetViewModel.getAlbum().getTitle());
dismiss();
artistAlbum = view.findViewById(R.id.album_artist_text_view);
artistAlbum.setText(albumBottomSheetViewModel.getAlbum().getArtistName());
playRadio = view.findViewById(R.id.play_radio_text_view);
playRadio.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Play radio", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
}); });
button2.setOnClickListener(v -> { playRandom = view.findViewById(R.id.play_random_text_view);
Toast.makeText(requireContext(), album.getArtistName(), Toast.LENGTH_SHORT).show(); playRandom.setOnClickListener(v -> {
dismiss(); Toast.makeText(requireContext(), "Play next", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
playNext = view.findViewById(R.id.play_next_text_view);
playNext.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Play next", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
addToQueue = view.findViewById(R.id.add_to_queue_text_view);
addToQueue.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Add to queue", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
Download = view.findViewById(R.id.download_text_view);
Download.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Download", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
addToPlaylist = view.findViewById(R.id.add_to_playlist_text_view);
addToPlaylist.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Add to playlist", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
goToArtist = view.findViewById(R.id.go_to_artist_text_view);
goToArtist.setOnClickListener(v -> {
Artist artist = albumBottomSheetViewModel.getArtist();
if(artist != null) {
Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artist);
NavHostFragment.findNavController(this).navigate(R.id.artistPageFragment, bundle);
}
else Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
}); });
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
dismissBottomSheet();
}
private void dismissBottomSheet() {
dismiss(); dismiss();
} }
} }

View file

@ -0,0 +1,78 @@
package com.cappielloantonio.play.ui.fragment.bottomsheetdialog;
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 android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.viewmodel.ArtistBottomSheetViewModel;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
private static final String TAG = "AlbumBottomSheetDialog";
private ArtistBottomSheetViewModel artistBottomSheetViewModel;
private Artist artist;
private ImageView coverArtist;
private TextView nameArtist;
private TextView playRadio;
private TextView playRandom;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_sheet_artist_dialog, container, false);
artist = this.getArguments().getParcelable("artist_object");
artistBottomSheetViewModel = new ViewModelProvider(requireActivity()).get(ArtistBottomSheetViewModel.class);
artistBottomSheetViewModel.setArtist(artist);
init(view);
return view;
}
private void init(View view) {
coverArtist = view.findViewById(R.id.artist_cover_image_view);
CustomGlideRequest.Builder
.from(requireContext(), artistBottomSheetViewModel.getArtist().getPrimary(), artistBottomSheetViewModel.getArtist().getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
.build()
.into(coverArtist);
nameArtist = view.findViewById(R.id.song_title_text_view);
nameArtist.setText(artistBottomSheetViewModel.getArtist().getName());
playRadio = view.findViewById(R.id.play_radio_text_view);
playRadio.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Play radio", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
playRandom = view.findViewById(R.id.play_random_text_view);
playRandom.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Play random", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
}
@Override
public void onClick(View v) {
dismissBottomSheet();
}
private void dismissBottomSheet() {
dismiss();
}
}

View file

@ -11,17 +11,20 @@ import android.widget.ToggleButton;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.fragment.NavHostFragment;
import com.cappielloantonio.play.R; import com.cappielloantonio.play.R;
import com.cappielloantonio.play.glide.CustomGlideRequest; import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.viewmodel.AlbumBottomSheetViewModel; import com.cappielloantonio.play.viewmodel.SongBottomSheetViewModel;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class SongBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener { public class SongBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
private static final String TAG = "AlbumBottomSheetDialog"; private static final String TAG = "SongBottomSheetDialog";
private AlbumBottomSheetViewModel albumBottomSheetViewModel; private SongBottomSheetViewModel songBottomSheetViewModel;
private Song song; private Song song;
private ImageView coverSong; private ImageView coverSong;
@ -34,19 +37,18 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
private TextView addToQueue; private TextView addToQueue;
private TextView Download; private TextView Download;
private TextView addToPlaylist; private TextView addToPlaylist;
private TextView goToAlbum;
private TextView goToArtist; private TextView goToArtist;
public SongBottomSheetDialog(Song song) {
this.song = song;
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_sheet_song_dialog, container, false); View view = inflater.inflate(R.layout.bottom_sheet_song_dialog, container, false);
albumBottomSheetViewModel = new ViewModelProvider(requireActivity()).get(AlbumBottomSheetViewModel.class);
albumBottomSheetViewModel.setSong(song); song = this.getArguments().getParcelable("song_object");
songBottomSheetViewModel = new ViewModelProvider(requireActivity()).get(SongBottomSheetViewModel.class);
songBottomSheetViewModel.setSong(song);
init(view); init(view);
@ -56,20 +58,20 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
private void init(View view) { private void init(View view) {
coverSong = view.findViewById(R.id.song_cover_image_view); coverSong = view.findViewById(R.id.song_cover_image_view);
CustomGlideRequest.Builder CustomGlideRequest.Builder
.from(requireContext(), albumBottomSheetViewModel.getSong().getPrimary(), albumBottomSheetViewModel.getSong().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY) .from(requireContext(), songBottomSheetViewModel.getSong().getPrimary(), songBottomSheetViewModel.getSong().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
.build() .build()
.into(coverSong); .into(coverSong);
titleSong = view.findViewById(R.id.song_title_text_view); titleSong = view.findViewById(R.id.song_title_text_view);
titleSong.setText(albumBottomSheetViewModel.getSong().getTitle()); titleSong.setText(songBottomSheetViewModel.getSong().getTitle());
artistSong = view.findViewById(R.id.song_artist_text_view); artistSong = view.findViewById(R.id.song_artist_text_view);
artistSong.setText(albumBottomSheetViewModel.getSong().getArtistName()); artistSong.setText(songBottomSheetViewModel.getSong().getArtistName());
thumbToggle = view.findViewById(R.id.button_favorite); thumbToggle = view.findViewById(R.id.button_favorite);
thumbToggle.setChecked(albumBottomSheetViewModel.getSong().isFavorite()); thumbToggle.setChecked(songBottomSheetViewModel.getSong().isFavorite());
thumbToggle.setOnClickListener(v -> { thumbToggle.setOnClickListener(v -> {
albumBottomSheetViewModel.setFavorite(); songBottomSheetViewModel.setFavorite();
dismissBottomSheet(); dismissBottomSheet();
}); });
@ -103,9 +105,30 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
dismissBottomSheet(); dismissBottomSheet();
}); });
goToAlbum = view.findViewById(R.id.go_to_album_text_view);
goToAlbum.setOnClickListener(v -> {
Album album = songBottomSheetViewModel.getAlbum();
if(album != null) {
Bundle bundle = new Bundle();
bundle.putParcelable("album_object", album);
NavHostFragment.findNavController(this).navigate(R.id.albumPageFragment, bundle);
}
else Toast.makeText(requireContext(), "Error retrieving album", Toast.LENGTH_SHORT).show();
dismissBottomSheet();
});
goToArtist = view.findViewById(R.id.go_to_artist_text_view); goToArtist = view.findViewById(R.id.go_to_artist_text_view);
goToArtist.setOnClickListener(v -> { goToArtist.setOnClickListener(v -> {
Toast.makeText(requireContext(), "Go to artist", Toast.LENGTH_SHORT).show(); Artist artist = songBottomSheetViewModel.getArtist();
if(artist != null) {
Bundle bundle = new Bundle();
bundle.putParcelable("artist_object", artist);
NavHostFragment.findNavController(this).navigate(R.id.artistPageFragment, bundle);
}
else Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
dismissBottomSheet(); dismissBottomSheet();
}); });
} }

View file

@ -2,7 +2,6 @@ package com.cappielloantonio.play.util;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import com.cappielloantonio.play.App; import com.cappielloantonio.play.App;
import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.interfaces.MediaCallback;
@ -222,8 +221,6 @@ public class SyncUtil {
private static Song updateSongData(Map<Integer, Song> library, Song newSong) { private static Song updateSongData(Map<Integer, Song> library, Song newSong) {
if(library.containsKey(newSong.hashCode())) { if(library.containsKey(newSong.hashCode())) {
Log.d(TAG, "updateSongData: " + newSong.getTitle());
Song oldSong = library.get(newSong.hashCode()); Song oldSong = library.get(newSong.hashCode());
newSong.setFavorite(oldSong.isFavorite()); newSong.setFavorite(oldSong.isFavorite());
newSong.setAdded(oldSong.getAdded()); newSong.setAdded(oldSong.getAdded());

View file

@ -5,35 +5,30 @@ import android.app.Application;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.repository.SongRepository; import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.repository.ArtistRepository;
public class AlbumBottomSheetViewModel extends AndroidViewModel { public class AlbumBottomSheetViewModel extends AndroidViewModel {
private SongRepository songRepository; private ArtistRepository artistRepository;
private Song song;
private Album album;
public AlbumBottomSheetViewModel(@NonNull Application application) { public AlbumBottomSheetViewModel(@NonNull Application application) {
super(application); super(application);
songRepository = new SongRepository(application); artistRepository = new ArtistRepository(application);
} }
public void setSong(Song song) { public Album getAlbum() {
this.song = song; return album;
} }
public Song getSong() { public void setAlbum(Album album) {
return song; this.album = album;
} }
public void setFavorite() { public Artist getArtist() {
if(song.isFavorite()) { return artistRepository.getArtistByID(album.getArtistId());
song.setFavorite(false);
}
else {
song.setFavorite(true);
}
songRepository.setFavoriteStatus(song);
} }
} }

View file

@ -0,0 +1,24 @@
package com.cappielloantonio.play.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import com.cappielloantonio.play.model.Artist;
public class ArtistBottomSheetViewModel extends AndroidViewModel {
private Artist artist;
public ArtistBottomSheetViewModel(@NonNull Application application) {
super(application);
}
public void setArtist(Artist artist) {
this.artist = artist;
}
public Artist getArtist() {
return artist;
}
}

View file

@ -0,0 +1,54 @@
package com.cappielloantonio.play.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.AlbumRepository;
import com.cappielloantonio.play.repository.ArtistRepository;
import com.cappielloantonio.play.repository.SongRepository;
public class SongBottomSheetViewModel extends AndroidViewModel {
private SongRepository songRepository;
private AlbumRepository albumRepository;
private ArtistRepository artistRepository;
private Song song;
public SongBottomSheetViewModel(@NonNull Application application) {
super(application);
songRepository = new SongRepository(application);
albumRepository = new AlbumRepository(application);
artistRepository = new ArtistRepository(application);
}
public void setSong(Song song) {
this.song = song;
}
public Song getSong() {
return song;
}
public void setFavorite() {
if(song.isFavorite())
song.setFavorite(false);
else
song.setFavorite(true);
songRepository.setFavoriteStatus(song);
}
public Album getAlbum() {
return albumRepository.getAlbumByID(song.getAlbumId());
}
public Artist getArtist() {
return artistRepository.getArtistByID(song.getArtistId());
}
}

View file

@ -4,6 +4,6 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="#FF000000" android:fillColor="@color/titleTextColor"
android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2z"/> android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2z"/>
</vector> </vector>

View file

@ -4,6 +4,6 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="#FF000000" android:fillColor="@color/titleTextColor"
android:pathData="M9,21h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.58,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2zM9,9l4.34,-4.34L12,10h9v2l-3,7H9V9zM1,9h4v12H1z"/> android:pathData="M9,21h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.58,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2zM9,9l4.34,-4.34L12,10h9v2l-3,7H9V9zM1,9h4v12H1z"/>
</vector> </vector>

View file

@ -1,23 +1,188 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="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="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp"> android:background="@color/cardColor">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingStart="20dp"
android:paddingEnd="20dp">
<!-- Header -->
<androidx.cardview.widget.CardView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:backgroundTint="@color/cardColor"
android:paddingTop="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/subtitleTextColor"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="0dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="false">
<ImageView
android:id="@+id/album_cover_image_view"
android:layout_width="54dp"
android:layout_height="54dp" />
</androidx.cardview.widget.CardView>
<TextView <TextView
android:id="@+id/album_title_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="This is a BottomSheet" android:ellipsize="end"
android:textSize="25sp" /> android:fontFamily="@font/open_sans_font_family"
<Button android:maxLines="1"
android:id="@+id/button1" android:paddingTop="8dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/label_placeholder"
android:textColor="@color/titleTextColor"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/album_artist_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="button 1" /> android:fontFamily="@font/open_sans_font_family"
<Button android:paddingStart="12dp"
android:id="@+id/button2" android:text="@string/label_placeholder"
android:layout_width="wrap_content" android:textColor="@color/subtitleTextColor"
android:textSize="12sp"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/album_title_text_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/option_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="button 2" /> android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:paddingTop="8dp"
android:paddingBottom="12dp">
<TextView
android:id="@+id/play_radio_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Avvia radio"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="20dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
<TextView
android:id="@+id/play_random_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Riproduzione casuale"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true" />
<TextView
android:id="@+id/play_next_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Riproduci dopo"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true" />
<TextView
android:id="@+id/add_to_queue_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Aggiungi alla coda"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
<TextView
android:id="@+id/download_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Scarica"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true"
/>
<TextView
android:id="@+id/add_to_playlist_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Aggiungi alla playlist"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
<TextView
android:id="@+id/go_to_artist_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Vai all'artista"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/cardColor">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingStart="20dp"
android:paddingEnd="20dp">
<!-- Header -->
<androidx.cardview.widget.CardView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:backgroundTint="@color/cardColor"
android:paddingTop="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/subtitleTextColor"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="0dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="false">
<ImageView
android:id="@+id/artist_cover_image_view"
android:layout_width="54dp"
android:layout_height="54dp" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/song_title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/open_sans_font_family"
android:maxLines="1"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/label_placeholder"
android:textColor="@color/titleTextColor"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/option_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:paddingTop="8dp"
android:paddingBottom="12dp">
<TextView
android:id="@+id/play_radio_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Avvia radio"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="20dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
<TextView
android:id="@+id/play_random_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Riproduzione casuale"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true" />
</LinearLayout>
</LinearLayout>

View file

@ -67,7 +67,7 @@
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:text="@string/label_placeholder" android:text="@string/label_placeholder"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="18sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintStart_toEndOf="@+id/imageView" app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -80,7 +80,7 @@
android:paddingStart="12dp" android:paddingStart="12dp"
android:text="@string/label_placeholder" android:text="@string/label_placeholder"
android:textColor="@color/subtitleTextColor" android:textColor="@color/subtitleTextColor"
android:textSize="14sp" android:textSize="12sp"
app:layout_constraintStart_toEndOf="@+id/imageView" app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/song_title_text_view" /> app:layout_constraintTop_toBottomOf="@+id/song_title_text_view" />
@ -103,10 +103,10 @@
android:text="Avvia radio" android:text="Avvia radio"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700" android:textFontWeight="700"
android:textSize="15dp" android:textSize="14dp"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:paddingTop="14dp" android:paddingTop="12dp"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:paddingStart="20dp" android:paddingStart="20dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true"/> android:clickable="true"/>
@ -115,13 +115,13 @@
android:id="@+id/play_next_text_view" android:id="@+id/play_next_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="14dp" android:paddingTop="12dp"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:text="Riproduci dopo" android:text="Riproduci dopo"
android:paddingStart="20dp" android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700" android:textFontWeight="700"
android:textSize="15dp" android:textSize="14dp"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" /> android:clickable="true" />
@ -130,13 +130,13 @@
android:id="@+id/add_to_queue_text_view" android:id="@+id/add_to_queue_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="14dp" android:paddingTop="12dp"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:text="Aggiungi alla coda" android:text="Aggiungi alla coda"
android:paddingStart="20dp" android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700" android:textFontWeight="700"
android:textSize="15dp" android:textSize="14dp"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true"/> android:clickable="true"/>
@ -145,13 +145,13 @@
android:id="@+id/download_text_view" android:id="@+id/download_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="14dp" android:paddingTop="12dp"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:text="Scarica" android:text="Scarica"
android:paddingStart="20dp" android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700" android:textFontWeight="700"
android:textSize="15dp" android:textSize="14dp"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
@ -161,13 +161,28 @@
android:id="@+id/add_to_playlist_text_view" android:id="@+id/add_to_playlist_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="14dp" android:paddingTop="12dp"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:text="Aggiungi alla playlist" android:text="Aggiungi alla playlist"
android:paddingStart="20dp" android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700" android:textFontWeight="700"
android:textSize="15dp" android:textSize="14dp"
android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
<TextView
android:id="@+id/go_to_album_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:text="Vai all'album"
android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700"
android:textSize="14dp"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true"/> android:clickable="true"/>
@ -176,13 +191,13 @@
android:id="@+id/go_to_artist_text_view" android:id="@+id/go_to_artist_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="14dp" android:paddingTop="12dp"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:text="Vai all'artista" android:text="Vai all'artista"
android:paddingStart="20dp" android:paddingStart="20dp"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:textFontWeight="700" android:textFontWeight="700"
android:textSize="15dp" android:textSize="14dp"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true"/> android:clickable="true"/>

View file

@ -66,39 +66,18 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<!-- Label and button --> <!-- Label and button -->
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="@font/open_sans_font_family" android:fontFamily="@font/open_sans_font_family"
android:paddingStart="8dp" android:layout_marginTop="12dp"
android:paddingEnd="8dp" android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="Songs" android:text="Songs"
android:textColor="@color/titleTextColor" android:textColor="@color/titleTextColor"
android:textSize="22sp" android:textSize="22sp"
android:textStyle="bold" /> android:textStyle="bold" />
<ImageButton
android:id="@+id/album_settings_image_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_marginTop="-6dp"
android:backgroundTint="@android:color/transparent"
android:tint="@color/titleTextColor"
android:src="@drawable/ic_more" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/song_recycler_view" android:id="@+id/song_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -14,7 +14,8 @@
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp" card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/artist_page_album_cover_image_view" android:id="@+id/artist_page_album_cover_image_view"

View file

@ -14,12 +14,13 @@
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp" card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/track_cover_image_view" android:id="@+id/track_cover_image_view"
android:layout_width="172dp" android:layout_width="172dp"
android:layout_height="172dp"/> android:layout_height="172dp" />
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView

View file

@ -14,7 +14,8 @@
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp" card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/album_cover_image_view" android:id="@+id/album_cover_image_view"

View file

@ -15,7 +15,8 @@
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp" card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/artist_cover_image_view" android:id="@+id/artist_cover_image_view"

View file

@ -17,7 +17,8 @@
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp" card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/album_catalogue_cover_image_view" android:id="@+id/album_catalogue_cover_image_view"

View file

@ -17,7 +17,8 @@
card_view:cardCornerRadius="4dp" card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp" card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/artist_catalogue_cover_image_view" android:id="@+id/artist_catalogue_cover_image_view"

View file

@ -178,4 +178,22 @@
android:name="com.cappielloantonio.play.ui.fragment.SongListPageFragment" android:name="com.cappielloantonio.play.ui.fragment.SongListPageFragment"
android:label="SongListPageFragment" android:label="SongListPageFragment"
tools:layout="@layout/fragment_song_list_page"/> tools:layout="@layout/fragment_song_list_page"/>
<dialog
android:id="@+id/songBottomSheetDialog"
android:name="com.cappielloantonio.play.ui.fragment.bottomsheetdialog.SongBottomSheetDialog"
android:label="SongBottomSheetDialog"
tools:layout="@layout/bottom_sheet_song_dialog">
</dialog>
<dialog
android:id="@+id/artistBottomSheetDialog"
android:name="com.cappielloantonio.play.ui.fragment.bottomsheetdialog.ArtistBottomSheetDialog"
android:label="ArtistBottomSheetDialog"
tools:layout="@layout/bottom_sheet_artist_dialog">
</dialog>
<dialog
android:id="@+id/albumBottomSheetDialog"
android:name="com.cappielloantonio.play.ui.fragment.bottomsheetdialog.AlbumBottomSheetDialog"
android:label="AlbumBottomSheetDialog"
tools:layout="@layout/bottom_sheet_album_dialog">
</dialog>
</navigation> </navigation>