Search in sources :

Example 96 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project android by nextcloud.

the class ExtendedListFragment method saveIndexAndTopPosition.

/*
     * Save index and top position
     */
protected void saveIndexAndTopPosition(int index) {
    mIndexes.add(index);
    RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
    int firstPosition;
    if (layoutManager instanceof GridLayoutManager) {
        firstPosition = ((GridLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
    } else {
        firstPosition = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
    }
    mFirstPositions.add(firstPosition);
    View view = mRecyclerView.getChildAt(0);
    int top = (view == null) ? 0 : view.getTop();
    mTops.add(top);
    // Save the height of a cell
    mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) EmptyRecyclerView(com.owncloud.android.ui.EmptyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) GridView(android.widget.GridView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) EmptyRecyclerView(com.owncloud.android.ui.EmptyRecyclerView) BottomNavigationView(android.support.design.widget.BottomNavigationView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 97 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project android by nextcloud.

the class OCFileListFragment method switchLayoutManager.

public void switchLayoutManager(boolean grid) {
    int position = 0;
    if (getRecyclerView().getLayoutManager() != null) {
        position = ((LinearLayoutManager) getRecyclerView().getLayoutManager()).findFirstCompletelyVisibleItemPosition();
    }
    RecyclerView.LayoutManager layoutManager;
    if (grid) {
        layoutManager = new GridLayoutManager(getContext(), getColumnSize());
        ((GridLayoutManager) layoutManager).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                if (position == getAdapter().getItemCount() - 1) {
                    return ((GridLayoutManager) layoutManager).getSpanCount();
                } else {
                    return 1;
                }
            }
        });
    } else {
        layoutManager = new LinearLayoutManager(getContext());
    }
    getRecyclerView().setLayoutManager(layoutManager);
    getRecyclerView().scrollToPosition(position);
    getAdapter().setGridView(grid);
    getRecyclerView().setAdapter(getAdapter());
    getAdapter().notifyDataSetChanged();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 98 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project JustAndroid by chinaltz.

the class DividerGridItemDecoration method getSpanCount.

private int getSpanCount(RecyclerView parent) {
    // 列数
    int spanCount = -1;
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
    }
    return spanCount;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) GridLayoutManager(android.support.v7.widget.GridLayoutManager) LayoutManager(android.support.v7.widget.RecyclerView.LayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager)

Example 99 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project JustAndroid by chinaltz.

the class WeChatCircleActivity method initView.

private void initView() {
    initUploadDialog();
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(new DivItemDecoration(2, true));
    recyclerView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (edittextbody.getVisibility() == View.VISIBLE) {
                return true;
            }
            return false;
        }
    });
    recyclerView.setOnScrollListener(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) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                Glide.with(mContext).resumeRequests();
            } else {
                Glide.with(mContext).pauseRequests();
            }
        }
    });
    circleAdapter = new CircleAdapter(this);
    recyclerView.setAdapter(circleAdapter);
    edittextbody = (LinearLayout) findViewById(R.id.editTextBodyLl);
    editText = (EditText) findViewById(R.id.circleEt);
    sendIv = (ImageView) findViewById(R.id.sendIv);
    sendIv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
    setViewTreeObserver();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DivItemDecoration(com.litingzhe.justandroid.ui.listandGridView.wechatCircle.widgets.DivItemDecoration) CommentListView(com.litingzhe.justandroid.ui.listandGridView.wechatCircle.widgets.CommentListView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent) CircleAdapter(com.litingzhe.justandroid.ui.listandGridView.adapter.CircleAdapter)

Example 100 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project BBS-Android by bdpqchen.

the class MyReplyFragment method initFragment.

@Override
protected void initFragment() {
    myReplyAdapter = new MyReplyAdapter(getActivity(), data);
    layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setHasFixedSize(true);
    rv.setLayoutManager(layoutManager);
    rv.setAdapter(myReplyAdapter);
    rv.addItemDecoration(new RecyclerViewItemDecoration(5));
    srl.setOnRefreshListener(this);
    srl.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
    eros = new EndlessRecyclerOnScrollListener(layoutManager) {

        @Override
        public void onLoadMore() {
            mPresenter.getMyReplyList();
        }
    };
    rv.addOnScrollListener(eros);
    mPresenter.initMyReplyList();
}
Also used : EndlessRecyclerOnScrollListener(com.twtstudio.bbs.bdpqchen.bbs.individual.my_release.EndlessRecyclerOnScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewItemDecoration(com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)430 RecyclerView (android.support.v7.widget.RecyclerView)371 View (android.view.View)261 GridLayoutManager (android.support.v7.widget.GridLayoutManager)128 TextView (android.widget.TextView)113 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)79 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)73 ImageView (android.widget.ImageView)71 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)47 Intent (android.content.Intent)46 ArrayList (java.util.ArrayList)43 Bundle (android.os.Bundle)37 Nullable (android.support.annotation.Nullable)33 Context (android.content.Context)29 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)28 BindView (butterknife.BindView)28 Toolbar (android.support.v7.widget.Toolbar)25 ViewGroup (android.view.ViewGroup)25 Handler (android.os.Handler)22 FloatingActionButton (android.support.design.widget.FloatingActionButton)21