public Bitmap getLazyAvatar(boolean delayed) { if (avatar != null) return avatar; Lime.getInstance().vcardResolver.queryTop(); if (avatarId != null) { if (avatarId.equals(Vcard.AVATAR_PENDING)) return null; if (avatarId.equals(Vcard.AVATAR_MISSING)) return null; // cache lookup Vcard cached = new Vcard(jid, avatarId); avatar = cached.getAvatar(); // cache hit? if (avatar != null) return avatar; // cache miss avatarId = null; } if (delayed) return null; // query vcard if (avatarId == null) { // TODO: request avatar avatarId = Vcard.AVATAR_PENDING; Lime.getInstance().vcardResolver.queryVcard(this); } // fallback - avatar request already queried return null; }
public Chat getChat(String visavisJid, String myJid) { Contact visavis = null; // 1. search already opened chat for (int index = 0; index < chats.size(); index++) { Chat c = chats.get(index); visavis = c.visavis; if (visavis.getJid().equals(visavisJid) && visavis.getRosterJid().equals(myJid)) return c; } // 2. searching visavis in roster visavis = Lime.getInstance().getRoster().findContact(visavisJid, myJid); // 3. initial policy: drop message if contact is not in our rosters if (visavis == null) return null; // 4. creating chat for existing contact Chat c = new Chat(visavis); synchronized (chats) { chats.add(c); } // TODO: raise unread counter // PROFIT! return c; }