當前位置: 首頁>>代碼示例>>Java>>正文


Java DatabaseReference.keepSynced方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:24,代碼來源:KeepSyncedTestIT.java

示例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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:26,代碼來源:KeepSyncedTestIT.java

示例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();
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:26,代碼來源:KeepSyncedTestIT.java

示例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();

            }
        }
    });
}
 
開發者ID:Elbehiry,項目名稱:Viajes,代碼行數:22,代碼來源:AddActivity.java

示例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);
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:10,代碼來源:KeepSyncedTestIT.java

示例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);
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:14,代碼來源:KeepSyncedTestIT.java

示例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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:14,代碼來源:KeepSyncedTestIT.java

示例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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:13,代碼來源:KeepSyncedTestIT.java

示例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));
}
 
開發者ID:wahibhaq,項目名稱:urdu-font-comparator-app,代碼行數:9,代碼來源:FirebaseModule.java


注:本文中的com.google.firebase.database.DatabaseReference.keepSynced方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。