Search in sources :

Example 1 with ModeratorAdapter

use of me.ccrama.redditslide.Adapters.ModeratorAdapter in project Slide by ccrama.

the class ModPage method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false);
    RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content));
    final PreCachingLayoutManager mLayoutManager;
    mLayoutManager = new PreCachingLayoutManager(getActivity());
    rv.setLayoutManager(mLayoutManager);
    v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
    final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getActivity()));
    // If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
    // So, we estimate the height of the header in dp
    mSwipeRefreshLayout.setProgressViewOffset(false, Constants.TAB_HEADER_VIEW_OFFSET - Constants.PTR_OFFSET_TOP, Constants.TAB_HEADER_VIEW_OFFSET + Constants.PTR_OFFSET_BOTTOM);
    mSwipeRefreshLayout.post(new Runnable() {

        @Override
        public void run() {
            mSwipeRefreshLayout.setRefreshing(true);
        }
    });
    posts = new ModeratorPosts(id, sub);
    adapter = new ModeratorAdapter(getActivity(), posts, rv);
    rv.setAdapter(adapter);
    rv.setOnScrollListener(new ToolbarScrollHideHandler(((ModQueue) getActivity()).mToolbar, (getActivity()).findViewById(R.id.header)));
    posts.bindAdapter(adapter, mSwipeRefreshLayout);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            posts.loadMore(adapter, id, sub);
        }
    });
    return v;
}
Also used : ModQueue(me.ccrama.redditslide.Activities.ModQueue) ModeratorAdapter(me.ccrama.redditslide.Adapters.ModeratorAdapter) ModeratorPosts(me.ccrama.redditslide.Adapters.ModeratorPosts) RecyclerView(android.support.v7.widget.RecyclerView) PreCachingLayoutManager(me.ccrama.redditslide.Views.PreCachingLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ToolbarScrollHideHandler(me.ccrama.redditslide.handler.ToolbarScrollHideHandler)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ModQueue (me.ccrama.redditslide.Activities.ModQueue)1 ModeratorAdapter (me.ccrama.redditslide.Adapters.ModeratorAdapter)1 ModeratorPosts (me.ccrama.redditslide.Adapters.ModeratorPosts)1 PreCachingLayoutManager (me.ccrama.redditslide.Views.PreCachingLayoutManager)1 ToolbarScrollHideHandler (me.ccrama.redditslide.handler.ToolbarScrollHideHandler)1