コード例 #1
0
 public void parseConferencePresence(PresencePacket packet, Account account) {
   final Conversation conversation =
       packet.getFrom() == null
           ? null
           : mXmppConnectionService.find(account, packet.getFrom().toBareJid());
   if (conversation != null) {
     final MucOptions mucOptions = conversation.getMucOptions();
     boolean before = mucOptions.online();
     int count = mucOptions.getUserCount();
     final List<MucOptions.User> tileUserBefore = mucOptions.getUsers(5);
     processConferencePresence(packet, mucOptions);
     final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5);
     if (!tileUserAfter.equals(tileUserBefore)) {
       mXmppConnectionService.getAvatarService().clear(mucOptions);
     }
     if (before != mucOptions.online()
         || (mucOptions.online() && count != mucOptions.getUserCount())) {
       mXmppConnectionService.updateConversationUi();
     } else if (mucOptions.online()) {
       mXmppConnectionService.updateMucRosterUi();
     }
   }
 }
コード例 #2
0
  public Bitmap get(MucOptions mucOptions, int size) {
    final String KEY = key(mucOptions, size);
    Bitmap bitmap = this.mXmppConnectionService.getBitmapCache().get(KEY);
    if (bitmap != null) {
      return bitmap;
    }
    List<MucOptions.User> users = mucOptions.getUsers();
    int count = users.size();
    bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    bitmap.eraseColor(TRANSPARENT);

    if (count == 0) {
      String name = mucOptions.getConversation().getName();
      String letter = name.substring(0, 1);
      int color = this.getColorForName(name);
      drawTile(canvas, letter, color, 0, 0, size, size);
    } else if (count == 1) {
      drawTile(canvas, users.get(0), 0, 0, size, size);
    } else if (count == 2) {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size);
      drawTile(canvas, users.get(1), size / 2 + 1, 0, size, size);
    } else if (count == 3) {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size);
      drawTile(canvas, users.get(1), size / 2 + 1, 0, size, size / 2 - 1);
      drawTile(canvas, users.get(2), size / 2 + 1, size / 2 + 1, size, size);
    } else if (count == 4) {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size / 2 - 1);
      drawTile(canvas, users.get(1), 0, size / 2 + 1, size / 2 - 1, size);
      drawTile(canvas, users.get(2), size / 2 + 1, 0, size, size / 2 - 1);
      drawTile(canvas, users.get(3), size / 2 + 1, size / 2 + 1, size, size);
    } else {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size / 2 - 1);
      drawTile(canvas, users.get(1), 0, size / 2 + 1, size / 2 - 1, size);
      drawTile(canvas, users.get(2), size / 2 + 1, 0, size, size / 2 - 1);
      drawTile(canvas, "\u2026", PLACEHOLDER_COLOR, size / 2 + 1, size / 2 + 1, size, size);
    }
    this.mXmppConnectionService.getBitmapCache().put(KEY, bitmap);
    return bitmap;
  }