Skip to content

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

Merged
merged 121 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
28c366c
Add a callback in FirebaseIndexArray when a Key doesn't exist in a ref
SUPERCILEX Dec 9, 2016
641297c
Add documentation
SUPERCILEX Dec 9, 2016
a62a025
Rename listeners
SUPERCILEX Dec 14, 2016
703f85d
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into db-cal…
SUPERCILEX Dec 14, 2016
f1e702b
Add JoinResolver.java interface
SUPERCILEX Dec 15, 2016
af39a1e
Cleanup
SUPERCILEX Dec 15, 2016
25fc4df
Rename ChangeListener to ChangeEventListener
SUPERCILEX Dec 15, 2016
5486e8c
Cleanup
SUPERCILEX Dec 15, 2016
23806d7
Make JoinResolver.java public
SUPERCILEX Dec 15, 2016
06fb7d0
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into db-cal…
SUPERCILEX Dec 16, 2016
0b56e99
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into db-cal…
SUPERCILEX Dec 22, 2016
331b4bf
Rename
SUPERCILEX Jan 3, 2017
f396fec
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into db-cal…
SUPERCILEX Jan 3, 2017
cfdb305
Fix compile error
SUPERCILEX Jan 3, 2017
cc3729c
Merge branch 'version-1.1.0-dev' into db-callback
SUPERCILEX Jan 5, 2017
f5d06b2
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into db-cal…
SUPERCILEX Jan 9, 2017
2b65f11
Make FirebaseArray.java fully decked out and implementing List
SUPERCILEX Jan 9, 2017
961f9d7
Make stuff public
SUPERCILEX Jan 11, 2017
de52c1d
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into db-cal…
SUPERCILEX Jan 11, 2017
97d9cb0
Fix merge mistakes
SUPERCILEX Jan 11, 2017
0f11146
Merge branch 'db-callback' into FirebaseArray
SUPERCILEX Jan 11, 2017
460b733
Merge remote-tracking branch 'firebase/master' into FirebaseArray
SUPERCILEX Jan 13, 2017
e7297d4
Merge remote-tracking branch 'firebase/master' into db-callback
SUPERCILEX Jan 13, 2017
9a03342
Merge remote-tracking branch 'firebase/master' into db-callback
SUPERCILEX Jan 17, 2017
8f87492
Merge branch 'version-1.2.0-dev' of https://github.com/firebase/Fireb…
SUPERCILEX Jan 22, 2017
dcf96bf
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into db-cal…
SUPERCILEX Jan 25, 2017
48ea75a
Fix a ton of merge mistakes
SUPERCILEX Jan 25, 2017
4a5a1be
Provide default join resolver
SUPERCILEX Jan 25, 2017
dbbf0dc
Fix tests and bugs
SUPERCILEX Jan 25, 2017
b37c8bd
Cleanup
SUPERCILEX Jan 25, 2017
d25245b
More cleanup
SUPERCILEX Jan 25, 2017
ea72dbf
Merge branch 'db-callback' into FirebaseArray
SUPERCILEX Jan 25, 2017
c9aa717
Cleanup
SUPERCILEX Jan 25, 2017
6b6c253
Update equals toString and hashCode
SUPERCILEX Jan 25, 2017
7e01eb1
Fix spacing
SUPERCILEX Jan 25, 2017
8ca1681
Merge branch 'db-callback' into FirebaseArray
SUPERCILEX Jan 25, 2017
78f0a90
Remove references to JoinResolver.java
SUPERCILEX Jan 25, 2017
26ae829
Update documentation
SUPERCILEX Jan 25, 2017
98412fa
Update api to follow a add/remove model which allows for more flexibi…
SUPERCILEX Jan 25, 2017
2b9ff05
Fix broken everything
SUPERCILEX Jan 25, 2017
b68ec5c
Add a wrapper around a list of DataSnapshots
SUPERCILEX Jan 25, 2017
712320f
Update api
SUPERCILEX Jan 25, 2017
964c912
Incentivize people to move to the new FirebaseRecyclerAdapter.java api
SUPERCILEX Jan 25, 2017
692b819
Add a DataSnapshot to list of object converter method
SUPERCILEX Jan 26, 2017
e96ae37
Deprecate old adapters and add the new ones
SUPERCILEX Jan 26, 2017
1ac786f
Cleanup
SUPERCILEX Jan 26, 2017
6ef42aa
Cleanup
SUPERCILEX Jan 26, 2017
9f6bf5e
Nuke ListView adapters. This is up to debate, but I don't think we sh…
SUPERCILEX Jan 26, 2017
b062491
Merge remote-tracking branch 'firebase/master' into FirebaseArray
SUPERCILEX Jan 26, 2017
6543bbf
Update documentation to use FirebaseRecyclerAdapter.java
SUPERCILEX Jan 26, 2017
6e89a1a
Remove old documentation
SUPERCILEX Jan 26, 2017
32eab68
Add temporary fix for https://github.com/firebase/FirebaseUI-Android/…
SUPERCILEX Jan 26, 2017
cdb2a38
Fix for #547
SUPERCILEX Jan 26, 2017
c329d0b
Fix garbagey hashCode methods
SUPERCILEX Jan 27, 2017
ecd88a9
Add SnapshotParser.java interface
SUPERCILEX Jan 27, 2017
f2e862b
Add back FirebaseListAdapter.java
SUPERCILEX Jan 27, 2017
0bf90eb
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Jan 27, 2017
ee1d2d2
The cherry on top: add FirebaseAdapter.java interface
SUPERCILEX Jan 27, 2017
54f5f7c
Update documentation
SUPERCILEX Jan 28, 2017
e5ccd0c
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Jan 28, 2017
fff42e8
Rename objects array: sounded too much like "FirebaseObjects array". …
SUPERCILEX Jan 28, 2017
189d355
Add getSnapshots method to FirebaseArrayOfObjects.java and update api…
SUPERCILEX Jan 28, 2017
16d654d
Update api so you can't pass in a query for index stuff
SUPERCILEX Jan 29, 2017
a14e3ed
Woops, fix compile errors for old adapters
SUPERCILEX Jan 29, 2017
75aa4f4
Update documentation
SUPERCILEX Jan 31, 2017
3ba6dd5
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Jan 31, 2017
7e53c95
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Jan 31, 2017
43a6b7a
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Jan 31, 2017
d286df5
Optimize FirebaseArrayOfObjects.java
SUPERCILEX Feb 1, 2017
9316ed9
Cleanup
SUPERCILEX Feb 1, 2017
c98d2f9
Remove all non-critical changes
SUPERCILEX Feb 1, 2017
91bf3cc
Make listener logic clearer
SUPERCILEX Feb 1, 2017
23dba32
Fix refactoring mistake
SUPERCILEX Feb 1, 2017
1d3ffd2
Cleanup FirebaseArrayOfObjectsOptimized.java variables
SUPERCILEX Feb 1, 2017
e29cfb8
Bug fixes
SUPERCILEX Feb 1, 2017
8496ad1
Fix permuted arguments
SUPERCILEX Feb 2, 2017
f8bdf9a
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 2, 2017
788727f
Lock mListeners
SUPERCILEX Feb 2, 2017
3ffc538
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 5, 2017
8dbdfa8
Fix proguard saying SubscriptionEventListener.EventType doesn't exist
SUPERCILEX Feb 5, 2017
2816314
Fix proguard saying SubscriptionEventListener.EventType doesn't exist
SUPERCILEX Feb 5, 2017
2bbb8c9
Fix proguard saying SubscriptionEventListener.EventType doesn't exist
SUPERCILEX Feb 5, 2017
31c5627
Fix proguard
SUPERCILEX Feb 5, 2017
49cafe8
Didn't work, just use an enum instead
SUPERCILEX Feb 5, 2017
6e0031a
Fix compile errors
SUPERCILEX Feb 5, 2017
e2d6ef4
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 6, 2017
9ae6b95
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 6, 2017
5e01b45
Make everything that shouldn't be extended final
SUPERCILEX Feb 7, 2017
7d46339
Notify of existing listeners/items for new listeners in `addFooListener`
SUPERCILEX Feb 7, 2017
327d182
Fix `concurrentmodificationexception`s
SUPERCILEX Feb 7, 2017
fda5417
Fix FirebaseArrayOfObjects$FirebaseArrayOfObjectsOptimized.java being…
SUPERCILEX Feb 7, 2017
ad67210
Remove synchronized since we're using `CopyOnWriteArrayList`
SUPERCILEX Feb 7, 2017
3e25e25
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 9, 2017
34652db
Fix merge mistakes
SUPERCILEX Feb 9, 2017
28aa758
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 14, 2017
97b958f
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 16, 2017
074af0c
Replace old adapters with new ones
SUPERCILEX Feb 16, 2017
7b703b6
Merge branch 'version-1.2.0-dev' into FirebaseArray
SUPERCILEX Feb 16, 2017
cd0b0f3
Cleanup
SUPERCILEX Feb 16, 2017
c70d0c1
Merge remote-tracking branch 'firebase/version-1.2.0-dev' into Fireba…
SUPERCILEX Feb 16, 2017
fc61556
Fix SubscriptionEventListener.java mess
SUPERCILEX Feb 18, 2017
2417e2a
Make toStrings nicer
SUPERCILEX Feb 20, 2017
1948ece
Add annotations and make extending FirebaseArray.java sticker
SUPERCILEX Feb 20, 2017
8aabf1a
Merge remote-tracking branch 'origin/patch-1' into FirebaseArray
SUPERCILEX Feb 20, 2017
8507e21
Merge remote-tracking branch 'firebase/master' into FirebaseArray
SUPERCILEX Feb 21, 2017
1c31e16
Fix bug where custom snapshot parser was not applied in FirebaseArray…
SUPERCILEX Feb 22, 2017
bdeb6e2
Update optimized array name
SUPERCILEX Feb 22, 2017
b067bab
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into Fireba…
SUPERCILEX Feb 24, 2017
15eb5d8
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into Fireba…
SUPERCILEX Feb 24, 2017
fdf9be8
Initial commit of refactor. Far from done, but enough that the sampl…
samtstern Feb 25, 2017
03d6bf4
Clean up some TODOs, make the tests compile, some tests pass.
samtstern Feb 25, 2017
a38c1b2
Tests pass, TODOs resolved, code made DRY
samtstern Feb 27, 2017
a87a0d9
Fix build and docs
samtstern Feb 27, 2017
51b05e6
Respond to review comments
samtstern Mar 1, 2017
be09c80
Make FirebaseAdapter protected
samtstern Mar 1, 2017
a4d7ad1
Merge branch 'FirebaseArray' into firebase-array-explore
SUPERCILEX Mar 1, 2017
ce0302d
Cleanup, fix documentation typos, make preconditions return passed in…
SUPERCILEX Mar 1, 2017
7601ded
Remove null parser possibility and fix broken FirebaseIndexAdapters
SUPERCILEX Mar 1, 2017
fa6265e
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into Fireba…
SUPERCILEX Mar 2, 2017
42c639a
Fix circular SnapshotParser dependency in adapters
SUPERCILEX Mar 4, 2017
cfef2c5
Remove getItemId method - hashcode isn't stable
SUPERCILEX Mar 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void populateViewHolder(ChatHolder holder, Chat chat, int position) {
}

