ListItem.java

 1package eu.siacs.conversations.entities;
 2
 3import android.content.Context;
 4
 5import java.util.List;
 6import java.util.Locale;
 7
 8import eu.siacs.conversations.services.AvatarService;
 9import eu.siacs.conversations.xmpp.Jid;
10
11
12public interface ListItem extends Comparable<ListItem>, AvatarService.Avatarable {
13	String getDisplayName();
14
15	Jid getJid();
16
17	List<Tag> getTags(Context context);
18
19	final class Tag {
20		private final String name;
21		private final int color;
22
23		public Tag(final String name, final int color) {
24			this.name = name;
25			this.color = color;
26		}
27
28		public int getColor() {
29			return this.color;
30		}
31
32		public String getName() {
33			return this.name;
34		}
35
36		public String toString() {
37			return getName();
38		}
39
40		public boolean equals(Object o) {
41			if (!(o instanceof Tag)) return false;
42			Tag ot = (Tag) o;
43			return name.toLowerCase(Locale.US).equals(ot.getName().toLowerCase(Locale.US)) && color == ot.getColor();
44		}
45
46		public int hashCode() {
47			return name.toLowerCase(Locale.US).hashCode();
48		}
49	}
50
51	boolean match(Context context, final String needle);
52}