aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Contact.java40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java
index b69f421ff..3872ceecb 100644
--- a/src/main/java/de/pixart/messenger/entities/Contact.java
+++ b/src/main/java/de/pixart/messenger/entities/Contact.java
@@ -5,6 +5,7 @@ import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
+import android.support.annotation.NonNull;
import android.text.TextUtils;
import org.json.JSONArray;
@@ -37,18 +38,18 @@ public class Contact implements ListItem, Blockable {
public static final String LAST_PRESENCE = "last_presence";
public static final String LAST_TIME = "last_time";
public static final String GROUPS = "groups";
- protected String accountUuid;
- protected String systemName;
- protected String serverName;
- protected String presenceName;
- protected String commonName;
+ private String accountUuid;
+ private String systemName;
+ private String serverName;
+ private String presenceName;
+ private String commonName;
protected Jid jid;
- protected int subscription = 0;
- protected String systemAccount;
- protected String photoUri;
- protected JSONObject keys = new JSONObject();
- protected JSONArray groups = new JSONArray();
- protected final Presences presences = new Presences();
+ private int subscription = 0;
+ private String systemAccount;
+ private String photoUri;
+ private final JSONObject keys;
+ private JSONArray groups = new JSONArray();
+ private final Presences presences = new Presences();
protected Account account;
protected Avatar avatar;
@@ -67,11 +68,13 @@ public class Contact implements ListItem, Blockable {
this.subscription = subscription;
this.photoUri = photoUri;
this.systemAccount = systemAccount;
+ JSONObject tmpJsonObject;
try {
- this.keys = (keys == null ? new JSONObject("") : new JSONObject(keys));
+ tmpJsonObject = (keys == null ? new JSONObject("") : new JSONObject(keys));
} catch (JSONException e) {
- this.keys = new JSONObject();
+ tmpJsonObject = new JSONObject();
}
+ this.keys = tmpJsonObject;
if (avatar != null) {
this.avatar = new Avatar();
this.avatar.sha1sum = avatar;
@@ -88,6 +91,7 @@ public class Contact implements ListItem, Blockable {
public Contact(final Jid jid) {
this.jid = jid;
+ this.keys = new JSONObject();
}
public static Contact fromCursor(final Cursor cursor) {
@@ -162,8 +166,8 @@ public class Contact implements ListItem, Blockable {
needle = needle.toLowerCase(Locale.US).trim();
String[] parts = needle.split("\\s+");
if (parts.length > 1) {
- for (int i = 0; i < parts.length; ++i) {
- if (!match(context, parts[i])) {
+ for (String part : parts) {
+ if (!match(context, part)) {
return false;
}
}
@@ -284,8 +288,8 @@ public class Contact implements ListItem, Blockable {
this.systemAccount = account;
}
- public List<String> getGroups() {
- ArrayList<String> groups = new ArrayList<String>();
+ private List<String> getGroups() {
+ ArrayList<String> groups = new ArrayList<>();
for (int i = 0; i < this.groups.length(); ++i) {
try {
groups.add(this.groups.getString(i));
@@ -438,7 +442,7 @@ public class Contact implements ListItem, Blockable {
}
@Override
- public int compareTo(final ListItem another) {
+ public int compareTo(@NonNull final ListItem another) {
return this.getDisplayName().compareToIgnoreCase(
another.getDisplayName());
}