use of android.support.v7.widget.DividerItemDecoration in project FlexibleAdapter by davideas.
the class FragmentInstagramHeaders method initializeRecyclerView.
@SuppressWarnings({ "unchecked", "ConstantConditions" })
private void initializeRecyclerView() {
// Initialize Adapter and RecyclerView
// true = it makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
mAdapter = new FlexibleAdapter<>(DatabaseService.getInstance().getDatabaseList(), getActivity(), true);
mAdapter.addListener(getActivity()).setAnimationOnScrolling(true).setAnimationOnReverseScrolling(true);
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
mRecyclerView.setAdapter(mAdapter);
//Size of RV will not change
mRecyclerView.setHasFixedSize(true);
// NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
// a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
// Custom divider item decorator with 24dpi as empty space between sections
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), 0, 24));
//Show Headers at startUp!
mAdapter.setDisplayHeadersAtStartUp(true).setStickyHeaders(//Make headers sticky
true).setEndlessScrollListener(this, new ProgressItem()).setEndlessScrollThreshold(//Default=1
1);
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);
}
use of android.support.v7.widget.DividerItemDecoration in project FlexibleAdapter by davideas.
the class FragmentSelectionModes method initializeRecyclerView.
@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
private void initializeRecyclerView(Bundle savedInstanceState) {
//Get copy of the Database list
List<AbstractFlexibleItem> items = DatabaseService.getInstance().getDatabaseList();
// Initialize Adapter and RecyclerView
// ExampleAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
mAdapter = new ExampleAdapter(items, getActivity());
//This will rebind new item when refreshed
mAdapter.setNotifyChangeOfUnfilteredItems(true).setMode(SelectableAdapter.MODE_SINGLE);
// Experimenting NEW features (v5.0.0)
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
mRecyclerView.setAdapter(mAdapter);
//Size of RV will not change
mRecyclerView.setHasFixedSize(true);
// NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
// a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
// Divider item decorator with DrawOver enabled
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), R.drawable.divider).withDrawOver(true));
mRecyclerView.postDelayed(new Runnable() {
@Override
public void run() {
Snackbar.make(getView(), "Selection MODE_SINGLE is enabled", Snackbar.LENGTH_SHORT).show();
}
}, 1500L);
// Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
mAdapter.setFastScroller((FastScroller) getView().findViewById(R.id.fast_scroller), Utils.getColorAccent(getActivity()), (MainActivity) getActivity());
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_SINGLE);
// Add 2 Scrollable Headers
mAdapter.addUserLearnedSelection(savedInstanceState == null);
mAdapter.addScrollableHeaderWithDelay(new ScrollableUseCaseItem(getString(R.string.selection_modes_use_case_title), getString(R.string.selection_modes_use_case_description)), 1100L, true);
}
use of android.support.v7.widget.DividerItemDecoration in project remusic by aa112901.
the class RankPlaylistActivity method setList.
private void setList() {
recyclerView = (ObservableRecyclerView) findViewById(R.id.recyclerview);
recyclerView.setScrollViewCallbacks(RankPlaylistActivity.this);
recyclerView.setLayoutManager(new LinearLayoutManager(RankPlaylistActivity.this));
recyclerView.setHasFixedSize(true);
mAdapter = new PlaylistDetailAdapter(RankPlaylistActivity.this, adapterList);
recyclerView.setAdapter(mAdapter);
recyclerView.addItemDecoration(new DividerItemDecoration(RankPlaylistActivity.this, DividerItemDecoration.VERTICAL_LIST));
}
use of android.support.v7.widget.DividerItemDecoration in project remusic by aa112901.
the class MusicFragment method loadView.
private void loadView() {
//setUservisibleHint 可能先与attach
if (view == null && mContext != null) {
view = LayoutInflater.from(mContext).inflate(R.layout.recylerview, frameLayout, false);
dialogText = (TextView) view.findViewById(R.id.dialog_text);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new Adapter(null);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
//fastScroller = (FastScroller) view.findViewById(R.id.fastscroller);
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
sideBar = (SideBar) view.findViewById(R.id.sidebar);
sideBar.setOnTouchingLetterChangedListener(new SideBar.OnTouchingLetterChangedListener() {
@Override
public void onTouchingLetterChanged(String s) {
dialogText.setText(s);
sideBar.setView(dialogText);
if (positionMap.get(s) != null) {
int i = positionMap.get(s);
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(i + 1, 0);
}
}
});
reloadAdapter();
Log.e("MusicFragment", "load l");
}
}
use of android.support.v7.widget.DividerItemDecoration in project remusic by aa112901.
the class MainFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
//swipeRefresh.setColorSchemeResources(R.color.theme_color_PrimaryAccent);
swipeRefresh.setColorSchemeColors(ThemeUtils.getColorById(mContext, R.color.theme_color_primary));
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
reloadAdapter();
}
});
//先给adapter设置空数据,异步加载好后更新数据,防止Recyclerview no attach
mAdapter = new MainFragmentAdapter(mContext);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
//设置没有item动画
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
reloadAdapter();
mContext.getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
return view;
}
Aggregations