{"id":21969945,"url":"https://github.com/kroegerama/recycler-swipe-stack","last_synced_at":"2025-04-28T10:40:32.495Z","repository":{"id":57725992,"uuid":"343214787","full_name":"kroegerama/recycler-swipe-stack","owner":"kroegerama","description":"An easy to use helper for RecyclerViews. StackLayoutManager and ItemTouchHelperCallback.","archived":false,"fork":false,"pushed_at":"2021-04-22T17:23:04.000Z","size":4163,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-01T11:04:07.641Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/kroegerama.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-02-28T21:06:24.000Z","updated_at":"2022-05-19T00:43:14.000Z","dependencies_parsed_at":"2022-09-11T17:12:04.010Z","dependency_job_id":null,"html_url":"https://github.com/kroegerama/recycler-swipe-stack","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kroegerama%2Frecycler-swipe-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kroegerama%2Frecycler-swipe-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kroegerama%2Frecycler-swipe-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kroegerama%2Frecycler-swipe-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kroegerama","download_url":"https://codeload.github.com/kroegerama/recycler-swipe-stack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227142737,"owners_count":17737023,"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-11-29T14:28:08.684Z","updated_at":"2024-11-29T14:28:09.535Z","avatar_url":"https://github.com/kroegerama.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Recycler Swipe Stack\n\n**An easy to use helper for RecyclerViews. StackLayoutManager and ItemTouchHelperCallback.**\n\n---\n\n\n![Publish](https://github.com/kroegerama/recycler-swipe-stack/workflows/Publish/badge.svg)\n\n![License](https://img.shields.io/github/license/kroegerama/recycler-swipe-stack)\n\n| Artifact | Version |\n|:-|:-:|\n| recycler-swipe-stack | [![Maven Central](https://img.shields.io/maven-central/v/com.kroegerama/recycler-swipe-stack)](https://search.maven.org/artifact/com.kroegerama/recycler-swipe-stack) |\n\n```kotlin\nimplementation(\"com.kroegerama:recycler-swipe-stack:$VERSION\")\n```\n\n---\n\n### Preview\n\n![Preview](design/preview.gif)\n\n### Usage\n\n#### 1. Create your `SwiperConfig`\n\n```kotlin\nval config = SwiperConfig(\n    showCount = 5,\n    swipeDirections = SwipeDirection.LEFT or SwipeDirection.RIGHT or SwipeDirection.UP,\n    stackDirection = StackDirection.Down,\n    itemTranslate = 0.02f,\n    itemRotation = 15f,\n    itemScale = .0f\n)\n```\n\n#### 2. Create a `SwipeListener`\n\n```kotlin\nprivate val listener = object : SwipeListener {\n    override fun onSwipe(\n        viewHolder: RecyclerView.ViewHolder,\n        dX: Float,\n        dY: Float,\n        direction: Int\n    ) {\n    }\n\n    override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {\n        Timber.d(\"onSwiped($direction)\")\n        //example: remove item from Adapter (and call notifyItemRemoved,\n        //if your adapter doesn't do it automatically)\n        itemAdapter.removeAt(viewHolder.bindingAdapterPosition)\n    }\n\n    override fun onSwipeEnd(viewHolder: RecyclerView.ViewHolder) {\n        Timber.d(\"onSwipeEnd()\")\n    }\n\n    override fun isSwipeAllowed(viewHolder: RecyclerView.ViewHolder) = viewHolder is MyViewHolder\n}\n```\n\n#### 3. Setup the library\n\n##### 3a Use the helper function\n\n```kotlin\nrecycler.setupStack(\n    config,\n    listener\n) {\n    itemAnimator = DefaultItemAnimator().apply {\n        addDuration = 200\n        removeDuration = 200\n    }\n    adapter = myAdapter\n}\n```\n\n##### 3b Or setup the classes yourself\n\n###### Create an `ItemTouchHelper` and a `StackLayoutManager`\n\n```kotlin\nval itemTouchHelper = ItemTouchHelper(StackSwipeTouchHelperCallback(listener, config))\nval layoutManager = StackLayoutManager(config)\n```\n\n###### Setup your `RecyclerView`\n\n```kotlin\nrecycler.layoutManager = layoutManager\nitemTouchHelper.attachToRecyclerView(recycler)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkroegerama%2Frecycler-swipe-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkroegerama%2Frecycler-swipe-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkroegerama%2Frecycler-swipe-stack/lists"}