use of com.github.obsessive.library.adapter.ViewHolderCreator in project SimplifyReader by chentao0707.
the class VideosListFragment method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
mListViewAdapter = new ListViewDataAdapter<VideosListEntity>(new ViewHolderCreator<VideosListEntity>() {
@Override
public ViewHolderBase<VideosListEntity> createViewHolder(int position) {
return new ViewHolderBase<VideosListEntity>() {
TextView mItemTitle;
ImageView mItemImage;
ImageButton mItemPlay;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_videos_card, null);
mItemTitle = ButterKnife.findById(convertView, R.id.list_item_videos_card_title);
mItemImage = ButterKnife.findById(convertView, R.id.list_item_videos_card_image);
mItemPlay = ButterKnife.findById(convertView, R.id.list_item_videos_card_play);
return convertView;
}
@Override
public void showData(final int position, VideosListEntity itemData) {
if (null != itemData) {
if (!CommonUtils.isEmpty(itemData.getTitle())) {
mItemTitle.setText(CommonUtils.decodeUnicodeStr(itemData.getTitle()));
}
if (!CommonUtils.isEmpty(itemData.getThumbnail_v2())) {
ImageLoader.getInstance().displayImage(itemData.getThumbnail_v2(), mItemImage);
}
mItemPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListViewAdapter) {
if (position >= 0 && position < mListViewAdapter.getDataList().size()) {
mVideosListPresenter.onItemClickListener(position, mListViewAdapter.getDataList().get(position));
}
}
}
});
}
}
};
}
});
mMultiItemRowListAdapter = new MultiItemRowListAdapter(mContext, mListViewAdapter, 1, 0);
mListView.setAdapter(mMultiItemRowListAdapter);
mListView.setOnLoadMoreListener(this);
mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.gplus_color_1), getResources().getColor(R.color.gplus_color_2), getResources().getColor(R.color.gplus_color_3), getResources().getColor(R.color.gplus_color_4));
mSwipeRefreshLayout.setOnRefreshListener(this);
}
Aggregations