@Override protected Boolean doInBackground(Void... args) { FeedbackAttachment attachment = downloadJob.getFeedbackAttachment(); if (attachment.isAvailableInCache()) { HockeyLog.error("Cached..."); loadImageThumbnail(); return true; } else { HockeyLog.error("Downloading..."); boolean success = downloadAttachment(attachment.getUrl(), attachment.getCacheId()); if (success) { loadImageThumbnail(); } return success; } }
private void loadImageThumbnail() { try { String filename = downloadJob.getFeedbackAttachment().getCacheId(); AttachmentView attachmentView = downloadJob.getAttachmentView(); bitmapOrientation = ImageUtils.determineOrientation(new File(dropFolder, filename)); int width = bitmapOrientation == ImageUtils.ORIENTATION_LANDSCAPE ? attachmentView.getWidthLandscape() : attachmentView.getWidthPortrait(); int height = bitmapOrientation == ImageUtils.ORIENTATION_LANDSCAPE ? attachmentView.getMaxHeightLandscape() : attachmentView.getMaxHeightPortrait(); bitmap = ImageUtils.decodeSampledBitmap(new File(dropFolder, filename), width, height); } catch (IOException e) { e.printStackTrace(); bitmap = null; } }