GeezerVison is showing github.com — Flattening nested data · Issue #280 · firebase/FirebaseUI-Android
Flattening nested data #280
Description
http://stackoverflow.com/questions/39258219/firebaserecycleradapter-with-2-childs?noredirect=1#comment65887443_39258219
If I have this Data Structure:
Database:
X:{
UserID:{
UNIQUE_ID_GENERATED_BY_PUSH_METHOD:{
x:"hello",
y:"hey there!"
}
UNIQUE_ID_2_GENERATED_BY_PUSH_METHOD:{
x:"what's up?",
y:"Nothing Much"
}
}
UserID2:{
UNIQUE_ID_GENERATED_BY_PUSH_METHOD:{
x:"bye",
y:"Have a nice day!"
}
UNIQUE_ID_2_GENERATED_BY_PUSH_METHOD:{
x:"what's up?",
y:"Nothing Much"
}
}
}
And I'm trying to retrieve x and y into a FireBaseRecyclerAdapter, and it's not possible without making my own huge code. I'd love a feature like this; it'll make things much easier and will trim up my database.
Activity
SUPERCILEX commented on Sep 6, 2016
Check out this pull request: #276
I think it could be what you are looking for: if you index your data, all you have to do is provide it a list of keys to get x and y. See the documentation: https://github.com/SUPERCILEX/FirebaseUI-Android/blob/7e2be3aed73735e3d4e1a318cf268a5c9db67475/database/README.md#using-firebaseui-with-indexed-data
I think you would have to change your data structure to be something like this:
message-keys: {
uid1: {
key1: true
key2: true
}
uid2: {
key1: true
key2: true
}
}
messages: {
key1: {
x: "bye"
y: "Have a nice day!"
}
key2: {
x: "what's up?"
y: "Nothing Much"
}
}
Then you would create a RecyclerView like so:
new FirebaseRecyclerAdapter<Chat, ChatHolder>(Chat.class, android.R.layout.two_line_list_item, ChatHolder.class, ref.child("message-keys").child(uid), ref.child("messages"))
Hope this helps!
Metadata
Metadata
Development
No branches or pull requestsIssue actions