コード例 #1
0
  public void onData(JID jid, String id, byte[] avatarData) {
    LOGGER.info("new avatar, jid: " + jid + " id: " + id);

    if (avatarData.length > MAX_SIZE) LOGGER.info("avatar data too long: " + avatarData.length);

    Contact contact = ContactList.getInstance().get(jid).orElse(null);
    if (contact == null) {
      LOGGER.warning("can't find contact with jid:" + jid);
      return;
    }

    if (!id.equals(DigestUtils.sha1Hex(avatarData))) {
      LOGGER.warning("this is not what we wanted");
      return;
    }

    BufferedImage img = MediaUtils.readImage(avatarData).orElse(null);
    if (img == null) return;

    contact.setAvatar(new Avatar(id, img));
  }
コード例 #2
0
 void onNewMessage(InMessage newMessage) {
   if (newMessage.getChat() == mView.getCurrentShownChat().orElse(null)
       && mView.mainFrameIsFocused()) return;
   MediaUtils.playSound(MediaUtils.Sound.NOTIFICATION);
 }