Search in sources :

Example 1 with RecyclerViewExpandableItemManager

use of com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager in project android-advancedrecyclerview by h6ah4i.

the class AlreadyExpandedGroupsExpandableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) 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);
    // Expand all group items by default. This method must be called before creating a wrapper adapter.
    //
    // FYI: AbstractExpandableItemAdapter.getInitialGroupExpandedState() can also be used if you
    // need fine control of initial group items' state.
    mRecyclerViewExpandableItemManager.setDefaultGroupsExpandedState(true);
    //adapter
    final AlreadyExpandedGroupsExpandableExampleAdapter myItemAdapter = new AlreadyExpandedGroupsExpandableExampleAdapter(mRecyclerViewExpandableItemManager, getDataProvider());
    mAdapter = myItemAdapter;
    // 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 2 with RecyclerViewExpandableItemManager

use of com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager in project android-advancedrecyclerview by h6ah4i.

the class ExpandableWithHeaderFooterExampleActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_minimal);
    OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {

        @Override
        public void onItemClicked(String message) {
            View container = findViewById(R.id.container);
            Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
        }
    };
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    // Setup expandable feature and RecyclerView
    RecyclerViewExpandableItemManager expMgr = new RecyclerViewExpandableItemManager(null);
    // Create wrapped adapter:  MyItemAdapter -> expMgr.createWrappedAdapter -> MyHeaderFooterAdapter
    RecyclerView.Adapter adapter;
    adapter = new SimpleDemoExpandableItemAdapter(expMgr, clickListener);
    adapter = expMgr.createWrappedAdapter(adapter);
    adapter = new DemoHeaderFooterAdapter(adapter, clickListener);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    // NOTE: need to disable change animations to ripple effect work properly
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    expMgr.attachRecyclerView(recyclerView);
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) OnListItemClickMessageListener(com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener) SimpleDemoExpandableItemAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoExpandableItemAdapter) RecyclerView(android.support.v7.widget.RecyclerView) DemoHeaderFooterAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)

Example 3 with RecyclerViewExpandableItemManager

use of com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager in project android-advancedrecyclerview by h6ah4i.

the class CompositionAllExampleActivity method createComposedAdapter.

private ComposedAdapter createComposedAdapter(RecyclerView rv, OnListItemClickMessageListener clickListener) {
    RecyclerViewDragDropManager dragMgr = new RecyclerViewDragDropManager();
    RecyclerViewDragDropManager dragMgr2 = new RecyclerViewDragDropManager();
    RecyclerViewSwipeManager swipeMgr = new RecyclerViewSwipeManager();
    RecyclerViewSwipeManager swipeMgr2 = new RecyclerViewSwipeManager();
    RecyclerViewExpandableItemManager expMgr = new RecyclerViewExpandableItemManager(null);
    RecyclerViewExpandableItemManager expMgr2 = new RecyclerViewExpandableItemManager(null);
    dragMgr.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z3));
    dragMgr2.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z3));
    ComposedAdapter composedAdapter = new ComposedAdapter();
    composedAdapter.addAdapter(new MySectionHeaderAdapter("Draggable - 1"));
    composedAdapter.addAdapter(dragMgr.createWrappedAdapter(new MyDraggableAdapter(clickListener)));
    composedAdapter.addAdapter(new MySectionHeaderAdapter("Draggable - 2"));
    composedAdapter.addAdapter(dragMgr2.createWrappedAdapter(new MyDraggableAdapter(clickListener)));
    composedAdapter.addAdapter(new MySectionHeaderAdapter("Swipeable - 1"));
    composedAdapter.addAdapter(swipeMgr.createWrappedAdapter(new MySwipeableAdapter(clickListener)));
    composedAdapter.addAdapter(new MySectionHeaderAdapter("Swipeable - 2"));
    composedAdapter.addAdapter(swipeMgr2.createWrappedAdapter(new MySwipeableAdapter(clickListener)));
    composedAdapter.addAdapter(new MySectionHeaderAdapter("Expandable - 1"));
    composedAdapter.addAdapter(expMgr.createWrappedAdapter(new MyExpandableAdapter(expMgr, clickListener)));
    composedAdapter.addAdapter(new MySectionHeaderAdapter("Expandable - 2"));
    composedAdapter.addAdapter(expMgr2.createWrappedAdapter(new MyExpandableAdapter(expMgr2, clickListener)));
    dragMgr.attachRecyclerView(rv);
    dragMgr2.attachRecyclerView(rv);
    swipeMgr.attachRecyclerView(rv);
    swipeMgr2.attachRecyclerView(rv);
    expMgr.attachRecyclerView(rv);
    expMgr2.attachRecyclerView(rv);
    return composedAdapter;
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) ComposedAdapter(com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)

Example 4 with RecyclerViewExpandableItemManager

use of com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager in project android-advancedrecyclerview by h6ah4i.

the class AddRemoveExpandableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) 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 AddRemoveExpandableExampleAdapter myItemAdapter = new AddRemoveExpandableExampleAdapter(mRecyclerViewExpandableItemManager, getDataProvider());
    mAdapter = myItemAdapter;
    // 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 5 with RecyclerViewExpandableItemManager

use of com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager 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 = (RecyclerView) 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)

Aggregations

RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)5 Parcelable (android.os.Parcelable)5 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)5 ItemShadowDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator)5 SimpleListDividerDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator)5 RecyclerView (android.support.v7.widget.RecyclerView)3 RefactoredDefaultItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator)3 RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)3 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)3 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)2 View (android.view.View)2 RecyclerViewTouchActionGuardManager (com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager)2 DemoHeaderFooterAdapter (com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter)1 OnListItemClickMessageListener (com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener)1 SimpleDemoExpandableItemAdapter (com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoExpandableItemAdapter)1 DraggableItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator)1 SwipeDismissItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator)1 ComposedAdapter (com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter)1