remove pointless Bitmap allocation for ImageSlides

Fixes #2248
// FREEBIE
This commit is contained in:
Jake McGinty 2014-12-22 16:25:51 -08:00
parent 25028b7178
commit ebf6a2d833
3 changed files with 6 additions and 8 deletions

View File

@ -826,7 +826,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private void addAttachmentImage(Uri imageUri) { private void addAttachmentImage(Uri imageUri) {
try { try {
attachmentManager.setImage(masterSecret, imageUri); attachmentManager.setImage(imageUri);
} catch (IOException | BitmapDecodingException e) { } catch (IOException | BitmapDecodingException e) {
Log.w(TAG, e); Log.w(TAG, e);
attachmentManager.clear(); attachmentManager.clear();

View File

@ -64,8 +64,8 @@ public class AttachmentManager {
attachmentListener.onAttachmentChanged(); attachmentListener.onAttachmentChanged();
} }
public void setImage(MasterSecret masterSecret, Uri image) throws IOException, BitmapDecodingException { public void setImage(Uri image) throws IOException, BitmapDecodingException {
setMedia(new ImageSlide(context, masterSecret, image), 345, 261); setMedia(new ImageSlide(context, image), 345, 261);
} }
public void setVideo(Uri video) throws IOException, MediaTooLargeException { public void setVideo(Uri video) throws IOException, MediaTooLargeException {

View File

@ -62,8 +62,8 @@ public class ImageSlide extends Slide {
super(context, masterSecret, part); super(context, masterSecret, part);
} }
public ImageSlide(Context context, MasterSecret masterSecret, Uri uri) throws IOException, BitmapDecodingException { public ImageSlide(Context context, Uri uri) throws IOException, BitmapDecodingException {
super(context, constructPartFromUri(context, masterSecret, uri)); super(context, constructPartFromUri(uri));
} }
@Override @Override
@ -190,13 +190,11 @@ public class ImageSlide extends Slide {
return SmilUtil.createMediaElement("img", document, new String(getPart().getName())); return SmilUtil.createMediaElement("img", document, new String(getPart().getName()));
} }
private static PduPart constructPartFromUri(Context context, MasterSecret masterSecret, Uri uri) private static PduPart constructPartFromUri(Uri uri)
throws IOException, BitmapDecodingException throws IOException, BitmapDecodingException
{ {
PduPart part = new PduPart(); PduPart part = new PduPart();
byte[] data = BitmapUtil.createScaledBytes(context, masterSecret, uri, 1280, 1280, MAX_MESSAGE_SIZE);
part.setData(data);
part.setDataUri(uri); part.setDataUri(uri);
part.setContentType(ContentType.IMAGE_JPEG.getBytes()); part.setContentType(ContentType.IMAGE_JPEG.getBytes());
part.setContentId((System.currentTimeMillis()+"").getBytes()); part.setContentId((System.currentTimeMillis()+"").getBytes());