com.google.android.gms.drive.events.CompletionEvent Java Examples

The following examples show how to use com.google.android.gms.drive.events.CompletionEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConflictResolver.java    From android-samples with Apache License 2.0 5 votes vote down vote up
ConflictResolver(CompletionEvent conflictedCompletionEvent, Context context,
        ExecutorService executorService) {
    this.mConflictedCompletionEvent = conflictedCompletionEvent;
    mBroadcaster = LocalBroadcastManager.getInstance(context);
    mContext = context;
    mExecutorService = executorService;
}
 
Example #2
Source File: MyDriveEventService.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@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();
    }
}