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


Java SnapshotContents类代码示例

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


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

示例1: processOpenSnapshotResult

import com.google.android.gms.games.snapshot.SnapshotContents; //导入依赖的package包/类
private void processOpenSnapshotResult(OpenSnapshotResult result, final UserData userData, IConflictResolver resolver) {
    final Snapshot snapshot = result.getSnapshot();
    if (result.getStatus().isSuccess()) {
        final SnapshotContents contents = snapshot.getSnapshotContents();
        final Map server = fromBytes(contents);
        if (server != null && server.containsKey("uuid") && !server.get("uuid").equals(userData.uuid())) {
            performUserResolve(server, resolver, new IConflictResolverCallback() {
                @Override public void onResolved(boolean useLocal) {
                    contents.writeBytes(useLocal ? toBytes(userData) : toBytes(server));
                    Games.Snapshots.commitAndClose(client, snapshot, EMPTY_CHANGE);
                }
            });
        } else {
            contents.writeBytes(toBytes(userData));
            Games.Snapshots.commitAndClose(client, snapshot, EMPTY_CHANGE);
        }
    } else if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_SNAPSHOT_CONFLICT) {
        Snapshot conflictingSnapshot = result.getConflictingSnapshot();
        startResolving(userData, conflictingSnapshot, result.getConflictId(), resolver);
    }
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:22,代码来源:GoogleCloudSave.java

示例2: startResolving

import com.google.android.gms.games.snapshot.SnapshotContents; //导入依赖的package包/类
private void startResolving(final UserData userData, final Snapshot conflictingSnapshot, final String conflictId, final IConflictResolver resolver) {
    final SnapshotContents contents = conflictingSnapshot.getSnapshotContents();
    final Map server = fromBytes(contents);
    if (server == null) {
        contents.writeBytes(toBytes(userData));
        Games.Snapshots.resolveConflict(client, conflictId, SNAPSHOT_ID, EMPTY_CHANGE, contents);
        return;
    }
    performUserResolve(server, resolver, new IConflictResolverCallback() {
        @SuppressWarnings("unchecked")
        @Override public void onResolved(boolean useLocal) {
            contents.writeBytes(useLocal ? toBytes(userData) : toBytes(server));
            Games.Snapshots
                .resolveConflict(client, conflictId, SNAPSHOT_ID, EMPTY_CHANGE, contents)
                .setResultCallback(new ResultCallback<OpenSnapshotResult>() {
                    @Override public void onResult(OpenSnapshotResult result) {
                        if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_SNAPSHOT_CONFLICT) {
                            startResolving(userData, result.getConflictingSnapshot(), result.getConflictId(), resolver);
                        }
                    }
                });
        }
    });
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:25,代码来源:GoogleCloudSave.java

示例3: writeToSnapshot

import com.google.android.gms.games.snapshot.SnapshotContents; //导入依赖的package包/类
private void writeToSnapshot(String snapshotId, byte[] content) {
	Log.i("Play Games", "Streaming to " + snapshotId);
	PendingResult<Snapshots.OpenSnapshotResult> result = Games.Snapshots.open(googleApiClient, snapshotId, true, Snapshots.RESOLUTION_POLICY_MOST_RECENTLY_MODIFIED);

	Snapshots.OpenSnapshotResult openResult = result.await(5, TimeUnit.SECONDS);
	Snapshot snapshot = openResult.getSnapshot();

	if (openResult.getStatus().isSuccess() && snapshot != null) {
		SnapshotContents contents = snapshot.getSnapshotContents();
		contents.writeBytes(content);

		PendingResult<Snapshots.CommitSnapshotResult> pendingResult = Games.Snapshots.commitAndClose(googleApiClient, snapshot, SnapshotMetadataChange.EMPTY_CHANGE);
		pendingResult.setResultCallback(new ResultCallback<Snapshots.CommitSnapshotResult>() {
			@Override
			public void onResult(@NonNull Snapshots.CommitSnapshotResult commitSnapshotResult) {
				if (commitSnapshotResult.getStatus().isSuccess()) {
					Log.i("Play Games", "commit ok");
				} else {
					EventCollector.logEvent("Play Games", "commit" + commitSnapshotResult.getStatus().getStatusMessage());
				}
			}
		});
	}
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:25,代码来源:PlayGames.java

示例4: resolveConflict

import com.google.android.gms.games.snapshot.SnapshotContents; //导入依赖的package包/类
@Override
public PendingResult<OpenSnapshotResult> resolveConflict(GoogleApiClient googleApiClient,
                                                         String conflictId, String snapshotId,
                                                         SnapshotMetadataChange snapshotMetadataChange,
                                                         SnapshotContents snapshotContents) {

    // Since the unique name of the snapshot is unknown, this resolution method cannot be safely
    // used.  Please use another method of resolution.
    throw new IllegalStateException("resolving conflicts with ids is not supported.");
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:11,代码来源:SnapshotCoordinator.java

示例5: resolveConflict

import com.google.android.gms.games.snapshot.SnapshotContents; //导入依赖的package包/类
public Task<SnapshotsClient.DataOrConflict<Snapshot>> resolveConflict(SnapshotsClient snapshotsClient,
                                                                      String conflictId, String snapshotId,
                                                                      SnapshotMetadataChange snapshotMetadataChange,
                                                                      SnapshotContents snapshotContents) {
  // Since the unique name of the snapshot is unknown, this resolution method cannot be safely
  // used.  Please use another method of resolution.
  throw new IllegalStateException("resolving conflicts with ids is not supported.");
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:9,代码来源:SnapshotCoordinator.java


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