Search in sources :

Example 6 with StatusAdapter

use of com.funstill.kelefun.adapter.StatusAdapter in project keleFanfou by kelefun.

the class StatusListFragment method initView.

protected void initView(View view) {
    SwipeRefreshLayout mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.line_swipe_refresh);
    // 禁用下拉刷新
    mRefreshLayout.setEnabled(false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.line_recycler);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new StatusAdapter(getActivity(), data);
    mRecyclerView.setAdapter(mAdapter);
    Map<String, String> map = new ArrayMap<>();
    map.put("id", tuserId);
    map.put("page", "1");
    getUserTimeLineStatus(map);
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE && (mLayoutManager.findLastVisibleItemPosition() + 1 == mLayoutManager.getItemCount()) && !isLoadingMore) {
                isLoadingMore = true;
                if (data.size() > 0) {
                    Map<String, String> loadMoreParam = new ArrayMap<>();
                    loadMoreParam.put("max_id", data.get(data.size() - 1).getId());
                    loadMoreParam.put("count", "20");
                    loadMoreParam.put("id", tuserId);
                    loadMoreHomeLineStatus(loadMoreParam);
                }
            }
        }
    });
}
Also used : StatusAdapter(com.funstill.kelefun.adapter.StatusAdapter) ArrayMap(android.util.ArrayMap) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) Map(java.util.Map) ArrayMap(android.util.ArrayMap)

Example 7 with StatusAdapter

use of com.funstill.kelefun.adapter.StatusAdapter in project keleFanfou by kelefun.

the class HomeLineFragmentChild method initView.

private void initView(View view) {
    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    mToolbar.setTitle("TIMELINE");
    mRecyclerView = (RecyclerView) view.findViewById(R.id.line_recycler);
    mLayoutManager = new LinearLayoutManager(_mActivity);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
    mRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.colorOrange, R.color.colorRed);
    mRefreshLayout.setOnRefreshListener(this);
    mRefreshLayout.post(() -> mRefreshLayout.setRefreshing(true));
    mAdapter = new StatusAdapter(getActivity(), data);
    mRecyclerView.setAdapter(mAdapter);
    // 初始化数据
    Map<String, String> map = new ArrayMap<>();
    map.put("page", "1");
    getHomeLineStatus(map);
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            mScrollTotal += dy;
            mInAtTop = mScrollTotal <= 0;
        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE && (mLayoutManager.findLastVisibleItemPosition() + 1 == mLayoutManager.getItemCount()) && !isLoadingMore) {
                isLoadingMore = true;
                // 处理逻辑
                if (data.size() > 0) {
                    Map<String, String> loadMoreParam = new ArrayMap<>();
                    loadMoreParam.put("max_id", data.get(data.size() - 1).getId());
                    loadMoreParam.put("count", "20");
                    loadMoreHomeLineStatus(loadMoreParam);
                }
            }
        }
    });
}
Also used : StatusAdapter(com.funstill.kelefun.adapter.StatusAdapter) ArrayMap(android.util.ArrayMap) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Map(java.util.Map) ArrayMap(android.util.ArrayMap)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 RecyclerView (android.support.v7.widget.RecyclerView)7 ArrayMap (android.util.ArrayMap)7 StatusAdapter (com.funstill.kelefun.adapter.StatusAdapter)7 Map (java.util.Map)7 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)2