com.google.android.gms.drive.OpenFileActivityBuilder Java Examples

The following examples show how to use com.google.android.gms.drive.OpenFileActivityBuilder. 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: TheHubActivity.java    From ToDay with MIT License 6 votes vote down vote up
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case AppConstants.EXPORT_RESOLVE_CONNECTION_REQUEST_CODE:
                if (resultCode == RESULT_OK) {
//                    mGoogleApiClient.connect();
                }
                break;
            case AppConstants.EXPORT_CREATOR_REQUEST_CODE:
                if (resultCode == RESULT_OK) {
                    DriveId driveFileId = (DriveId) data.getParcelableExtra(
                            OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
                    writeDataExportToFile(driveFileId);
                }
                break;
            default:
                super.onActivityResult(requestCode, resultCode, data);
                break;
        }
    }
 
Example #2
Source File: CloudletDemoActivity.java    From faceswap with Apache License 2.0 4 votes vote down vote up
/**
 * file picker activie result
 * @param requestCode
 * @param resultCode
 * @param data
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case FilePickerActivity.REQUEST_FILE:
            if (resultCode==RESULT_OK){
                Bundle extras = data.getExtras();
                String path = (String) extras.get(FilePickerActivity.FILE_EXTRA_DATA_PATH);
                Log.d(TAG, "path: " + path);
                boolean isLoad=(boolean)extras.get(FilePickerActivity.INTENT_EXTRA_ACTION_READ);
                File file=new File(path);
                if (isLoad){
                    byte[] stateData= UIUtils.loadFromFile(file);
                    if (stateData!=null){
                        actionUploadStateByteArray(stateData);
                    } else {
                        Toast.makeText(this, "Invalid File",Toast.LENGTH_SHORT).show();
                    }
                } else {
                    if (this.asyncResponseExtra!=null){
                        UIUtils.saveToFile(file, this.asyncResponseExtra);
                    }
                }
            }
            break;
        case GDRIVE_RESOLVE_CONNECTION_REQUEST_CODE:
            if (resultCode == RESULT_OK) {
                Log.i(TAG, "drive client problem resolved. Trying to connect");
                mGoogleApiClient.connect();
            } else {
                //if not okay, then give up
                pendingGDriveAction=-1;
                Log.i(TAG, "drive connection resolution failed");
                Toast.makeText(this,"Failed to Connect Google Drive", Toast.LENGTH_LONG).show();
            }
            break;
        case GDRIVE_REQUEST_CODE_OPENER:
            if (resultCode == RESULT_OK) {
                DriveId fileId = (DriveId) data.getParcelableExtra(
                        OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
                Log.i(TAG, "user select drive file id: "+fileId);
                openDriveFile(fileId);
            }
            break;
        case GDRIVE_REQUEST_CODE_CREATOR:
            // Called after a file is saved to Drive.
            if (resultCode == RESULT_OK) {
                Log.i(TAG, "Image successfully saved.");
                Toast.makeText(this,
                        "succesfully saved to google drive", Toast.LENGTH_SHORT).show();
            }
            break;
    }
}