use of android.support.v7.widget.GridLayoutManager in project AndroidDevelop by 7449.
the class ContentsActivity method initCreate.
@Override
protected void initCreate(Bundle savedInstanceState) {
Bundle extras = getIntent().getExtras();
toolbar.setTitle(extras.getString(TITLE));
setSupportActionBar(toolbar);
swipeRefreshLayout.setEnabled(false);
xRecyclerViewAdapter = new XRecyclerViewAdapter<>();
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
list = new ArrayList<>();
recyclerView.setAdapter(xRecyclerViewAdapter.initXData(list).addRecyclerView(recyclerView).setLayoutId(R.layout.item_contents).onXBind(this).setOnItemClickListener(this));
new ContentsPresenterImpl(this).startContents(extras.getString(URL));
}
use of android.support.v7.widget.GridLayoutManager in project AndroidDevelop by 7449.
the class CheckFragment method initData.
@Override
protected void initData() {
mPresenter = new CheckPresenterImpl(this);
mSaveApp.setOnClickListener(this);
mSaveAppAll.setOnClickListener(this);
mSwipeRefreshLayout.setOnRefreshListener(this);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 4));
mAdapter = new CheckAdapter(new ArrayList<>());
mAdapter.setOnItemClickListener(this);
mAdapter.setOnLongClickListener(this);
mRecyclerView.setAdapter(mAdapter);
onRefresh();
}
use of android.support.v7.widget.GridLayoutManager in project AndroidDevelop by 7449.
the class SuperAdapter method onAttachedToRecyclerView.
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager instanceof GridLayoutManager) {
final GridLayoutManager gridManager = ((GridLayoutManager) manager);
gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (!(getItemViewType(position) == TYPE_ITEM)) {
return gridManager.getSpanCount();
} else {
return 1;
}
}
});
}
}
use of android.support.v7.widget.GridLayoutManager 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);
}
}
}
});
}
use of android.support.v7.widget.GridLayoutManager in project SwipeToLoadLayout by Aspsine.
the class RecyclerCharactersAdapter method onAttachedToRecyclerView.
@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
RecyclerView.Adapter adapter = recyclerView.getAdapter();
if (isFullSpanType(adapter.getItemViewType(position))) {
return gridLayoutManager.getSpanCount();
}
return 1;
}
});
}
}
Aggregations