CardPager

A modified ViewPager that behaves like a card stack

License

License

GroupId

GroupId

com.oguzbabaoglu
ArtifactId

ArtifactId

cardpager
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

aar
Description

Description

CardPager
A modified ViewPager that behaves like a card stack
Project URL

Project URL

https://github.com/oguzbabaoglu/android-card-pager
Source Code Management

Source Code Management

https://github.com/oguzbabaoglu/android-card-pager

Download cardpager

How to add to project

<!-- https://jarcasting.com/artifacts/com.oguzbabaoglu/cardpager/ -->
<dependency>
    <groupId>com.oguzbabaoglu</groupId>
    <artifactId>cardpager</artifactId>
    <version>0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.oguzbabaoglu/cardpager/
implementation 'com.oguzbabaoglu:cardpager:0.1'
// https://jarcasting.com/artifacts/com.oguzbabaoglu/cardpager/
implementation ("com.oguzbabaoglu:cardpager:0.1")
'com.oguzbabaoglu:cardpager:aar:0.1'
<dependency org="com.oguzbabaoglu" name="cardpager" rev="0.1">
  <artifact name="cardpager" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.oguzbabaoglu', module='cardpager', version='0.1')
)
libraryDependencies += "com.oguzbabaoglu" % "cardpager" % "0.1"
[com.oguzbabaoglu/cardpager "0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » support-v4 jar 22.1.0

Project Modules

There are no modules declared in this project.

CardPager

A modified ViewPager that behaves like a card stack.

Pages can be swiped left or right, moving onto the next page in the stack. A common use case is to like or dislike content based on swipe direction.

Including In Your Project

Latest version: Maven Central

dependencies {
    compile 'com.oguzbabaoglu:cardpager:0.1'
}

Usage

For a working implementation see the example/ folder.

Usage is very similar to a normal ViewPager.

  1. Include a CardPager in your layout.
<com.oguzbabaoglu.cardpager.CardPager
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/view_cardpager"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
/>
  1. Attach a PagerAdapter.
CardPager cardPager = (CardPager) findViewById(R.id.view_cardpager);
cardPager.setAdapter(new ColorAdapter(this));
  1. Implement a OnCardChangeListener to react to swipes.
cardPager.setOnCardChangeListener(new CardPager.SimpleOnCardChangeListener() {
   @Override
   public void onCardDismissed(int position, boolean right) {
       if (right) {
           onLike(position);
       } else {
           onDisLike(position);
       }
   }
});

Todo

  • Allow margins on pages.
  • Allow transformers for different swipe effects.
  • Add back Accessibility options.

License

Copyright 2015 Oguz Babaoglu

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.

Versions

Version
0.1