目前,我正在扫描 QR 码,然后在 Cloud Firestore 中更新我的出勤收集。它没有将它们放在正确的位置,我使用的是 type 的模型类Attendance。这是我的代码:
final FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
final DocumentReference docRef = rootRef.collection("Session").document(rawValue);
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()){
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Date timeToCheck = calendar.getTime();
Session session = document.toObject(Session.class);
Date startTime = session.getStartTime();
Date endTime = session.getEndTime();
if (timeToCheck.after(startTime) && (timeToCheck.before(endTime))) {
Attendance attendance = new Attendance(rawValue, userUID, date, userEmail);
attendanceRef3.add(attendance);
Toast.makeText(StudentAccount.this,
"Your attendance has been recorded", Toast.LENGTH_SHORT).show();
}
潇潇雨雨
相关分类