本文整理匯總了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;
}
});
}