private int getHeaderViewPosition() { //Return to header view notify position if (getEmptyViewCount() == 1) { if (mHeadAndEmptyEnable) { return 0; } } else { return 0; } return -1; }
private int getFooterViewPosition() { //Return to footer view notify position if (getEmptyViewCount() == 1) { int position = 1; if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) { position++; } if (mFootAndEmptyEnable) { return position; } } else { return getHeaderLayoutCount() + mData.size(); } return -1; }
public void setEmptyView(View emptyView) { boolean insert = false; if (mEmptyLayout == null) { mEmptyLayout = new FrameLayout(emptyView.getContext()); final LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); final ViewGroup.LayoutParams lp = emptyView.getLayoutParams(); if (lp != null) { layoutParams.width = lp.width; layoutParams.height = lp.height; } mEmptyLayout.setLayoutParams(layoutParams); insert = true; } mEmptyLayout.removeAllViews(); mEmptyLayout.addView(emptyView); mIsUseEmpty = true; if (insert) { if (getEmptyViewCount() == 1) { int position = 0; if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) { position++; } notifyItemInserted(position); } } }
@Override public int getItemCount() { int count; if (getEmptyViewCount() == 1) { count = 1; if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) { count++; } if (mFootAndEmptyEnable && getFooterLayoutCount() != 0) { count++; } } else { count = getHeaderLayoutCount() + mData.size() + getFooterLayoutCount() + getLoadMoreViewCount(); } return count; }
@Override public int getItemViewType(int position) { if (getEmptyViewCount() == 1) { boolean header = mHeadAndEmptyEnable && getHeaderLayoutCount() != 0; switch (position) {