public void updateFileExistIcon() {
   if (message != null && message.messageOwner.media != null) {
     String fileName = null;
     File cacheFile;
     if (message.messageOwner.attachPath == null
         || message.messageOwner.attachPath.length() == 0
         || !(new File(message.messageOwner.attachPath).exists())) {
       cacheFile = FileLoader.getPathToMessage(message.messageOwner);
       if (!cacheFile.exists()) {
         fileName = FileLoader.getAttachFileName(message.messageOwner.media.document);
       }
     }
     loaded = false;
     if (fileName == null) {
       statusImageView.setVisibility(INVISIBLE);
       dateTextView.setPadding(0, 0, 0, 0);
       loading = false;
       loaded = true;
       MediaController.getInstance().removeLoadingFileObserver(this);
     } else {
       MediaController.getInstance().addLoadingFileObserver(fileName, this);
       loading = FileLoader.getInstance().isLoadingFile(fileName);
       statusImageView.setVisibility(VISIBLE);
       statusImageView.setImageResource(
           loading ? R.drawable.media_doc_pause : R.drawable.media_doc_load);
       dateTextView.setPadding(
           LocaleController.isRTL ? 0 : AndroidUtilities.dp(14),
           0,
           LocaleController.isRTL ? AndroidUtilities.dp(14) : 0,
           0);
       if (loading) {
         progressView.setVisibility(VISIBLE);
         Float progress = ImageLoader.getInstance().getFileProgress(fileName);
         if (progress == null) {
           progress = 0.0f;
         }
         progressView.setProgress(progress, false);
       } else {
         progressView.setVisibility(INVISIBLE);
       }
     }
   } else {
     loading = false;
     loaded = true;
     progressView.setVisibility(INVISIBLE);
     progressView.setProgress(0, false);
     statusImageView.setVisibility(INVISIBLE);
     dateTextView.setPadding(0, 0, 0, 0);
     MediaController.getInstance().removeLoadingFileObserver(this);
   }
 }
  public void setDocument(MessageObject document, boolean divider) {
    needDivider = divider;
    message = document;
    loaded = false;
    loading = false;

    if (document != null && document.messageOwner.media != null) {
      int idx;
      String name = FileLoader.getDocumentFileName(document.messageOwner.media.document);
      placeholderImabeView.setVisibility(VISIBLE);
      extTextView.setVisibility(VISIBLE);
      placeholderImabeView.setImageResource(
          getThumbForNameOrMime(name, document.messageOwner.media.document.mime_type));
      nameTextView.setText(name);
      extTextView.setText(
          (idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase());
      if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty
          || document.messageOwner.media.document.thumb == null) {
        thumbImageView.setVisibility(INVISIBLE);
        thumbImageView.setImageBitmap(null);
      } else {
        thumbImageView.setVisibility(VISIBLE);
        thumbImageView.setImage(
            document.messageOwner.media.document.thumb.location, "40_40", (Drawable) null);
      }
      long date = (long) document.messageOwner.date * 1000;
      dateTextView.setText(
          String.format(
              "%s, %s",
              AndroidUtilities.formatFileSize(document.messageOwner.media.document.size),
              LocaleController.formatString(
                  "formatDateAtTime",
                  R.string.formatDateAtTime,
                  LocaleController.formatterYear.format(new Date(date)),
                  LocaleController.formatterDay.format(new Date(date)))));
    } else {
      nameTextView.setText("");
      extTextView.setText("");
      dateTextView.setText("");
      placeholderImabeView.setVisibility(VISIBLE);
      extTextView.setVisibility(VISIBLE);
      thumbImageView.setVisibility(INVISIBLE);
      thumbImageView.setImageBitmap(null);
    }

    setWillNotDraw(!needDivider);
    progressView.setProgress(0, false);
    updateFileExistIcon();
  }
 public void setMessageObject(MessageObject messageObject) {
   if (currentMessageObject == messageObject) {
     return;
   }
   currentMessageObject = messageObject;
   previousWidth = 0;
   if (currentMessageObject.type == 11) {
     int id = 0;
     if (messageObject.messageOwner.to_id != null) {
       if (messageObject.messageOwner.to_id.chat_id != 0) {
         id = messageObject.messageOwner.to_id.chat_id;
       } else {
         id = messageObject.messageOwner.to_id.user_id;
         if (id == UserConfig.getClientUserId()) {
           id = messageObject.messageOwner.from_id;
         }
       }
     }
     avatarDrawable.setInfo(id, null, null, false);
     if (currentMessageObject.messageOwner.action
         instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
       imageReceiver.setImage(
           currentMessageObject.messageOwner.action.newUserPhoto.photo_small,
           "50_50",
           avatarDrawable,
           null,
           false);
     } else {
       TLRPC.PhotoSize photo =
           FileLoader.getClosestPhotoSizeWithSize(
               currentMessageObject.photoThumbs, AndroidUtilities.dp(64));
       if (photo != null) {
         imageReceiver.setImage(photo.location, "50_50", avatarDrawable, null, false);
       } else {
         imageReceiver.setImageBitmap(avatarDrawable);
       }
     }
     imageReceiver.setVisible(
         !PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
   } else {
     imageReceiver.setImageBitmap((Bitmap) null);
   }
   requestLayout();
 }