{"id":25948606,"url":"https://github.com/diftco/SwipeToAction","last_synced_at":"2025-03-04T11:01:58.488Z","repository":{"id":34793661,"uuid":"38777815","full_name":"vcalvello/SwipeToAction","owner":"vcalvello","description":"*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.","archived":false,"fork":false,"pushed_at":"2018-05-03T21:01:36.000Z","size":931,"stargazers_count":219,"open_issues_count":11,"forks_count":45,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-22T22:31:59.188Z","etag":null,"topics":["android","swipe-actions"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vcalvello.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-08T20:21:19.000Z","updated_at":"2024-07-17T08:18:45.000Z","dependencies_parsed_at":"2022-07-17T05:30:32.630Z","dependency_job_id":null,"html_url":"https://github.com/vcalvello/SwipeToAction","commit_stats":null,"previous_names":["diftco/swipetoaction"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcalvello%2FSwipeToAction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcalvello%2FSwipeToAction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcalvello%2FSwipeToAction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcalvello%2FSwipeToAction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vcalvello","download_url":"https://codeload.github.com/vcalvello/SwipeToAction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241836204,"owners_count":20028150,"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":["android","swipe-actions"],"created_at":"2025-03-04T11:01:37.161Z","updated_at":"2025-03-04T11:01:58.473Z","avatar_url":"https://github.com/vcalvello.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`"],"sub_categories":[],"readme":"SwipeToAction\n================\n[![Download](https://api.bintray.com/packages/diftco/maven/swipetoaction/images/download.svg) ](https://bintray.com/diftco/maven/swipetoaction/_latestVersion)\n\n\nAn easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items.\nJust like in Gmail or Inbox apps.\n\n![SwipeToAction Sample](https://raw.githubusercontent.com/diftco/SwipeToAction/master/screenshots/swipetoaction.gif)\n\n### Integration\nThe lib is available on Maven Central, you can find it with [Gradle, please](http://gradleplease.appspot.com/#swipetoaction)\n\n```\ndependencies {\n    compile 'co.dift.ui.swipetoaction:library:1.1'\n}\n\n```\n\n### Usage\n\nCheck a demo project in the `sample/` folder.\n\n1. The view you'll use for the items should have at least 3 children:\n - the one at the front (the last one or anyone with the `tag=front`)\n - the one to reveal when you swipe to left (before the front view or anyone with `tag=reveal-left`)\n - the one to reveal when you swipe to right (before the reveal-left view or anyone with `tag=reveal-right`)\n\n    ```xml\n     \u003c!-- this view reveals when swipe right --\u003e\n     \u003cRelativeLayout\n        android:tag=\"reveal-right\"\n        android:background=\"@color/accent\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\u003e\n    \n        \u003cImageView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentLeft=\"true\"\n            android:layout_centerVertical=\"true\"\n            android:layout_marginLeft=\"20dp\"\n            android:tint=\"@color/icons\"\n            android:src=\"@mipmap/ic_favorite_black_24dp\"/\u003e\n     \u003c/RelativeLayout\u003e\n    \n     \u003c!-- this view reveals when swipe left --\u003e\n     \u003cRelativeLayout\n        android:tag=\"reveal-left\"\n        android:background=\"@color/primary\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\u003e\n    \n        \u003cImageView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentRight=\"true\"\n            android:layout_centerVertical=\"true\"\n            android:layout_marginRight=\"20dp\"\n            android:tint=\"@color/icons\"\n            android:src=\"@mipmap/ic_delete_black_24dp\"/\u003e\n     \u003c/RelativeLayout\u003e\n    \n     \u003c!-- this is the item front view --\u003e\n     \u003cRelativeLayout\n        android:tag=\"front\"\n        android:background=\"@color/item_background\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:padding=\"@dimen/item_padding\"\u003e\n    \n        \u003cTextView\n            android:id=\"@+id/title\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_toRightOf=\"@+id/image\"\n            android:singleLine=\"true\"\n            android:textSize=\"16dp\"\n            android:textStyle=\"bold\" /\u003e\n    \n     \u003c/RelativeLayout\u003e\n    ```\n\n2. In the adapter for your `RecyclerView` create a ViewHolder that extends SwipeToAction.ViewHolder\u003cT\u003e.\nFor instance, in the sample project I have a list of books and my items are instances of a Book class, therefore, the ViewHolder inside the adapter looks like this:\n\n    ```java\n       public class BookViewHolder extends SwipeToAction.ViewHolder\u003cBook\u003e {\n         ...\n         public BookViewHolder(View v) {\n           super(v);\n           ...\n         }\n       }\n    ```\n    Also, in the `onBindViewHolder` method remember to set the item data to the view holder instance\n    \n    ```java\n      @Override\n      public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {\n        Book item = items.get(position);\n        BookViewHolder vh = (BookViewHolder) holder;\n        vh.data = item;\n    \n        ...\n    \n      }\n    ```\n\n3. Set the `RecyclerView` as usual to create a vertical list, set the previous adapter and instantiate SwipeToAction\nproviding the recyclerView instance and a swipe listener `SwipeToAction.SwipeListener\u003cT\u003e`\n\n    ```java\n      recyclerView = (RecyclerView) findViewById(R.id.recycler);\n      LinearLayoutManager layoutManager = new LinearLayoutManager(this);\n      recyclerView.setLayoutManager(layoutManager);\n      recyclerView.setHasFixedSize(true);\n    \n      adapter = new BooksAdapter(this.books);\n      recyclerView.setAdapter(adapter);\n    \n      swipeToAction = new SwipeToAction(recyclerView, new SwipeToAction.SwipeListener\u003cBook\u003e() {\n        @Override\n        public boolean swipeLeft(final Book itemData) {\n            //do something\n            return true; //true will move the front view to its starting position\n        }\n    \n        @Override\n        public boolean swipeRight(Book itemData) {\n            //do something\n            return true;\n        }\n    \n        @Override\n        public void onClick(Book itemData) {\n            //do something\n        }\n    \n        @Override\n        public void onLongClick(Book itemData) {\n            //do something\n        }\n      });\n    ```\n\n# License\n\n    Copyright (C) 2015 Dift.co\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiftco%2FSwipeToAction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiftco%2FSwipeToAction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiftco%2FSwipeToAction/lists"}