Program: 142175
Project: 142175
Buggy source:
private View findAndLoadCaseTile(final Activity activity){
  final View holder=LayoutInflater.from(activity).inflate(R.layout.com_tile_holder,null);
  final Pair<View,TreeReference> tileData=this.loadTile(activity);
  View tile=tileData == null ? null : tileData.first;
  if (tile == null) {
    return null;
  }
  final String inlineDetail=(String)tile.getTag();
  ((ViewGroup)holder.findViewById(R.id.com_tile_holder_frame)).addView(tile,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  final ImageButton infoButton=((ImageButton)holder.findViewById(R.id.com_tile_holder_btn_open));
  OnClickListener toggleButtonClickListener=new OnClickListener(){
    private boolean isClosed=true;
    @Override public void onClick(    View v){
      if (isClosed) {
        if (mInternalDetailView == null) {
          mInternalDetailView=(TabbedDetailView)holder.findViewById(R.id.com_tile_holder_detail_frame);
          mInternalDetailView.setRoot(mInternalDetailView);
          AndroidSessionWrapper asw=CommCareApplication._().getCurrentSessionWrapper();
          CommCareSession session=asw.getSession();
          NodeEntityFactory factory=new NodeEntityFactory(session.getDetail(inlineDetail),session.getEvaluationContext(new CommCareInstanceInitializer(session)));
          Detail detail=factory.getDetail();
          mInternalDetailView.setDetail(detail);
          mInternalDetailView.refresh(factory.getDetail(),tileData.second,0,false);
        }
        infoButton.setImageResource(R.drawable.icon_info_fill_brandbg);
        expand(activity,holder.findViewById(R.id.com_tile_holder_detail_master));
        isClosed=false;
      }
 else {
        infoButton.setImageResource(R.drawable.icon_info_outline_brandbg);
        collapse(holder.findViewById(R.id.com_tile_holder_detail_master),new Runnable(){
          @Override public void run(){
          }
        }
);
        isClosed=true;
      }
    }
  }
;
  infoButton.setOnClickListener(toggleButtonClickListener);
  return holder;
}

Fixed version (ground truth):
private View findAndLoadCaseTile(final Activity activity){
  final View holder=LayoutInflater.from(activity).inflate(R.layout.com_tile_holder,null);
  final Pair<View,TreeReference> tileData=this.loadTile(activity);
  View tile=tileData == null ? null : tileData.first;
  if (tile == null) {
    return null;
  }
  final String inlineDetail=(String)tile.getTag();
  ((ViewGroup)holder.findViewById(R.id.com_tile_holder_frame)).addView(tile,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  final ImageButton infoButton=((ImageButton)holder.findViewById(R.id.com_tile_holder_btn_open));
  Detail contextDetail=CommCareApplication._().getCurrentSessionWrapper().getSession().getDetail(inlineDetail);
  if (contextDetail == null) {
    infoButton.setVisibility(View.GONE);
  }
  OnClickListener toggleButtonClickListener=new OnClickListener(){
    private boolean isClosed=true;
    @Override public void onClick(    View v){
      if (isClosed) {
        if (mInternalDetailView == null) {
          mInternalDetailView=(TabbedDetailView)holder.findViewById(R.id.com_tile_holder_detail_frame);
          mInternalDetailView.setRoot(mInternalDetailView);
          AndroidSessionWrapper asw=CommCareApplication._().getCurrentSessionWrapper();
          CommCareSession session=asw.getSession();
          NodeEntityFactory factory=new NodeEntityFactory(session.getDetail(inlineDetail),session.getEvaluationContext(new CommCareInstanceInitializer(session)));
          Detail detail=factory.getDetail();
          mInternalDetailView.setDetail(detail);
          mInternalDetailView.refresh(factory.getDetail(),tileData.second,0,false);
        }
        infoButton.setImageResource(R.drawable.icon_info_fill_brandbg);
        expand(activity,holder.findViewById(R.id.com_tile_holder_detail_master));
        isClosed=false;
      }
 else {
        infoButton.setImageResource(R.drawable.icon_info_outline_brandbg);
        collapse(holder.findViewById(R.id.com_tile_holder_detail_master),new Runnable(){
          @Override public void run(){
          }
        }
);
        isClosed=true;
      }
    }
  }
;
  infoButton.setOnClickListener(toggleButtonClickListener);
  return holder;
}