aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/ui/ConversationFragment.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-19 08:21:33 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-19 08:21:33 +0100
commit94ab61d5c0b060e2aea5caf58ac06864f980956b (patch)
tree2b2aa490845a07a00ef206385bcf66df453fe3f6 /src/de/gultsch/chat/ui/ConversationFragment.java
parent746f9591553a5373e8ce1211ed066cbbf6a31cb5 (diff)
more speed optimizations
Diffstat (limited to 'src/de/gultsch/chat/ui/ConversationFragment.java')
-rw-r--r--src/de/gultsch/chat/ui/ConversationFragment.java54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java
index 8be44f49..0d2116e6 100644
--- a/src/de/gultsch/chat/ui/ConversationFragment.java
+++ b/src/de/gultsch/chat/ui/ConversationFragment.java
@@ -157,18 +157,14 @@ public class ConversationFragment extends Fragment {
int type = getItemViewType(position);
ViewHolder viewHolder;
if (view == null) {
+ viewHolder = new ViewHolder();
switch (type) {
case SENT:
- viewHolder = new ViewHolder();
view = (View) inflater.inflate(R.layout.message_sent,
null);
viewHolder.imageView = (ImageView) view
.findViewById(R.id.message_photo);
- viewHolder.messageBody = (TextView) view
- .findViewById(R.id.message_body);
- viewHolder.time = (TextView) view
- .findViewById(R.id.message_time);
- view.setTag(viewHolder);
+ viewHolder.imageView.setImageBitmap(selfBitmap);
break;
case RECIEVED:
viewHolder = new ViewHolder();
@@ -176,36 +172,43 @@ public class ConversationFragment extends Fragment {
R.layout.message_recieved, null);
viewHolder.imageView = (ImageView) view
.findViewById(R.id.message_photo);
- viewHolder.messageBody = (TextView) view
- .findViewById(R.id.message_body);
- viewHolder.time = (TextView) view
- .findViewById(R.id.message_time);
- view.setTag(viewHolder);
+ if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
+ Uri uri = item.getConversation().getProfilePhotoUri();
+ if (uri != null) {
+ viewHolder.imageView
+ .setImageBitmap(mBitmapCache.get(item
+ .getConversation().getName(), uri));
+ } else {
+ viewHolder.imageView
+ .setImageBitmap(mBitmapCache.get(item
+ .getConversation().getName(), null));
+ }
+ }
break;
default:
viewHolder = null;
break;
}
+ viewHolder.messageBody = (TextView) view
+ .findViewById(R.id.message_body);
+ viewHolder.time = (TextView) view
+ .findViewById(R.id.message_time);
+
+ view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
if (type == RECIEVED) {
- if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
- Uri uri = item.getConversation().getProfilePhotoUri();
- if (uri != null) {
- viewHolder.imageView.setImageBitmap(mBitmapCache.get(item.getConversation().getName(), uri));
- } else {
- viewHolder.imageView.setImageBitmap(mBitmapCache.get(item.getConversation().getName(),null));
- }
- } else if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
+ if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
if (item.getCounterpart() != null) {
- viewHolder.imageView.setImageBitmap(mBitmapCache.get(item.getCounterpart(),null));
+ viewHolder.imageView.setImageBitmap(mBitmapCache
+ .get(item.getCounterpart(), null));
} else {
- viewHolder.imageView.setImageBitmap(mBitmapCache.get(item.getConversation().getName(),null));
+ viewHolder.imageView
+ .setImageBitmap(mBitmapCache.get(item
+ .getConversation().getName(), null));
}
}
- } else {
- viewHolder.imageView.setImageBitmap(selfBitmap);
}
String body = item.getBody();
if (body != null) {
@@ -406,15 +409,16 @@ public class ConversationFragment extends Fragment {
protected ImageView imageView;
}
-
+
private class BitmapCache {
private HashMap<String, Bitmap> bitmaps = new HashMap<String, Bitmap>();
+
public Bitmap get(String name, Uri uri) {
if (bitmaps.containsKey(name)) {
return bitmaps.get(name);
} else {
Bitmap bm;
- if (uri!=null) {
+ if (uri != null) {
try {
bm = BitmapFactory.decodeStream(getActivity()
.getContentResolver().openInputStream(uri));