@Override
protected void onDataChanged() {
public void onDataChanged() {
// If there are no chat messages, show a view that invites the user to add a message.
mEmptyListMessage.setVisibility(mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
}
Expand Down
12 changes: 12 additions & 0 deletions database/src/androidTest/java/com/firebase/ui/database/Bean.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,16 @@ public String getText() {
public boolean isBool() {
return mBool;
}

public void setNumber(int number) {
mNumber = number;
}

public void setText(String text) {
mText = text;
}

public void setBool(boolean bool) {
mBool = bool;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import java.util.concurrent.Callable;

import static com.firebase.ui.database.TestUtils.getAppInstance;
import static com.firebase.ui.database.TestUtils.getBean;
import static com.firebase.ui.database.TestUtils.runAndWaitUntil;

@RunWith(AndroidJUnit4.class)
public class FirebaseArrayOfObjectsTest {
private static final int INITIAL_SIZE = 3;

private DatabaseReference mRef;
private FirebaseArray mArray;
private FirebaseArray<Bean> mArray;
private ChangeEventListener mListener;

@Before
public void setUp() throws Exception {
Expand All @@ -46,9 +46,9 @@ public void setUp() throws Exception {
.getReference()
.child("firebasearray")
.child("objects");
mArray = new FirebaseArray(mRef);
mArray = new FirebaseArray<>(mRef, Bean.class);
mRef.removeValue();
runAndWaitUntil(mArray, new Runnable() {
mListener = runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
for (int i = 1; i <= INITIAL_SIZE; i++) {
Expand All @@ -58,14 +58,14 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getCount() == INITIAL_SIZE;
return mArray.size() == INITIAL_SIZE;
}
});
}

@After
public void tearDown() throws Exception {
mArray.cleanup();
mArray.removeChangeEventListener(mListener);
mRef.getRoot().removeValue();
}

Expand All @@ -79,7 +79,7 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getCount() == 4;
return mArray.size() == 4;
}
});
}
Expand All @@ -94,7 +94,7 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getItem(3).getValue(Bean.class).getNumber() == 4;
return mArray.getObject(3).getNumber() == 4;
}
});
}
Expand All @@ -109,9 +109,8 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getItem(3).getValue(Bean.class).getNumber() == 3 && mArray.getItem(0)
.getValue(Bean.class)
.getNumber() == 4;
return mArray.getObject(3).getNumber() == 3
&& mArray.getObject(0).getNumber() == 4;
}
});
}
Expand All @@ -121,16 +120,47 @@ public void testChangePriorities() throws Exception {
runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
mArray.getItem(2).getRef().setPriority(0.5);
mArray.get(2).getRef().setPriority(0.5);
}
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return getBean(mArray, 0).getNumber() == 3
&& getBean(mArray, 1).getNumber() == 1
&& getBean(mArray, 2).getNumber() == 2;
return mArray.getObject(0).getNumber() == 3
&& mArray.getObject(1).getNumber() == 1
&& mArray.getObject(2).getNumber() == 2;
//return isValuesEqual(mArray, new int[]{3, 1, 2});
}
});
}

