use of android.support.v7.widget.GridLayoutManager in project mosby by sockeqwe.
the class SearchFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search, container, false);
unbinder = ButterKnife.bind(this, view);
adapter = new SearchAdapter(inflater, this);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), spanCount));
recyclerView.addItemDecoration(new GridSpacingItemDecoration(spanCount, getResources().getDimensionPixelSize(R.dimen.grid_spacing), true));
return view;
}
use of android.support.v7.widget.GridLayoutManager in project mosby by sockeqwe.
the class HomeFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
unbinder = ButterKnife.bind(this, view);
adapter = new HomeAdapter(inflater, this);
layoutManager = new GridLayoutManager(getActivity(), spanCount);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
int viewType = adapter.getItemViewType(position);
if (viewType == HomeAdapter.VIEW_TYPE_LOADING_MORE_NEXT_PAGE || viewType == HomeAdapter.VIEW_TYPE_SECTION_HEADER) {
return spanCount;
}
return 1;
}
});
recyclerView.addItemDecoration(new GridSpacingItemDecoration(spanCount, getResources().getDimensionPixelSize(R.dimen.grid_spacing), true));
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(layoutManager);
return view;
}
use of android.support.v7.widget.GridLayoutManager in project platform_frameworks_base by android.
the class NekoLand method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.neko_activity);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setLogo(Cat.create(this));
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(true);
}
mPrefs = new PrefState(this);
mPrefs.setListener(this);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.holder);
mAdapter = new CatAdapter();
recyclerView.setAdapter(mAdapter);
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
int numCats = updateCats();
MetricsLogger.histogram(this, "egg_neko_visit_gallery", numCats);
}
use of android.support.v7.widget.GridLayoutManager in project QuickReturn by lawloretienne.
the class QuickReturnHeaderRecyclerViewFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mValues = getResources().getStringArray(R.array.countries);
if (mLayoutManagerType.equals("linear")) {
CountriesLinearLayoutAdapter countriesLinearLayoutAdapter = new CountriesLinearLayoutAdapter(Arrays.asList(mValues));
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), null));
mRecyclerView.setAdapter(countriesLinearLayoutAdapter);
} else if (mLayoutManagerType.equals("grid")) {
CountriesGridLayoutAdapter countriesGridLayoutAdapter = new CountriesGridLayoutAdapter(Arrays.asList(mValues));
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new GridSpacesItemDecoration(QuickReturnUtils.dp2px(getActivity(), 8)));
mRecyclerView.setAdapter(countriesGridLayoutAdapter);
}
int headerHeight = getActivity().getResources().getDimensionPixelSize(R.dimen.header_height2);
switch(mQuickReturnAnimationType) {
case TRANSLATION_SIMPLE:
if (mLayoutManagerType.equals("grid")) {
mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).build();
} else {
mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).build();
}
mRecyclerView.addOnScrollListener(mScrollListener);
break;
case TRANSLATION_SNAP:
if (mLayoutManagerType.equals("grid")) {
mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).isSnappable(true).build();
} else {
mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).isSnappable(true).build();
}
mRecyclerView.addOnScrollListener(mScrollListener);
break;
case TRANSLATION_ANTICIPATE_OVERSHOOT:
if (mLayoutManagerType.equals("grid")) {
mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.HEADER).header(mQuickReturnTextView).columnCount(2).build();
} else {
mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.HEADER).header(mQuickReturnTextView).build();
}
mRecyclerView.addOnScrollListener(mScrollListener2);
break;
default:
if (mLayoutManagerType.equals("grid")) {
mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).build();
} else {
mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).build();
}
mRecyclerView.addOnScrollListener(mScrollListener);
break;
}
}
use of android.support.v7.widget.GridLayoutManager in project boilerplate by koush.
the class GridRecyclerView method setNumColumns.
private void setNumColumns(Context context, int numColumns) {
if (gridLayoutManager == null) {
gridLayoutManager = new GridLayoutManager(context, numColumns);
typeToSpan = new Hashtable<Integer, Integer>();
gridLayoutManager.setSpanSizeLookup(spanSizeLookup = new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
int viewType = getAdapter().getItemViewType(position);
Integer span = typeToSpan.get(viewType);
if (span != null)
return span;
ViewHolder vh = getAdapter().createViewHolder(GridRecyclerView.this, viewType);
int foundSpan;
if (vh instanceof SpanningViewHolder)
foundSpan = ((SpanningViewHolder) vh).getSpanSize(gridLayoutManager.getSpanCount());
else
foundSpan = 1;
typeToSpan.put(viewType, foundSpan);
return foundSpan;
}
});
setLayoutManager(gridLayoutManager);
} else {
gridLayoutManager.setSpanCount(numColumns);
}
typeToSpan.clear();
spanSizeLookup.invalidateSpanIndexCache();
requestLayout();
}
Aggregations