Search in sources :

Example 1 with SimpleListDividerDecorator

use of com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator in project android-advancedrecyclerview by h6ah4i.

the class SwipeableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // noinspection ConstantConditions
    mRecyclerView = 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 SwipeableExampleAdapter myItemAdapter = new SwipeableExampleAdapter(getDataProvider());
    myItemAdapter.setEventListener(new SwipeableExampleAdapter.EventListener() {

        @Override
        public void onItemRemoved(int position) {
            ((SwipeableExampleActivity) getActivity()).onItemRemoved(position);
        }

        @Override
        public void onItemPinned(int position) {
            ((SwipeableExampleActivity) 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);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 2 with SimpleListDividerDecorator

use of com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator in project android-advancedrecyclerview by h6ah4i.

the class SwipeableWithButtonExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // noinspection ConstantConditions
    mRecyclerView = getView().findViewById(R.id.recycler_view);
    mLayoutManager = new LinearLayoutManager(getContext());
    // 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 SwipeableWithButtonExampleAdapter myItemAdapter = new SwipeableWithButtonExampleAdapter(getDataProvider());
    myItemAdapter.setEventListener(new SwipeableWithButtonExampleAdapter.EventListener() {

        @Override
        public void onItemPinned(int position) {
            ((SwipeableWithButtonExampleActivity) getActivity()).onItemPinned(position);
        }

        @Override
        public void onItemViewClicked(View v) {
            handleOnItemViewClicked(v);
        }

        @Override
        public void onUnderSwipeableViewButtonClicked(View v) {
            handleOnUnderSwipeableViewButtonClicked(v);
        }
    });
    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);
// mRecyclerViewSwipeManager.setMoveToOutsideWindowAnimationDuration(2000);
// mRecyclerViewSwipeManager.setReturnToDefaultPositionAnimationDuration(2000);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 3 with SimpleListDividerDecorator

use of com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator in project android-advancedrecyclerview by h6ah4i.

the class ViewPagerSwipeableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // noinspection ConstantConditions
    mRecyclerView = 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 ViewPagerSwipeableExampleAdapter myItemAdapter = new ViewPagerSwipeableExampleAdapter(getDataProvider(), mCanSwipeLeft);
    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);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 4 with SimpleListDividerDecorator

use of com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator in project android-advancedrecyclerview by h6ah4i.

the class DraggableSwipeableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // noinspection ConstantConditions
    mRecyclerView = getView().findViewById(R.id.recycler_view);
    mLayoutManager = new LinearLayoutManager(getContext());
    // 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);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // swipe manager
    mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
    // adapter
    final DraggableSwipeableExampleAdapter myItemAdapter = new DraggableSwipeableExampleAdapter(getDataProvider());
    myItemAdapter.setEventListener(new DraggableSwipeableExampleAdapter.EventListener() {

        @Override
        public void onItemRemoved(int position) {
            ((DraggableSwipeableExampleActivity) getActivity()).onItemRemoved(position);
        }

        @Override
        public void onItemPinned(int position) {
            ((DraggableSwipeableExampleActivity) getActivity()).onItemPinned(position);
        }

        @Override
        public void onItemViewClicked(View v, boolean pinned) {
            onItemViewClick(v, pinned);
        }
    });
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    // wrap for swiping
    mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    // 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);
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
// animator.setDebug(true);
// animator.setMoveDuration(2000);
// animator.setRemoveDuration(2000);
// mRecyclerViewSwipeManager.setMoveToOutsideWindowAnimationDuration(2000);
// mRecyclerViewSwipeManager.setReturnToDefaultPositionAnimationDuration(2000);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 5 with SimpleListDividerDecorator

use of com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator 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 = 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)

Aggregations

NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)16 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)16 ItemShadowDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator)16 SimpleListDividerDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator)16 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)8 RecyclerViewTouchActionGuardManager (com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager)8 RecyclerView (android.support.v7.widget.RecyclerView)7 View (android.view.View)7 SwipeDismissItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator)7 RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)7 DraggableItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator)6 Parcelable (android.os.Parcelable)5 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)5 RefactoredDefaultItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator)3 ActionBar (android.support.v7.app.ActionBar)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 Window (android.view.Window)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1