@Test
public void testCacheInvalidates() throws Exception {
final DatabaseReference pushRef = mRef.push();

// Set initial value to "5"
runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
pushRef.setValue(new Bean(5), 100);
}
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getObject(3).getNumber() == 5;
}
});

// Change the value to "6" and ensure that the change is propagated
runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
pushRef.setValue(new Bean(6), 100);
}
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getObject(3).getNumber() == 6;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ public class FirebaseArrayTest {
private static final int INITIAL_SIZE = 3;
private DatabaseReference mRef;
private FirebaseArray mArray;
private ChangeEventListener mListener;

@Before
public void setUp() throws Exception {
FirebaseApp app = getAppInstance(InstrumentationRegistry.getContext());
mRef = FirebaseDatabase.getInstance(app).getReference().child("firebasearray");
mArray = new FirebaseArray(mRef);
mRef.removeValue();
runAndWaitUntil(mArray, new Runnable() {
mListener = runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
for (int i = 1; i <= INITIAL_SIZE; i++) {
Expand All @@ -54,14 +55,14 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getCount() == INITIAL_SIZE;
return mArray.size() == INITIAL_SIZE;
}
});
}

@After
public void tearDown() throws Exception {
mArray.cleanup();
mArray.removeChangeEventListener(mListener);
mRef.getRoot().removeValue();
}

Expand All @@ -75,7 +76,7 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getCount() == 4;
return mArray.size() == 4;
}
});
}
Expand All @@ -90,7 +91,7 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getItem(3).getValue(Integer.class).equals(4);
return mArray.get(3).getValue(Integer.class).equals(4);
}
});
}
Expand All @@ -105,8 +106,8 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getItem(3).getValue(Integer.class).equals(3)
&& mArray.getItem(0).getValue(Integer.class).equals(4);
return mArray.get(3).getValue(Integer.class).equals(3)
&& mArray.get(0).getValue(Integer.class).equals(4);
}
});
}
Expand All @@ -116,7 +117,7 @@ public void testChangePriorityBackToFront() throws Exception {
runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
mArray.getItem(2).getRef().setPriority(0.5);
mArray.get(2).getRef().setPriority(0.5);
}
}, new Callable<Boolean>() {
@Override
Expand All @@ -131,7 +132,7 @@ public void testChangePriorityFrontToBack() throws Exception {
runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
mArray.getItem(0).getRef().setPriority(4);
mArray.get(0).getRef().setPriority(4);
}
}, new Callable<Boolean>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.concurrent.Callable;

