Search in sources :

Example 1 with GankAndroidAdapter

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

the class CustomFragment method initRecyclerView.

private void initRecyclerView() {
    adapter = new GankAndroidAdapter();
    View mHeaderView = LayoutInflater.from(getContext()).inflate(R.layout.header_item_gank_custom, (ViewGroup) bindingView.xrvAndroid.getParent(), false);
    bindingView.xrvAndroid.addHeaderView(mHeaderView);
    initHeader(mHeaderView);
    RefreshHelper.initLinear(bindingView.xrvAndroid, false);
    bindingView.xrvAndroid.setAdapter(adapter);
    bindingView.xrvAndroid.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            int page = viewModel.getPage();
            page++;
            viewModel.setPage(page);
            loadCustomData();
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) GankAndroidAdapter(com.example.jingbin.cloudreader.adapter.GankAndroidAdapter) ByRecyclerView(me.jingbin.library.ByRecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with GankAndroidAdapter

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

the class GankHomeFragment method initRecyclerView.

private void initRecyclerView() {
    mAdapter = new GankAndroidAdapter();
    mAdapter.setAllType(true);
    mHeaderBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.header_item_everyday, null, false);
    bindingView.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    bindingView.recyclerView.setLoadMoreEnabled(true);
    bindingView.recyclerView.setHasFixedSize(false);
    bindingView.recyclerView.addHeaderView(mHeaderBinding.getRoot());
    // bindingView.recyclerView.setAdapter(mAdapter);
    // 显示日期,去掉第一位的"0"
    String day = getTodayTime().get(2);
    mHeaderBinding.includeEveryday.tvDailyText.setText(day.indexOf("0") == 0 ? day.replace("0", "") : day);
    mHeaderBinding.includeEveryday.ibXiandu.setOnClickListener(listener);
    mHeaderBinding.includeEveryday.ibWanAndroid.setOnClickListener(listener);
    mHeaderBinding.includeEveryday.ibMovieHot.setOnClickListener(listener);
    mHeaderBinding.includeEveryday.flEveryday.setOnClickListener(listener);
    DensityUtil.setWidthHeight(mHeaderBinding.banner, DensityUtil.getDisplayWidth(), 2.2f);
    onObserveViewModel();
    showItemSkeleton();
}
Also used : GankAndroidAdapter(com.example.jingbin.cloudreader.adapter.GankAndroidAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 3 with GankAndroidAdapter

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

the class AndroidFragment method initRecyclerView.

private void initRecyclerView() {
    adapter = new GankAndroidAdapter();
    // 加了分割线,滚动条才会置顶
    SpacesItemDecoration itemDecoration = new SpacesItemDecoration(activity, SpacesItemDecoration.VERTICAL, 1);
    itemDecoration.setDrawable(R.drawable.shape_transparent);
    RefreshHelper.initLinear(bindingView.xrvAndroid, false).addItemDecoration(itemDecoration);
    bindingView.xrvAndroid.setAdapter(adapter);
    bindingView.xrvAndroid.setOnRefreshListener(new ByRecyclerView.OnRefreshListener() {

        @Override
        public void onRefresh() {
            viewModel.setPage(1);
            loadAndroidData();
        }
    });
    bindingView.xrvAndroid.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            int page = viewModel.getPage();
            page++;
            viewModel.setPage(page);
            loadAndroidData();
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) GankAndroidAdapter(com.example.jingbin.cloudreader.adapter.GankAndroidAdapter) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration)

Aggregations

GankAndroidAdapter (com.example.jingbin.cloudreader.adapter.GankAndroidAdapter)3 ByRecyclerView (me.jingbin.library.ByRecyclerView)2 View (android.view.View)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 SpacesItemDecoration (me.jingbin.library.decoration.SpacesItemDecoration)1