|
40 | 40 | import com.dropbox.sync.android.DbxFileSystem; |
41 | 41 | import com.dropbox.sync.android.DbxPath; |
42 | 42 | import com.google.android.gms.common.api.GoogleApiClient; |
43 | | -import com.google.android.gms.common.api.ResultCallback; |
44 | 43 | import com.google.android.gms.drive.Drive; |
45 | 44 | import com.google.android.gms.drive.DriveApi; |
46 | 45 | import com.google.android.gms.drive.DriveContents; |
@@ -321,6 +320,16 @@ private void moveExportToGoogleDrive(){ |
321 | 320 | Crashlytics.logException(e); |
322 | 321 | Log.e(TAG, e.getMessage()); |
323 | 322 | } |
| 323 | + |
| 324 | + if (driveFileResult == null) |
| 325 | + return; |
| 326 | + |
| 327 | + if (!driveFileResult.getStatus().isSuccess()) { |
| 328 | + Log.e(TAG, "Error creating file in Google Drive"); |
| 329 | + showToastFromNonUiThread("Couldn't create the file in Google Drive", Toast.LENGTH_LONG); |
| 330 | + } else { |
| 331 | + Log.i(TAG, "Created file with id: " + driveFileResult.getDriveFile().getDriveId()); |
| 332 | + } |
324 | 333 | } |
325 | 334 |
|
326 | 335 | private void moveExportToDropbox() { |
@@ -525,4 +534,14 @@ public void moveFile(String src, String dst) throws IOException { |
525 | 534 | srcFile.delete(); |
526 | 535 | } |
527 | 536 |
|
| 537 | + private void showToastFromNonUiThread(final String message, final int duration) { |
| 538 | + if (mContext instanceof Activity) { |
| 539 | + ((Activity) mContext).runOnUiThread(new Runnable() { |
| 540 | + @Override |
| 541 | + public void run() { |
| 542 | + Toast.makeText(mContext, message, duration).show(); |
| 543 | + } |
| 544 | + }); |
| 545 | + } |
| 546 | + } |
528 | 547 | } |
0 commit comments