|
@@ -10,6 +10,8 @@ import android.widget.TextView;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
public class MusicAdapter extends RecyclerView.Adapter<MusicAdapter.ViewHolder> implements CellPrototypeInterface{
|
|
public class MusicAdapter extends RecyclerView.Adapter<MusicAdapter.ViewHolder> implements CellPrototypeInterface{
|
|
@@ -17,11 +19,19 @@ public class MusicAdapter extends RecyclerView.Adapter<MusicAdapter.ViewHolder>
|
|
List<Music> musicList;
|
|
List<Music> musicList;
|
|
CellPrototypeInterface cellPrototypeInterface;
|
|
CellPrototypeInterface cellPrototypeInterface;
|
|
|
|
|
|
|
|
+ /*
|
|
@Override
|
|
@Override
|
|
public void cellClicked(Music music) {
|
|
public void cellClicked(Music music) {
|
|
cellPrototypeInterface.cellClicked(music);
|
|
cellPrototypeInterface.cellClicked(music);
|
|
notifyDataSetChanged();
|
|
notifyDataSetChanged();
|
|
}
|
|
}
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void cellClicked(String name, int adapterPosition) {
|
|
|
|
+ cellPrototypeInterface.cellClicked(name, adapterPosition);
|
|
|
|
+ notifyDataSetChanged();
|
|
|
|
+ }
|
|
|
|
|
|
class ViewHolder extends RecyclerView.ViewHolder{
|
|
class ViewHolder extends RecyclerView.ViewHolder{
|
|
|
|
|
|
@@ -29,12 +39,17 @@ public class MusicAdapter extends RecyclerView.Adapter<MusicAdapter.ViewHolder>
|
|
|
|
|
|
public ViewHolder(View itemView) {
|
|
public ViewHolder(View itemView) {
|
|
super(itemView);
|
|
super(itemView);
|
|
- View musicName = itemView.findViewById(R.id.cell);
|
|
|
|
|
|
+ Name = itemView.findViewById(R.id.cell);
|
|
|
|
+ Name.setOnClickListener(view -> {
|
|
|
|
+ cellPrototypeInterface.cellClicked(Name.getText().toString(),getAdapterPosition());
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public MusicAdapter(List<Music> musicList1){
|
|
|
|
- musicList = musicList1;
|
|
|
|
|
|
+ public MusicAdapter(CellPrototypeInterface cellPrototypeInterface1){
|
|
|
|
+ musicList = new ArrayList<>();
|
|
|
|
+ this.cellPrototypeInterface = cellPrototypeInterface1;
|
|
|
|
+ File file = new File("/assets");
|
|
}
|
|
}
|
|
|
|
|
|
@NonNull
|
|
@NonNull
|
|
@@ -42,6 +57,7 @@ public class MusicAdapter extends RecyclerView.Adapter<MusicAdapter.ViewHolder>
|
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell,parent,false);
|
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell,parent,false);
|
|
ViewHolder viewHolder = new ViewHolder(view);
|
|
ViewHolder viewHolder = new ViewHolder(view);
|
|
|
|
+ //CellPrototypeInterface prototypeInterface = new CellPrototypeInterface(view) ;
|
|
return viewHolder;
|
|
return viewHolder;
|
|
}
|
|
}
|
|
|
|
|