FastAdapter icon indicating copy to clipboard operation
FastAdapter copied to clipboard

how can i swipe and keep the item fill after?

Open kwf2030 opened this issue 10 years ago • 4 comments

Please never mind my poor English.

I want to swipe an item and keep the animation/transition fill after(not anim back to original state), and then shows action buttons on left/right for clicking.

new SimpleSwipeCallback(this, null, ItemTouchHelper.LEFT, ContextCompat.getColor(this, android.R.color.transparent)) {
            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                if (dX < -200) {
                    return;
                }
                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
            }

            @Override
            public void onChildDrawOver(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                if (dX < -200) {
                    return;
                }
                super.onChildDrawOver(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
            }
        }

Above code only stop swiping when "dX < -200", but will anim back to original state. also , i don't kow how to add/show buttons on the item when swiping.

Thanks for your help.

kwf2030 avatar Oct 24 '16 13:10 kwf2030

@kwf2030 the included Swiping functionality was not meant to be used in the way you try it to implement. It was created to support the functionality you can see inside the sample app.

There are libraries out which are created to support exactly the behavior you want on views, and I suggest you use a lib like this, for this requirement It may is possible to bring in similar functionality to the included swipeCallback. If you want to implement something like this you can open a PR to bring it back to the lib.

thanks

mikepenz avatar Oct 24 '16 14:10 mikepenz

Maybe this lib could be used: https://github.com/VictorAlbertos/SwipeCoordinator

Rainer-Lang avatar Oct 24 '16 15:10 Rainer-Lang

Thanks for all your help, and I found this helpful: https://github.com/daimajia/AndroidSwipeLayout

kwf2030 avatar Oct 25 '16 00:10 kwf2030

Great :)

mikepenz avatar Oct 27 '16 15:10 mikepenz