本文整理汇总了Java中com.google.android.gms.games.snapshot.SnapshotMetadata.getUniqueName方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotMetadata.getUniqueName方法的具体用法?Java SnapshotMetadata.getUniqueName怎么用?Java SnapshotMetadata.getUniqueName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.games.snapshot.SnapshotMetadata
的用法示例。
在下文中一共展示了SnapshotMetadata.getUniqueName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的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");
}
}
示例2: displaySnapshotMetadata
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的package包/类
/**
* Display metadata about Snapshot save data.
* @param metadata the SnapshotMetadata associated with the saved game.
*/
private void displaySnapshotMetadata(SnapshotMetadata metadata) {
TextView metaDataView = (TextView) findViewById(R.id.text_metadata);
if (metadata == null) {
metaDataView.setText("");
return;
}
String metadataStr = "Source: Saved Games" + '\n'
+ "Description: " + metadata.getDescription() + '\n'
+ "Name: " + metadata.getUniqueName() + '\n'
+ "Last Modified: " + String.valueOf(metadata.getLastModifiedTimestamp()) + '\n'
+ "Played Time: " + String.valueOf(metadata.getPlayedTime()) + '\n'
+ "Cover Image URL: " + metadata.getCoverImageUrl();
metaDataView.setText(metadataStr);
}
示例3: open
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的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");
}
}
示例4: open
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的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");
}
}
示例5: open
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的package包/类
public Task<SnapshotsClient.DataOrConflict<Snapshot>> open(final SnapshotsClient snapshotsClient,
final SnapshotMetadata snapshotMetadata) {
final String filename = snapshotMetadata.getUniqueName();
return setIsOpeningTask(filename).continueWithTask(new Continuation<Void, Task<SnapshotsClient.DataOrConflict<Snapshot>>>() {
@Override
public Task<SnapshotsClient.DataOrConflict<Snapshot>> then(@NonNull Task<Void> task) throws Exception {
return snapshotsClient.open(snapshotMetadata)
.addOnCompleteListener(createOpenListener(filename));
}
});
}
示例6: resolveSnapshotConflict
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的package包/类
/**
* Handles resolving the snapshot conflict asynchronously.
*
* @param requestCode - the request currently being processed. This is used to forward on the
* information to another activity, or to send the result intent.
* @param conflictId - the id of the conflict being resolved.
* @param retryCount - the current iteration of the retry. The first retry should be 0.
* @param snapshotMetadata - the metadata of the snapshot that is selected to resolve the conflict.
*/
private void resolveSnapshotConflict(final int requestCode, final String conflictId,
final int retryCount,
final SnapshotMetadata snapshotMetadata) {
Log.i(TAG,"Resolving conflict retry count = " + retryCount + " conflictid = " + conflictId);
AsyncTask<Void, Void, Snapshots.OpenSnapshotResult> task =
new AsyncTask<Void, Void, Snapshots.OpenSnapshotResult>() {
@Override
protected Snapshots.OpenSnapshotResult doInBackground(Void... voids) {
Snapshots.OpenSnapshotResult result;
if (snapshotMetadata.getUniqueName() != null) {
Log.d(TAG,"Opening unique name " + snapshotMetadata.getUniqueName());
result = Games.Snapshots.open(mGoogleApiClient, snapshotMetadata)
.await();
}
else {
Log.d(TAG,"Opening current save name " + currentSaveName);
result = Games.Snapshots.open(mGoogleApiClient, currentSaveName, true)
.await();
}
Log.d(TAG,"opening from metadata - result is " + result.getStatus() +
" snapshot is " + result.getSnapshot());
return Games.Snapshots
.resolveConflict(mGoogleApiClient, conflictId, result.getSnapshot())
.await();
}
@Override
protected void onPostExecute(Snapshots.OpenSnapshotResult openSnapshotResult) {
Snapshot snapshot = processSnapshotOpenResult(requestCode,
openSnapshotResult,
retryCount);
Log.d(TAG,"resolved snapshot conflict - snapshot is " + snapshot);
// if there is a snapshot returned, then pass it along to onActivityResult.
// otherwise, another activity will be used to resolve the conflict so we
// don't need to do anything here.
if (snapshot != null) {
Intent intent = new Intent("");
intent.putExtra(SelectSnapshotActivity.SNAPSHOT_METADATA,
snapshot.getMetadata().freeze());
onActivityResult(requestCode, RESULT_OK, intent);
}
}
};
task.execute();
}
示例7: onActivityResult
import com.google.android.gms.games.snapshot.SnapshotMetadata; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
dismissProgressDialog();
if (requestCode == RC_SIGN_IN) {
Log.d(TAG, "onActivityResult: RC_SIGN_IN, resultCode = " + resultCode);
mSignInClicked = false;
mIsResolving = false;
if (resultCode == RESULT_OK) {
// Sign-in was successful, connect the API Client
Log.d(TAG, "onActivityResult: RC_SIGN_IN (OK)");
mGoogleApiClient.connect();
} else {
// There was an error during sign-in, display a Dialog with the appropriate message
// to the user.
Log.d(TAG, "onActivityResult: RC_SIGN_IN (Error)");
BaseGameUtils.showActivityResultError(this, requestCode, resultCode, R.string.signin_other_error);
}
} else if (requestCode == RC_SELECT_SNAPSHOT) {
Log.d(TAG, "onActivityResult: RC_SELECT_SNAPSHOT, resultCode = " + resultCode);
if (resultCode == RESULT_OK) {
// Successfully returned from Snapshot selection UI
if (data != null) {
Bundle bundle = data.getExtras();
SnapshotMetadata selected = Games.Snapshots.getSnapshotFromBundle(bundle);
if (selected == null) {
// No snapshot in the Intent bundle, display error message
displayMessage(getString(R.string.saved_games_select_failure), true);
setData(null);
displaySnapshotMetadata(null);
} else {
// Found Snapshot Metadata in Intent bundle. Load Snapshot by name.
String snapshotName = selected.getUniqueName();
savedGamesLoad(snapshotName);
}
}
} else {
// User canceled the select intent or it failed for some other reason
displayMessage(getString(R.string.saved_games_select_cancel), true);
setData(null);
displaySnapshotMetadata(null);
}
}
}