Search in sources :

Example 1 with OnItemFilterClickListener

use of me.jingbin.library.view.OnItemFilterClickListener in project CloudReader by youlookwhat.

the class TreeFragment method initRefreshView.

private void initRefreshView() {
    RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
    bindingView.srlWan.setOnRefreshListener(() -> bindingView.srlWan.postDelayed(this::getTree, 150));
    LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
    bindingView.xrvWan.setLayoutManager(layoutManager);
    mTreeAdapter = new TreeAdapter(activity);
    bindingView.xrvWan.setAdapter(mTreeAdapter);
    HeaderItemTreeBinding oneBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_item_tree, null, false);
    bindingView.xrvWan.addHeaderView(oneBinding.getRoot());
    oneBinding.tvPosition.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mTreeAdapter.isSelect()) {
                GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("选择类别");
                mTreeAdapter.setSelect(true);
                mTreeAdapter.notifyDataSetChanged();
                bindingView.xrvWan.addItemDecoration(new SpacesItemDecoration(activity).setNoShowDivider(1, 0).setDrawable(R.drawable.shape_line));
            } else {
                LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("发现页内容订制");
                mTreeAdapter.setSelect(false);
                mTreeAdapter.notifyDataSetChanged();
                if (bindingView.xrvWan.getItemDecorationCount() > 0) {
                    bindingView.xrvWan.removeItemDecorationAt(0);
                }
            }
        }
    });
    bindingView.xrvWan.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            if (mTreeAdapter.isSelect()) {
                if (mTreeAdapter.getSelectedPosition() == position) {
                    ToastUtil.showToastLong("当前已经是\"" + mTreeAdapter.getData().get(position).getName() + "\"");
                    return;
                }
                LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("发现页内容订制");
                mTreeAdapter.setSelect(false);
                mTreeAdapter.notifyDataSetChanged();
                if (bindingView.xrvWan.getItemDecorationCount() > 0) {
                    bindingView.xrvWan.removeItemDecorationAt(0);
                }
                layoutManager.scrollToPositionWithOffset(position + bindingView.xrvWan.getCustomTopItemViewCount(), 0);
                RxBus.getDefault().post(RxCodeConstants.FIND_CUSTOM, position);
            }
        }
    });
}
Also used : HeaderItemTreeBinding(com.example.jingbin.cloudreader.databinding.HeaderItemTreeBinding) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) TreeAdapter(com.example.jingbin.cloudreader.adapter.TreeAdapter) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View)

Example 2 with OnItemFilterClickListener

use of me.jingbin.library.view.OnItemFilterClickListener in project CloudReader by youlookwhat.

the class FilmComingFragment method initRefreshView.

private void initRefreshView() {
    bindingView.srlWan.setColorSchemeColors(CommonUtils.getColor(activity, R.color.colorTheme));
    adapter = new FilmComingAdapter(activity);
    bindingView.xrvWan.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    bindingView.xrvWan.setItemAnimator(null);
    bindingView.xrvWan.setHasFixedSize(true);
    bindingView.xrvWan.setLoadMoreEnabled(true);
    viewModel.bookType.set(mType);
    bindingView.xrvWan.setAdapter(adapter);
    bindingView.xrvWan.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            ImageView imageView = v.findViewById(R.id.iv_top_photo);
            ComingFilmBean.MoviecomingsBean bean = adapter.getItemData(position);
            FilmItemBean filmItemBean = new FilmItemBean();
            filmItemBean.setId(bean.getId());
            filmItemBean.setDN(bean.getDirector());
            filmItemBean.setTCn(bean.getTitle());
            filmItemBean.setTEn(bean.getReleaseDate());
            filmItemBean.setMovieType(bean.getType());
            filmItemBean.setImg(bean.getImage());
            filmItemBean.setLocationName(bean.getLocationName());
            String actor1 = bean.getActor1();
            String actor2 = bean.getActor2();
            if (!TextUtils.isEmpty(actor2)) {
                actor1 = actor1 + " / " + actor2;
            }
            filmItemBean.setActors(actor1);
            FilmDetailActivity.start(activity, filmItemBean, imageView);
        }
    });
    bindingView.srlWan.setOnRefreshListener(this::getHotFilm);
}
Also used : OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) FilmItemBean(com.example.jingbin.cloudreader.bean.moviechild.FilmItemBean) FilmComingAdapter(com.example.jingbin.cloudreader.adapter.FilmComingAdapter) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

Example 3 with OnItemFilterClickListener

use of me.jingbin.library.view.OnItemFilterClickListener 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 4 with OnItemFilterClickListener

use of me.jingbin.library.view.OnItemFilterClickListener in project CloudReader by youlookwhat.

the class FilmShowingFragment method initRefreshView.

private void initRefreshView() {
    viewModel.bookType.set(mType);
    bindingView.srlWan.setColorSchemeColors(CommonUtils.getColor(activity, R.color.colorTheme));
    adapter = new FilmAdapter(activity);
    bindingView.xrvWan.setLayoutManager(new LinearLayoutManager(activity));
    bindingView.xrvWan.setItemAnimator(null);
    bindingView.xrvWan.setHasFixedSize(true);
    bindingView.xrvWan.setLoadMoreEnabled(true);
    bindingView.xrvWan.setAdapter(adapter);
    bindingView.xrvWan.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            ImageView imageView = v.findViewById(R.id.iv_one_photo);
            FilmItemBean itemData = adapter.getItemData(position);
            FilmDetailActivity.start(activity, itemData, imageView);
        }
    });
    bindingView.srlWan.setOnRefreshListener(this::getHotFilm);
}
Also used : OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) FilmItemBean(com.example.jingbin.cloudreader.bean.moviechild.FilmItemBean) FilmAdapter(com.example.jingbin.cloudreader.adapter.FilmAdapter) ImageView(android.widget.ImageView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View)

Example 5 with OnItemFilterClickListener

use of me.jingbin.library.view.OnItemFilterClickListener in project CloudReader by youlookwhat.

the class WelfareFragment method initRecycleView.

private void initRecycleView() {
    int width = (DensityUtil.getDisplayWidth() - 36) / 2;
    mWelfareAdapter = new BaseBindingAdapter<GankIoDataBean.ResultBean, ItemWelfareBinding>(R.layout.item_welfare) {

        @Override
        protected void bindView(BaseBindingHolder holder, GankIoDataBean.ResultBean bean, ItemWelfareBinding binding, int position) {
            DensityUtil.setWidthHeight(binding.ivWelfare, width, 852 / 1280f);
            DensityUtil.setWidthHeight(binding.viewMask, width, 852 / 1280f);
            binding.setBean(bean);
        }
    };
    RefreshHelper.initStaggeredGrid(bindingView.xrvWelfare, 2, 12);
    bindingView.xrvWelfare.setAdapter(mWelfareAdapter);
    bindingView.xrvWelfare.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            int page = viewModel.getPage();
            page++;
            viewModel.setPage(page);
            loadWelfareData();
        }
    }, 300);
    bindingView.xrvWelfare.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            ViewBigImageActivity.startImageList(getContext(), position, imgList, imgTitleList);
        }
    });
    viewModel.getImageAndTitle().observe(getViewLifecycleOwner(), new Observer<ArrayList<ArrayList<String>>>() {

        @Override
        public void onChanged(@Nullable ArrayList<ArrayList<String>> arrayLists) {
            if (arrayLists != null && arrayLists.size() == 2) {
                imgList.addAll(arrayLists.get(0));
                imgTitleList.addAll(arrayLists.get(1));
            }
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) ArrayList(java.util.ArrayList) ByRecyclerView(me.jingbin.library.ByRecyclerView) View(android.view.View) GankIoDataBean(com.example.jingbin.cloudreader.bean.GankIoDataBean) ItemWelfareBinding(com.example.jingbin.cloudreader.databinding.ItemWelfareBinding) BaseBindingHolder(me.jingbin.bymvvm.adapter.BaseBindingHolder)

Aggregations

View (android.view.View)6 OnItemFilterClickListener (me.jingbin.library.view.OnItemFilterClickListener)6 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 ByRecyclerView (me.jingbin.library.ByRecyclerView)3 ImageView (android.widget.ImageView)2 FilmItemBean (com.example.jingbin.cloudreader.bean.moviechild.FilmItemBean)2 ViewGroup (android.view.ViewGroup)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 CoinAdapter (com.example.jingbin.cloudreader.adapter.CoinAdapter)1 FilmAdapter (com.example.jingbin.cloudreader.adapter.FilmAdapter)1 FilmComingAdapter (com.example.jingbin.cloudreader.adapter.FilmComingAdapter)1 NavigationAdapter (com.example.jingbin.cloudreader.adapter.NavigationAdapter)1 NavigationContentAdapter (com.example.jingbin.cloudreader.adapter.NavigationContentAdapter)1 TreeAdapter (com.example.jingbin.cloudreader.adapter.TreeAdapter)1 CoinLogBean (com.example.jingbin.cloudreader.bean.CoinLogBean)1 GankIoDataBean (com.example.jingbin.cloudreader.bean.GankIoDataBean)1 ArticlesBean (com.example.jingbin.cloudreader.bean.wanandroid.ArticlesBean)1