且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android-Firebase无法正确插入

更新时间:2023-12-05 21:44:46

这可能是在将最新的 Marker 添加到之前遍历 markers 映射的问题.它,这样地图就不会包含相同数量的项目.

This is likely an issue with iterating over the markers map before the newest Marker has been added to it, so the maps then don't contain the same number of items.

我建议同时创建两个标记,例如:

I'd recommend creating both markers at the same time, something like:

String markerId = userRef.push().getKey();

FirebaseMarker marker = new FirebaseMarker(address, time, latitude, longitude);
PartialMarker partialMarker = new PartialMarker(address, time)

markers.put(markerId, marker);
partialMarkers.put(markerId, partialMarker);

这样,可以确保两个地图具有相同数量的物品.

This way, it's guaranteed that both maps have the same number of items.