コード例 #1
0
  Recipient getRecipient(Context context, long recipientId, boolean asynchronous) {
    Recipient cachedRecipient = recipientCache.get(recipientId);
    if (cachedRecipient != null && !cachedRecipient.isStale()) return cachedRecipient;

    String number = CanonicalAddressDatabase.getInstance(context).getAddressFromId(recipientId);

    if (asynchronous) {
      cachedRecipient =
          new Recipient(
              recipientId,
              number,
              cachedRecipient,
              getRecipientDetailsAsync(context, recipientId, number));
    } else {
      cachedRecipient =
          new Recipient(recipientId, getRecipientDetailsSync(context, recipientId, number));
    }

    recipientCache.set(recipientId, cachedRecipient);
    return cachedRecipient;
  }
コード例 #2
0
 void clearCache() {
   recipientCache.reset();
   recipientsCache.reset();
 }