mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Add experimental bottom sheet player
This commit is contained in:
parent
9af0afa441
commit
f837bb14e2
65 changed files with 1570 additions and 547 deletions
|
|
@ -0,0 +1,76 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerNowPlayingSongAdapter extends RecyclerView.Adapter<PlayerNowPlayingSongAdapter.ViewHolder> {
|
||||
private static final String TAG = "DiscoverSongAdapter";
|
||||
|
||||
private List<Song> songs;
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
|
||||
public PlayerNowPlayingSongAdapter(Context context) {
|
||||
this.context = context;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.songs = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = inflater.inflate(R.layout.item_player_now_playing_song, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Song song = songs.get(position);
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return songs.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
ImageView cover;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
cover = itemView.findViewById(R.id.discover_song_cover_image_view);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
songRepository.increasePlayCount(songs.get(getAdapterPosition()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue