Search in sources :

Example 26 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project Douya by DreaminginCodeZH.

the class ProfileFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mProfileResource = ProfileResource.attachTo(mUserIdOrUid, mSimpleUser, mUser, this);
    mScrollLayout.setListener(new ProfileLayout.Listener() {

        @Override
        public void onEnterAnimationEnd() {
        }

        @Override
        public void onExitAnimationEnd() {
            getActivity().finish();
        }
    });
    if (savedInstanceState == null) {
        mScrollLayout.enter();
    }
    mDismissView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            exit();
        }
    });
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    activity.getSupportActionBar().setTitle(null);
    if (mProfileResource.hasUser()) {
        mHeaderLayout.bindUser(mProfileResource.getUser());
    } else if (mProfileResource.hasSimpleUser()) {
        mHeaderLayout.bindSimpleUser(mProfileResource.getSimpleUser());
    }
    mHeaderLayout.setListener(this);
    if (ViewUtils.hasSw600Dp(activity)) {
        mContentList.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    } else {
        mContentList.setLayoutManager(new LinearLayoutManager(activity));
    }
    mProfileAdapter = new ProfileAdapter(this);
    mContentList.setAdapter(mProfileAdapter);
    if (mProfileResource.isLoaded()) {
        mProfileResource.notifyChangedIfLoaded();
    } else {
        mContentStateLayout.setLoading();
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 27 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project BaseRecyclerViewAdapterHelper by CymChad.

the class BaseQuickAdapter method disableLoadMoreIfNotFullPage.

/**
     * check if full page after {@link #setNewData(List)}, if full, it will enable load more again.
     *
     * @param recyclerView your recyclerView
     * @see #setNewData(List)
     */
public void disableLoadMoreIfNotFullPage(RecyclerView recyclerView) {
    if (recyclerView == null)
        return;
    RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
    if (manager == null)
        return;
    if (manager instanceof LinearLayoutManager) {
        final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {

            @Override
            public void run() {
                if ((linearLayoutManager.findLastCompletelyVisibleItemPosition() + 1) != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    } else if (manager instanceof StaggeredGridLayoutManager) {
        final StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) manager;
        recyclerView.postDelayed(new Runnable() {

            @Override
            public void run() {
                final int[] positions = new int[staggeredGridLayoutManager.getSpanCount()];
                staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(positions);
                int pos = getTheBiggestNumber(positions) + 1;
                if (pos != getItemCount()) {
                    setEnableLoadMore(true);
                }
            }
        }, 50);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 28 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project SwipeToLoadLayout by Aspsine.

the class TwitterRecyclerFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
    recyclerView = (RecyclerView) view.findViewById(R.id.swipe_target);
    RecyclerView.LayoutManager layoutManager = null;
    if (mType == TYPE_LINEAR) {
        layoutManager = new LinearLayoutManager(getContext());
    } else if (mType == TYPE_GRID) {
        layoutManager = new GridLayoutManager(getContext(), 2);
    } else if (mType == TYPE_STAGGERED_GRID) {
        layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    }
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(mAdapter);
    swipeToLoadLayout.setOnRefreshListener(this);
    swipeToLoadLayout.setOnLoadMoreListener(this);
    recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                if (!ViewCompat.canScrollVertically(recyclerView, 1)) {
                    swipeToLoadLayout.setLoadingMore(true);
                }
            }
        }
    });
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 29 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project AndroidDevelop by 7449.

the class SearchFragment method initActivityCreated.

@Override
protected void initActivityCreated() {
    FloatingActionButton mFAB = (FloatingActionButton) getActivity().findViewById(R.id.fa_btn);
    mFAB.setOnClickListener(this);
    showExplanation();
    mPresenter = new SearchPresenterImpl(this);
    mAdapter = new XRecyclerViewAdapter<>();
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(Constant.RECYCLERVIEW_LISTVIEW, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.setAdapter(mAdapter.setLayoutId(R.layout.item_search).onXBind(this));
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) SearchPresenterImpl(com.codekk.search.presenter.SearchPresenterImpl)

Example 30 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project AndroidDevelop by 7449.

the class MainActivity method initCreate.

@Override
protected void initCreate(Bundle savedInstanceState) {
    toolbar.setTitle("推荐");
    setSupportActionBar(toolbar);
    presenter = new RecommendPresenterImpl(this);
    adapter = new RecommendAdapter();
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getBaseContext(), R.color.colorPrimary));
    swipeRefreshLayout.post(new Runnable() {

        @Override
        public void run() {
            onRefresh();
        }
    });
}
Also used : RecommendPresenterImpl(com.bilirecommendui.main.presenter.RecommendPresenterImpl) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecommendAdapter(com.bilirecommendui.main.widget.adapter.RecommendAdapter)

Aggregations

StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)71 RecyclerView (android.support.v7.widget.RecyclerView)47 View (android.view.View)32 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)30 GridLayoutManager (android.support.v7.widget.GridLayoutManager)22 Handler (android.os.Handler)7 TextView (android.widget.TextView)7 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)6 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)5 ViewGroup (android.view.ViewGroup)5 AbsListView (android.widget.AbsListView)5 ScrollView (android.widget.ScrollView)5 BindView (butterknife.BindView)5 Intent (android.content.Intent)4 WebView (android.webkit.WebView)4 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 Nullable (android.support.annotation.Nullable)3 MenuItem (android.view.MenuItem)3 RefreshListenerAdapter (com.lcodecore.tkrefreshlayout.RefreshListenerAdapter)3