-
Notifications
You must be signed in to change notification settings - Fork 1.9k
The Big Kahuna of firebase-ui-database #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Big Kahuna of firebase-ui-database #544
Conversation
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
…lback # Conflicts: # app/src/main/java/com/firebase/uidemo/database/ChatActivity.java # database/src/main/java/com/firebase/ui/database/FirebaseArray.java # database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java # database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Signed-off-by: Alex Saveau <[email protected]>
# Conflicts: # database/src/main/java/com/firebase/ui/database/FirebaseArray.java
# Conflicts: # database/src/androidTest/java/com/firebase/ui/database/TestUtils.java
# Conflicts: # database/src/androidTest/java/com/firebase/ui/database/TestUtils.java
…lback # Conflicts: # app/src/main/java/com/firebase/uidemo/database/ChatActivity.java # database/src/androidTest/java/com/firebase/ui/database/TestUtils.java # database/src/main/java/com/firebase/ui/database/FirebaseArray.java # database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java # database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java # database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@samtstern Hmmm, your branch looks really interesting! The gist I got from it was to make the model class a first class citizen instead of |
Agreed with Alex that this looks promising. I only looked at
`FirebaseArray` for now, so still need to see how the extensions (such as
the indexed array or a re-sorted array) would work.
I'd prefer to not expose too many lists though. If it exposes a `List<E>`,
there should also be a `List<String>` with the keys. And when you have both
of those, they're really just syntactic sugar for `List<DataSnapshot>`.
Nothing wrong with syntactic sugar, but three lists feels like a bit much.
…On Fri, Feb 24, 2017 at 6:58 PM Alex Saveau ***@***.***> wrote:
@samtstern <https://github.com/samtstern> Hmmm, your branch looks really
interesting! The gist I got from it was to make the model class a first
class citizen instead of DataSnapshot which makes way more sense. I don't
really like that you have a getObject instead of getSnapshot method thus
moving the model class a little further back. What do you think of
rewriting this PR with your changes, but implementing List<E> in
ObservableSnapshotArray instead of List<DataSnapshot>? (We could call it
ObservableModelArray<T> or something better.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3w39hrT8tOWWgEXvxFQ8viYkMOLSWhks5rf5jtgaJpZM4LuMcz>
.
|
Change-Id: I831fd0bae52970ff7db6f4ab1ae2fdb7aa04200a
… object, change type name to `E` in ObservableSnapshotArray to unhide type T in toArray method, remove getSnapshots(int) method from FirebaseArray since there's already get(int), use `index` instead of `newIndex` in onKeyMove in FirebaseIndexArray Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@samtstern The index adapters were completely broken because we forgot to pass in a parser. Since I feel like this could be a recurring theme, I just removed the possibility of a null parser in 7601ded. If devs really don't want to provide a model class for some reason, they can just pass in var1.equals(Object.class)?var0:(var1.isEnum()?zzd(var0, var1):zze(var0, var1)); I also had to write a hacky constructor that really bothers me, but I couldn't think of a better way of doing it that would still let devs extend the adapters while passing in their own |
|
public class First {
public First(String foo) {}
}
private class Second extends First {
public Second() {} // Doesn't compile
public Second(String bar) { super(bar); } // Compiles
} Since we also can't pass |
super(activity, modelClass, modelLayout, new FirebaseIndexArray(keyRef, dataRef)); | ||
Query keyQuery, | ||
DatabaseReference dataRef) { | ||
init(activity, new FirebaseIndexArray<>(keyQuery, dataRef, this), modelClass, modelLayout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm now I see what happened here. Having init
be protected and called by the super class definitely "smells" and makes me think we got something wrong.
Seems like the problem is the circular reference between the adapter and the array, even though it goes through the SnapshotParser
interface.
Any thoughts on how we can make this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samtstern Hmmm, I found out that you can't reference non-static fields or methods either in a constructor call so that means no forwarding calls or anything like that. At this point, the only solution I can think of is using a setter for the parser, but I feel like that's way more hacky and makes the intentions less clear. Also, that beats the point of initializing everything for people because they will have to call setParser. @puf Have you encountered this kind of issue before or have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a possible answer. Since we're breaking parseSnapshot anyway, what if we removed it from the adapter entirely and instead had the adapters take an optional SnapshotParser
in their constructor. They would pass it through to the FirebaseArray
if provided.
This seems to be a better representation of the hierarchy anyway,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samtstern As long as you're fine with making more breaking api changes, that solution sounds awesome to me!
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@samtstern I'm getting this really weird crash because Here are some screenshots showing that even though |
@SUPERCILEX looks like maybe it's how we're casting? We're calling |
@samtstern I was confused by that too, but I think it's just a decompiling bug (java doesn't let you do what's in the screenshot anyway--I checked). If you look at our real code, we are casting things correctly: https://github.com/firebase/FirebaseUI-Android/pull/544/files#diff-fd5c505ad432166321255bc4541624ddR89 so I'm pretty sure this is an issue with the RTDB. |
@SUPERCILEX yep you're right, it's not the casting issue. I just took a look at this and (I can't believe I'm saying it) but I'm ready to merge this beast! Could you file a new issue about the possible listener removal race condition thing? Definitely worth tracking but it does not seem to be a direct result of this PR. Do you have any oppositions to my doing a 'squash and merge' on this PR? |
@samtstern AWESOME!!!! Yeah, I already filed a bug for the slow listener removal. No objections at all, please don't do anything but a squash. There are way too many commits in this PR! |
Haha, nice gif! |
Enables #539 (I think)
#337
@TheCraftKid I think this one will make you happy! (and your library obsolete 😄)
@samtstern Sorry about this one, the amount of changes is high up there on my list of biggest PRs, but I believe all of this is necessary for us to be able to commit to maintaining
firebase-ui-database
in the long term.equals
andhashCode
.FirebaseArrayOfObjects
FirebaseArrayOfObjectsOptimized
(Fixed in fda5417)