import static com.firebase.ui.database.TestUtils.getAppInstance;
import static com.firebase.ui.database.TestUtils.getBean;
import static com.firebase.ui.database.TestUtils.runAndWaitUntil;

@RunWith(AndroidJUnit4.class)
Expand All @@ -37,7 +36,8 @@ public class FirebaseIndexArrayOfObjectsTest {

private DatabaseReference mRef;
private DatabaseReference mKeyRef;
private FirebaseArray mArray;
private ObservableSnapshotArray<Bean> mArray;
private ChangeEventListener mListener;

@Before
public void setUp() throws Exception {
Expand All @@ -46,11 +46,11 @@ public void setUp() throws Exception {
mRef = databaseInstance.getReference().child("firebasearray").child("objects");
mKeyRef = databaseInstance.getReference().child("firebaseindexarray").child("objects");

mArray = new FirebaseIndexArray(mKeyRef, mRef);
mArray = new FirebaseIndexArray<>(mKeyRef, mRef, Bean.class);
mRef.removeValue();
mKeyRef.removeValue();

runAndWaitUntil(mArray, new Runnable() {
mListener = runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
for (int i = 1; i <= INITIAL_SIZE; i++) {
Expand All @@ -60,14 +60,14 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getCount() == INITIAL_SIZE;
return mArray.size() == INITIAL_SIZE;
}
});
}

@After
public void tearDown() throws Exception {
mArray.cleanup();
mArray.removeChangeEventListener(mListener);
mRef.getRoot().removeValue();
}

Expand All @@ -81,7 +81,7 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getCount() == 4;
return mArray.size() == 4;
}
});
}
Expand All @@ -96,7 +96,7 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getItem(3).getValue(Bean.class).getNumber() == 4;
return mArray.getObject(3).getNumber() == 4;
}
});
}
Expand All @@ -111,9 +111,8 @@ public void run() {
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mArray.getItem(3).getValue(Bean.class).getNumber() == 3 && mArray.getItem(0)
.getValue(Bean.class)
.getNumber() == 4;
return mArray.getObject(3).getNumber() == 3
&& mArray.getObject(0).getNumber() == 4;
}
});
}
Expand All @@ -123,14 +122,14 @@ public void testChangePriorities() throws Exception {
runAndWaitUntil(mArray, new Runnable() {
@Override
public void run() {
mKeyRef.child(mArray.getItem(2).getKey()).setPriority(0.5);
mKeyRef.child(mArray.get(2).getKey()).setPriority(0.5);
}
}, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return getBean(mArray, 0).getNumber() == 3
&& getBean(mArray, 1).getNumber() == 1
&& getBean(mArray, 2).getNumber() == 2;
return mArray.getObject(0).getNumber() == 3
&& mArray.getObject(1).getNumber() == 1
&& mArray.getObject(2).getNumber() == 2;
//return isValuesEqual(mArray, new int[]{3, 1, 2});
}
});
Expand Down
Loading