aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-25 13:46:33 +0200
committerChristian Schneppe <christian@pix-art.de>2016-08-26 19:46:43 +0200
commitb9435954f908984a30f006a4b215809702b89f32 (patch)
tree01182c0fa9ce207d25a2b07c686d67a4285fe304 /src
parent89dd22d279754cf8a04c588ff6d61bc1fed1cf38 (diff)
made image preview size smaller for low res images
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index e7e06f6d1..4efdf6701 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -506,16 +506,22 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.image.setVisibility(View.VISIBLE);
FileParams params = message.getFileParams();
double target = metrics.density * 200;
- int scalledW;
- int scalledH;
- if (params.width <= params.height) {
- scalledW = (int) (params.width / ((double) params.height / target));
- scalledH = (int) target;
+ int scaledW;
+ int scaledH;
+ if (Math.max(params.height, params.width) * metrics.density <= target) {
+ scaledW = (int) (params.width * metrics.density);
+ scaledH = (int) (params.height * metrics.density);
+ } else if (Math.max(params.height,params.width) <= target) {
+ scaledW = params.width;
+ scaledH = params.height;
+ } else if (params.width <= params.height) {
+ scaledW = (int) (params.width / ((double) params.height / target));
+ scaledH = (int) target;
} else {
- scalledW = (int) target;
- scalledH = (int) (params.height / ((double) params.width / target));
+ scaledW = (int) target;
+ scaledH = (int) (params.height / ((double) params.width / target));
}
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(scalledW, scalledH);
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(scaledW, scaledH);
layoutParams.setMargins(0, (int) (metrics.density * 4), 0, (int) (metrics.density * 4));
viewHolder.image.setLayoutParams(layoutParams);
activity.loadBitmap(message, viewHolder.image);