aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationFragment.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-25 16:24:56 +0200
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-25 16:24:56 +0200
commitbf2d0d5596a08872230056d056241ee906962171 (patch)
tree08f722037b19e7a94985360874f7de2f646b2f13 /src/eu/siacs/conversations/ui/ConversationFragment.java
parent18c183a7676e24fa3141a50f628688a0a690f259 (diff)
smoother scrolling (first step)
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationFragment.java')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index a4259f273..d42b33c4a 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -297,27 +297,38 @@ public class ConversationFragment extends Fragment {
}
});
} else {
- try {
- Bitmap thumbnail = activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288));
- viewHolder.image.setImageBitmap(thumbnail);
- viewHolder.messageBody.setVisibility(View.GONE);
- viewHolder.image.setVisibility(View.VISIBLE);
- viewHolder.image.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- Uri uri = Uri.parse("content://eu.siacs.conversations.images/"+item.getConversationUuid()+"/"+item.getUuid());
- Log.d("xmppService","staring intent with uri:"+uri.toString());
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(uri, "image/*");
- startActivity(intent);
- }
- });
- } catch (FileNotFoundException e) {
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.messageBody.setText("error loading image file");
- viewHolder.messageBody.setVisibility(View.VISIBLE);
- }
+ viewHolder.messageBody.setVisibility(View.GONE);
+ viewHolder.image.setVisibility(View.VISIBLE);
+ String[] params = item.getBody().split(",");
+ if (params.length==3) {
+ int target = (int) (metrics.density * 288);
+ int w = Integer.parseInt(params[1]);
+ int h = Integer.parseInt(params[2]);
+ int scalledW;
+ int scalledH;
+ if (w <= h) {
+ scalledW = (int) (w / ((double) h / target));
+ scalledH = target;
+ } else {
+ scalledW = target;
+ scalledH = (int) (h / ((double) w / target));
+ }
+ viewHolder.image.setLayoutParams(new LinearLayout.LayoutParams(scalledW, scalledH));
+ } else {
+ Log.d("xmppService","message body has less than 3 params");
+ }
+ activity.loadBitmap(item, viewHolder.image);
+ viewHolder.image.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Uri uri = Uri.parse("content://eu.siacs.conversations.images/"+item.getConversationUuid()+"/"+item.getUuid());
+ Log.d("xmppService","staring intent with uri:"+uri.toString());
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setDataAndType(uri, "image/*");
+ startActivity(intent);
+ }
+ });
}
} else {
viewHolder.image.setVisibility(View.GONE);
@@ -686,13 +697,6 @@ public class ConversationFragment extends Fragment {
return bm;
}
}
-
- public Bitmap getError() {
- if (error == null) {
- error = UIHelper.getErrorPicture(200);
- }
- return error;
- }
}
class DecryptMessage extends AsyncTask<Message, Void, Boolean> {