Skip to content

Commit

Permalink
Make sure Diaspora image folder exists before sharing/downloading images
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Jan 24, 2017
1 parent 392b76c commit 9f39e3c
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,17 @@ public void onClick(DialogInterface dialog, int which) {
}
}
if (writeToStoragePermitted) {
//Make sure, Diaspora Folder exists
File destinationFolder = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora");

This comment has been minimized.

Copy link
@gsantner

gsantner Jan 24, 2017

Owner

Note: Let's make a function to get this path, or sub filepaths - when we rework the image stuff

This comment has been minimized.

Copy link
@vanitasvitae

vanitasvitae Jan 25, 2017

Author Collaborator

Yep, that'd be wise

if(!destinationFolder.exists()) {
destinationFolder.mkdirs();
}

if (url != null) {
Uri source = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(source);
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"
+ System.currentTimeMillis() + ".png");
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"+ System.currentTimeMillis() + ".png");

request.setDestinationUri(Uri.fromFile(destinationFile));
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);

Expand Down Expand Up @@ -150,6 +156,12 @@ public void onClick(DialogInterface dialog, int which) {
}
}
if (writeToStoragePermitted) {
//Make sure, Diaspora Folder exists
File destinationFolder = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora");
if(!destinationFolder.exists()) {
destinationFolder.mkdirs();
}

final Uri local = Uri.parse(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/" + System.currentTimeMillis() + ".png");
new ImageDownloadTask(null, local.getPath()) {
@Override
Expand Down

0 comments on commit 9f39e3c

Please sign in to comment.