当前位置: 首页>>代码示例>>Java>>正文


Java Tasks.call方法代码示例

本文整理汇总了Java中com.google.android.gms.tasks.Tasks.call方法的典型用法代码示例。如果您正苦于以下问题:Java Tasks.call方法的具体用法?Java Tasks.call怎么用?Java Tasks.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.tasks.Tasks的用法示例。


在下文中一共展示了Tasks.call方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteCollection

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
/**
 * Delete all documents in a collection. Uses an Executor to perform work on a background
 * thread. This does *not* automatically discover and delete subcollections.
 */
private static Task<Void> deleteCollection(final CollectionReference collection,
                                           final int batchSize,
                                           Executor executor) {

    // Perform the delete operation on the provided Executor, which allows us to use
    // simpler synchronous logic without blocking the main thread.
    return Tasks.call(executor, () -> {
        // Get the first batch of documents in the collection
        Query query = collection.orderBy("__name__").limit(batchSize);

        // Get a list of deleted documents
        List<DocumentSnapshot> deleted = deleteQueryBatch(query);

        // While the deleted documents in the last batch indicate that there
        // may still be more documents in the collection, page down to the
        // next batch and delete again
        while (deleted.size() >= batchSize) {
            // Move the query cursor to start after the last doc in the batch
            DocumentSnapshot last = deleted.get(deleted.size() - 1);
            query = collection.orderBy("__name__")
                    .startAfter(last.getId())
                    .limit(batchSize);

            deleted = deleteQueryBatch(query);
        }

        return null;
    });

}
 
开发者ID:amrro,项目名称:firestore-android-arch-components,代码行数:35,代码来源:RestaurantUtil.java

示例2: asyncGetRegisterRequest

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
private Task<RegisterRequestParams> asyncGetRegisterRequest(final Boolean allowReregistration) {
    return Tasks.call(THREAD_POOL_EXECUTOR, new Callable<RegisterRequestParams>() {
        @Override
        public RegisterRequestParams call() throws Exception {
            gaeService = GAEService.getInstance(U2FDemoActivity.this, mGoogleSignInAccount);
            return gaeService.getRegistrationRequest(allowReregistration);
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:10,代码来源:U2FDemoActivity.java

示例3: asyncUpdateRegisterResponseToServer

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
private Task<String> asyncUpdateRegisterResponseToServer(
    final RegisterResponseData registerResponseData) {
    return Tasks.call(THREAD_POOL_EXECUTOR, new Callable<String>() {
        @Override
        public String call() throws Exception {
            gaeService = GAEService.getInstance(U2FDemoActivity.this, mGoogleSignInAccount);
            return gaeService.getRegisterResponseFromServer(registerResponseData);
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:11,代码来源:U2FDemoActivity.java

示例4: asyncGetSignRequest

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
private Task<SignRequestParams> asyncGetSignRequest() {
    return Tasks.call(THREAD_POOL_EXECUTOR, new Callable<SignRequestParams>() {
        @Override
        public SignRequestParams call() throws Exception {
            gaeService = GAEService.getInstance(U2FDemoActivity.this, mGoogleSignInAccount);
            return gaeService.getSignRequest();
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:10,代码来源:U2FDemoActivity.java

示例5: asyncUpdateSignResponseToServer

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
private Task<String> asyncUpdateSignResponseToServer(final SignResponseData signResponseData) {
    return Tasks.call(THREAD_POOL_EXECUTOR, new Callable<String>() {
        @Override
        public String call() throws Exception {
            gaeService = GAEService.getInstance(U2FDemoActivity.this, mGoogleSignInAccount);
            return gaeService.getSignResponseFromServer(signResponseData);
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:10,代码来源:U2FDemoActivity.java

示例6: asyncRefreshSecurityKey

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
private Task<List<Map<String, String>>> asyncRefreshSecurityKey() {
    return Tasks.call(THREAD_POOL_EXECUTOR, new Callable<List<Map<String, String>>>() {
        @Override
        public List<Map<String, String>> call() {
            gaeService = GAEService.getInstance(U2FDemoActivity.this, mGoogleSignInAccount);
            return gaeService.getAllSecurityTokens();
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:10,代码来源:U2FDemoActivity.java

示例7: asyncRemoveSecurityKey

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
private Task<String> asyncRemoveSecurityKey(final int tokenPositionInList) {
    return Tasks.call(THREAD_POOL_EXECUTOR, new Callable<String>() {
        @Override
        public String call() {
            gaeService = GAEService.getInstance(U2FDemoActivity.this, mGoogleSignInAccount);
            return gaeService.removeSecurityKey(securityTokens.get(tokenPositionInList)
                .get(KEY_PUB_KEY));
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:11,代码来源:U2FDemoActivity.java

示例8: deleteCollection

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
/**
 * Delete all documents in a collection. Uses an Executor to perform work on a background
 * thread. This does *not* automatically discover and delete subcollections.
 */
private Task<Void> deleteCollection(final CollectionReference collection,
                                    final int batchSize,
                                    Executor executor) {

    // Perform the delete operation on the provided Executor, which allows us to use
    // simpler synchronous logic without blocking the main thread.
    return Tasks.call(executor, new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            // Get the first batch of documents in the collection
            Query query = collection.orderBy(FieldPath.documentId()).limit(batchSize);

            // Get a list of deleted documents
            List<DocumentSnapshot> deleted = deleteQueryBatch(query);

            // While the deleted documents in the last batch indicate that there
            // may still be more documents in the collection, page down to the
            // next batch and delete again
            while (deleted.size() >= batchSize) {
                // Move the query cursor to start after the last doc in the batch
                DocumentSnapshot last = deleted.get(deleted.size() - 1);
                query = collection.orderBy(FieldPath.documentId())
                        .startAfter(last.getId())
                        .limit(batchSize);

                deleted = deleteQueryBatch(query);
            }

            return null;
        }
    });

}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:38,代码来源:DocSnippets.java

示例9: deleteCollection

import com.google.android.gms.tasks.Tasks; //导入方法依赖的package包/类
/**
 * Delete all documents in a collection. Uses an Executor to perform work on a background
 * thread. This does *not* automatically discover and delete subcollections.
 */
private static Task<Void> deleteCollection(final CollectionReference collection,
                                           final int batchSize,
                                           Executor executor) {

    // Perform the delete operation on the provided Executor, which allows us to use
    // simpler synchronous logic without blocking the main thread.
    return Tasks.call(executor, new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            // Get the first batch of documents in the collection
            Query query = collection.orderBy("__name__").limit(batchSize);

            // Get a list of deleted documents
            List<DocumentSnapshot> deleted = deleteQueryBatch(query);

            // While the deleted documents in the last batch indicate that there
            // may still be more documents in the collection, page down to the
            // next batch and delete again
            while (deleted.size() >= batchSize) {
                // Move the query cursor to start after the last doc in the batch
                DocumentSnapshot last = deleted.get(deleted.size() - 1);
                query = collection.orderBy("__name__")
                        .startAfter(last.getId())
                        .limit(batchSize);

                deleted = deleteQueryBatch(query);
            }

            return null;
        }
    });

}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:38,代码来源:RestaurantUtil.java


注:本文中的com.google.android.gms.tasks.Tasks.call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。