本文整理汇总了Java中com.google.firebase.firestore.FirebaseFirestoreSettings类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseFirestoreSettings类的具体用法?Java FirebaseFirestoreSettings怎么用?Java FirebaseFirestoreSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseFirestoreSettings类属于com.google.firebase.firestore包,在下文中一共展示了FirebaseFirestoreSettings类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.google.firebase.firestore.FirebaseFirestoreSettings; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
LocalBroadcastManager.getInstance(this);
FirebaseApp.initializeApp(this);
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(true)
.build();
FirebaseFirestore.getInstance().setFirestoreSettings(settings);
}
示例2: setup
import com.google.firebase.firestore.FirebaseFirestoreSettings; //导入依赖的package包/类
private void setup() {
// [START get_firestore_instance]
FirebaseFirestore db = FirebaseFirestore.getInstance();
// [END get_firestore_instance]
// [START set_firestore_settings]
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(true)
.build();
db.setFirestoreSettings(settings);
// [END set_firestore_settings]
}
示例3: setUp
import com.google.firebase.firestore.FirebaseFirestoreSettings; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
FirebaseApp app = getAppInstance(InstrumentationRegistry.getContext());
// Configure Firestore and disable persistence
FirebaseFirestore.getInstance(app)
.setFirestoreSettings(new FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(false)
.build());
// Get a fresh 'test' subcollection for each test
mCollectionRef = FirebaseFirestore.getInstance(app).collection("firestorearray")
.document().collection("test");
Log.d(TAG, "Test Collection: " + getConsoleLink(mCollectionRef));
// Query is the whole collection ordered by field
mArray = new FirestoreArray<>(
mCollectionRef.orderBy("field", Query.Direction.ASCENDING),
new ClassSnapshotParser<>(IntegerDocument.class));
// Add a listener to the array so that it's active
mListener = mArray.addChangeEventListener(new LoggingListener());
// Add some initial data
runAndVerify(new Callable<Task<?>>() {
@Override
public Task<?> call() {
List<Task> tasks = new ArrayList<>();
for (int i = 0; i < INITIAL_SIZE; i++) {
tasks.add(mCollectionRef.document().set(new IntegerDocument(i)));
}
return Tasks.whenAll(tasks.toArray(new Task[tasks.size()]));
}
}, new Callable<Boolean>() {
@Override
public Boolean call() {
return mArray.size() == INITIAL_SIZE;
}
});
}