Program: 27279
Project: 27279
Buggy source:
private void init(final Context context){
  setCanceledOnTouchOutside(cancelOnTouchOutside);
  final ClosableSlidingLayout mDialogView=(ClosableSlidingLayout)View.inflate(context,R.layout.bottom_sheet_dialog,null);
  setContentView(mDialogView);
  if (!cancelOnSwipeDown)   mDialogView.swipeable=cancelOnSwipeDown;
  mDialogView.setSlideListener(new ClosableSlidingLayout.SlideListener(){
    @Override public void onClosed(){
      BottomSheet.this.dismiss();
    }
    @Override public void onOpened(){
      showFullItems();
    }
  }
);
  this.setOnShowListener(new OnShowListener(){
    @Override public void onShow(    DialogInterface dialogInterface){
      actions=menuItem;
      list.setAdapter(adapter);
      list.startLayoutAnimation();
      if (builder.icon == null)       icon.setVisibility(View.GONE);
 else {
        icon.setVisibility(View.VISIBLE);
        icon.setImageDrawable(builder.icon);
      }
    }
  }
);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    mDialogView.setPadding(0,mStatusBarAvailable ? mStatusBarHeight : 0,0,0);
    mDialogView.getChildAt(0).setPadding(0,0,0,mNavBarAvailable ? getNavigationBarHeight(getContext()) + mDialogView.getPaddingBottom() : 0);
  }
  final TextView title=(TextView)mDialogView.findViewById(R.id.bottom_sheet_title);
  if (builder.title != null) {
    title.setVisibility(View.VISIBLE);
    title.setText(builder.title);
  }
  icon=(ImageView)mDialogView.findViewById(R.id.bottom_sheet_title_image);
  list=(GridView)mDialogView.findViewById(R.id.bottom_sheet_gridview);
  mDialogView.mTarget=list;
  if (!builder.grid) {
    list.setNumColumns(1);
  }
  menuItem=builder.menuItems;
  if (builder.grid) {
    Iterator<MenuItem> i=menuItem.iterator();
    while (i.hasNext()) {
      MenuItem item=i.next();
      if (item.divider)       i.remove();
 else       if (item.icon == null) {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
  }
  if (builder.limit > 0)   limit=builder.limit * getNumColumns();
 else   limit=Integer.MAX_VALUE;
  mDialogView.setCollapsible(false);
  if (menuItem.size() > limit) {
    fullMenuItem=new ArrayList<>(menuItem);
    menuItem=menuItem.subList(0,limit - 1);
    menuItem.add(new MenuItem(R.id.bs_more,moreText,more));
    mDialogView.setCollapsible(true);
  }
  actions=menuItem;
  adapter=new BaseAdapter(){
    @Override public int getCount(){
      return actions.size();
    }
    @Override public MenuItem getItem(    int position){
      return actions.get(position);
    }
    @Override public long getItemId(    int position){
      return position;
    }
    @Override public int getViewTypeCount(){
      return 2;
    }
    @Override public boolean isEnabled(    int position){
      return getItemViewType(position) == 0;
    }
    @Override public boolean areAllItemsEnabled(){
      return false;
    }
    @Override public int getItemViewType(    int position){
      return getItem(position).divider ? 1 : 0;
    }
    @Override public View getView(    int position,    View convertView,    ViewGroup parent){
      ViewHolder holder;
      if (getItemViewType(position) == 0) {
        if (convertView == null) {
          LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          if (builder.grid)           convertView=inflater.inflate(R.layout.bs_grid_entry,parent,false);
 else           convertView=inflater.inflate(R.layout.bs_list_entry,parent,false);
          holder=new ViewHolder();
          holder.title=(TextView)convertView.findViewById(R.id.bs_list_title);
          holder.image=(ImageView)convertView.findViewById(R.id.bs_list_image);
          convertView.setTag(holder);
        }
 else {
          holder=(ViewHolder)convertView.getTag();
        }
        MenuItem item=getItem(position);
        holder.title.setText(item.text);
        if (item.icon == null)         holder.image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE);
 else {
          holder.image.setVisibility(View.VISIBLE);
          holder.image.setImageDrawable(item.icon);
        }
        return convertView;
      }
 else {
        if (convertView == null) {
          LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView=inflater.inflate(R.layout.bs_list_divider,parent,false);
          convertView.setVisibility(View.VISIBLE);
        }
        return convertView;
      }
    }
class ViewHolder {
      private TextView title;
      private ImageView image;
    }
  }
;
  list.setAdapter(adapter);
  list.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (((MenuItem)adapter.getItem(position)).id == R.id.bs_more) {
        showFullItems();
        mDialogView.setCollapsible(false);
        return;
      }
      if (builder.listener != null) {
        builder.listener.onClick(BottomSheet.this,((MenuItem)adapter.getItem(position)).id);
      }
      dismiss();
    }
  }
);
  if (builder.dismissListener != null) {
    setOnDismissListener(builder.dismissListener);
  }
  setListLayout();
}

