Skip to content

Commit ebf2738

Browse files
committed
Extract code to report success to the user into a new method
1 parent 9d04947 commit ebf2738

1 file changed

Lines changed: 34 additions & 30 deletions

File tree

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

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -187,36 +187,7 @@ protected void onPostExecute(Boolean exportResult) {
187187
Toast.LENGTH_LONG).show();
188188
return;
189189
} else {
190-
String targetLocation;
191-
switch (mExportParams.getExportTarget()){
192-
case SD_CARD:
193-
targetLocation = "SD card";
194-
break;
195-
case DROPBOX:
196-
targetLocation = "DropBox -> Apps -> GnuCash";
197-
break;
198-
case GOOGLE_DRIVE:
199-
targetLocation = "Google Drive -> " + mContext.getString(R.string.app_name);
200-
break;
201-
case OWNCLOUD:
202-
targetLocation = mContext.getSharedPreferences(
203-
mContext.getString(R.string.owncloud_pref),
204-
Context.MODE_PRIVATE).getBoolean(
205-
mContext.getString(R.string.owncloud_sync), false) ?
206-
207-
"ownCloud -> " +
208-
mContext.getSharedPreferences(
209-
mContext.getString(R.string.owncloud_pref),
210-
Context.MODE_PRIVATE).getString(
211-
mContext.getString(R.string.key_owncloud_dir), null) :
212-
"ownCloud sync not enabled";
213-
break;
214-
default:
215-
targetLocation = mContext.getString(R.string.label_export_target_external_service);
216-
}
217-
Toast.makeText(mContext,
218-
String.format(mContext.getString(R.string.toast_exported_to), targetLocation),
219-
Toast.LENGTH_LONG).show();
190+
reportSuccess();
220191
}
221192
}
222193

@@ -532,4 +503,37 @@ public void moveFile(String src, String dst) throws IOException {
532503
}
533504
srcFile.delete();
534505
}
506+
507+
private void reportSuccess() {
508+
String targetLocation;
509+
switch (mExportParams.getExportTarget()){
510+
case SD_CARD:
511+
targetLocation = "SD card";
512+
break;
513+
case DROPBOX:
514+
targetLocation = "DropBox -> Apps -> GnuCash";
515+
break;
516+
case GOOGLE_DRIVE:
517+
targetLocation = "Google Drive -> " + mContext.getString(R.string.app_name);
518+
break;
519+
case OWNCLOUD:
520+
targetLocation = mContext.getSharedPreferences(
521+
mContext.getString(R.string.owncloud_pref),
522+
Context.MODE_PRIVATE).getBoolean(
523+
mContext.getString(R.string.owncloud_sync), false) ?
524+
525+
"ownCloud -> " +
526+
mContext.getSharedPreferences(
527+
mContext.getString(R.string.owncloud_pref),
528+
Context.MODE_PRIVATE).getString(
529+
mContext.getString(R.string.key_owncloud_dir), null) :
530+
"ownCloud sync not enabled";
531+
break;
532+
default:
533+
targetLocation = mContext.getString(R.string.label_export_target_external_service);
534+
}
535+
Toast.makeText(mContext,
536+
String.format(mContext.getString(R.string.toast_exported_to), targetLocation),
537+
Toast.LENGTH_LONG).show();
538+
}
535539
}

0 commit comments

Comments
 (0)