From 8f62d95e1fb5980daab5294148106ce09237e386 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Wed, 3 Dec 2014 10:45:47 +0100 Subject: [PATCH] further npe checks --- .../siacs/conversations/entities/Bookmark.java | 3 ++- .../ui/adapter/ListItemAdapter.java | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java index 91dc25beb..559e2f2dd 100644 --- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java +++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java @@ -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); } diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java index 250a69c3a..0865d1aaf 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java @@ -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 { 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 { 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;