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


Java Result类代码示例

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


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

示例1: await

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@NonNull
@Override
public Result await() {
    if (!canceled && latch != null) {
        try {
            latch.await();
        } catch (InterruptedException e) {
            return new Result() {
                @Override
                public Status getStatus() {
                    return Canceled;
                }
            };
        }
    }
    return new Result() {
        @Override
        public Status getStatus() {
            return canceled ? Canceled : Success;
        }
    };
}
 
开发者ID:sarveshchavan7,项目名称:Trivia-Knowledge,代码行数:23,代码来源:SnapshotCoordinator.java

示例2: forFlowable

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
public static <R extends Result> FlowableTransformer<R, R> forFlowable() {
    return upstream -> upstream.onErrorResumeNext(throwable -> {
        if(throwable instanceof StatusException) {
            StatusException statusException = (StatusException) throwable;

            if(statusException.getStatus().hasResolution()) {
                return Flowable.just((R) statusException.getResult());
            } else {
                return Flowable.error(throwable);
            }

        } else {
            return Flowable.error(throwable);
        }
    });
}
 
开发者ID:florent37,项目名称:RxGps,代码行数:17,代码来源:StatusExceptionResumeNextTransformer.java

示例3: delete

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public PendingResult<DeleteSnapshotResult> delete(GoogleApiClient googleApiClient,
                                                  final SnapshotMetadata snapshotMetadata) {
    if (!isAlreadyOpen(snapshotMetadata.getUniqueName()) &&
            !isAlreadyClosing(snapshotMetadata.getUniqueName())) {
        setIsClosing(snapshotMetadata.getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.delete(googleApiClient, snapshotMetadata),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // deleted files are closed.
                            setClosed(snapshotMetadata.getUniqueName());
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshotMetadata.getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshotMetadata.getUniqueName() +
                " is either open or is busy");
    }
}
 
开发者ID:MartensCedric,项目名称:Hexpert,代码行数:26,代码来源:SnapshotCoordinator.java

