recyclerView에 이미지가 7장 까지는 정상적으로 스크롤이 가능하고 순서도 일정한데요 8장 부터 스크롤 시에 막 꼬이기 시작합니다. 8 장부터가 뷰를 재활용 하는가본데 여기에서 무슨 문제가 발생합니다;;
text는 문제없이 출력되는데 이미지만 이렇습니다.
private Context context;
private List<Chat_room> items;
private int item_layout;
private Chat_room chat_room;
private String name;
private String getUri;
private String imageFileName;
private String imagePath;
private File imageFile;
private String imageFilePath;
private FirebaseStorage storage = FirebaseStorage.getInstance();
private StorageReference storageRef;
private StorageReference pathReference;
private StorageReference storageReference;
private Bitmap bitmap;
private Uri imageUri;
private boolean check = true;
public AdapterActivity(Context context, List<Chat_room> items, int item_layout, String value) {
this.context = context;
this.items = items;
this.item_layout = item_layout;
this.name = value;
}
public int getItemViewType(int position) {
if (items.get(position).getName().equals(name)) {
return 1;
} else {
return 2;
}
}
@Override
public AdapterActivity.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View view;
if (viewType == 1) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.chat_items, parent, false);
} else {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.chat_items_user, parent, false);
}
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final AdapterActivity.ViewHolder holder, int position) {
//holder.setIsRecyclable(false);
String checkFile = items.get(position).getMsg();
String uri = checkFile.substring(checkFile.lastIndexOf(".") + 1, checkFile.length());
//items.get(position).getMsg().contains(uri)
Log.i("확장자", String.valueOf(uri));
Log.i("checkFile", checkFile);
Log.i("position", String.valueOf(position));
imageFileName = checkFile;
imageFilePath = items.get(position).getImagePath();
imageFile = items.get(position).getImageFile();
storageRef = storage.getReference();
storageReference = storageRef.child("images/" + imageFileName);
storageReference.getFile(imageFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
// Local temp file has been created
Log.i("FIie Download", "Success");
Glide.with(context).load(imageFilePath)
.override(300, 300)
.fitCenter()
.into(holder.imagePicasso);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
try
{
Log.i("imageFilePath", imageFilePath);
}
catch (Exception E)
{
E.printStackTrace();
}
//holder.msg.setText(items.get(position).getMsg()); // <- text는 문제없이 가능.
}
@Override
public int getItemCount()
{
Log.i("items-size", String.valueOf(items.size()));
return this.items.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView msg;
ImageView imagePicasso;
public ViewHolder(View itemView) {
super(itemView);
msg = (TextView)itemView.findViewById(R.id.chat_name);
imagePicasso = (ImageView)itemView.findViewById(R.id.imagePicasso);
}
}
}
왜그런건가요 ??? 답변 부탁드리겠습니다!!!