i wanna select in json data from my firebase database query like this statement
select * from timecheck where time = timeValue and date = dateValue
and i want to check the value and insert it in listview, but i don't know how to make it in firebase query
this is my Adapter
public class AppointmentAdapter extends BaseAdapter {
private Activity activity;
private List<Appointment> appointmentList;
LayoutInflater inflater;
public AppointmentAdapter(Activity activity, List<Appointment> appointments) {
this.activity = activity;
this.appointmentList = appointments;
inflater = activity.getLayoutInflater();
}
@Override
public int getCount() {
return appointmentList.size();
}
@Override
public Object getItem(int i) {
return i;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
LayoutInflater inflater = activity.getLayoutInflater();
View listItemView = inflater.inflate(R.layout.list_view_time,null,true);
TextView textViewTime = listItemView.findViewById(R.id.txt_time_list);
ImageButton imageButtonCheck = listItemView.findViewById(R.id.img_time_list);
Appointment appointment = appointmentList.get(i);
textViewTime.setText(appointment.getTime_appointment());
if (appointment.isActive_appointment()){
imageButtonCheck.setEnabled(false);
imageButtonCheck.setBackgroundResource(R.drawable.checked);
}else {
imageButtonCheck.setEnabled(true);
imageButtonCheck.setBackgroundResource(R.drawable.check);
}
return null;
}
public void updateRecord(List<Appointment> appointments){
this.appointmentList = appointments;
notifyDataSetChanged();
}
}
and this is my firebase data
the node call appointment and i want to check date_appointment and time_appointment
"appointment" : {
"-MH2n6VOOd-1AS95Yr52" : {
"active_appointment" : "checked",
"date_appointment" : "13/Aug/2020",
"doctor_number" : "1",
"id_appointment" : "-MH2n6VOOd-1AS95Yr52",
"time_appointment" : "8:00 am"
},
"-MH2nEveOjSV4rAQ0hWJ" : {
"active_appointment" : "checked",
"date_appointment" : "13/Aug/2020",
"doctor_number" : "1",
"id_appointment" : "-MH2nEveOjSV4rAQ0hWJ",
"time_appointment" : "8:00 am"
},
"-MH5eMK-gp3oTvMwavQn" : {
"active_appointment" : "checked",
"date_appointment" : "15/Aug/2020",
"doctor_number" : "2",
"id_appointment" : "-MH5eMK-gp3oTvMwavQn",
"time_appointment" : "9:00 am"
},
"-MHA-5gV7x75PdPZcRZ4" : {
"active_appointment" : "checked",
"date_appointment" : "16/Aug/2020",
"doctor_number" : "3",
"id_appointment" : "-MHA-5gV7x75PdPZcRZ4",
"time_appointment" : "9:00 am"
},
my datasnap in my activity
databaseRefrence_time = FirebaseDatabase.getInstance().getReference().child("appointment");
appointmentList = new ArrayList<>();
databaseRefrence_time.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
appointmentList.clear();
for (DataSnapshot dataSnapshot : snapshot.getChildren()){
Appointment appointment = dataSnapshot.getValue(Appointment.class);
appointmentList.add(appointment);
}
AppointmentAdapter adapter = new AppointmentAdapter(booking.this,appointmentList);
listView.setAdapter(adapter);
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});