示例4: await

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@NonNull
@Override
public Result await(long l, @NonNull TimeUnit timeUnit) {
    if (!canceled && latch != null) {
        try {
            latch.await(l, timeUnit);
        } catch (InterruptedException e) {
            return new Result() {
                @Override
                public Status getStatus() {
                    return Canceled;
                }
            };
        }
    }
    return new Result() {
        @Override
        public Status getStatus() {
            return canceled ? Canceled : Success;
        }
    };
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:23,代码来源:SnapshotCoordinator.java

示例5: forObservable

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
public static <R extends Result> ObservableTransformer<R, R> forObservable() {
    return upstream -> upstream.onErrorResumeNext(throwable -> {
        if(throwable instanceof StatusException) {
            StatusException statusException = (StatusException) throwable;

            if(statusException.getStatus().hasResolution()) {
                return Observable.just((R) statusException.getResult());
            } else {
                return Observable.error(throwable);
            }

        } else {
            return Observable.error(throwable);
        }
    });
}
 
开发者ID:florent37,项目名称:RxGps,代码行数:17,代码来源:StatusExceptionResumeNextTransformer.java

示例6: forSingle

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
public static <R extends Result> SingleTransformer<R, R> forSingle() {
    return upstream -> upstream.onErrorResumeNext(throwable -> {
        if(throwable instanceof StatusException) {
            StatusException statusException = (StatusException) throwable;

            if(statusException.getStatus().hasResolution()) {
                return Single.just((R) statusException.getResult());
            } else {
                return Single.error(throwable);
            }

        } else {
            return Single.error(throwable);
        }
    });
}
 
开发者ID:florent37,项目名称:RxGps,代码行数:17,代码来源:StatusExceptionResumeNextTransformer.java

示例7: setupLocationPendingResult

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
protected final <T extends Result> void setupLocationPendingResult(PendingResult<T> pendingResult, ResultCallback<T> resultCallback) {
    if (timeoutTime != null && timeoutUnit != null) {
        pendingResult.setResultCallback(resultCallback, timeoutTime, timeoutUnit);
    } else {
        pendingResult.setResultCallback(resultCallback);
    }
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:8,代码来源:RxLocationBaseOnSubscribe.java

示例8: cancel

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public void cancel() {
    if (listener != null) {
        listener.onResult(new Result() {

            @Override
            public Status getStatus() {
                return new Status(CommonStatusCodes.CANCELED);
            }
        });
    }
    innerResult.cancel();
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:14,代码来源:SnapshotCoordinator.java

示例9: waitForClosed

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
/**
 * Blocking wait for the given file to be closed.  Returns immediately if the
 * file is not open.
 *
 * @param filename - the file name in question.
 */
public PendingResult<Result> waitForClosed(String filename) {
    CountDownLatch l;
    synchronized (this) {
        l = opened.get(filename);
    }
    return new CountDownPendingResult(l);
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:14,代码来源:SnapshotCoordinator.java

示例10: open

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public PendingResult<OpenSnapshotResult> open(GoogleApiClient googleApiClient,
                                              final SnapshotMetadata snapshotMetadata) {
    // check if the file is already open
    if (!isAlreadyOpen(snapshotMetadata.getUniqueName())) {
        setIsOpening(snapshotMetadata.getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.open(googleApiClient, snapshotMetadata),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // if open failed, set the file to closed, otherwise, keep it open.
                            if (!result.getStatus().isSuccess()) {
                                Log.d(TAG, "Open was not a success: " +
                                        result.getStatus() + " for filename " +
                                        snapshotMetadata.getUniqueName());
                                setClosed(snapshotMetadata.getUniqueName());
                            } else {
                                Log.d(TAG, "Open was successful: " +
                                        snapshotMetadata.getUniqueName());
                            }
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshotMetadata.getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshotMetadata.getUniqueName() + " is already open");
    }
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:33,代码来源:SnapshotCoordinator.java

示例11: commitAndClose

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public PendingResult<CommitSnapshotResult> commitAndClose(GoogleApiClient googleApiClient,
                                                          final Snapshot snapshot,
                                                          SnapshotMetadataChange
                                                                  snapshotMetadataChange) {
    if (isAlreadyOpen(snapshot.getMetadata().getUniqueName()) &&
            !isAlreadyClosing(snapshot.getMetadata().getUniqueName())) {
        setIsClosing(snapshot.getMetadata().getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.commitAndClose(googleApiClient, snapshot,
                            snapshotMetadataChange),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // even if commit and close fails, the file is closed.
                            Log.d(TAG, "CommitAndClose complete, closing " +
                                    snapshot.getMetadata().getUniqueName());
                            setClosed(snapshot.getMetadata().getUniqueName());
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshot.getMetadata().getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshot.getMetadata().getUniqueName() +
                " is either closed or is closing");
    }
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:31,代码来源:SnapshotCoordinator.java

示例12: resolveConflict

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public PendingResult<OpenSnapshotResult> resolveConflict(GoogleApiClient googleApiClient,
                                                         String conflictId,
                                                         final Snapshot snapshot) {
    if (!isAlreadyOpen(snapshot.getMetadata().getUniqueName()) &&
            !isAlreadyClosing(snapshot.getMetadata().getUniqueName())) {
        setIsOpening(snapshot.getMetadata().getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.resolveConflict(googleApiClient, conflictId, snapshot),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            if (!result.getStatus().isSuccess()) {
                                setClosed(snapshot.getMetadata().getUniqueName());
                            }
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshot.getMetadata().getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshot.getMetadata().getUniqueName() +
                " is already open or is busy");
    }
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:28,代码来源:SnapshotCoordinator.java

示例13: open

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public PendingResult<OpenSnapshotResult> open(GoogleApiClient googleApiClient,
                                              final String filename, boolean createIfNotFound) {
    // check if the file is already open
    if (!isAlreadyOpen(filename)) {
        setIsOpening(filename);
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.open(googleApiClient, filename, createIfNotFound),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // if open failed, set the file to closed, otherwise, keep it open.
                            if (!result.getStatus().isSuccess()) {
                                Log.d(TAG, "Open was not a success: " +
                                        result.getStatus() + " for filename " + filename);
                                setClosed(filename);
                            } else {
                                Log.d(TAG, "Open successful: " + filename);
                            }
                        }
                    });
        } catch (RuntimeException e) {
            // catch runtime exceptions here - they should not happen, but they do.
            // mark the file as closed so it can be attempted to be opened again.
            setClosed(filename);
            throw e;
        }
    } else {
        // a more sophisticated solution could attach this operation to a future
        // that would be triggered by closing the file, but this will at least avoid
        // corrupting the data with non-resolvable conflicts.
        throw new IllegalStateException(filename + " is already open");
    }
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:36,代码来源:SnapshotCoordinator.java

示例14: open

import com.google.android.gms.common.api.Result; //导入依赖的package包/类
@Override
public PendingResult<OpenSnapshotResult> open(GoogleApiClient googleApiClient,
                                              final SnapshotMetadata snapshotMetadata,
                                              int conflictPolicy) {
    // check if the file is already open
    if (!isAlreadyOpen(snapshotMetadata.getUniqueName())) {
        setIsOpening(snapshotMetadata.getUniqueName());
        try {
            return new CoordinatedPendingResult<>(Games.Snapshots.open(
                    googleApiClient, snapshotMetadata, conflictPolicy),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // if open failed, set the file to closed, otherwise, keep it open.
                            if (!result.getStatus().isSuccess()) {
                                Log.d(TAG, "Open was not a success: " +
                                        result.getStatus() + " for filename " +
                                        snapshotMetadata.getUniqueName());
                                setClosed(snapshotMetadata.getUniqueName());
                            } else {
                                Log.d(TAG, "Open was successful: " +
                                        snapshotMetadata.getUniqueName());
                            }
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshotMetadata.getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshotMetadata.getUniqueName() + " is already open");
    }
}
 
开发者ID:MartensCedric,项目名称:Hexpert,代码行数:34,代码来源:SnapshotCoordinator.java


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