Search in sources :

Example 51 with DividerItemDecoration

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);
}
Also used : DividerItemDecoration(eu.davidea.flexibleadapter.common.DividerItemDecoration) ProgressItem(eu.davidea.samples.flexibleadapter.items.ProgressItem) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 52 with DividerItemDecoration

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);
}
Also used : ScrollableUseCaseItem(eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem) AbstractFlexibleItem(eu.davidea.flexibleadapter.items.AbstractFlexibleItem) ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) DividerItemDecoration(eu.davidea.flexibleadapter.common.DividerItemDecoration) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 53 with DividerItemDecoration

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));
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.wm.remusic.widget.DividerItemDecoration)

Example 54 with DividerItemDecoration

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");
    }
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.wm.remusic.widget.DividerItemDecoration) SideBar(com.wm.remusic.widget.SideBar)

Example 55 with DividerItemDecoration

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;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) MainFragmentAdapter(com.wm.remusic.adapter.MainFragmentAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.wm.remusic.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)73 RecyclerView (android.support.v7.widget.RecyclerView)42 View (android.view.View)36 TextView (android.widget.TextView)23 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)19 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)15 ImageView (android.widget.ImageView)14 DividerItemDecoration (com.wm.remusic.widget.DividerItemDecoration)9 Drawable (android.graphics.drawable.Drawable)8 DividerItemDecoration (de.madcyph3r.example.DividerItemDecoration)8 DividerItemDecoration (io.hefuyi.listener.widget.DividerItemDecoration)7 Nullable (android.support.annotation.Nullable)6 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)6 Context (android.content.Context)5 Toolbar (android.support.v7.widget.Toolbar)5 Intent (android.content.Intent)4 ActionBar (android.support.v7.app.ActionBar)4 DividerItemDecoration (com.lzy.demo.base.DividerItemDecoration)4 DividerItemDecoration (org.michenux.drodrolib.ui.recyclerview.DividerItemDecoration)4 TargetApi (android.annotation.TargetApi)3