Я обрабатываю изображение и получаю из него «данные».Затем я показываю их в RecyclerView .Я исправляю некоторые данные в RecyclerView при необходимости.Как загрузить исправленные данные со всеми остальными, потому что, даже если исправление показывает в RecyclerView, оно не загружает изменения, загружаются скорее ошибочные данные.Может кто-нибудь помочь, пожалуйста, я застрял на несколько дней ...
Это часть моей основной деятельности, где я добавляю данные в Recyclerview ?
TextExtractionActivity.class
if (fileDirectory.isDirectory()) {
listCroppedImages.clear();
EmptyViewCroppedImage.setVisibility(View.GONE);
RVCroppedImages.setVisibility(View.VISIBLE);
listCroppedImages.clear();
String PhotoPath[] = new String[100];
final String StudentMatric[] = new String[100];
final String AttendanceRecord[] = new String[100];
for (int i = 1; i <= fileDirectory.listFiles().length; i++) {
PhotoPath[i] = croppedImageDirectory + i + ".jpg";
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap croppedimageold = BitmapFactory.decodeFile(PhotoPath[i], options);
Bitmap croppedimagenew = Bitmap.createScaledBitmap(croppedimageold, 460, 66, true);
StudentMatric[i] = TextImageProcess(croppedimagenew);
AttendanceRecord[i] = CircleDetection(croppedimagenew, StudentMatric[i]);
listCroppedImages.add(new CroppedImageModel(String.valueOf(i), PhotoPath[i], StudentMatric[i], AttendanceRecord[i]));
btnUploadAttendance.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int x = 1; x <= listCroppedImages.size(); x++) {
UploadData(StudentMatric[x], AttendanceRecord[x], x);
}
}
});
}
} else {
EmptyViewCroppedImage.setVisibility(View.VISIBLE);
RVCroppedImages.setVisibility(View.GONE);
}
-----------------------------------------------------------------------
public void UploadData(final String StudentMatric, final String AttendanceRecord, final int x) {
ProgressUploadAttendance.setVisibility(View.VISIBLE);
Query query = StudentsRef.orderByKey().equalTo(StudentMatric);
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
int progress = x / listCroppedImages.size() * 100;
DatabaseReference StudentMatricRef = StudentsRef.child(StudentMatric).child("Attendance").push();
StudentMatricRef.child("Status").setValue(AttendanceRecord);
StudentMatricRef.child("Date").setValue(getCurrentDate());
ProgressUploadAttendance.setProgress(progress);
} else {
Toast.makeText(TextExtractionActivity.this, "Could not Find " + StudentMatric, Toast.LENGTH_LONG).show();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
throw databaseError.toException(); // don't ignore errors
}
});
}
"RecyclerViewAdapterCroppedImages.class"
class RecyclerViewAdapterCroppedImages extends RecyclerView.Adapter<RecyclerViewAdapterCroppedImages.CroppedimageViewHolder> {
private Context mContext;
private List<CroppedImageModel> mData;
int x =0;
// private String StudentMatric, studentMatric, AttendanceStatus, attendanceStatus;
public RecyclerViewAdapterCroppedImages() { } //Constructor
public RecyclerViewAdapterCroppedImages(Context mContext, List<CroppedImageModel> mData) {
this.mContext = mContext;
this.mData = mData;
}
@Override
public CroppedimageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View croppedimageview;
LayoutInflater mInflater = LayoutInflater.from(mContext);
croppedimageview = mInflater.inflate(R.layout.item_cropped_image, parent, false);
return new CroppedimageViewHolder(croppedimageview);
}
@Override
public void onBindViewHolder(final CroppedimageViewHolder holder, final int position) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap croppedimageold = BitmapFactory.decodeFile(mData.get(position).getCroppedImagePath(), options);
Bitmap croppedimagenew = Bitmap.createScaledBitmap(croppedimageold, 528, 80, true);
holder.StudentNo.setText(mData.get(position).getStudentNo());
holder.CroppedImage.setImageBitmap(croppedimagenew);
holder.StudentId.setText(mData.get(position).getStudentMatric());
holder.StudentStatus.setText(mData.get(position).getAttendanceRecord());
holder.StudentStatus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mData.get(position).getAttendanceRecord().equals("Failed")) {
holder.StudentStatus.setText("Present");
} else if (mData.get(position).getAttendanceRecord().equals("Present")) {
holder.StudentStatus.setText("Absent");
} else if (mData.get(position).getAttendanceRecord().equals("Absent")) {
holder.StudentStatus.setText("Present");
}
}
});
}
@Override
public int getItemCount() {
return mData.size();
}
class CroppedimageViewHolder extends RecyclerView.ViewHolder {
TextView StudentNo, StudentId, StudentStatus;
ImageView CroppedImage;
private CroppedimageViewHolder(View itemView) {
super(itemView);
StudentNo = itemView.findViewById(R.id.tvtxtprocessstudentno);
CroppedImage = itemView.findViewById(R.id.ivcroppedimage);
StudentId = itemView.findViewById(R.id.tvtxtprocessstudentid);
StudentStatus = itemView.findViewById(R.id.tvtxtprocessstudentstatus);
}
}
}