I'm new to Firebase, and so far I really enjoyed it. I have a problem's; I am using FirebaseListAdapter, similar to the tutorial diagram here: https://github.com/firebase/AndroidChat
To use the FirebaseListAdapter, I need to use data model objects (for auto-binding to work well). The problem is that I also want to save the timestamp value with this model object, and I want to get the timestamp from the Firebase server.
I am not currently working, this is a DataModelObject class (similar to com.firebase.androidchat.Chat in a demo) with a constructor like:
DataModelObject(String data1, String data2, Map enQTimeStamp)
which I then try to use as follows:
DataModelObject dmo = new DataModelObject ("foo", "bar", ServerValue.TIMESTAMP); myFirebaseRef.push().setValue(dmo);
This throws a JsonMappingException when I try to run this code. I found the code snippet here:
https://www.firebase.com/blog/2015-02-11-firebase-unique-identifiers.html
But it’s worth noting that in line 4 of the Android code example, this will cause a compile-time error (since it tries to put ServerValue.TIMESTAMP on the card, and TIMESTAMP is the card itself)
What is the right way to do this and maintain compatibility with FirebaseListAdapter?
source share