[android][database] Fix issue #100
This commit is contained in:
parent
c7eb09ddd5
commit
c4f8688348
|
@ -216,12 +216,12 @@ public class Utils {
|
|||
* @return
|
||||
*/
|
||||
private static boolean isArray(DataSnapshot snapshot) {
|
||||
long expectedKey = 0;
|
||||
long expectedKey = -1;
|
||||
for (DataSnapshot child : snapshot.getChildren()) {
|
||||
try {
|
||||
long key = Long.parseLong(child.getKey());
|
||||
if (key == expectedKey) {
|
||||
expectedKey++;
|
||||
if (key > expectedKey) {
|
||||
expectedKey = key;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -238,11 +238,11 @@ public class Utils {
|
|||
* @return
|
||||
*/
|
||||
private static boolean isArray(MutableData mutableData) {
|
||||
long expectedKey = 0;
|
||||
long expectedKey = -1;
|
||||
for (MutableData child : mutableData.getChildren()) {
|
||||
try {
|
||||
long key = Long.parseLong(child.getKey());
|
||||
if (key == expectedKey) {
|
||||
if (key > expectedKey) {
|
||||
expectedKey++;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -261,8 +261,16 @@ public class Utils {
|
|||
* @return
|
||||
*/
|
||||
private static <Any> WritableArray buildArray(DataSnapshot snapshot) {
|
||||
long expectedKey = 0;
|
||||
WritableArray array = Arguments.createArray();
|
||||
for (DataSnapshot child : snapshot.getChildren()) {
|
||||
long key = Long.parseLong(child.getKey());
|
||||
if (key > expectedKey) {
|
||||
for (long i = expectedKey; i < key; i++) {
|
||||
array.pushNull();
|
||||
}
|
||||
expectedKey = key;
|
||||
}
|
||||
Any castedChild = castValue(child);
|
||||
switch (castedChild.getClass().getName()) {
|
||||
case "java.lang.Boolean":
|
||||
|
@ -288,6 +296,7 @@ public class Utils {
|
|||
Log.w(TAG, "Invalid type: " + castedChild.getClass().getName());
|
||||
break;
|
||||
}
|
||||
expectedKey++;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -299,8 +308,16 @@ public class Utils {
|
|||
* @return
|
||||
*/
|
||||
private static <Any> WritableArray buildArray(MutableData mutableData) {
|
||||
long expectedKey = 0;
|
||||
WritableArray array = Arguments.createArray();
|
||||
for (MutableData child : mutableData.getChildren()) {
|
||||
long key = Long.parseLong(child.getKey());
|
||||
if (key > expectedKey) {
|
||||
for (long i = expectedKey; i < key; i++) {
|
||||
array.pushNull();
|
||||
}
|
||||
expectedKey = key;
|
||||
}
|
||||
Any castedChild = castValue(child);
|
||||
switch (castedChild.getClass().getName()) {
|
||||
case "java.lang.Boolean":
|
||||
|
@ -326,6 +343,7 @@ public class Utils {
|
|||
Log.w(TAG, "Invalid type: " + castedChild.getClass().getName());
|
||||
break;
|
||||
}
|
||||
expectedKey++;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class MainApplication extends Application implements ReactApplication {
|
|||
|
||||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
||||
@Override
|
||||
protected boolean getUseDeveloperSupport() {
|
||||
public boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ function childTests({ fdescribe, it, context, firebase }) {
|
|||
// Assertion
|
||||
console.warn(JSON.stringify(snapshot.val()));
|
||||
|
||||
snapshot.val().should.eql(DatabaseContents.ISSUES[100]);
|
||||
snapshot.val().should.eql([null, DatabaseContents.ISSUES[100][1], DatabaseContents.ISSUES[100][2], DatabaseContents.ISSUES[100][3]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue