Skip to content

Commit a082531

Browse files
committed
Show an error message if there's an error exporting to Google Drive.
Fixes #616
1 parent bfb7718 commit a082531

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import com.dropbox.sync.android.DbxFileSystem;
4141
import com.dropbox.sync.android.DbxPath;
4242
import com.google.android.gms.common.api.GoogleApiClient;
43-
import com.google.android.gms.common.api.ResultCallback;
4443
import com.google.android.gms.drive.Drive;
4544
import com.google.android.gms.drive.DriveApi;
4645
import com.google.android.gms.drive.DriveContents;
@@ -321,6 +320,16 @@ private void moveExportToGoogleDrive(){
321320
Crashlytics.logException(e);
322321
Log.e(TAG, e.getMessage());
323322
}
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+
}
324333
}
325334

326335
private void moveExportToDropbox() {
@@ -525,4 +534,14 @@ public void moveFile(String src, String dst) throws IOException {
525534
srcFile.delete();
526535
}
527536

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+
}
528547
}

0 commit comments

Comments
 (0)