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


Java OnFailureListener类代码示例

本文整理汇总了Java中com.google.firebase.tasks.OnFailureListener的典型用法代码示例。如果您正苦于以下问题:Java OnFailureListener类的具体用法?Java OnFailureListener怎么用?Java OnFailureListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: findInternal

import com.google.firebase.tasks.OnFailureListener; //导入依赖的package包/类
private Optional<UserRecord> findInternal(String medium, String address) {
    final UserRecord[] r = new UserRecord[1];
    CountDownLatch l = new CountDownLatch(1);

    OnSuccessListener<UserRecord> success = result -> {
        log.info("Found 3PID match for {}:{} - UID is {}", medium, address, result.getUid());
        r[0] = result;
        l.countDown();
    };

    OnFailureListener failure = e -> {
        log.info("No 3PID match for {}:{} - {}", medium, address, e.getMessage());
        r[0] = null;
        l.countDown();
    };

    if (ThreePidMedium.Email.is(medium)) {
        log.info("Performing E-mail 3PID lookup for {}", address);
        getFirebase().getUserByEmail(address)
                .addOnSuccessListener(success)
                .addOnFailureListener(failure);
        waitOnLatch(l);
    } else if (ThreePidMedium.PhoneNumber.is(medium)) {
        log.info("Performing msisdn 3PID lookup for {}", address);
        getFirebase().getUserByPhoneNumber(address)
                .addOnSuccessListener(success)
                .addOnFailureListener(failure);
        waitOnLatch(l);
    } else {
        log.info("{} is not a supported 3PID medium", medium);
        r[0] = null;
    }

    return Optional.ofNullable(r[0]);
}
 
开发者ID:kamax-io,项目名称:mxisd,代码行数:36,代码来源:GoogleFirebaseProvider.java


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