Beispiel #1
0
  public void setDescription(DialogWireframe description, Object preparedLayouts) {
    this.preparedLayouts = (DialogLayout[]) preparedLayouts;
    this.description = description;
    this.state = description.getMessageState();

    if (description.getPeerType() == PeerType.PEER_CHAT) {
      this.typingUids = application.getTypingStates().getChatTypes(description.getPeerId());
    } else {
      this.userTypes = application.getTypingStates().isUserTyping(description.getPeerId());
    }

    photo = description.getDialogAvatar();

    if (description.getPeerType() == PeerType.PEER_USER_ENCRYPTED) {
      EncryptedChat encryptedChat =
          application.getEngine().getEncryptedChat(description.getPeerId());
      avatarBgPaint.setColor(Placeholders.getBgColor(encryptedChat.getUserId()));
      placeholder = userPlaceHolder;
    } else if (description.getPeerType() == PeerType.PEER_USER) {
      avatarBgPaint.setColor(Placeholders.getBgColor(description.getPeerId()));
      placeholder = userPlaceHolder;
    } else if (description.getPeerType() == PeerType.PEER_CHAT) {
      avatarBgPaint.setColor(Placeholders.getBgColor(description.getPeerId()));
      placeholder = groupPlaceHolder;
    } else {
      throw new UnsupportedOperationException("Unknown peer type #" + description.getPeerType());
    }

    if (photo instanceof TLLocalAvatarPhoto) {
      if (!loader.requestAvatar(
          ((TLLocalAvatarPhoto) photo).getPreviewLocation(),
          IS_LARGE ? AvatarLoader.TYPE_MEDIUM2 : AvatarLoader.TYPE_MEDIUM,
          this)) {
        releaseAvatar();
      }
    } else {
      releaseAvatar();
      loader.cancelRequest(this);
    }

    if (getMeasuredHeight() != 0 || getMeasuredWidth() != 0) {
      buildLayout();
      invalidate();
    } else {
      requestLayout();
    }

    needNewUpdateTyping = true;
  }
Beispiel #2
0
  public DialogView(Context context) {
    super(context);
    checkResources(context);

    this.application = (TelegramApplication) context.getApplicationContext();

    this.loader = application.getUiKernel().getAvatarLoader();

    this.currentUserUid = application.getCurrentUid();

    application.getTypingStates().registerListener(this);

    avatarBgPaint = new Paint();
    avatarBgPaint.setStyle(Paint.Style.FILL);

    statePending = getResources().getDrawable(R.drawable.st_dialogs_clock);
    stateSent = getResources().getDrawable(R.drawable.st_dialogs_check);
    stateHalfCheck = getResources().getDrawable(R.drawable.st_dialogs_halfcheck);
    stateFailure = getResources().getDrawable(R.drawable.st_dialogs_warning);
    secureIcon = getResources().getDrawable(R.drawable.st_dialogs_lock);

    userPlaceHolder =
        ((BitmapDrawable) getResources().getDrawable(R.drawable.st_user_placeholder_dialog))
            .getBitmap();
    groupPlaceHolder =
        ((BitmapDrawable) getResources().getDrawable(R.drawable.st_group_placeholder)).getBitmap();
  }