Search in sources :

Example 6 with RefactoredDefaultItemAnimator

use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project android-advancedrecyclerview by h6ah4i.

the class ExpandableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // noinspection ConstantConditions
    mRecyclerView = getView().findViewById(R.id.recycler_view);
    mLayoutManager = new LinearLayoutManager(getContext());
    final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
    mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
    mRecyclerViewExpandableItemManager.setOnGroupExpandListener(this);
    mRecyclerViewExpandableItemManager.setOnGroupCollapseListener(this);
    // adapter
    final ExpandableExampleAdapter myItemAdapter = new ExpandableExampleAdapter(getDataProvider());
    // wrap for expanding
    mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Need to disable them when using animation indicator.
    animator.setSupportsChangeAnimations(false);
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setHasFixedSize(false);
    // noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
    mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Also used : RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) Parcelable(android.os.Parcelable) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 7 with RefactoredDefaultItemAnimator

use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project Phonograph by kabouzeid.

the class FlatPlayerFragment method setUpRecyclerView.

private void setUpRecyclerView() {
    recyclerViewDragDropManager = new RecyclerViewDragDropManager();
    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
    playingQueueAdapter = new PlayingQueueAdapter(((AppCompatActivity) getActivity()), MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition(), R.layout.item_list, false, null);
    wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(playingQueueAdapter);
    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(wrappedAdapter);
    recyclerView.setItemAnimator(animator);
    recyclerViewDragDropManager.attachRecyclerView(recyclerView);
    layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
}
Also used : RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) PlayingQueueAdapter(com.kabouzeid.gramophone.adapter.song.PlayingQueueAdapter)

Aggregations

GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)7 RefactoredDefaultItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)4 ItemShadowDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator)4 RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)4 Parcelable (android.os.Parcelable)3 SimpleListDividerDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator)3 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 PlayingQueueAdapter (com.kabouzeid.gramophone.adapter.song.PlayingQueueAdapter)2 Context (android.content.Context)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 LoaderManager (android.support.v4.app.LoaderManager)1 Loader (android.support.v4.content.Loader)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1