Instead of the code reading the album cover inside the folder, it reads the covers of the playlist
private ArrayList<String> folderNames;
static ArrayList<MusicFiles> musicFiles;
private Context mContext;
public FolderAdapter(ArrayList<String> folderNames, ArrayList<MusicFiles> musicFiles, Context mContext) {
this.folderNames = folderNames;
this.musicFiles = musicFiles;
this.mContext = mContext;
}
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.folder_item, parent,
false);
return new MyHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyHolder holder, final int position) {
int index = folderNames.get(position).lastIndexOf("/");
String folder = folderNames.get(position).substring(index + 1);
holder.folder.setText(folder);
holder.counterFiles.setText(String.valueOf(NumberOffFiles(folderNames.get(position))));
Bitmap image = getAlbum(musicFiles.get(position).getPatch());
if (image != null) {
Glide.with(mContext).asBitmap()
.load(image)
.into(holder.cover);
} else {
Glide.with(mContext)
.load(R.drawable.img_music)
.into(holder.cover);
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(mContext,VideoFolderActivity.class);
intent.putExtra("folderNames", folderNames.get(position));
mContext.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return folderNames.size();
}
static class MyHolder extends RecyclerView.ViewHolder {
TextView folder, counterFiles;
ImageView capa_da_pasta;
public MyHolder(@NonNull View itemView) {
super(itemView);
folder = itemView.findViewById(R.id.folderName);
counterFiles = itemView.findViewById(R.id.count_files_folder);
cover = itemView.findViewById(R.id.folderImage);
}
}
int NumberOffFiles(String folderNames){
int countFiles = 0;
for (MusicFiles musicFiles : musicFiles) {
if (musicFiles.getPatch()
.substring(0, musicFiles.getPatch().lastIndexOf("/"))
.endsWith(folderNames)) {
countFiles++;
}
}
return countFiles;
}
The code has to read the album covers!!!
The code has to read the album covers!!!
Instead of the code reading the album cover inside the folder, it reads the covers of the playlist