мой код работал хорошо, чтобы обновить выбранного ребенка новыми данными, но теперь это не так!
Я использовал отладчик, чтобы убедиться, что данные были установлены правильно, и обнаружил, что они установлены правильно, но в базе данных Firebase есть некоторые значения, которые были пропущены. Как решить эту проблему, пожалуйста?
скриншот отладчика ![enter image description here](https://i.stack.imgur.com/zNvEg.jpg)
скриншот базы данных ![id](https://i.stack.imgur.com/GxTam.jpg)
мой объект класса
import android.os.Parcel;
import android.os.Parcelable;
import com.google.firebase.database.IgnoreExtraProperties;
@IgnoreExtraProperties
public class Hour implements Parcelable {
private int hour;
private boolean available;
private String userName;
private String userId;
private String bookTime;
private int index;
public Hour() {
}
public static final Creator<Hour> CREATOR = new Creator<Hour>() {
@Override
public Hour createFromParcel(Parcel in) {
return new Hour(in);
}
@Override
public Hour[] newArray(int size) {
return new Hour[size];
}
};
private Hour(Parcel in) {
hour = in.readInt();
available = in.readByte() != 0;
userName = in.readString();
userId = in.readString();
bookTime = in.readString();
index = in.readInt();
}
public int getHour() {
return hour;
}
public boolean isAvailable() {
return available;
}
public String getUserId() {
return userId;
}
public int getIndex() {
return index;
}
public void setAvailable(boolean available) {
this.available = available;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setBookTime(String bookTime) {
this.bookTime = bookTime;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(hour);
dest.writeByte((byte) (available ? 1 : 0));
dest.writeString(userName);
dest.writeString(userId);
dest.writeString(bookTime);
dest.writeInt(index);
}
}
способ обновления ..
void updateAppointment(Context context, DatabaseReference reference, int selectedDayIndex, Hour hour, int position) {
if (hour.isAvailable()) {
hour.setAvailable(false);
hour.setBookTime(getCurrentTime());
hour.setUserId(firebaseUser.getUid());
hour.setUserName(firebaseUser.getDisplayName());
} else {
hour.setAvailable(true);
}
reference.child(getChildName()).child(selectedDayIndex + PATH_HOURS + position).setValue(hour)
.addOnSuccessListener(aVoid -> showShortToastMsg(context, context.getString(R.string.done_label)))
.addOnFailureListener(e -> {
showShortToastMsg(context, context.getString(R.string.error_update_firebase_db_msg));
});
}
Спасибо