use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.
the class UserHomePageFragment method setCoins.
private void setCoins() {
int count = mUserCoinsInfo.getData().getCount();
if (count == 0) {
coinsLayout.setVisibility(View.GONE);
}
List<UserCoinsInfo.DataBean.ListBean> list = mUserCoinsInfo.getData().getList();
mCoinsRecycler.setHasFixedSize(false);
mCoinsRecycler.setNestedScrollingEnabled(false);
mCoinsRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
mCoinsRecycler.setAdapter(new UserHomePagerCoinsAdapter(mCoinsRecycler, list));
mCoinsCount.setText(String.valueOf(count));
}
use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.
the class UserHomePageFragment method setChaseBangumi.
private void setChaseBangumi() {
int count = mUserChaseBangumiInfo.getData().getCount();
if (count == 0) {
chaseBangumiLayout.setVisibility(View.GONE);
}
List<UserChaseBangumiInfo.DataBean.ResultBean> result = mUserChaseBangumiInfo.getData().getResult();
mChaseBangumiRecycler.setHasFixedSize(false);
mChaseBangumiRecycler.setNestedScrollingEnabled(false);
mChaseBangumiRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));
mChaseBangumiRecycler.setAdapter(new UserHomePagerChaseBangumiAdapter(mChaseBangumiRecycler, result));
mChaseBangumiCount.setText(String.valueOf(count));
}
use of android.support.v7.widget.GridLayoutManager in project PullZoomView by Frank-Zhu.
the class PullToZoomRecyclerViewEx method isFirstItemVisible.
private boolean isFirstItemVisible() {
if (mRootView != null) {
final RecyclerView.Adapter adapter = mRootView.getAdapter();
final GridLayoutManager mLayoutmanager = (GridLayoutManager) mRootView.getLayoutManager();
if (null == adapter || adapter.getItemCount() == 0) {
return true;
} else {
/**
* This check should really just be:
* mRootView.getFirstVisiblePosition() == 0, but PtRListView
* internally use a HeaderView which messes the positions up. For
* now we'll just add one to account for it and rely on the inner
* condition which checks getTop().
*/
int[] into = { 0, 0 };
if (mLayoutmanager != null)
into[0] = mLayoutmanager.findFirstVisibleItemPosition();
if (into.length > 0 && into.length > 0 && into[0] <= 1) {
final View firstVisibleChild = mRootView.getChildAt(0);
if (firstVisibleChild != null) {
return firstVisibleChild.getTop() >= mRootView.getTop();
}
}
}
}
return false;
}
use of android.support.v7.widget.GridLayoutManager in project PullZoomView by Frank-Zhu.
the class PullToZoomRecyclerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pull_to_zoom_recycler_view);
listView = (PullToZoomRecyclerViewEx) findViewById(R.id.recyclerview);
final RecyclerViewHeaderAdapter mAdapter = new RecyclerAdapterCustom(this);
final GridLayoutManager manager = new GridLayoutManager(this, 2);
manager.setOrientation(GridLayoutManager.VERTICAL);
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return mAdapter.getItemViewType(position) == RecyclerViewHeaderAdapter.INT_TYPE_HEADER ? 2 : 1;
}
});
listView.setAdapterAndLayoutManager(mAdapter, manager);
DisplayMetrics localDisplayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
int mScreenHeight = localDisplayMetrics.heightPixels;
int mScreenWidth = localDisplayMetrics.widthPixels;
AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
listView.setHeaderLayoutParams(localObject);
}
use of android.support.v7.widget.GridLayoutManager in project bilibili-android-client by HotBitmapGG.
the class HomeRecommendedFragment method initRecyclerView.
@Override
protected void initRecyclerView() {
mSectionedAdapter = new SectionedRecyclerViewAdapter();
GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 2);
mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(mSectionedAdapter.getSectionItemViewType(position)) {
case SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER:
return 2;
case SectionedRecyclerViewAdapter.VIEW_TYPE_FOOTER:
return 2;
default:
return 1;
}
}
});
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mSectionedAdapter);
setRecycleNoScroll();
}
Aggregations