aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-15 16:55:38 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-15 16:55:38 +0100
commit209e62d68be4cbc1514928730095c2576f2cf41a (patch)
treed1474af3d40a6ad6b159de28a17a2951d61c6253
parentf8a496a5f1e225585d0ecaec68fb81e8cffa3083 (diff)
avoid npe on weird platform bugs
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 32062699..478586b9 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -268,7 +268,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
@Override
public void onClick(View v) {
- startDonwloadable(message);
+ startDownloadable(message);
}
});
viewHolder.download_button.setOnLongClickListener(openContextMenu);
@@ -284,7 +284,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
@Override
public void onClick(View v) {
- openDonwloadable(file);
+ openDownloadable(file);
}
});
viewHolder.download_button.setOnLongClickListener(openContextMenu);
@@ -438,6 +438,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
view.setLayoutParams(view.getLayoutParams());
return view;
+ } else if (viewHolder.messageBody == null || viewHolder.image == null) {
+ return view; //avoiding weird platform bugs
} else if (type == RECEIVED) {
Contact contact = message.getContact();
if (contact != null) {
@@ -446,38 +448,36 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.contact_picture.setImageBitmap(activity.avatarService().get(getDisplayedMucCounterpart(message.getCounterpart()),
activity.getPixel(48)));
}
- } else if (type == SENT && viewHolder.contact_picture != null) {
+ } else if (type == SENT) {
viewHolder.contact_picture.setImageBitmap(activity.avatarService().get(account, activity.getPixel(48)));
}
- if (viewHolder != null && viewHolder.contact_picture != null) {
- viewHolder.contact_picture
- .setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (MessageAdapter.this.mOnContactPictureClickedListener != null) {
- MessageAdapter.this.mOnContactPictureClickedListener
- .onContactPictureClicked(message);
- }
+ viewHolder.contact_picture
+ .setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (MessageAdapter.this.mOnContactPictureClickedListener != null) {
+ MessageAdapter.this.mOnContactPictureClickedListener
+ .onContactPictureClicked(message);
}
- });
- viewHolder.contact_picture
- .setOnLongClickListener(new OnLongClickListener() {
-
- @Override
- public boolean onLongClick(View v) {
- if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
- MessageAdapter.this.mOnContactPictureLongClickedListener
- .onContactPictureLongClicked(message);
- return true;
- } else {
- return false;
- }
+
+ }
+ });
+ viewHolder.contact_picture
+ .setOnLongClickListener(new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
+ MessageAdapter.this.mOnContactPictureLongClickedListener
+ .onContactPictureLongClicked(message);
+ return true;
+ } else {
+ return false;
}
- });
- }
+ }
+ });
if (message.getDownloadable() != null && message.getDownloadable().getStatus() != Downloadable.STATUS_UPLOADING) {
Downloadable d = message.getDownloadable();
@@ -546,7 +546,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return view;
}
- public void startDonwloadable(Message message) {
+ public void startDownloadable(Message message) {
Downloadable downloadable = message.getDownloadable();
if (downloadable != null) {
if (!downloadable.start()) {
@@ -556,7 +556,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
}
- public void openDonwloadable(DownloadableFile file) {
+ public void openDownloadable(DownloadableFile file) {
if (!file.exists()) {
Toast.makeText(activity,R.string.file_deleted,Toast.LENGTH_SHORT).show();
return;