本文整理汇总了Java中com.google.android.gms.drive.events.CompletionEvent.STATUS_SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java CompletionEvent.STATUS_SUCCESS属性的具体用法?Java CompletionEvent.STATUS_SUCCESS怎么用?Java CompletionEvent.STATUS_SUCCESS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.gms.drive.events.CompletionEvent
的用法示例。
在下文中一共展示了CompletionEvent.STATUS_SUCCESS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCompletion
@Override
public void onCompletion(CompletionEvent event) {
boolean eventHandled = false;
switch (event.getStatus()) {
case CompletionEvent.STATUS_SUCCESS:
// Commit completed successfully.
// Can now access the remote resource Id
// [START_EXCLUDE]
String resourceId = event.getDriveId().getResourceId();
Log.d(TAG, "Remote resource ID: " + resourceId);
eventHandled = true;
// [END_EXCLUDE]
break;
case CompletionEvent.STATUS_FAILURE:
// Handle failure....
// Modified contents and metadata failed to be applied to the server.
// They can be retrieved from the CompletionEvent to try to be applied later.
// [START_EXCLUDE]
// CompletionEvent is only dismissed here. In a real world application failure
// should be handled before the event is dismissed.
eventHandled = true;
// [END_EXCLUDE]
break;
case CompletionEvent.STATUS_CONFLICT:
// Handle completion conflict.
// [START_EXCLUDE]
ConflictResolver conflictResolver =
new ConflictResolver(event, this, mExecutorService);
conflictResolver.resolve();
eventHandled = false; // Resolver will snooze or dismiss
// [END_EXCLUDE]
break;
}
if (eventHandled) {
event.dismiss();
}
}
示例2: onCompletion
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public void onCompletion(CompletionEvent event) {
Log.i(TAG, "Received completion event from Drive.");
if(event.getStatus() == CompletionEvent.STATUS_SUCCESS) {
final MetadataChangeSet metadata = event.getModifiedMetadataChangeSet();
final String hash = metadata.getCustomPropertyChangeMap().get(sHashKey);
Log.i(TAG, "Photo hash: " + hash);
if(hash != null) {
final ContentResolver cr = getContentResolver();
final String[] projection = new String[] {
Tables.Photos._ID,
Tables.Photos.ENTRY
};
final String where = Tables.Photos.HASH + " = ?";
final String[] whereArgs = new String[] {hash};
final Cursor cursor =
cr.query(Tables.Photos.CONTENT_URI, projection, where, whereArgs, null);
if(cursor != null) {
try {
if(cursor.moveToFirst()) {
final long id =
cursor.getLong(cursor.getColumnIndex(Tables.Photos._ID));
final long entryId =
cursor.getLong(cursor.getColumnIndex(Tables.Photos.ENTRY));
final ContentValues values = new ContentValues();
values.put(Tables.Photos.DRIVE_ID, event.getDriveId().getResourceId());
cr.update(ContentUris.withAppendedId(Tables.Photos.CONTENT_ID_URI_BASE,
id), values, null, null);
EntryUtils.markChanged(cr, entryId);
BackendUtils.requestDataSync(this);
}
} finally {
cursor.close();
}
}
}
}
event.dismiss();
}