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


Java FirebaseFirestoreSettings類代碼示例

本文整理匯總了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);
}
 
開發者ID:whirlwind-studios,項目名稱:School1-Android,代碼行數:11,代碼來源:Application.java

示例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]
}
 
開發者ID:firebase,項目名稱:snippets-android,代碼行數:13,代碼來源:DocSnippets.java

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


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