├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.gradle ├── example ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── lorentzos │ │ └── swipecards │ │ └── MyActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ ├── dog.jpg │ └── ic_launcher.png │ ├── drawable │ ├── card_bg.xml │ └── shadow.xml │ ├── layout │ ├── activity_my.xml │ ├── buttons.xml │ └── item.xml │ ├── values-v21 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── lorentzos │ │ └── flingswipe │ │ ├── BaseFlingAdapterView.java │ │ ├── FlingCardListener.java │ │ ├── LinearRegression.java │ │ └── SwipeFlingAdapterView.java │ └── res │ └── values │ ├── attrs.xml │ ├── strings.xml │ └── styles.xml ├── screenshot.gif ├── settings.gradle └── swipecard.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings 5 | .checkstyle 6 | 7 | # IntelliJ IDEA 8 | .idea 9 | *.iml 10 | *.ipr 11 | *.iws 12 | classes 13 | gen-external-apklibs 14 | 15 | # Gradle 16 | .gradle 17 | build 18 | 19 | # Maven 20 | target 21 | release.properties 22 | pom.xml.* 23 | 24 | # Ant 25 | bin 26 | gen 27 | build.xml 28 | ant.properties 29 | local.properties 30 | proguard-project.txt 31 | 32 | #Crashlytics 33 | .crashlytics_data 34 | com_crashlytics_export_strings.xml 35 | 36 | # Other 37 | out/ 38 | .DS_Store 39 | tmp 40 | gradle 41 | 42 | 43 | 44 | 45 | 46 | ### OSX template 47 | .DS_Store 48 | .AppleDouble 49 | .LSOverride 50 | 51 | # Icon must end with two \r 52 | Icon 53 | 54 | # Thumbnails 55 | ._* 56 | 57 | # Files that might appear on external disk 58 | .Spotlight-V100 59 | .Trashes 60 | 61 | # Directories potentially created on remote AFP share 62 | .AppleDB 63 | .AppleDesktop 64 | Network Trash Folder 65 | Temporary Items 66 | .apdisk 67 | 68 | 69 | library/build 70 | example/build -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | - platform-tools 6 | - tools 7 | 8 | - build-tools-22.0.1 9 | - android-22 10 | 11 | 12 | script: ./gradlew build check 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | #### 1.0.9 2 | - Merged pull requests: Fixes with ViewPager conflict, Picasso and IllagalException erors -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 Dionysis Lorentzos 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Swipecards 2 | ========== 3 | fork 自Diolor的Swipecards.添加了一个物理层叠的视觉效果。 4 | - 5 | 效果如下:
6 | ![](/swipecard.gif)
7 | 原项目效果如下:
8 | ![ ](/screenshot.gif) 9 | 10 | 添加了几个控制的方法 11 | 12 | /** 13 | * 打开卡片的物理层叠效果 14 | * @param showPhysicalVision 15 | */ 16 | public void showPhysicalVision(boolean showPhysicalVision){ 17 | this.showPhysicalVision = showPhysicalVision; 18 | } 19 | 20 | /** 21 | * 设置卡片弹出动画时长 22 | * @param duration 23 | */ 24 | public void setPopCardAnimationDuration(long duration){ 25 | this.popAnimDura = duration; 26 | } 27 | /** 28 | * 设置卡片层叠递减值 29 | * @param decrease 30 | */ 31 | public void setCardDecrease(int decrease){ 32 | this.decrease = decrease; 33 | } 34 | 35 | 其他使用方法不变。请参考下面的详情和demo 36 | 37 | 38 | 39 | Travis master: [![Build Status](https://travis-ci.org/Diolor/Swipecards.svg?branch=master)](https://travis-ci.org/Diolor/Swipecards) 40 | 41 | 42 | A Tinder-like cards effect as of August 2014. You can swipe left or right to like or dislike the content. 43 | The library creates a similar effect to Tinder's swipable cards with Fling animation. 44 | 45 | It was inspired by [Kikoso's Swipeable-Cards] but I decided to create a more simple and fresh approach with less bugs. 46 | 47 | It handles greatly asynchronous loading of adapter's data and uses the same layout parameters as FrameLayout (you may use `android:layout_gravity` in your layout xml file). 48 | 49 | Installation(这个是原项目的使用引入跟本fork无关) 50 | ======= 51 | 52 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.lorentzos.swipecards/library/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.lorentzos.swipecards/library) 53 | 54 | Go ahead find the latest version on [Gradle please] cowboy! 55 | Be sure to add the `@aar` suffix. 56 | 57 | 58 | ```groovy 59 | dependencies { 60 | compile 'com.lorentzos.swipecards:library:X.X.X@aar' 61 | } 62 | ``` 63 | 64 | 65 | 66 | Example 67 | ======= 68 | 69 | The example is quite straightforward and documented in comments. 70 | You may find it under the relevant directory. 71 | 72 | 73 | ```java 74 | 75 | //implement the onFlingListener 76 | public class MyActivity extends Activity { 77 | ... 78 | 79 | @Override 80 | protected void onCreate(Bundle savedInstanceState) { 81 | ... 82 | 83 | //add the view via xml or programmatically 84 | SwipeFlingAdapterView flingContainer = (SwipeFlingAdapterView) findViewById(R.id.frame); 85 | 86 | al = new ArrayList(); 87 | al.add("php"); 88 | al.add("c"); 89 | al.add("python"); 90 | al.add("java"); 91 | 92 | //choose your favorite adapter 93 | arrayAdapter = new ArrayAdapter(this, R.layout.item, R.id.helloText, al ); 94 | 95 | //set the listener and the adapter 96 | flingContainer.setAdapter(arrayAdapter); 97 | flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() { 98 | @Override 99 | public void removeFirstObjectInAdapter() { 100 | // this is the simplest way to delete an object from the Adapter (/AdapterView) 101 | Log.d("LIST", "removed object!"); 102 | al.remove(0); 103 | arrayAdapter.notifyDataSetChanged(); 104 | } 105 | 106 | @Override 107 | public void onLeftCardExit(Object dataObject) { 108 | //Do something on the left! 109 | //You also have access to the original object. 110 | //If you want to use it just cast it (String) dataObject 111 | Toast.makeText(MyActivity.this, "Left!", Toast.LENGTH_SHORT).show(); 112 | } 113 | 114 | @Override 115 | public void onRightCardExit(Object dataObject) { 116 | Toast.makeText(MyActivity.this, "Right!", Toast.LENGTH_SHORT).show(); 117 | } 118 | 119 | @Override 120 | public void onAdapterAboutToEmpty(int itemsInAdapter) { 121 | // Ask for more data here 122 | al.add("XML ".concat(String.valueOf(i))); 123 | arrayAdapter.notifyDataSetChanged(); 124 | Log.d("LIST", "notified"); 125 | i++; 126 | } 127 | }); 128 | 129 | // Optionally add an OnItemClickListener 130 | flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() { 131 | @Override 132 | public void onItemClicked(int itemPosition, Object dataObject) { 133 | makeToast(MyActivity.this, "Clicked!"); 134 | } 135 | }); 136 | } 137 | } 138 | ``` 139 | 140 | You can alternatively use a helpful method which sets in one line both the listeners and the adapter. 141 | 142 | ```java 143 | // where "this" stands for the Context 144 | flingContainer.init(this, arrayAdapter); 145 | ```` 146 | 147 | 148 | **Adding buttons** is easy. Get the top card listener and trigger manually the right or left animation. 149 | On the end of the animation the above listeners (e.g. removeFirstObjectInAdapter) will be triggered depending on the direction. 150 | 151 | 152 | ```java 153 | /** 154 | * Trigger the right event manually. 155 | */ 156 | flingContainer.getTopCardListener().selectRight(); 157 | ``` 158 | 159 | 160 | 161 | **Tip**: If you start a new Activity in the `onItemClicked` you will probably want to avoid double activity instances. 162 | If so these solutions might work for you: [1](http://stackoverflow.com/a/8077776/1447885), 163 | [2](http://stackoverflow.com/a/17270364/1447885) and I personally prefer [3](http://stackoverflow.com/a/21906867/1447885) 164 | 165 | 166 | 167 | Configuration 168 | ============= 169 | 170 | You can optionally specify some attrs for the animation and the stack. The easiest way is in xml: 171 | 172 | ```xml 173 | 181 | ``` 182 | 183 | Or use styles: 184 | 185 | ```xml 186 | 187 | 191 | ``` 192 | 193 | - rotation_degrees: the degrees of the card rotation offset 194 | - max_visible: the max visible cards at the time 195 | - min_adapter_stack: the min number of objects left. Initiates onAdapterAboutToEmpty() method. 196 | 197 | License 198 | ====== 199 | 200 | ``` 201 | Copyright 2014 Dionysis Lorentzos 202 | 203 | Licensed under the Apache License, Version 2.0 (the "License"); 204 | you may not use this file except in compliance with the License. 205 | You may obtain a copy of the License at 206 | 207 | http://www.apache.org/licenses/LICENSE-2.0 208 | 209 | Unless required by applicable law or agreed to in writing, software 210 | distributed under the License is distributed on an "AS IS" BASIS, 211 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 212 | See the License for the specific language governing permissions and 213 | limitations under the License. 214 | ``` 215 | 216 | [Gradle please]:http://gradleplease.appspot.com/#com.lorentzos.swipecards 217 | [Kikoso's Swipeable-Cards]:https://github.com/kikoso/Swipeable-Cards 218 | 219 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Swipecards-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1028) 220 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | //apply plugin: 'maven' 3 | 4 | buildscript { 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:1.5.0' 10 | 11 | 12 | } 13 | } 14 | 15 | allprojects { 16 | version = VERSION_NAME 17 | group = GROUP 18 | 19 | repositories { 20 | jcenter() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.lorentzos.swipecards.example" 9 | minSdkVersion 15 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "1.0.0" 13 | } 14 | buildTypes { 15 | release { 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | minifyEnabled false 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile project(':library') 25 | compile 'com.jakewharton:butterknife:5.1.2' 26 | } 27 | -------------------------------------------------------------------------------- /example/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/src/main/java/com/lorentzos/swipecards/MyActivity.java: -------------------------------------------------------------------------------- 1 | package com.lorentzos.swipecards; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.widget.ArrayAdapter; 8 | import android.widget.Toast; 9 | 10 | import com.lorentzos.flingswipe.SwipeFlingAdapterView; 11 | 12 | import java.util.ArrayList; 13 | 14 | import butterknife.ButterKnife; 15 | import butterknife.InjectView; 16 | 17 | 18 | public class MyActivity extends Activity { 19 | 20 | private ArrayList al; 21 | private ArrayAdapter arrayAdapter; 22 | private int i; 23 | 24 | @InjectView(R.id.frame) SwipeFlingAdapterView flingContainer; 25 | 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_my); 31 | ButterKnife.inject(this); 32 | 33 | 34 | al = new ArrayList<>(); 35 | al.add("php"); 36 | al.add("c"); 37 | al.add("python"); 38 | al.add("java"); 39 | al.add("html"); 40 | al.add("c++"); 41 | al.add("css"); 42 | al.add("javascript"); 43 | 44 | arrayAdapter = new ArrayAdapter<>(this, R.layout.item, R.id.helloText, al ); 45 | 46 | // flingContainer.showPhysicalVision(false); 47 | // flingContainer.setPopCardAnimationDuration(500); 48 | flingContainer.setAdapter(arrayAdapter); 49 | flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() { 50 | @Override 51 | public void removeFirstObjectInAdapter() { 52 | // this is the simplest way to delete an object from the Adapter (/AdapterView) 53 | Log.d("LIST", "removed object!"); 54 | al.remove(0); 55 | arrayAdapter.notifyDataSetChanged(); 56 | } 57 | 58 | @Override 59 | public void onLeftCardExit(Object dataObject) { 60 | //Do something on the left! 61 | //You also have access to the original object. 62 | //If you want to use it just cast it (String) dataObject 63 | makeToast(MyActivity.this, "Left!"); 64 | } 65 | 66 | @Override 67 | public void onRightCardExit(Object dataObject) { 68 | makeToast(MyActivity.this, "Right!"); 69 | } 70 | 71 | @Override 72 | public void onAdapterAboutToEmpty(int itemsInAdapter) { 73 | // Ask for more data here 74 | if(i<20){ 75 | al.add("XML ".concat(String.valueOf(i))); 76 | arrayAdapter.notifyDataSetChanged(); 77 | Log.d("LIST", "notified"); 78 | i++; 79 | } 80 | } 81 | 82 | @Override 83 | public void onScroll(float scrollProgressPercent) { 84 | // View view = flingContainer.getSelectedView(); 85 | // view.findViewById(R.id.item_swipe_right_indicator).setAlpha(scrollProgressPercent < 0 ? -scrollProgressPercent : 0); 86 | // view.findViewById(R.id.item_swipe_left_indicator).setAlpha(scrollProgressPercent > 0 ? scrollProgressPercent : 0); 87 | } 88 | }); 89 | 90 | 91 | // Optionally add an OnItemClickListener 92 | flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() { 93 | @Override 94 | public void onItemClicked(int itemPosition, Object dataObject) { 95 | makeToast(MyActivity.this, "Clicked!"); 96 | } 97 | }); 98 | 99 | } 100 | 101 | static void makeToast(Context ctx, String s){ 102 | Toast.makeText(ctx, s, Toast.LENGTH_SHORT).show(); 103 | } 104 | 105 | 106 | 107 | 108 | 109 | 110 | } 111 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yilylong/Swipecards/83a4309eb0dd1d06e8daa8187843d0abe46fd994/example/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yilylong/Swipecards/83a4309eb0dd1d06e8daa8187843d0abe46fd994/example/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yilylong/Swipecards/83a4309eb0dd1d06e8daa8187843d0abe46fd994/example/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yilylong/Swipecards/83a4309eb0dd1d06e8daa8187843d0abe46fd994/example/src/main/res/drawable-xxhdpi/dog.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yilylong/Swipecards/83a4309eb0dd1d06e8daa8187843d0abe46fd994/example/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable/card_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/src/main/res/drawable/shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_my.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /example/src/main/res/layout/buttons.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 |