Search in sources :

Example 6 with ViewHolderBase

use of com.github.obsessive.library.adapter.ViewHolderBase 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)6 View (android.view.View)6 InjectView (butterknife.InjectView)6 ViewHolderBase (com.github.obsessive.library.adapter.ViewHolderBase)6 ViewHolderCreator (com.github.obsessive.library.adapter.ViewHolderCreator)6 ImageView (android.widget.ImageView)5 AdapterView (android.widget.AdapterView)4 TextView (android.widget.TextView)4 ListView (android.widget.ListView)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 GridView (android.widget.GridView)1 ImageButton (android.widget.ImageButton)1 MultiItemRowListAdapter (com.github.obsessive.library.adapter.MultiItemRowListAdapter)1 BaseWebActivity (com.github.obsessive.library.base.BaseWebActivity)1 ImageBucket (com.github.obsessive.library.picker.ImageBucket)1 ImageItem (com.github.obsessive.library.picker.ImageItem)1