mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Add artist page
This commit is contained in:
parent
8b7e383dc2
commit
c2be2711b9
44 changed files with 1028 additions and 191 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -10,21 +11,26 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoverSongAdapter extends PagerAdapter {
|
||||
private static final String TAG = "DiscoverSongAdapter";
|
||||
|
||||
private List<Song> songs;
|
||||
private LayoutInflater layoutInflater;
|
||||
private Context context;
|
||||
private View view;
|
||||
|
||||
public DiscoverSongAdapter(Context context, List<Song> models) {
|
||||
public DiscoverSongAdapter(Context context, List<Song> songs) {
|
||||
this.context = context;
|
||||
this.songs = models;
|
||||
this.songs = songs;
|
||||
|
||||
Log.d(TAG, "DiscoverSongAdapter: " + songs.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -41,30 +47,31 @@ public class DiscoverSongAdapter extends PagerAdapter {
|
|||
@Override
|
||||
public Object instantiateItem(@NonNull ViewGroup container, final int position) {
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
View view = layoutInflater.inflate(R.layout.item_home_discover_song, container, false);
|
||||
|
||||
TextView title;
|
||||
TextView desc;
|
||||
|
||||
title = view.findViewById(R.id.title_discover_song_label);
|
||||
desc = view.findViewById(R.id.artist_discover_song_label);
|
||||
view = layoutInflater.inflate(R.layout.item_home_discover_song, container, false);
|
||||
|
||||
TextView title = view.findViewById(R.id.title_discover_song_label);
|
||||
TextView desc = view.findViewById(R.id.artist_discover_song_label);
|
||||
title.setText(songs.get(position).getTitle());
|
||||
desc.setText(songs.get(position).getAlbumName());
|
||||
|
||||
view.setOnClickListener(v -> Toast.makeText(context, songs.get(position).getTitle(), Toast.LENGTH_SHORT).show());
|
||||
view.setOnClickListener(v -> {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
songRepository.update(songs.get(position));
|
||||
});
|
||||
|
||||
container.addView(view, 0);
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
Log.d(TAG, "setItems: CHANGING");
|
||||
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
container.removeView((View)object);
|
||||
container.removeView((View) object);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue