Search in sources :

Example 1 with HostRankAdapter

use of cn.nicolite.palm300heroes.view.adapter.HostRankAdapter in project Palm300Heroes by nicolite.

the class HostRankFragment method doBusiness.

@Override
protected void doBusiness() {
    lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new HostRankAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    if (type == TYPE_RANK_TITLE) {
        lRecyclerView.setLoadMoreEnabled(false);
    }
    hostRankPresenter = new HostRankPresenter(this, this);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            switch(type) {
                case TYPE_RANK_TITLE:
                    hostRankPresenter.showRankTitle();
                    break;
                case TYPE_RANK_LIST:
                    hostRankPresenter.showRankList(index);
                    break;
            }
        }
    });
    lRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            switch(type) {
                case TYPE_RANK_TITLE:
                    break;
                case TYPE_RANK_LIST:
                    currentPage++;
                    hostRankPresenter.loadMore(index, currentPage);
                    break;
            }
        }
    });
    lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            RecordRank.RankBean.ListBean list = dataList.get(position);
            switch(type) {
                case TYPE_RANK_TITLE:
                    Bundle bundle = new Bundle();
                    bundle.putInt("type", ContainerActivity.TYPE_RECORD_RANK_LIST);
                    bundle.putString("title", list.getName());
                    bundle.putString("extra", String.valueOf(list.getIndex()));
                    startActivity(ContainerActivity.class, bundle);
                    break;
                case TYPE_RANK_LIST:
                    break;
            }
        }
    });
    if (isFirstVisible && ListUtils.isEmpty(dataList)) {
        lRecyclerView.forceToRefresh();
    }
}
Also used : OnLoadMoreListener(com.github.jdsjlzx.interfaces.OnLoadMoreListener) HostRankAdapter(cn.nicolite.palm300heroes.view.adapter.HostRankAdapter) RecordRank(cn.nicolite.palm300heroes.model.bean.RecordRank) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) HostRankPresenter(cn.nicolite.palm300heroes.presenter.HostRankPresenter) Bundle(android.os.Bundle) ContainerActivity(cn.nicolite.palm300heroes.view.activity.ContainerActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) TextView(android.widget.TextView) IHostRankView(cn.nicolite.palm300heroes.view.iview.IHostRankView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Aggregations

Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 RecordRank (cn.nicolite.palm300heroes.model.bean.RecordRank)1 HostRankPresenter (cn.nicolite.palm300heroes.presenter.HostRankPresenter)1 ContainerActivity (cn.nicolite.palm300heroes.view.activity.ContainerActivity)1 HostRankAdapter (cn.nicolite.palm300heroes.view.adapter.HostRankAdapter)1 IHostRankView (cn.nicolite.palm300heroes.view.iview.IHostRankView)1 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)1 OnLoadMoreListener (com.github.jdsjlzx.interfaces.OnLoadMoreListener)1 OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)1 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)1 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)1