本文整理汇总了Java中com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager.setInitiateOnMove方法的典型用法代码示例。如果您正苦于以下问题:Java RecyclerViewDragDropManager.setInitiateOnMove方法的具体用法?Java RecyclerViewDragDropManager.setInitiateOnMove怎么用?Java RecyclerViewDragDropManager.setInitiateOnMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
的用法示例。
在下文中一共展示了RecyclerViewDragDropManager.setInitiateOnMove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入方法依赖的package包/类
@Override
public void onViewCreated(View aView, @Nullable Bundle aSavedInstanceState) {
super.onViewCreated(aView, aSavedInstanceState);
mRecyclerView = (RecyclerView) aView.findViewById(R.id.recycler_view);
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
mLayoutManager = new LinearLayoutManager(getContext());
mRecyclerView.setLayoutManager(mLayoutManager);
final DragOnLongPressAdapter myItemAdapter = new DragOnLongPressAdapter(
((MainActivity) getActivity()).getDataSet());
mAdapter = myItemAdapter;
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.addItemDecoration(
new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(),
R.drawable.list_divider_h), true));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
}
示例2: onViewCreated
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; //导入方法依赖的package包/类
@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(getActivity());
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
(NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
//adapter
final MyDraggableItemAdapter myItemAdapter = new MyDraggableItemAdapter(getDataProvider());
mAdapter = myItemAdapter;
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter); // wrap for dragging
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
mRecyclerView.setItemAnimator(animator);
// additional decorations
//noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) getResources().getDrawable(R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
// animator.setDebug(true);
// animator.setMoveDuration(2000);
}