Need help with ReSwipeCard?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

JerryChan123
242 Stars 47 Forks Apache License 2.0 63 Commits 10 Opened issues

Description

a light lib for swipe the cards implemented by RecyclerView

Services available

!
?

Need anything else?

Contributors list

# 250,485
Java
tantan
swipevi...
31 commits
# 330,253
Java
tantan
swipevi...
12 commits
# 535,743
Java
tantan
swipevi...
Kotlin
1 commit
# 369,318
Dart
Kotlin
tantan
swipevi...
1 commit

ReSwipeCard

This project is no longer maintained, feel free to pull request if you have some fixs.

plz start the project if u feel nice xD

version log

1.0.1 :fix some bugs

ReSwipeCard is based on CardSwipeLayout

中文说明

Introduction:

  • Solve the conflict between scroll and click

  • support for defining directions to slide

  • support for defining directions to slide out

  • support for defining durations to slide out

  • support for looping the card or not

  • support for defining the way to stack the cards

  • support for defining the numbers of the stacked card

  • support for sliding card automatically

below is the demo of this projec ,you could install the app-debug.apk to see on the mobile:

gif


How to use:

//don't use RecyclerView on your project
dependencies {
    compile ('lin.jerrylin0322.reswipecard:reswipecard:1.0.1')
}
//already use RecyclerView on your project
dependencies {
    compile ('lin.jerrylin0322.reswipecard:reswipecard:1.0.1') {
                exclude module:'recyclerview-v7' }
}

maven:

  lin.jerrylin0322.reswipecard
  reswipecard
  1.0.1
  pom

in Java:

 CardSetting setting=new CardSetting();
        setting.setSwipeListener(new OnSwipeCardListener() {
            @Override
            public void onSwiping(RecyclerView.ViewHolder viewHolder, float dx, float dy, int direction) {
                switch (direction) {
                    case ReItemTouchHelper.DOWN:
                        Log.e("aaa", "swiping direction=down");
                        break;
                    case ReItemTouchHelper.UP:
                        Log.e("aaa", "swiping direction=up");
                        break;
                    case ReItemTouchHelper.LEFT:
                        Log.e("aaa", "swiping direction=left");
                        break;
                    case ReItemTouchHelper.RIGHT:
                        Log.e("aaa", "swiping direction=right");
                        break;
                }
            }

        @Override
        public void onSwipedOut(RecyclerView.ViewHolder viewHolder, CardBean o, int direction) {
            switch (direction) {
                case ReItemTouchHelper.DOWN:
                    Toast.makeText(NormalActivity.this, "swipe down out", Toast.LENGTH_SHORT).show();
                    break;
                case ReItemTouchHelper.UP:
                    Toast.makeText(NormalActivity.this, "swipe up out ", Toast.LENGTH_SHORT).show();
                    break;
                case ReItemTouchHelper.LEFT:
                    Toast.makeText(NormalActivity.this, "swipe left out", Toast.LENGTH_SHORT).show();
                    break;
                case ReItemTouchHelper.RIGHT:
                    Toast.makeText(NormalActivity.this, "swipe right out", Toast.LENGTH_SHORT).show();
                    break;
            }
        }

        @Override
        public void onSwipedClear() {
            Toast.makeText(NormalActivity.this, "cards are consumed", Toast.LENGTH_SHORT).show();
        }
    });
    CardTouchHelperCallback helperCallback = new CardTouchHelperCallback(mRecyclerView, list,setting);
    mReItemTouchHelper = new ReItemTouchHelper(helperCallback);
    CardLayoutManager layoutManager = new CardLayoutManager(mReItemTouchHelper, setting);
    mRecyclerView.setLayoutManager(layoutManager);
    CardAdapter cardAdapter = new CardAdapter(list);
    mRecyclerView.setAdapter(cardAdapter);

You need to use SwipeTouchLayout as the root node in your adapter's xml item:

...

</com.lin.cardlib.swipetouchlayout>


CardSetting

All parameters are defined on

CardSetting
.

The direction for sliding:

public int getSwipeDirection() {
        return ReItemTouchHelper.LEFT | ReItemTouchHelper.RIGHT
                | ReItemTouchHelper.UP |ReItemTouchHelper.DOWN;
    }

If you don't need the left slide,just remove from the above,and the effect is like below:

gif

The direction for sliding out:

    public int couldSwipeOutDirection() {
        return ReItemTouchHelper.LEFT | ReItemTouchHelper.RIGHT
                | ReItemTouchHelper.UP |ReItemTouchHelper.DOWN;
    }

If you don't need the top slide out,just remove from the above,and the effect is like below:

gif

The way to stack the cards:

CardConfig.java
public int getStackDirection() {
        return  ReItemTouchHelper.DOWN;
    }

All ways to stack the cards:

Alt text

Whether needs to loop thr card

 public boolean isLoopCard() {
        return true;
    }

The example for not looping the card:

gif

Sliding out the card automatically:

//direction=ReItemTouchHelper.LEFT or ReItemTouchHelper.RIGHT .etc
mReItemTouchHelper.swipeManually(direction);

The degressive scale value for every card(first card is 1f,second card is 0.9f ...)

    public float getCardScale() {
        return DEFAULT_SCALE;
    }

The count for show cards:

  public int getShowCount() {
        return DEFAULT_SHOW_ITEM;
    }

Max rotate value when sliding card:

   public float getCardRotateDegree() {
        return DEFAULT_ROTATE_DEGREE;
    }

The offset value for every card(first card is 0,second card is DEFAULTTRANSLATEY,third card is DEFAULTTRANSLATEY*2 ...)

 public int getCardTranslateDistance() {
        return DEFAULT_TRANSLATE_Y;
    }

Need to open the haveware acceleration:

    public boolean enableHardWare() {
        return true;
    }

The duration for sliding out:

    public int getSwipeOutAnimDuration() {
        return 400;
    }

Decide the Distance for notifing the card to slided out,default is the RecyclerView's width'*0.3f:

    public float getSwipeThreshold() {
        return 0.3f;
    }

If you have any problem ,talk to me through Issues


License

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.