diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-12-03 10:45:47 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-12-03 10:45:47 +0100 |
commit | 8f62d95e1fb5980daab5294148106ce09237e386 (patch) | |
tree | b4c00a4645acc5ae76a72b8f6a44ddc818abd4fe /src | |
parent | aaeba697bd3fe5fa74ef726fd5a99de496fd92f2 (diff) |
further npe checks
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Bookmark.java | 3 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/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 91dc25be..559e2f2d 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 250a69c3..0865d1aa 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<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; |