本文整理汇总了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;
}
};
}
示例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);
}
});
}
示例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");
}
}
示例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;
}
};
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
}
示例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();
}
示例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);
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}