Search in sources :

Example 1 with VideosListEntity

use of com.github.obsessive.simplifyreader.bean.VideosListEntity 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);
}
Also used : ImageButton(android.widget.ImageButton) MultiItemRowListAdapter(com.github.obsessive.library.adapter.MultiItemRowListAdapter) ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) VideosListEntity(com.github.obsessive.simplifyreader.bean.VideosListEntity) ResponseVideosListEntity(com.github.obsessive.simplifyreader.bean.ResponseVideosListEntity) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator) VideosListView(com.github.obsessive.simplifyreader.view.VideosListView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) LoadMoreListView(com.github.obsessive.simplifyreader.widgets.LoadMoreListView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 InjectView (butterknife.InjectView)1 MultiItemRowListAdapter (com.github.obsessive.library.adapter.MultiItemRowListAdapter)1 ViewHolderBase (com.github.obsessive.library.adapter.ViewHolderBase)1 ViewHolderCreator (com.github.obsessive.library.adapter.ViewHolderCreator)1 ResponseVideosListEntity (com.github.obsessive.simplifyreader.bean.ResponseVideosListEntity)1 VideosListEntity (com.github.obsessive.simplifyreader.bean.VideosListEntity)1 VideosListView (com.github.obsessive.simplifyreader.view.VideosListView)1 LoadMoreListView (com.github.obsessive.simplifyreader.widgets.LoadMoreListView)1