Program: 193303
Project: 193303
Buggy source:
@Override public void onBindViewHolder(DocumentHolder holder,int position){
  final Context context=getContext();
  final State state=getDisplayState(DirectoryFragment.this);
  final DocumentInfo doc=getArguments().getParcelable(EXTRA_DOC);
  final RootsCache roots=DocumentsApplication.getRootsCache(context);
  final ThumbnailCache thumbs=DocumentsApplication.getThumbnailsCache(context,mThumbSize);
  final Cursor cursor=mModel.getItem(position);
  checkNotNull(cursor,"String_Node_Str");
  final String docAuthority=getCursorString(cursor,RootCursorWrapper.COLUMN_AUTHORITY);
  final String docRootId=getCursorString(cursor,RootCursorWrapper.COLUMN_ROOT_ID);
  final String docId=getCursorString(cursor,Document.COLUMN_DOCUMENT_ID);
  final String docMimeType=getCursorString(cursor,Document.COLUMN_MIME_TYPE);
  final String docDisplayName=getCursorString(cursor,Document.COLUMN_DISPLAY_NAME);
  final long docLastModified=getCursorLong(cursor,Document.COLUMN_LAST_MODIFIED);
  final int docIcon=getCursorInt(cursor,Document.COLUMN_ICON);
  final int docFlags=getCursorInt(cursor,Document.COLUMN_FLAGS);
  final String docSummary=getCursorString(cursor,Document.COLUMN_SUMMARY);
  final long docSize=getCursorLong(cursor,Document.COLUMN_SIZE);
  holder.docId=docId;
  final View itemView=holder.view;
  itemView.setActivated(isSelected(position));
  final View line1=itemView.findViewById(R.id.line1);
  final View line2=itemView.findViewById(R.id.line2);
  final ImageView iconMime=(ImageView)itemView.findViewById(R.id.icon_mime);
  final ImageView iconThumb=(ImageView)itemView.findViewById(R.id.icon_thumb);
  final TextView title=(TextView)itemView.findViewById(android.R.id.title);
  final ImageView icon1=(ImageView)itemView.findViewById(android.R.id.icon1);
  final ImageView icon2=(ImageView)itemView.findViewById(android.R.id.icon2);
  final TextView summary=(TextView)itemView.findViewById(android.R.id.summary);
  final TextView date=(TextView)itemView.findViewById(R.id.date);
  final TextView size=(TextView)itemView.findViewById(R.id.size);
  final ThumbnailAsyncTask oldTask=(ThumbnailAsyncTask)iconThumb.getTag();
  if (oldTask != null) {
    oldTask.preempt();
    iconThumb.setTag(null);
  }
  iconMime.animate().cancel();
  iconThumb.animate().cancel();
  final boolean supportsThumbnail=(docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
  final boolean allowThumbnail=(state.derivedMode == MODE_GRID) || MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES,docMimeType);
  final boolean showThumbnail=supportsThumbnail && allowThumbnail && !mSvelteRecents;
  final boolean enabled=isDocumentEnabled(docMimeType,docFlags);
  final float iconAlpha=(state.derivedMode == MODE_LIST && !enabled) ? 0.5f : 1f;
  boolean cacheHit=false;
  if (showThumbnail) {
    final Uri uri=DocumentsContract.buildDocumentUri(docAuthority,docId);
    final Bitmap cachedResult=thumbs.get(uri);
    if (cachedResult != null) {
      iconThumb.setImageBitmap(cachedResult);
      cacheHit=true;
    }
 else {
      iconThumb.setImageDrawable(null);
      final ThumbnailAsyncTask task=new ThumbnailAsyncTask(uri,iconMime,iconThumb,mThumbSize,iconAlpha);
      iconThumb.setTag(task);
      ProviderExecutor.forAuthority(docAuthority).execute(task);
    }
  }
  if (cacheHit) {
    iconMime.setAlpha(0f);
    iconMime.setImageDrawable(null);
    iconThumb.setAlpha(1f);
  }
 else {
    iconMime.setAlpha(1f);
    iconThumb.setAlpha(0f);
    iconThumb.setImageDrawable(null);
    iconMime.setImageDrawable(getDocumentIcon(mContext,docAuthority,docId,docMimeType,docIcon,state));
  }
  boolean hasLine1=false;
  boolean hasLine2=false;
  final boolean hideTitle=(state.derivedMode == MODE_GRID) && mHideGridTitles;
  if (!hideTitle) {
    title.setText(docDisplayName);
    hasLine1=true;
  }
  Drawable iconDrawable=null;
  if (mType == TYPE_RECENT_OPEN) {
    final RootInfo root=roots.getRootBlocking(docAuthority,docRootId);
    if (state.derivedMode == MODE_GRID) {
      iconDrawable=root.loadGridIcon(mContext);
    }
 else {
      iconDrawable=root.loadIcon(mContext);
    }
    if (summary != null) {
      final boolean alwaysShowSummary=getResources().getBoolean(R.bool.always_show_summary);
      if (alwaysShowSummary) {
        summary.setText(root.getDirectoryString());
        summary.setVisibility(View.VISIBLE);
        hasLine2=true;
      }
 else {
        if (iconDrawable != null && roots.isIconUniqueBlocking(root)) {
          summary.setVisibility(View.INVISIBLE);
        }
 else {
          summary.setText(root.getDirectoryString());
          summary.setVisibility(View.VISIBLE);
          summary.setTextAlignment(TextView.TEXT_ALIGNMENT_TEXT_END);
          hasLine2=true;
        }
      }
    }
  }
 else {
    if (Document.MIME_TYPE_DIR.equals(docMimeType) && state.derivedMode == MODE_GRID && showThumbnail) {
      iconDrawable=IconUtils.applyTintAttr(mContext,R.drawable.ic_doc_folder,android.R.attr.textColorPrimaryInverse);
    }
    if (summary != null) {
      if (docSummary != null) {
        summary.setText(docSummary);
        summary.setVisibility(View.VISIBLE);
        hasLine2=true;
      }
 else {
        summary.setVisibility(View.INVISIBLE);
      }
    }
  }
  if (icon1 != null)   icon1.setVisibility(View.GONE);
  if (icon2 != null)   icon2.setVisibility(View.GONE);
  if (iconDrawable != null) {
    if (hasLine1) {
      icon1.setVisibility(View.VISIBLE);
      icon1.setImageDrawable(iconDrawable);
    }
 else {
      icon2.setVisibility(View.VISIBLE);
      icon2.setImageDrawable(iconDrawable);
    }
  }
  if (docLastModified == -1) {
    date.setText(null);
  }
 else {
    date.setText(formatTime(mContext,docLastModified));
    hasLine2=true;
  }
  if (state.showSize) {
    size.setVisibility(View.VISIBLE);
    if (Document.MIME_TYPE_DIR.equals(docMimeType) || docSize == -1) {
      size.setText(null);
    }
 else {
      size.setText(Formatter.formatFileSize(mContext,docSize));
      hasLine2=true;
    }
  }
 else {
    size.setVisibility(View.GONE);
  }
  if (line1 != null) {
    line1.setVisibility(hasLine1 ? View.VISIBLE : View.GONE);
  }
  if (line2 != null) {
    line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
  }
  setEnabledRecursive(itemView,enabled);
  iconMime.setAlpha(iconAlpha);
  iconThumb.setAlpha(iconAlpha);
  if (icon1 != null)   icon1.setAlpha(iconAlpha);
  if (icon2 != null)   icon2.setAlpha(iconAlpha);
  if (DEBUG_ENABLE_DND) {
    setupDragAndDropOnDocumentView(itemView,cursor);
  }
}

