Search in sources :

Example 6 with RecyclerViewDragDropManager

use of com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager 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 7 with RecyclerViewDragDropManager

use of com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager in project android-advancedrecyclerview by h6ah4i.

the class DraggableExampleFragment 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(), LinearLayoutManager.VERTICAL, false);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    //adapter
    final DraggableExampleItemAdapter myItemAdapter = new DraggableExampleItemAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    //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));
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 8 with RecyclerViewDragDropManager

use of com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager in project android-advancedrecyclerview by h6ah4i.

the class DraggableCheckCanDropExampleFragment 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(), LinearLayoutManager.VERTICAL, false);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // !!! this method is required to use onCheckCanDrop()
    mRecyclerViewDragDropManager.setCheckCanDropEnabled(true);
    //adapter
    final DraggableCheckCanDropExampleItemAdapter myItemAdapter = new DraggableCheckCanDropExampleItemAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    //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));
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 9 with RecyclerViewDragDropManager

use of com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager in project android-advancedrecyclerview by h6ah4i.

the class MinimalDraggableExampleActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_minimal);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    // Setup D&D feature and RecyclerView
    RecyclerViewDragDropManager dragMgr = new RecyclerViewDragDropManager();
    dragMgr.setInitiateOnMove(false);
    dragMgr.setInitiateOnLongPress(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(dragMgr.createWrappedAdapter(new MyAdapter()));
    dragMgr.attachRecyclerView(recyclerView);
    Snackbar.make(findViewById(R.id.container), "TIP: Long press item to initiate Drag & Drop action!", Snackbar.LENGTH_LONG).show();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)

Example 10 with RecyclerViewDragDropManager

use of com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager in project android-advancedrecyclerview by h6ah4i.

the class DragOnLongPressExampleFragment 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());
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // Start dragging after long press
    mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
    mRecyclerViewDragDropManager.setInitiateOnMove(false);
    //adapter
    final DragOnLongPressExampleAdapter myItemAdapter = new DragOnLongPressExampleAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    //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));
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Aggregations

RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)13 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)11 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)10 ItemShadowDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 DraggableItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator)9 SimpleListDividerDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator)7 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)5 RecyclerView (android.support.v7.widget.RecyclerView)4 RecyclerViewTouchActionGuardManager (com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager)4 View (android.view.View)3 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)3 Parcelable (android.os.Parcelable)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 Window (android.view.Window)1 TextView (android.widget.TextView)1 RefactoredDefaultItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator)1 SwipeDismissItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator)1 ComposedAdapter (com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter)1