I have a recyclerview and I populate data on it using firebaserecycleradapter. Every item in the list contains reference to firebase storage. So When I click on download button (red button), the download start and I can get informations about the view. When the download is in progress and I leave the activity and come back the download still on progress but never return the correct item View.
How can I get the correct item View when I come back so that I can show the download progress at specific item and make some changes to that specific item when download complete.
Code behind download button
storageReference.getFile(zipFile)
.addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Log.d("visibilitedocSuccess", ""+holder+"|"+key+"|holder"+holder+"|holderid:"+holder.getAdapterPosition()+"|oldpos:"+holder.getOldPosition());
holder.txtProgress.setVisibility(View.GONE);
holder.progressBar.setVisibility(View.GONE);
holder.imgDocumentChecker.setVisibility(View.VISIBLE);
holder.imgDocumentChecker.setImageResource(R.drawable.done_ic);
}
})
.addOnProgressListener(new OnProgressListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onProgress(FileDownloadTask.TaskSnapshot taskSnapshot) {
double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
Log.d("visibilitedocProgress:", progress + "% done"+"|holder"+holder+"|holderid:"+holder.getAdapterPosition()+"|oldpos:"+holder.getOldPosition());
holder.txtProgress.setText(((int) progress) + "%");
holder.progressBar.setProgress((int) progress);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d("visibilitedocFail:", e + "");
holder.txtProgress.setVisibility(View.GONE);
holder.progressBar.setVisibility(View.GONE);
holder.imgDocumentChecker.setVisibility(View.VISIBLE);
holder.imgDocumentChecker.setImageResource(R.drawable.download_icon);
Toasty.error(DocumentsListActivity.this, "Chargement annulé", Toast.LENGTH_LONG, true).show();
}
});
Logcat shows below informations related to the ViewHolder
ViewHolder{ace0130 position=-1 id=-1, oldPos=-1, pLpos:-1 unbound no parent}
How to fixe it please ?