From c044ed3e07cf5510859577f560e63e231e256e3a Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Wed, 15 Aug 2018 20:47:36 +0200 Subject: [PATCH] fix OOM crash when trying to caption large image (#756) --- .../main/java/com/keylesspalace/tusky/ComposeActivity.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 53626477..51653724 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -64,6 +64,7 @@ import android.text.InputType; import android.text.TextUtils; import android.text.TextWatcher; import android.text.style.URLSpan; +import android.util.DisplayMetrics; import android.util.Log; import android.view.MenuItem; import android.view.View; @@ -1110,8 +1111,14 @@ public final class ComposeActivity dialogLayout.setOrientation(LinearLayout.VERTICAL); ImageView imageView = new ImageView(this); + + DisplayMetrics displayMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + Picasso.with(this) .load(item.uri) + .resize(displayMetrics.widthPixels, displayMetrics.heightPixels) + .onlyScaleDown() .into(imageView); int margin = Utils.dpToPx(this, 4);