{"id":13396412,"url":"https://github.com/Diolor/Swipecards","last_synced_at":"2025-03-13T23:31:01.263Z","repository":{"id":39617949,"uuid":"22678518","full_name":"Diolor/Swipecards","owner":"Diolor","description":"A Tinder-like Android library to create the swipe cards effect. You can swipe left or right to like or dislike the content.","archived":false,"fork":false,"pushed_at":"2019-04-13T16:25:00.000Z","size":19383,"stargazers_count":2334,"open_issues_count":73,"forks_count":582,"subscribers_count":87,"default_branch":"master","last_synced_at":"2024-10-29T17:46:22.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Diolor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-06T10:15:32.000Z","updated_at":"2024-10-24T18:05:33.000Z","dependencies_parsed_at":"2022-09-18T14:24:50.366Z","dependency_job_id":null,"html_url":"https://github.com/Diolor/Swipecards","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diolor%2FSwipecards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diolor%2FSwipecards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diolor%2FSwipecards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diolor%2FSwipecards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Diolor","download_url":"https://codeload.github.com/Diolor/Swipecards/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243499906,"owners_count":20300713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:50.447Z","updated_at":"2025-03-13T23:31:00.910Z","avatar_url":"https://github.com/Diolor.png","language":"Java","readme":"Swipecards\n==========\n\nTravis master: [![Build Status](https://travis-ci.org/Diolor/Swipecards.svg?branch=master)](https://travis-ci.org/Diolor/Swipecards) \n\n\nA Tinder-like cards effect as of August 2014. You can swipe left or right to like or dislike the content.\nThe library creates a similar effect to Tinder's swipable cards with Fling animation.\n\nIt 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).\n\n![ ](/screenshot.gif)\n\n---\n\n\nInstallation\n=======\n\n[![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)\n\nGo ahead find the latest version on [Gradle please] cowboy! \nBe sure to add the `@aar` suffix.\n\n\n```groovy\ndependencies {\n    compile 'com.lorentzos.swipecards:library:X.X.X@aar'\n}\n```\n\n\n\nExample\n=======\n\nThe example is quite straightforward and documented in comments. \nYou may find it under the relevant directory.\n\n\n```java\n\n//implement the onFlingListener\npublic class MyActivity extends Activity {\n    ...\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        ...\n\n        //add the view via xml or programmatically\n        SwipeFlingAdapterView flingContainer = (SwipeFlingAdapterView) findViewById(R.id.frame);\n\n        al = new ArrayList\u003cString\u003e();\n        al.add(\"php\");\n        al.add(\"c\");\n        al.add(\"python\");\n        al.add(\"java\");\n\n        //choose your favorite adapter\n        arrayAdapter = new ArrayAdapter\u003cString\u003e(this, R.layout.item, R.id.helloText, al );\n        \n        //set the listener and the adapter\n        flingContainer.setAdapter(arrayAdapter);\n        flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() {\n            @Override\n            public void removeFirstObjectInAdapter() {\n                // this is the simplest way to delete an object from the Adapter (/AdapterView)\n                Log.d(\"LIST\", \"removed object!\");\n                al.remove(0);\n                arrayAdapter.notifyDataSetChanged();\n            }\n\n            @Override\n            public void onLeftCardExit(Object dataObject) {\n                //Do something on the left!\n                //You also have access to the original object.\n                //If you want to use it just cast it (String) dataObject\n                Toast.makeText(MyActivity.this, \"Left!\", Toast.LENGTH_SHORT).show();\n            }\n\n            @Override\n            public void onRightCardExit(Object dataObject) {\n                Toast.makeText(MyActivity.this, \"Right!\", Toast.LENGTH_SHORT).show();\n            }\n\n            @Override\n            public void onAdapterAboutToEmpty(int itemsInAdapter) {\n                // Ask for more data here\n                al.add(\"XML \".concat(String.valueOf(i)));\n                arrayAdapter.notifyDataSetChanged();\n                Log.d(\"LIST\", \"notified\");\n                i++;\n            }\n        });\n        \n        // Optionally add an OnItemClickListener\n        flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() {\n            @Override\n            public void onItemClicked(int itemPosition, Object dataObject) {\n                makeToast(MyActivity.this, \"Clicked!\");\n            }\n        });\n    }\n}\n```\n\nYou can alternatively use a helpful method which sets in one line both the listeners and the adapter.\n\n```java\n    // where \"this\" stands for the Context\n    flingContainer.init(this, arrayAdapter);\n````\n\n\n**Adding buttons** is easy. Get the top card listener and trigger manually the right or left animation.\nOn the end of the animation the above listeners (e.g. removeFirstObjectInAdapter) will be triggered depending on the direction.\n \n\n```java\n    /**\n     * Trigger the right event manually.\n     */\n    flingContainer.getTopCardListener().selectRight();\n```\n\n\n\n**Tip**: If you start a new Activity in the `onItemClicked` you will probably want to avoid double activity instances.\nIf so these solutions might work for you: [1](http://stackoverflow.com/a/8077776/1447885), \n[2](http://stackoverflow.com/a/17270364/1447885) and I personally prefer [3](http://stackoverflow.com/a/21906867/1447885)\n\n\n\nConfiguration\n=============\n\nYou can optionally specify some attrs for the animation and the stack. The easiest way is in xml:\n\n```xml\n\u003ccom.lorentzos.flingswipe.SwipeFlingAdapterView\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:rotation_degrees=\"16\"\n    app:max_visible=\"4\"\n    app:min_adapter_stack=\"6\" /\u003e\n```\n\nOr use styles:\n\n```xml\n\u003c!-- Base application theme. --\u003e\n\u003cstyle name=\"AppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\"\u003e\n    \u003c!-- Customize your theme here. --\u003e\n    \u003citem name=\"SwipeFlingStyle\"\u003e@style/SwipeFling\u003c/item\u003e\n\u003c/style\u003e\n```\n\n- rotation_degrees: the degrees of the card rotation offset\n- max_visible: the max visible cards at the time\n- min_adapter_stack: the min number of objects left. Initiates onAdapterAboutToEmpty() method.\n\nLicense\n======\n\n```\n   Copyright 2014 Dionysis Lorentzos\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n[Gradle please]:http://gradleplease.appspot.com/#com.lorentzos.swipecards\n[Kikoso's Swipeable-Cards]:https://github.com/kikoso/Swipeable-Cards\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Swipecards-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1028)\n","funding_links":[],"categories":["Index `(light-weight pages)`","Index","Java","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDiolor%2FSwipecards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDiolor%2FSwipecards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDiolor%2FSwipecards/lists"}