Example:
final String campus = "BISU Calape";
private ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
facultyList.clear();
for(DataSnapshot dataSnapshot : snapshot.getChildren()){
Faculty faculty = dataSnapshot.getValue(Faculty.class);
faculty.setKey(dataSnapshot.getKey());
if(faculty.getCampus().equals(campus) && faculty.getMemStatus.equals("Approved")){
facultyList.add(faculty);
}
}
if(facultyList.size() > 0){
tv_noresult.setVisibility(View.INVISIBLE);
}else{
tv_noresult.setVisibility(View.VISIBLE);
}
adapter.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
Toast.makeText(FacultyActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
}
};
This code is working so far, but what if this code will have to fetch/filter millions of records?