From 209e62d68be4cbc1514928730095c2576f2cf41a Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Mon, 15 Dec 2014 16:55:38 +0100 Subject: avoid npe on weird platform bugs --- .../conversations/ui/adapter/MessageAdapter.java | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src/main/java') 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 { @Override public void onClick(View v) { - startDonwloadable(message); + startDownloadable(message); } }); viewHolder.download_button.setOnLongClickListener(openContextMenu); @@ -284,7 +284,7 @@ public class MessageAdapter extends ArrayAdapter { @Override public void onClick(View v) { - openDonwloadable(file); + openDownloadable(file); } }); viewHolder.download_button.setOnLongClickListener(openContextMenu); @@ -438,6 +438,8 @@ public class MessageAdapter extends ArrayAdapter { } 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 { 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 { 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 { } } - 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; -- cgit v1.2.3