Search in sources :

Example 1 with CoinAdapter

use of com.example.jingbin.cloudreader.adapter.CoinAdapter 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)

Example 2 with CoinAdapter

use of com.example.jingbin.cloudreader.adapter.CoinAdapter in project CloudReader by youlookwhat.

the class CoinDetailFragment method initRefreshView.

private void initRefreshView() {
    headerBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_coin_detail, (ViewGroup) bindingView.xrvWan.getParent(), false);
    RefreshHelper.initLinear(bindingView.xrvWan, true, 1);
    RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
    mAdapter = new CoinAdapter(activity, false);
    bindingView.xrvWan.setAdapter(mAdapter);
    bindingView.xrvWan.addHeaderView(headerBinding.getRoot());
    headerBinding.tvHeaderCoin.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);
                    getCoinLog();
                }
            }, 150);
        }
    });
    bindingView.xrvWan.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            if (!bindingView.srlWan.isRefreshing()) {
                int page = viewModel.getPage();
                viewModel.setPage(++page);
                getCoinLog();
            } else {
                bindingView.xrvWan.loadMoreComplete();
            }
        }
    });
    UserUtil.getUserInfo(new OnUserInfoListener() {

        @Override
        public void onSuccess(User user) {
            if (user != null) {
                headerBinding.tvHeaderCoin.setText(String.valueOf(user.getCoinCount()));
            }
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) OnUserInfoListener(com.example.jingbin.cloudreader.data.OnUserInfoListener) User(me.jingbin.bymvvm.room.User) CoinAdapter(com.example.jingbin.cloudreader.adapter.CoinAdapter) ViewGroup(android.view.ViewGroup) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout)

Aggregations

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