Program: 175794
Project: 175794
Buggy source:
@Override protected void initListener(){
  mRefreshLayout.setOnRefreshListener(new RefreshListenerAdapter(){
    @Override public void onRefresh(    TwinklingRefreshLayout refreshLayout){
      UIUtils.getHandler().postDelayed(() -> {
        List<Recommend.BooksBean> recommend=RecommendManager.getInstance().getRecommend();
        if (mRecommendAdapter != null)         mRecommendAdapter.replaceAll(recommend);
        refreshLayout.finishRefreshing();
      }
,250);
    }
    @Override public void onFinishRefresh(){
      checkIsEmpty();
    }
  }
);
  mRecommendAdapter.setOnItemLongClickListener((holder,position,item) -> new BookDialog(mContext).setBookTitle(item.getTitle()).setFromSDCard(item.isFromSD()).setOnDialogItemClickListener((dialog,viewHolder,pos,str) -> {
    dialog.dismissDialog();
    if (dialog.isFromSDCard()) {
switch (pos) {
case 0:
        break;
case 1:
      break;
case 2:
    break;
}
}
 else {
switch (pos) {
case 0:
  NavigationUtils.goToBookDetailPage(mActivity,item.getBookId(),false);
break;
case 1:
break;
case 2:
break;
case 3:
mCab=getActivity(MainActivity.class).openCab(R.menu.menu_book_manage,this);
mRecommendAdapter.longTouchSelectModeEnable(true);
break;
}
}
}
).showDialog());
mRecommendAdapter.setItemSelectedListener(new SelectAdapter.OnItemSelectedListener<Recommend.BooksBean>(){
@Override public void onItemSelected(BaseViewHolder viewHolder,int position,boolean isSelected,Recommend.BooksBean booksBean){
if (isSelected) {
mSelectedBooks.add(booksBean);
}
 else {
mSelectedBooks.remove(booksBean);
}
setMaterialCabTitle();
mCab.getMenu().findItem(R.id.action_delete).setEnabled(!mSelectedBooks.isEmpty());
mCab.getMenu().findItem(R.id.action_select_all).setTitle(mSelectedBooks.size() == mRecommendAdapter.getDataListSize() ? UIUtils.getString(R.string.un_select_all) : UIUtils.getString(R.string.select_all));
}
@Override public void onNothingSelected(){
}
}
);
mRecommendAdapter.setOnItemClickListener((holder,position,item) -> NavigationUtils.goToBookReadPage(mActivity,item));
}

Fixed version (ground truth):
@Override protected void initListener(){
  mRefreshLayout.setOnRefreshListener(new RefreshListenerAdapter(){
    @Override public void onRefresh(    TwinklingRefreshLayout refreshLayout){
      UIUtils.getHandler().postDelayed(() -> {
        List<Recommend.BooksBean> recommend=RecommendManager.getInstance().getRecommend();
        if (mRecommendAdapter != null)         mRecommendAdapter.replaceAll(recommend);
        refreshLayout.finishRefreshing();
      }
,250);
    }
    @Override public void onFinishRefresh(){
      checkIsEmpty();
    }
  }
);
  mRecommendAdapter.setOnItemLongClickListener((holder,position,item) -> new BookDialog(mContext).setBookTitle(item.getTitle()).setFromSDCard(item.isFromSD()).setOnDialogItemClickListener((dialog,viewHolder,pos,str) -> {
    dialog.dismissDialog();
    if (dialog.isFromSDCard()) {
switch (pos) {
case 0:
        break;
case 1:
      break;
case 2:
    break;
}
}
 else {
switch (pos) {
case 0:
  NavigationUtils.goToBookDetailPage(mActivity,item.getBookId(),false);
break;
case 1:
break;
case 2:
List<Recommend.BooksBean> selectedBooks=new ArrayList<>();
selectedBooks.add(mRecommendAdapter.getItem(position));
batchManage(selectedBooks);
break;
case 3:
mCab=getActivity(MainActivity.class).openCab(R.menu.menu_book_manage,this);
mRecommendAdapter.longTouchSelectModeEnable(true);
break;
}
}
}
).showDialog());
mRecommendAdapter.setItemSelectedListener(new SelectAdapter.OnItemSelectedListener<Recommend.BooksBean>(){
@Override public void onItemSelected(BaseViewHolder viewHolder,int position,boolean isSelected,Recommend.BooksBean booksBean){
if (isSelected) {
mSelectedBooks.add(booksBean);
}
 else {
mSelectedBooks.remove(booksBean);
}
setMaterialCabTitle();
mCab.getMenu().findItem(R.id.action_delete).setEnabled(!mSelectedBooks.isEmpty());
mCab.getMenu().findItem(R.id.action_select_all).setTitle(mSelectedBooks.size() == mRecommendAdapter.getDataListSize() ? UIUtils.getString(R.string.un_select_all) : UIUtils.getString(R.string.select_all));
}
@Override public void onNothingSelected(){
}
}
);
mRecommendAdapter.setOnItemClickListener((holder,position,item) -> NavigationUtils.goToBookReadPage(mActivity,item));
}