Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed extraneous return
Added try-with-resources for getMediaStoreInfo()
  • Loading branch information
AEFeinstein committed Jan 22, 2020
1 parent f9c72b5 commit c1b4e73
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ public void saveImageWithGlide(int whereTo) {
// Or display the path where it's saved
SnackbarWrapper.makeAndShowText(getActivity(), getString(R.string.card_view_image_saved) + msi.getFilePath(), SnackbarWrapper.LENGTH_LONG);
}
return;
} else {
runGlideTarget(new FamiliarGlideTarget(this, new FamiliarGlideTarget.DrawableLoadedCallback() {
/**
Expand Down Expand Up @@ -727,15 +726,13 @@ long getId() {
* @return The file path and ID for this card's image in the MediaStore, or null
*/
@javax.annotation.Nullable
MediaStoreInfo getMediaStoreInfo() {
Cursor mCursor = null;
try {
mCursor = getContext().getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID},
MediaStore.Images.Media.DISPLAY_NAME + " = ?",
new String[]{getSavedFileName()},
MediaStore.Images.Media.DEFAULT_SORT_ORDER);
private MediaStoreInfo getMediaStoreInfo() {
try (Cursor mCursor = getContext().getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID},
MediaStore.Images.Media.DISPLAY_NAME + " = ?",
new String[]{getSavedFileName()},
MediaStore.Images.Media.DEFAULT_SORT_ORDER)) {
if (mCursor.getCount() > 0) {
mCursor.moveToFirst();
return new MediaStoreInfo(
Expand All @@ -744,10 +741,6 @@ MediaStoreInfo getMediaStoreInfo() {
}
} catch (Exception e) {
// eat it
} finally {
if (null != mCursor) {
mCursor.close();
}
}
return null;
}
Expand Down

0 comments on commit c1b4e73

Please sign in to comment.