Last active
September 25, 2016 06:51
-
-
Save oatpano/bc162df4f0f2aeafbb037272056e733d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecyclerViewAdapter extends RecyclerView.Adapter<DataObjectHolder> { | |
public RecyclerViewAdapter() { | |
} | |
@Override | |
public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
Timber.i("onCreateViewHolder"); | |
View view = new ChatItemView(parent.getContext()); | |
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
view.setLayoutParams(lp); | |
DataObjectHolder dataObjectHolder = new DataObjectHolder(view); | |
return dataObjectHolder; | |
} | |
@Override | |
public void onBindViewHolder(DataObjectHolder holder, int position) { | |
int viewHeight = chatItemView.getMeasuredHeight(); | |
if (isShowEmptyView){ | |
if (viewHeight < recyclerViewHeight){ | |
chatItemView.setEmptyView(View.VISIBLE, recyclerViewHeight - viewHeight); //ผลลัพธ์ของ recyclerViewHeight - viewHeight ที่ค่า height ของ empty view | |
} | |
else{ | |
chatItemView.setEmptyView(View.GONE, 0); | |
} | |
} | |
else{ | |
chatItemView.setEmptyView(View.GONE, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment