当前位置: 首页>>代码示例>>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;未经允许,请勿转载。