mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
Changed playlistItem layout in library and Catalogue page
This commit is contained in:
parent
27845b4646
commit
0c891ca727
11 changed files with 369 additions and 282 deletions
12
.idea/misc.xml
generated
12
.idea/misc.xml
generated
|
|
@ -40,7 +40,7 @@
|
|||
<entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.2814814814814815" />
|
||||
<entry key="app/src/main/res/drawable/ic_launcher_foreground.xml" value="0.34322916666666664" />
|
||||
<entry key="app/src/main/res/drawable/ic_lyrics.xml" value="0.17314814814814813" />
|
||||
<entry key="app/src/main/res/drawable/ic_minimize.xml" value="0.28703703703703703" />
|
||||
<entry key="app/src/main/res/drawable/ic_minimize.xml" value="0.8" />
|
||||
<entry key="app/src/main/res/drawable/ic_mix_from_here.xml" value="0.28703703703703703" />
|
||||
<entry key="app/src/main/res/drawable/ic_more_vert.xml" value="0.28055555555555556" />
|
||||
<entry key="app/src/main/res/drawable/ic_pause.xml" value="0.28055555555555556" />
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
<entry key="app/src/main/res/layout/dialog_starred_sync.xml" value="0.528125" />
|
||||
<entry key="app/src/main/res/layout/fragment_album_catalogue.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/fragment_album_list_page.xml" value="0.225" />
|
||||
<entry key="app/src/main/res/layout/fragment_album_page.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/fragment_album_page.xml" value="0.3166496424923391" />
|
||||
<entry key="app/src/main/res/layout/fragment_artist_catalogue.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/fragment_artist_list_page.xml" value="0.225" />
|
||||
<entry key="app/src/main/res/layout/fragment_artist_page.xml" value="0.3229166666666667" />
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
<entry key="app/src/main/res/layout/fragment_genre_catalogue.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/fragment_home.xml" value="0.283363802559415" />
|
||||
<entry key="app/src/main/res/layout/fragment_landing.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/fragment_library.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/fragment_library.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/fragment_login.xml" value="0.3166496424923391" />
|
||||
<entry key="app/src/main/res/layout/fragment_player_bottom_sheet.xml" value="0.3166496424923391" />
|
||||
<entry key="app/src/main/res/layout/fragment_player_cover.xml" value="0.528125" />
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<entry key="app/src/main/res/layout/fragment_settings.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/fragment_song_list_page.xml" value="0.225" />
|
||||
<entry key="app/src/main/res/layout/inner_fragment_player_controller.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/inner_fragment_player_controller_layout.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/inner_fragment_player_controller_layout.xml" value="0.49016641452344933" />
|
||||
<entry key="app/src/main/res/layout/inner_fragment_player_cover.xml" value="0.40390879478827363" />
|
||||
<entry key="app/src/main/res/layout/inner_fragment_player_lyrics.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/inner_fragment_player_queue.xml" value="0.3229166666666667" />
|
||||
|
|
@ -120,8 +120,9 @@
|
|||
<entry key="app/src/main/res/layout/item_horizontal_album.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/item_horizontal_artist.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_horizontal_playlist.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_horizontal_playlist_dialog.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_horizontal_playlist_dialog_track.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_horizontal_track.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/item_horizontal_track.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_library_album.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_library_artist.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_library_artist_page_or_similar_album.xml" value="0.3229166666666667" />
|
||||
|
|
@ -130,6 +131,7 @@
|
|||
<entry key="app/src/main/res/layout/item_library_catalogue_genre.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_library_catalogue_playlist.xml" value="0.225" />
|
||||
<entry key="app/src/main/res/layout/item_library_genre.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_library_playlist.xml" value="0.1546875" />
|
||||
<entry key="app/src/main/res/layout/item_library_similar_artist.xml" value="0.3229166666666667" />
|
||||
<entry key="app/src/main/res/layout/item_login_server.xml" value="0.25" />
|
||||
<entry key="app/src/main/res/layout/item_placehoder_discovery.xml" value="0.3229166666666667" />
|
||||
|
|
|
|||
|
|
@ -1,156 +0,0 @@
|
|||
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.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistEditorDialog;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlaylistCatalogueAdapter extends RecyclerView.Adapter<PlaylistCatalogueAdapter.ViewHolder> implements Filterable {
|
||||
private static final String TAG = "PlaylistCatalogueAdapter";
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
private final MainActivity activity;
|
||||
private final Context context;
|
||||
private final boolean isOffline;
|
||||
|
||||
|
||||
private final Filter filtering = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Playlist> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(playlistsFull);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (Playlist item : playlistsFull) {
|
||||
if (item.getName().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
playlists.clear();
|
||||
playlists.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private List<Playlist> playlists;
|
||||
private List<Playlist> playlistsFull;
|
||||
|
||||
public PlaylistCatalogueAdapter(MainActivity activity, Context context, boolean isOffline) {
|
||||
this.activity = activity;
|
||||
this.context = context;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.playlists = new ArrayList<>();
|
||||
this.isOffline = isOffline;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.item_library_catalogue_playlist, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Playlist playlist = playlists.get(position);
|
||||
|
||||
holder.textPlaylistName.setText(MusicUtil.getReadableString(playlist.getName()));
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, playlist.getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return playlists.size();
|
||||
}
|
||||
|
||||
public Playlist getItem(int position) {
|
||||
return playlists.get(position);
|
||||
}
|
||||
|
||||
public void setItems(List<Playlist> playlists) {
|
||||
this.playlists = playlists;
|
||||
this.playlistsFull = new ArrayList<>(playlists);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filtering;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView textPlaylistName;
|
||||
ImageView cover;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
textPlaylistName = itemView.findViewById(R.id.playlist_name_text);
|
||||
cover = itemView.findViewById(R.id.playlist_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("playlist_object", playlists.get(getBindingAdapterPosition()));
|
||||
bundle.putBoolean("is_offline", isOffline);
|
||||
|
||||
Navigation.findNavController(view).navigate(R.id.action_playlistCatalogueFragment_to_playlistPageFragment, bundle);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("playlist_object", playlists.get(getBindingAdapterPosition()));
|
||||
|
||||
PlaylistEditorDialog dialog = new PlaylistEditorDialog();
|
||||
dialog.setArguments(bundle);
|
||||
dialog.show(activity.getSupportFragmentManager(), null);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistChooserDialog;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistChooserViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlaylistDialogHorizontalAdapter extends RecyclerView.Adapter<PlaylistDialogHorizontalAdapter.ViewHolder> {
|
||||
private static final String TAG = "PlaylistDialogHorizontalAdapter";
|
||||
|
||||
private final Context context;
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
private final PlaylistChooserViewModel playlistChooserViewModel;
|
||||
private final PlaylistChooserDialog playlistChooserDialog;
|
||||
|
||||
private List<Playlist> playlists;
|
||||
|
||||
public PlaylistDialogHorizontalAdapter(Context context, PlaylistChooserViewModel playlistChooserViewModel, PlaylistChooserDialog playlistChooserDialog) {
|
||||
this.context = context;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.playlists = new ArrayList<>();
|
||||
|
||||
this.playlistChooserViewModel = playlistChooserViewModel;
|
||||
this.playlistChooserDialog = playlistChooserDialog;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.item_horizontal_playlist_dialog, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Playlist playlist = playlists.get(position);
|
||||
|
||||
holder.playlistTitle.setText(MusicUtil.getReadableString(playlist.getName()));
|
||||
holder.playlistTrackCount.setText(context.getString(R.string.playlist_counted_tracks, playlist.getSongCount()));
|
||||
holder.playlistDuration.setText(MusicUtil.getReadableDurationString(playlist.getDuration(), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return playlists.size();
|
||||
}
|
||||
|
||||
public void setItems(List<Playlist> playlists) {
|
||||
this.playlists = playlists;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Playlist getItem(int id) {
|
||||
return playlists.get(id);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
TextView playlistTitle;
|
||||
TextView playlistTrackCount;
|
||||
TextView playlistDuration;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
playlistTitle = itemView.findViewById(R.id.playlist_dialog_title_text_view);
|
||||
playlistTrackCount = itemView.findViewById(R.id.playlist_dialog_count_text_view);
|
||||
playlistDuration = itemView.findViewById(R.id.playlist_dialog_duration_text_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
|
||||
playlistTitle.setSelected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
playlistChooserViewModel.addSongToPlaylist(playlists.get(getBindingAdapterPosition()).getId());
|
||||
playlistChooserDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,75 @@
|
|||
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.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistChooserDialog;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistEditorDialog;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistChooserViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlaylistHorizontalAdapter extends RecyclerView.Adapter<PlaylistHorizontalAdapter.ViewHolder> {
|
||||
private static final String TAG = "PlaylistHorizontalAdapter";
|
||||
public class PlaylistHorizontalAdapter extends RecyclerView.Adapter<PlaylistHorizontalAdapter.ViewHolder> implements Filterable {
|
||||
private static final String TAG = "PlaylistDialogHorizontalAdapter";
|
||||
|
||||
private List<Playlist> playlists;
|
||||
private List<Playlist> playlistsFull;
|
||||
|
||||
private final MainActivity activity;
|
||||
private final Context context;
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
private final PlaylistChooserViewModel playlistChooserViewModel;
|
||||
private final PlaylistChooserDialog playlistChooserDialog;
|
||||
private final Filter filtering = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Playlist> filteredList = new ArrayList<>();
|
||||
|
||||
private List<Playlist> playlists;
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(playlistsFull);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
public PlaylistHorizontalAdapter(Context context, PlaylistChooserViewModel playlistChooserViewModel, PlaylistChooserDialog playlistChooserDialog) {
|
||||
for (Playlist item : playlistsFull) {
|
||||
if (item.getName().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
playlists.clear();
|
||||
playlists.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public PlaylistHorizontalAdapter(MainActivity activity, Context context) {
|
||||
this.activity = activity;
|
||||
this.context = context;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.playlists = new ArrayList<>();
|
||||
|
||||
this.playlistChooserViewModel = playlistChooserViewModel;
|
||||
this.playlistChooserDialog = playlistChooserDialog;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
@ -59,16 +93,22 @@ public class PlaylistHorizontalAdapter extends RecyclerView.Adapter<PlaylistHori
|
|||
return playlists.size();
|
||||
}
|
||||
|
||||
public void setItems(List<Playlist> playlists) {
|
||||
this.playlists = playlists;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Playlist getItem(int id) {
|
||||
return playlists.get(id);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public void setItems(List<Playlist> playlists) {
|
||||
this.playlists = playlists;
|
||||
this.playlistsFull = new ArrayList<>(playlists);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filtering;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
TextView playlistTitle;
|
||||
TextView playlistTrackCount;
|
||||
TextView playlistDuration;
|
||||
|
|
@ -81,14 +121,41 @@ public class PlaylistHorizontalAdapter extends RecyclerView.Adapter<PlaylistHori
|
|||
playlistDuration = itemView.findViewById(R.id.playlist_dialog_duration_text_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
||||
playlistTitle.setSelected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
playlistChooserViewModel.addSongToPlaylist(playlists.get(getBindingAdapterPosition()).getId());
|
||||
playlistChooserDialog.dismiss();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("playlist_object", playlists.get(getBindingAdapterPosition()));
|
||||
|
||||
if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.libraryFragment) {
|
||||
bundle.putBoolean("is_offline", false);
|
||||
Navigation.findNavController(view).navigate(R.id.action_libraryFragment_to_playlistPageFragment, bundle);
|
||||
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.downloadFragment) {
|
||||
bundle.putBoolean("is_offline", true);
|
||||
Navigation.findNavController(view).navigate(R.id.action_downloadFragment_to_playlistPageFragment, bundle);
|
||||
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.playlistCatalogueFragment) {
|
||||
bundle.putBoolean("is_offline", false);
|
||||
Navigation.findNavController(view).navigate(R.id.action_playlistCatalogueFragment_to_playlistPageFragment, bundle);
|
||||
}
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("playlist_object", playlists.get(getBindingAdapterPosition()));
|
||||
|
||||
PlaylistEditorDialog dialog = new PlaylistEditorDialog();
|
||||
dialog.setArguments(bundle);
|
||||
dialog.show(activity.getSupportFragmentManager(), null);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistDialogHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.DialogPlaylistChooserBinding;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistChooserViewModel;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ public class PlaylistChooserDialog extends DialogFragment {
|
|||
private DialogPlaylistChooserBinding bind;
|
||||
private PlaylistChooserViewModel playlistChooserViewModel;
|
||||
|
||||
private PlaylistHorizontalAdapter playlistHorizontalAdapter;
|
||||
private PlaylistDialogHorizontalAdapter playlistDialogHorizontalAdapter;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
@ -79,15 +79,15 @@ public class PlaylistChooserDialog extends DialogFragment {
|
|||
bind.playlistDialogRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.playlistDialogRecyclerView.setHasFixedSize(true);
|
||||
|
||||
playlistHorizontalAdapter = new PlaylistHorizontalAdapter(requireContext(), playlistChooserViewModel, this);
|
||||
bind.playlistDialogRecyclerView.setAdapter(playlistHorizontalAdapter);
|
||||
playlistDialogHorizontalAdapter = new PlaylistDialogHorizontalAdapter(requireContext(), playlistChooserViewModel, this);
|
||||
bind.playlistDialogRecyclerView.setAdapter(playlistDialogHorizontalAdapter);
|
||||
|
||||
playlistChooserViewModel.getPlaylistList().observe(requireActivity(), playlists -> {
|
||||
if (playlists != null) {
|
||||
if (playlists.size() > 0) {
|
||||
if (bind != null) bind.noPlaylistsCreatedTextView.setVisibility(View.GONE);
|
||||
if (bind != null) bind.playlistDialogRecyclerView.setVisibility(View.VISIBLE);
|
||||
playlistHorizontalAdapter.setItems(playlists);
|
||||
playlistDialogHorizontalAdapter.setItems(playlists);
|
||||
} else {
|
||||
if (bind != null) bind.noPlaylistsCreatedTextView.setVisibility(View.VISIBLE);
|
||||
if (bind != null) bind.playlistDialogRecyclerView.setVisibility(View.GONE);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.session.MediaBrowser;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
|
|
@ -26,6 +25,9 @@ import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
|
|||
import com.cappielloantonio.play.adapter.ArtistAdapter;
|
||||
import com.cappielloantonio.play.adapter.GenreAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistDialogHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentLibraryBinding;
|
||||
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
||||
import com.cappielloantonio.play.helper.recyclerview.DotsIndicatorDecoration;
|
||||
|
|
@ -35,7 +37,6 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
|
|||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.LibraryViewModel;
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -52,6 +53,8 @@ public class LibraryFragment extends Fragment {
|
|||
private GenreAdapter genreAdapter;
|
||||
private PlaylistAdapter playlistAdapter;
|
||||
|
||||
private PlaylistHorizontalAdapter playlistHorizontalAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -254,11 +257,10 @@ public class LibraryFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void initPlaylistSlideView() {
|
||||
bind.playlistViewPager.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
|
||||
bind.playlistRecyclerView.setHasFixedSize(true);
|
||||
|
||||
playlistAdapter = new PlaylistAdapter(activity, requireContext(), false);
|
||||
bind.playlistViewPager.setAdapter(playlistAdapter);
|
||||
bind.playlistViewPager.setOffscreenPageLimit(3);
|
||||
playlistHorizontalAdapter = new PlaylistHorizontalAdapter(activity, requireContext());
|
||||
bind.playlistRecyclerView.setAdapter(playlistHorizontalAdapter);
|
||||
libraryViewModel.getPlaylistSample().observe(requireActivity(), playlists -> {
|
||||
if (playlists == null) {
|
||||
if (bind != null) bind.libraryPlaylistPlaceholder.placeholder.setVisibility(View.VISIBLE);
|
||||
|
|
@ -266,26 +268,22 @@ public class LibraryFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.libraryPlaylistPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.libraryPlaylistSector.setVisibility(!playlists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.playlistRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(playlists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
playlistAdapter.setItems(playlists);
|
||||
playlistHorizontalAdapter.setItems(playlists);
|
||||
}
|
||||
});
|
||||
|
||||
setDiscoverSongSlideViewOffset(20, 16);
|
||||
}
|
||||
SnapHelper starredTrackSnapHelper = new PagerSnapHelper();
|
||||
starredTrackSnapHelper.attachToRecyclerView(bind.playlistRecyclerView);
|
||||
|
||||
private void setDiscoverSongSlideViewOffset(float pageOffset, float pageMargin) {
|
||||
bind.playlistViewPager.setPageTransformer((page, position) -> {
|
||||
float myOffset = position * -(2 * pageOffset + pageMargin);
|
||||
if (bind.playlistViewPager.getOrientation() == ViewPager2.ORIENTATION_HORIZONTAL) {
|
||||
if (ViewCompat.getLayoutDirection(bind.playlistViewPager) == ViewCompat.LAYOUT_DIRECTION_RTL) {
|
||||
page.setTranslationX(-myOffset);
|
||||
} else {
|
||||
page.setTranslationX(myOffset);
|
||||
}
|
||||
} else {
|
||||
page.setTranslationY(myOffset);
|
||||
}
|
||||
});
|
||||
bind.playlistRecyclerView.addItemDecoration(
|
||||
new DotsIndicatorDecoration(
|
||||
getResources().getDimensionPixelSize(R.dimen.radius),
|
||||
getResources().getDimensionPixelSize(R.dimen.radius) * 4,
|
||||
getResources().getDimensionPixelSize(R.dimen.dots_height),
|
||||
requireContext().getResources().getColor(R.color.titleTextColor, null),
|
||||
requireContext().getResources().getColor(R.color.titleTextColor, null))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.PlaylistCatalogueAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentPlaylistCatalogueBinding;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
|
|
@ -37,7 +37,7 @@ public class PlaylistCatalogueFragment extends Fragment {
|
|||
private MainActivity activity;
|
||||
private PlaylistCatalogueViewModel playlistCatalogueViewModel;
|
||||
|
||||
private PlaylistCatalogueAdapter playlistCatalogueAdapter;
|
||||
private PlaylistHorizontalAdapter playlistHorizontalAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
|
@ -108,10 +108,10 @@ public class PlaylistCatalogueFragment extends Fragment {
|
|||
bind.playlistCatalogueRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.playlistCatalogueRecyclerView.setHasFixedSize(true);
|
||||
|
||||
playlistCatalogueAdapter = new PlaylistCatalogueAdapter(activity, requireContext(), playlistCatalogueViewModel.getType().equals(Playlist.DOWNLOADED));
|
||||
bind.playlistCatalogueRecyclerView.setAdapter(playlistCatalogueAdapter);
|
||||
playlistHorizontalAdapter = new PlaylistHorizontalAdapter(activity, requireContext());
|
||||
bind.playlistCatalogueRecyclerView.setAdapter(playlistHorizontalAdapter);
|
||||
|
||||
if(getActivity() != null) {
|
||||
if (getActivity() != null) {
|
||||
playlistCatalogueViewModel.getPlaylistList(requireActivity()).observe(requireActivity(), playlists ->
|
||||
playlistCatalogueViewModel.getPinnedPlaylistList(requireActivity()).observe(requireActivity(),
|
||||
pinnedPlaylists -> {
|
||||
|
|
@ -135,7 +135,7 @@ public class PlaylistCatalogueFragment extends Fragment {
|
|||
sortedList.addAll(unsortedList);
|
||||
}
|
||||
|
||||
playlistCatalogueAdapter.setItems(sortedList);
|
||||
playlistHorizontalAdapter.setItems(sortedList);
|
||||
playlistCatalogueViewModel.unpinPlaylist(pinnedPlaylistsNotFound);
|
||||
}));
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ public class PlaylistCatalogueFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
playlistCatalogueAdapter.getFilter().filter(newText);
|
||||
playlistHorizontalAdapter.getFilter().filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -284,7 +284,6 @@
|
|||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_playlist" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_catalogue_text_view_clickable"
|
||||
style="@style/TitleMedium"
|
||||
|
|
@ -297,11 +296,12 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- slideview -->
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/playlist_view_pager"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/playlist_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="212dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp" />
|
||||
|
|
@ -309,7 +309,7 @@
|
|||
|
||||
<include
|
||||
android:id="@+id/library_playlist_placeholder"
|
||||
layout="@layout/item_placeholder_album"
|
||||
layout="@layout/item_placeholder_horizontal"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:paddingBottom="@dimen/global_padding_bottom"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
|||
|
|
@ -1,71 +1,82 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/Widget.Material3.CardView.Filled"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clipChildren="false"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:checkable="true"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_title_text_view"
|
||||
style="@style/LabelMedium"
|
||||
android:layout_width="0dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/label_placeholder"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/playlist_dialog_title_text_view">
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clipChildren="false"
|
||||
android:padding="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_count_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:id="@+id/playlist_dialog_title_text_view"
|
||||
style="@style/LabelMedium"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:text="@string/label_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/queue_separator_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_dot_separator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_duration_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:text="@string/label_placeholder" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/label_placeholder"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/playlist_dialog_title_text_view">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_count_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:text="@string/label_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/queue_separator_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_dot_separator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_duration_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:text="@string/label_placeholder" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
71
app/src/main/res/layout/item_horizontal_playlist_dialog.xml
Normal file
71
app/src/main/res/layout/item_horizontal_playlist_dialog.xml
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clipChildren="false"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_title_text_view"
|
||||
style="@style/LabelMedium"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/label_placeholder"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/playlist_dialog_title_text_view">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_count_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:text="@string/label_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/queue_separator_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_dot_separator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_dialog_duration_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:text="@string/label_placeholder" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue