Skip to content

Commit 5628768

Browse files
committed
Graceful fail when couldn't save an image #4
1 parent 4459bef commit 5628768

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main/java/com/valleydevfest/androidify/PlaceholderFragment.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,14 @@ private void share() {
176176
requireActivity().getContentResolver(), bitmap,
177177
getResources().getString(R.string.android_avatar), null
178178
);
179-
Uri imageURI = Uri.parse(imagePath);
180-
startShareActivity(imageURI);
179+
if (imagePath == null) {
180+
Toast.makeText(getActivity(),
181+
getResources().getString(R.string.could_not_save),
182+
Toast.LENGTH_SHORT).show();
183+
} else {
184+
Uri imageURI = Uri.parse(imagePath);
185+
startShareActivity(imageURI);
186+
}
181187
}
182188

183189
private void startShareActivity(Uri imageURI) {

src/main/res/values/strings.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<string name="figure_saved">Figure Saved!</string>
1010
<string name="submit">Submit to website</string>
1111
<string name="back_to_website">Visit website</string>
12-
<string name="no_browser">Could not open browser</string>
12+
<string name="no_browser">So sorry, could not open browser</string>
1313
<string name="share">Save / Share</string>
14+
<string name="could_not_save">So sorry, could not save image</string>
1415
<string name="android_avatar">Android Avatar</string>
1516

1617
</resources>

0 commit comments

Comments
 (0)