本文整理匯總了Java中com.lqr.adapter.LQRAdapterForRecyclerView.getHeaderAndFooterAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java LQRAdapterForRecyclerView.getHeaderAndFooterAdapter方法的具體用法?Java LQRAdapterForRecyclerView.getHeaderAndFooterAdapter怎麽用?Java LQRAdapterForRecyclerView.getHeaderAndFooterAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.lqr.adapter.LQRAdapterForRecyclerView
的用法示例。
在下文中一共展示了LQRAdapterForRecyclerView.getHeaderAndFooterAdapter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAdapter
import com.lqr.adapter.LQRAdapterForRecyclerView; //導入方法依賴的package包/類
private void setAdapter() {
if (mAdapter == null) {
LQRAdapterForRecyclerView adapter = new LQRAdapterForRecyclerView<Friend>(mContext, mData, R.layout.item_contact) {
@Override
public void convert(LQRViewHolderForRecyclerView helper, Friend item, int position) {
helper.setText(R.id.tvName, item.getDisplayName());
ImageView ivHeader = helper.getView(R.id.ivHeader);
Glide.with(mContext).load(item.getPortraitUri()).centerCrop().into(ivHeader);
String str = "";
//得到當前字母
String currentLetter = item.getDisplayNameSpelling().charAt(0) + "";
if (position == 0) {
str = currentLetter;
} else {
//得到上一個字母
String preLetter = mData.get(position - 1).getDisplayNameSpelling().charAt(0) + "";
//如果和上一個字母的首字母不同則顯示字母欄
if (!preLetter.equalsIgnoreCase(currentLetter)) {
str = currentLetter;
}
}
int nextIndex = position + 1;
if (nextIndex < mData.size() - 1) {
//得到下一個字母
String nextLetter = mData.get(nextIndex).getDisplayNameSpelling().charAt(0) + "";
//如果和下一個字母的首字母不同則隱藏下劃線
if (!nextLetter.equalsIgnoreCase(currentLetter)) {
helper.setViewVisibility(R.id.vLine, View.INVISIBLE);
} else {
helper.setViewVisibility(R.id.vLine, View.VISIBLE);
}
} else {
helper.setViewVisibility(R.id.vLine, View.INVISIBLE);
}
if (position == mData.size() - 1) {
helper.setViewVisibility(R.id.vLine, View.GONE);
}
//根據str是否為空決定字母欄是否顯示
if (TextUtils.isEmpty(str)) {
helper.setViewVisibility(R.id.tvIndex, View.GONE);
} else {
helper.setViewVisibility(R.id.tvIndex, View.VISIBLE);
helper.setText(R.id.tvIndex, str);
}
}
};
adapter.addHeaderView(getView().getHeaderView());
adapter.addFooterView(getView().getFooterView());
mAdapter = adapter.getHeaderAndFooterAdapter();
getView().getRvContacts().setAdapter(mAdapter);
}
((LQRAdapterForRecyclerView) mAdapter.getInnerAdapter()).setOnItemClickListener((lqrViewHolder, viewGroup, view, i) -> {
Intent intent = new Intent(mContext, UserInfoActivity.class);
intent.putExtra("userInfo", DBManager.getInstance().getUserInfo(mData.get(i - 1).getUserId()));//-1是因為有頭部
mContext.jumpToActivity(intent);
});
}