further npe checks

This commit is contained in:
iNPUTmice 2014-12-03 10:45:47 +01:00
parent aaeba697bd
commit 8f62d95e1f
2 changed files with 13 additions and 6 deletions

View File

@ -128,7 +128,8 @@ public class Bookmark extends Element implements ListItem {
return true;
}
needle = needle.toLowerCase(Locale.US);
return getJid().toString().contains(needle) ||
final Jid jid = getJid();
return (jid != null && jid.toString().contains(needle)) ||
getDisplayName().toLowerCase(Locale.US).contains(needle) ||
matchInTag(needle);
}

View File

@ -5,6 +5,8 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.xmpp.jid.Jid;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@ -36,8 +38,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
if (view == null) {
view = inflater.inflate(R.layout.contact, parent, false);
}
TextView name = (TextView) view.findViewById(R.id.contact_display_name);
TextView jid = (TextView) view.findViewById(R.id.contact_jid);
TextView tvName = (TextView) view.findViewById(R.id.contact_display_name);
TextView tvJid = (TextView) view.findViewById(R.id.contact_jid);
ImageView picture = (ImageView) view.findViewById(R.id.contact_photo);
LinearLayout tagLayout = (LinearLayout) view.findViewById(R.id.tags);
@ -54,9 +56,13 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
tagLayout.addView(tv);
}
}
jid.setText(item.getJid().toString());
name.setText(item.getDisplayName());
final Jid jid = item.getJid();
if (jid != null) {
tvJid.setText(jid.toString());
} else {
tvJid.setText("");
}
tvName.setText(item.getDisplayName());
picture.setImageBitmap(activity.avatarService().get(item,
activity.getPixel(48)));
return view;