关闭。这个问题需要详细或明确。它目前不接受答案。
**想改进这个问题吗?**编辑这篇文章,添加细节并澄清问题。
两天前关门了。
改进这个问题
这是logcat显示我有问题的方法。更具体地说,它是第74行和第71行。我用粗体和斜体突出显示了这两行,只是为了更简单。我错过了什么?
private void showData() {
query = firestore.collection("tasks").orderBy("time" , Query.Direction.DESCENDING);
***listenerRegistration = query.addSnapshotListener(new EventListener<QuerySnapshot>() {***
@Override
public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
***for (DocumentChange documentChange : value.getDocumentChanges()){***
if (documentChange.getType() == DocumentChange.Type.ADDED){
String id = documentChange.getDocument().getId();
ToDoModel toDoModel = documentChange.getDocument().toObject(ToDoModel.class).withId(id);
mList.add(toDoModel);
adapter.notifyDataSetChanged();
}
}
listenerRegistration.remove();
}
});
错误日志:
2021-07-07 14:06:05.099 20857-20857/com.example.poe E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.poe, PID: 20857
java.lang.AssertionError
at com.example.poe.ListPokemon$2.onEvent(ListPokemon.java:74)
at com.example.poe.ListPokemon$2.onEvent(ListPokemon.java:71)
at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2$Query(Query.java:1126)
at com.google.firebase.firestore.-$$Lambda$Query$JWhMgzcsIac1Z-exZj1pTDRisJg.onEvent(Unknown Source:6)
at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0$AsyncEventListener(AsyncEventListener.java:42)
at com.google.firebase.firestore.core.-$$Lambda$AsyncEventListener$DNkggu2LY54oguDvcp-QtRg6Sfg.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
暂无答案!
目前还没有任何答案,快来回答吧!