Fixed version (ground truth):
@Override public void onBindViewHolder(DocumentHolder holder,int position){
  final Context context=getContext();
  final State state=getDisplayState(DirectoryFragment.this);
  final DocumentInfo doc=getArguments().getParcelable(EXTRA_DOC);
  final RootsCache roots=DocumentsApplication.getRootsCache(context);
  final ThumbnailCache thumbs=DocumentsApplication.getThumbnailsCache(context,mThumbSize);
  final Cursor cursor=mModel.getItem(position);
  checkNotNull(cursor,"String_Node_Str");
  final String docAuthority=getCursorString(cursor,RootCursorWrapper.COLUMN_AUTHORITY);
  final String docRootId=getCursorString(cursor,RootCursorWrapper.COLUMN_ROOT_ID);
  final String docId=getCursorString(cursor,Document.COLUMN_DOCUMENT_ID);
  final String docMimeType=getCursorString(cursor,Document.COLUMN_MIME_TYPE);
  final String docDisplayName=getCursorString(cursor,Document.COLUMN_DISPLAY_NAME);
  final long docLastModified=getCursorLong(cursor,Document.COLUMN_LAST_MODIFIED);
  final int docIcon=getCursorInt(cursor,Document.COLUMN_ICON);
  final int docFlags=getCursorInt(cursor,Document.COLUMN_FLAGS);
  final String docSummary=getCursorString(cursor,Document.COLUMN_SUMMARY);
  final long docSize=getCursorLong(cursor,Document.COLUMN_SIZE);
  holder.docId=docId;
  final View itemView=holder.itemView;
  holder.setSelected(isSelected(position));
  final View line1=itemView.findViewById(R.id.line1);
  final View line2=itemView.findViewById(R.id.line2);
  final ImageView iconMime=(ImageView)itemView.findViewById(R.id.icon_mime);
  final ImageView iconThumb=(ImageView)itemView.findViewById(R.id.icon_thumb);
  final TextView title=(TextView)itemView.findViewById(android.R.id.title);
  final ImageView icon1=(ImageView)itemView.findViewById(android.R.id.icon1);
  final ImageView icon2=(ImageView)itemView.findViewById(android.R.id.icon2);
  final TextView summary=(TextView)itemView.findViewById(android.R.id.summary);
  final TextView date=(TextView)itemView.findViewById(R.id.date);
  final TextView size=(TextView)itemView.findViewById(R.id.size);
  final ThumbnailAsyncTask oldTask=(ThumbnailAsyncTask)iconThumb.getTag();
  if (oldTask != null) {
    oldTask.preempt();
    iconThumb.setTag(null);
  }
  iconMime.animate().cancel();
  iconThumb.animate().cancel();
  final boolean supportsThumbnail=(docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
  final boolean allowThumbnail=(state.derivedMode == MODE_GRID) || MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES,docMimeType);
  final boolean showThumbnail=supportsThumbnail && allowThumbnail && !mSvelteRecents;
  final boolean enabled=isDocumentEnabled(docMimeType,docFlags);
  final float iconAlpha=(state.derivedMode == MODE_LIST && !enabled) ? 0.5f : 1f;
  boolean cacheHit=false;
  if (showThumbnail) {
    final Uri uri=DocumentsContract.buildDocumentUri(docAuthority,docId);
    final Bitmap cachedResult=thumbs.get(uri);
    if (cachedResult != null) {
      iconThumb.setImageBitmap(cachedResult);
      cacheHit=true;
    }
 else {
      iconThumb.setImageDrawable(null);
      final ThumbnailAsyncTask task=new ThumbnailAsyncTask(uri,iconMime,iconThumb,mThumbSize,iconAlpha);
      iconThumb.setTag(task);
      ProviderExecutor.forAuthority(docAuthority).execute(task);
    }
  }
  if (cacheHit) {
    iconMime.setAlpha(0f);
    iconMime.setImageDrawable(null);
    iconThumb.setAlpha(1f);
  }
 else {
    iconMime.setAlpha(1f);
    iconThumb.setAlpha(0f);
    iconThumb.setImageDrawable(null);
    iconMime.setImageDrawable(getDocumentIcon(mContext,docAuthority,docId,docMimeType,docIcon,state));
  }
  boolean hasLine1=false;
  boolean hasLine2=false;
  final boolean hideTitle=(state.derivedMode == MODE_GRID) && mHideGridTitles;
  if (!hideTitle) {
    title.setText(docDisplayName);
    hasLine1=true;
  }
  Drawable iconDrawable=null;
  if (mType == TYPE_RECENT_OPEN) {
    final RootInfo root=roots.getRootBlocking(docAuthority,docRootId);
    if (state.derivedMode == MODE_GRID) {
      iconDrawable=root.loadGridIcon(mContext);
    }
 else {
      iconDrawable=root.loadIcon(mContext);
    }
    if (summary != null) {
      final boolean alwaysShowSummary=getResources().getBoolean(R.bool.always_show_summary);
      if (alwaysShowSummary) {
        summary.setText(root.getDirectoryString());
        summary.setVisibility(View.VISIBLE);
        hasLine2=true;
      }
 else {
        if (iconDrawable != null && roots.isIconUniqueBlocking(root)) {
          summary.setVisibility(View.INVISIBLE);
        }
 else {
          summary.setText(root.getDirectoryString());
          summary.setVisibility(View.VISIBLE);
          summary.setTextAlignment(TextView.TEXT_ALIGNMENT_TEXT_END);
          hasLine2=true;
        }
      }
    }
  }
 else {
    if (Document.MIME_TYPE_DIR.equals(docMimeType) && state.derivedMode == MODE_GRID && showThumbnail) {
      iconDrawable=IconUtils.applyTintAttr(mContext,R.drawable.ic_doc_folder,android.R.attr.textColorPrimaryInverse);
    }
    if (summary != null) {
      if (docSummary != null) {
        summary.setText(docSummary);
        summary.setVisibility(View.VISIBLE);
        hasLine2=true;
      }
 else {
        summary.setVisibility(View.INVISIBLE);
      }
    }
  }
  if (icon1 != null)   icon1.setVisibility(View.GONE);
  if (icon2 != null)   icon2.setVisibility(View.GONE);
  if (iconDrawable != null) {
    if (hasLine1) {
      icon1.setVisibility(View.VISIBLE);
      icon1.setImageDrawable(iconDrawable);
    }
 else {
      icon2.setVisibility(View.VISIBLE);
      icon2.setImageDrawable(iconDrawable);
    }
  }
  if (docLastModified == -1) {
    date.setText(null);
  }
 else {
    date.setText(formatTime(mContext,docLastModified));
    hasLine2=true;
  }
  if (state.showSize) {
    size.setVisibility(View.VISIBLE);
    if (Document.MIME_TYPE_DIR.equals(docMimeType) || docSize == -1) {
      size.setText(null);
    }
 else {
      size.setText(Formatter.formatFileSize(mContext,docSize));
      hasLine2=true;
    }
  }
 else {
    size.setVisibility(View.GONE);
  }
  if (line1 != null) {
    line1.setVisibility(hasLine1 ? View.VISIBLE : View.GONE);
  }
  if (line2 != null) {
    line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
  }
  setEnabledRecursive(itemView,enabled);
  iconMime.setAlpha(iconAlpha);
  iconThumb.setAlpha(iconAlpha);
  if (icon1 != null)   icon1.setAlpha(iconAlpha);
  if (icon2 != null)   icon2.setAlpha(iconAlpha);
  if (DEBUG_ENABLE_DND) {
    setupDragAndDropOnDocumentView(itemView,cursor);
  }
}