【发布时间】:2018-02-28 04:58:33
【问题描述】:
我的应用分为 2 个部分,用户和管理员。管理员可以在 firebase db/node 中添加/删除新项目,这些项目会反映到用户应用程序中。考虑一下,用户应用程序一直处于打开状态并使用以下代码更新列表。
mFirebaseDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
arrayList.clear();
for (DataSnapshot dataSnapshotChild : dataSnapshot.getChildren()) {
for (DataSnapshot snapshot : dataSnapshotChild.getChildren()) {
Log.v("onDataChange", ":" + snapshot.getValue());
Model model = new Model();
model.setReceivedServiceCategory(dataSnapshotChild.getKey());
model.setKey(snapshot.getKey());
model.setReceivedFrom((String) snapshot.child("xxxxx").getValue());
model.setRaisedAtTimings((String) snapshot.child("xxxxx").getValue());
model.setReceivedStatus((String) snapshot.child("xxxx").getValue());
arrayList.add(model);
}
}
loadDataToRecyclerView();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.v("DatabaseError", databaseError.getMessage());
}
});
我的问题,我想针对 firebase db/node 中新添加的条目显示弹出窗口。现在,我可以看到更新的列表,但同时我想突出显示最新添加的条目。另外,我不想比较旧列表和最新列表,如果firebase 提供任何其他合适的方式,请提供解决方案,除了比较 2 个列表?
【问题讨论】:
标签: android firebase firebase-realtime-database firebase-authentication firebase-storage