use of com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator 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);
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator 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);
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator in project android-advancedrecyclerview by h6ah4i.
the class SwipeOnLongPressExampleFragment 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);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
mRecyclerViewTouchActionGuardManager.setEnabled(true);
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
//adapter
final SwipeOnLongPressExampleAdapter myItemAdapter = new SwipeOnLongPressExampleAdapter(getDataProvider());
myItemAdapter.setEventListener(new SwipeOnLongPressExampleAdapter.EventListener() {
@Override
public void onItemRemoved(int position) {
((SwipeOnLongPressExampleActivity) getActivity()).onItemRemoved(position);
}
@Override
public void onItemPinned(int position) {
((SwipeOnLongPressExampleActivity) getActivity()).onItemPinned(position);
}
@Override
public void onItemViewClicked(View v, boolean pinned) {
onItemViewClick(v, pinned);
}
});
mAdapter = myItemAdapter;
// wrap for swiping
mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(myItemAdapter);
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Disable the change animation in order to make turning back animation of swiped item works properly.
animator.setSupportsChangeAnimations(false);
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));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
//
// priority: TouchActionGuard > Swipe > DragAndDrop
mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
// for debugging
// animator.setDebug(true);
// animator.setMoveDuration(2000);
// animator.setRemoveDuration(2000);
// mRecyclerViewSwipeManager.setMoveToOutsideWindowAnimationDuration(2000);
// mRecyclerViewSwipeManager.setReturnToDefaultPositionAnimationDuration(2000);
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator 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.animator.GeneralItemAnimator 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