Hey I am implementing Notification functionality in my app, which is If any of the driver image changes if should give me a notification alert on my mobile app. The function I've implemented is working perfectly fine. But if any of the child node value change in that specific driver(user), it gives me a notification too. I want to Recieve a notification on just change of Image.
public void onDataChange(@NonNull DataSnapshot snapshot) {
drowsinessDriversList.clear();
for (DataSnapshot dataSnapshot2:snapshot.getChildren())
{
driverModel = dataSnapshot2.getValue(DriverModel.class);
// Assigned variable is important
adminUID = FirebaseAuth.getInstance().getCurrentUser().getUid();
if(adminUID.equals(driverModel.getAssignTo())) {
if (driverModel.getStatus().equals("Assigned")) {
drowsinessDriversList.add(driverModel);
recyclerView.setAdapter(driverDrowsinessAdapter);
Log.d("jawad", "arraylist.inner" + driverModel.getEmail());
}
}
stringNotification = driverModel.getDrowsinessImage();
if (stringNotification.equals("--")){
// Toast.makeText(AdminHomeActivity.this, "if condition: "+stringNotification, Toast.LENGTH_LONG).show();
}else {
Toast.makeText(AdminHomeActivity.this, "else condition: "+stringNotification, Toast.LENGTH_LONG).show();
notifyAdminDriverIsDrowsy();
}
}
driverDrowsinessAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});