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;
}
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);
}
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);
}
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();
}
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);
}
Aggregations