@Override
 public void onProgressDownload(String fileName, float progress) {
   if (progressView.getVisibility() != VISIBLE) {
     updateFileExistIcon();
   }
   progressView.setProgress(progress, true);
 }
 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();
  }
 @Override
 public void onSuccessDownload(String name) {
   progressView.setProgress(1, true);
   updateFileExistIcon();
 }