Fixed version (ground truth):
private void init(final Context context){
  setCanceledOnTouchOutside(cancelOnTouchOutside);
  final ClosableSlidingLayout mDialogView=(ClosableSlidingLayout)View.inflate(context,R.layout.bottom_sheet_dialog,null);
  setContentView(mDialogView);
  if (!cancelOnSwipeDown)   mDialogView.swipeable=cancelOnSwipeDown;
  mDialogView.setSlideListener(new ClosableSlidingLayout.SlideListener(){
    @Override public void onClosed(){
      BottomSheet.this.dismiss();
    }
    @Override public void onOpened(){
      showFullItems();
    }
  }
);
  this.setOnShowListener(new OnShowListener(){
    @Override public void onShow(    DialogInterface dialogInterface){
      actions=menuItem;
      list.setAdapter(adapter);
      list.startLayoutAnimation();
      if (builder.icon == null)       icon.setVisibility(View.GONE);
 else {
        icon.setVisibility(View.VISIBLE);
        icon.setImageDrawable(builder.icon);
      }
    }
  }
);
  int[] location=new int[2];
  mDialogView.getLocationOnScreen(location);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    mDialogView.setPadding(0,location[0] == 0 ? mStatusBarHeight : 0,0,0);
    mDialogView.getChildAt(0).setPadding(0,0,0,mNavBarAvailable ? getNavigationBarHeight(getContext()) + mDialogView.getPaddingBottom() : 0);
  }
  final TextView title=(TextView)mDialogView.findViewById(R.id.bottom_sheet_title);
  if (builder.title != null) {
    title.setVisibility(View.VISIBLE);
    title.setText(builder.title);
  }
  icon=(ImageView)mDialogView.findViewById(R.id.bottom_sheet_title_image);
  list=(GridView)mDialogView.findViewById(R.id.bottom_sheet_gridview);
  mDialogView.mTarget=list;
  if (!builder.grid) {
    list.setNumColumns(1);
  }
  menuItem=builder.menuItems;
  if (builder.grid) {
    Iterator<MenuItem> i=menuItem.iterator();
    while (i.hasNext()) {
      MenuItem item=i.next();
      if (item.divider)       i.remove();
 else       if (item.icon == null) {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
  }
  if (builder.limit > 0)   limit=builder.limit * getNumColumns();
 else   limit=Integer.MAX_VALUE;
  mDialogView.setCollapsible(false);
  if (menuItem.size() > limit) {
    fullMenuItem=new ArrayList<>(menuItem);
    menuItem=menuItem.subList(0,limit - 1);
    menuItem.add(new MenuItem(R.id.bs_more,moreText,more));
    mDialogView.setCollapsible(true);
  }
  actions=menuItem;
  adapter=new BaseAdapter(){
    @Override public int getCount(){
      return actions.size();
    }
    @Override public MenuItem getItem(    int position){
      return actions.get(position);
    }
    @Override public long getItemId(    int position){
      return position;
    }
    @Override public int getViewTypeCount(){
      return 2;
    }
    @Override public boolean isEnabled(    int position){
      return getItemViewType(position) == 0;
    }
    @Override public boolean areAllItemsEnabled(){
      return false;
    }
    @Override public int getItemViewType(    int position){
      return getItem(position).divider ? 1 : 0;
    }
    @Override public View getView(    int position,    View convertView,    ViewGroup parent){
      ViewHolder holder;
      if (getItemViewType(position) == 0) {
        if (convertView == null) {
          LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          if (builder.grid)           convertView=inflater.inflate(R.layout.bs_grid_entry,parent,false);
 else           convertView=inflater.inflate(R.layout.bs_list_entry,parent,false);
          holder=new ViewHolder();
          holder.title=(TextView)convertView.findViewById(R.id.bs_list_title);
          holder.image=(ImageView)convertView.findViewById(R.id.bs_list_image);
          convertView.setTag(holder);
        }
 else {
          holder=(ViewHolder)convertView.getTag();
        }
        MenuItem item=getItem(position);
        holder.title.setText(item.text);
        if (item.icon == null)         holder.image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE);
 else {
          holder.image.setVisibility(View.VISIBLE);
          holder.image.setImageDrawable(item.icon);
        }
        return convertView;
      }
 else {
        if (convertView == null) {
          LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView=inflater.inflate(R.layout.bs_list_divider,parent,false);
          convertView.setVisibility(View.VISIBLE);
        }
        return convertView;
      }
    }
class ViewHolder {
      private TextView title;
      private ImageView image;
    }
  }
;
  list.setAdapter(adapter);
  list.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (((MenuItem)adapter.getItem(position)).id == R.id.bs_more) {
        showFullItems();
        mDialogView.setCollapsible(false);
        return;
      }
      if (builder.listener != null) {
        builder.listener.onClick(BottomSheet.this,((MenuItem)adapter.getItem(position)).id);
      }
      dismiss();
    }
  }
);
  if (builder.dismissListener != null) {
    setOnDismissListener(builder.dismissListener);
  }
  setListLayout();
}