本文整理匯總了Java中com.google.firebase.database.DatabaseReference.keepSynced方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseReference.keepSynced方法的具體用法?Java DatabaseReference.keepSynced怎麽用?Java DatabaseReference.keepSynced使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.firebase.database.DatabaseReference
的用法示例。
在下文中一共展示了DatabaseReference.keepSynced方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMultipleKeepSynced
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testMultipleKeepSynced() throws Exception {
DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
try {
ref.keepSynced(true);
ref.keepSynced(true);
ref.keepSynced(true);
assertIsKeptSynced(ref);
// If it were balanced, this would not be enough
ref.keepSynced(false);
ref.keepSynced(false);
assertNotKeptSynced(ref);
// If it were balanced, this would not be enough
ref.keepSynced(true);
assertIsKeptSynced(ref);
} finally {
// cleanup
ref.keepSynced(false);
}
}
示例2: testRemoveSingleListener
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testRemoveSingleListener() throws Exception {
DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
ref.keepSynced(true);
try {
assertIsKeptSynced(ref);
// This will add and remove a listener.
new ReadFuture(
ref,
new ReadFuture.CompletionCondition() {
@Override
public boolean isComplete(List<EventRecord> events) {
return true;
}
})
.timedGet();
assertIsKeptSynced(ref);
} finally {
// cleanup
ref.keepSynced(false);
}
}
示例3: testKeepSyncedWithExistingListener
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testKeepSyncedWithExistingListener() throws Exception {
DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
ReadFuture readFuture;
ref.keepSynced(true);
try {
assertIsKeptSynced(ref);
readFuture =
new ReadFuture(ref, new ReadFuture.CompletionCondition() {
@Override
public boolean isComplete(List<EventRecord> events) {
return events.get(events.size() - 1).getSnapshot().getValue().equals("done");
}
});
} finally {
// cleanup
ref.keepSynced(false);
}
// Should trigger our listener.
ref.setValueAsync("done");
readFuture.timedGet();
}
示例4: addItem
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
private void addItem(HashMap<String, String> images, final Hotel item) {
DatabaseReference itemsRef = FirebaseDatabase.getInstance().getReferenceFromUrl(Constants.FIREBASE_URL_ITEMS);
itemsRef.keepSynced(true);
item.setImagesUrls(images);
itemsRef = itemsRef.push().getRef();
itemsRef.setValue(item, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
mUploadProgressDialog.dismiss();
if (databaseError == null) {
Toast.makeText(AddActivity.this, "Item uploaded Successfully.", Toast.LENGTH_SHORT).show();
startActivity(new Intent(AddActivity.this, MainActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
} else {
Toast.makeText(AddActivity.this, "unable to add.", Toast.LENGTH_SHORT).show();
}
}
});
}
示例5: testKeepSynced
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testKeepSynced() throws Exception {
DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
ref.keepSynced(true);
assertIsKeptSynced(ref);
ref.keepSynced(false);
assertNotKeptSynced(ref);
}
示例6: testKeepSyncedAffectOnQueries
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testKeepSyncedAffectOnQueries() throws Exception {
DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
ref.keepSynced(true);
Query query = ref.limitToFirst(5);
query.keepSynced(true);
assertIsKeptSynced(ref);
ref.keepSynced(false);
assertNotKeptSynced(ref);
// currently, setting false on the default query affects all queries at that location
assertNotKeptSynced(query);
}
示例7: testKeptSyncedChild
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testKeptSyncedChild() throws Exception {
DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
DatabaseReference child = ref.child("random-child");
ref.keepSynced(true);
try {
assertIsKeptSynced(child);
} finally {
// cleanup
ref.keepSynced(false);
}
}
示例8: testKeptSyncedRoot
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Test
public void testKeptSyncedRoot() throws Exception {
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
ref.keepSynced(true);
try {
assertIsKeptSynced(ref);
} finally {
// cleanup
ref.keepSynced(false);
}
}
示例9: provideDatabaseReference
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Singleton
@Provides
DatabaseReference provideDatabaseReference(Context context, FirebaseDatabase firebaseDatabase) {
DatabaseReference fontsRef = firebaseDatabase.getReference(
context.getString(R.string.fonts));
fontsRef.keepSynced(BuildConfig.DEBUG); //force sync on debug
return firebaseDatabase.getReference(context.getString(R.string.fonts));
}