Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
only creating temp file if a thumbnail has been created
Browse files Browse the repository at this point in the history
  • Loading branch information
widmoser committed Jan 29, 2015
1 parent 89e7665 commit 85b870b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static Bitmap fromPDF(final ParcelFileDescriptor input, final Point sizeH

} catch (Exception e) {
// something went wrong:
e.printStackTrace();
return null;
} finally {
is.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ protected String getDocumentThumbnailId(final String documentId, final Point siz
protected File getDocumentThumbnailFile(final String documentId, final Point sizeHint) throws FileNotFoundException {
FileOutputStream out = null;
try {
File cacheDir = getContext().getCacheDir();
File thumbnail = File.createTempFile(getDocumentThumbnailId(documentId, sizeHint), "", cacheDir);
String mimeType = mAccessor.getMimeType(new File(documentId));
Bitmap bitmap = Thumbnail.fromFile(documentId, sizeHint, mimeType);
if (bitmap != null) {
File cacheDir = getContext().getCacheDir();
File thumbnail = File.createTempFile(getDocumentThumbnailId(documentId, sizeHint), "", cacheDir);
out = new FileOutputStream(thumbnail);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
return thumbnail;
Expand Down

0 comments on commit 85b870b

Please sign in to comment.