Search in sources :

Example 1 with CoinLogBean

use of com.example.jingbin.cloudreader.bean.CoinLogBean in project CloudReader by youlookwhat.

the class CoinRankFragment method initRefreshView.

private void initRefreshView() {
    headerBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_coin_rank, (ViewGroup) bindingView.xrvWan.getParent(), false);
    RefreshHelper.initLinear(bindingView.xrvWan, true, 1);
    RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
    mAdapter = new CoinAdapter(activity, true);
    bindingView.xrvWan.setAdapter(mAdapter);
    bindingView.xrvWan.addHeaderView(headerBinding.getRoot());
    headerBinding.ivCoinRank.setVisibility(View.INVISIBLE);
    bindingView.srlWan.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            bindingView.xrvWan.postDelayed(new Runnable() {

                @Override
                public void run() {
                    viewModel.setPage(1);
                    getCoinRank();
                }
            }, 150);
        }
    });
    bindingView.xrvWan.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            if (!bindingView.srlWan.isRefreshing()) {
                int page = viewModel.getPage();
                viewModel.setPage(++page);
                getCoinRank();
            } else {
                bindingView.xrvWan.loadMoreComplete();
            }
        }
    });
    bindingView.xrvWan.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        protected void onSingleClick(View v, int position) {
            CoinLogBean bean = mAdapter.getItemData(position);
            MyShareActivity.start(activity, DataUtil.getName(bean.getUsername(), bean.getNickname()), bean.getUserId());
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) CoinAdapter(com.example.jingbin.cloudreader.adapter.CoinAdapter) OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) ViewGroup(android.view.ViewGroup) CoinLogBean(com.example.jingbin.cloudreader.bean.CoinLogBean) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) ByRecyclerView(me.jingbin.library.ByRecyclerView) View(android.view.View)

Aggregations

View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 CoinAdapter (com.example.jingbin.cloudreader.adapter.CoinAdapter)1 CoinLogBean (com.example.jingbin.cloudreader.bean.CoinLogBean)1 ByRecyclerView (me.jingbin.library.ByRecyclerView)1 OnItemFilterClickListener (me.jingbin.library.view.OnItemFilterClickListener)1