{"id":21820344,"url":"https://github.com/trademe/covert","last_synced_at":"2025-04-06T07:12:40.254Z","repository":{"id":33108547,"uuid":"147612342","full_name":"TradeMe/Covert","owner":"TradeMe","description":"Covert is an Android library for Material Swipe Actions within a RecyclerView","archived":false,"fork":false,"pushed_at":"2022-03-30T20:44:35.000Z","size":1309,"stargazers_count":363,"open_issues_count":4,"forks_count":19,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-30T06:05:08.966Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TradeMe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2018-09-06T03:26:50.000Z","updated_at":"2025-02-19T11:26:09.000Z","dependencies_parsed_at":"2022-08-07T20:00:32.831Z","dependency_job_id":null,"html_url":"https://github.com/TradeMe/Covert","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TradeMe%2FCovert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TradeMe%2FCovert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TradeMe%2FCovert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TradeMe%2FCovert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TradeMe","download_url":"https://codeload.github.com/TradeMe/Covert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445671,"owners_count":20939958,"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-27T16:31:57.421Z","updated_at":"2025-04-06T07:12:40.234Z","avatar_url":"https://github.com/TradeMe.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Covert\n\n![Covert](./art/covert_demo.gif)\n\n[ ![Download](https://api.bintray.com/packages/trademe/Covert/covert/images/download.svg) ](https://bintray.com/trademe/Covert/covert/_latestVersion)\n\n Covert is an Android Library for easily implementing Material Swipe Actions in a RecyclerView. The design of the animations was based heavily around the [Swipe Action Gestures](https://material.io/design/interaction/gestures.html#types-of-gestures) demonstrated in the Material Interaction guidelines.\n\n## Download\n\n```groovy\nimplementation 'nz.co.trademe.covert:covert:2.0.1'\n```\n\n## Usage\nA setup of Covert matching the demo takes three steps\n1. Set up your configuration - this is what tells Covert what to draw\n```kotlin\nval covertConfig = Covert.Config(\n        iconRes = R.drawable.ic_star_border_black_24dp, // The icon to show\n        iconDefaultColorRes = R.color.black,            // The color of the icon\n        actionColorRes = R.color.colorPrimary           // The color of the background\n)\n```\n2. Build Covert by defining your listeners and attaching to your `RecyclerView`\n```kotlin\nval covert = Covert.with(covertConfig)\n                .setIsActiveCallback {\n                    // This is a callback to check if the item is active, i.e checked\n                    repository.isActive(it.adapterPosition)\n                }\n                .doOnSwipe { viewHolder, _ -\u003e\n                    // This callback is fired when a ViewHolder is swiped\n                    repository.toggleActiveState(viewHolder.adapterPosition)\n                }\n                .attachTo(recyclerView)\n```\n3. Pass Covert to your adapter to apply your corner flags\n```kotlin\noverride fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, index: Int) {\n    covert.drawCornerFlag(viewHolder)\n    ...\n}\n```\n## Swipe Refresh Layouts\nIn some cases, swipe refresh layouts may consume touch events that Covert uses, leading to janky animations. To address this, you can add the following line to the builder.\n```kotlin\nCovert.with(covertConfig)\n                .setIsActiveCallback { ...}\n                .doOnSwipe { viewHolder, _ -\u003e ...}\n                .disablePullToRefreshOnSwipe(swipeRefreshLayout)\n                .attachTo(recyclerView)\n```\n\n## Optimisations\nCovert notifies the `RecyclerView` that the current `ViewHolder` has changed for each frame it draws. If the layout your using is complicated, this can sometimes drop frames and cause weird behaviour. To work around this, Covert triggers invalidations using a payload, which you can look for to skip a full rebind of your `ViewHolder`:\n\n```kotlin\noverride fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: List\u003cAny\u003e) {\n    // The following is an optimisation for Covert, allowing us to skip re-binding of ViewHolders if only drawing the child\n    if (payloads.size == 1 \u0026\u0026 payloads.contains(Covert.SKIP_FULL_BIND_PAYLOAD)) return\n    ...\n}\n```\n## Advanced Setup\nCovert tries to make set up as easy as possible. It does however support more advanced setup:\n```kotlin\nCovert.Config(\n        // Define the icon to show in an active state, with start and end colors \n        activeIcon = Icon(\n            iconRes = R.drawable.ic_active,\n            startColorRes = R.color.start,\n            endColorRes = R.color.end),\n\n        // Define the icon to show in an inactive state, with start and end colors \n        inactiveIcon = Icon(\n            iconRes = R.drawable.ic_inactive,\n            startColorRes = R.color.end,\n            endColorRes = R.color.start),\n        \n        // Define the backdrop color of the active background\n        activeBackdropColorRes = R.color.green,\n\n        // Define the backdrop color of the inactive background\n        inactiveBackdropColorRes = R.color.red,\n\n        // Toggle on and off haptic feedback (available in simple constructor)\n        isHapticFeedbackEnabled = (true | false),\n\n        // Choose your cornerflag (available in simple constructor)\n        cornerFlag: CornerFlag = (CornerFlag.Round | CornerFlag.Triangular | CornerFlag.Custom(R.dimen.size, R.drawable.flag) | CornerFlag.Disabled)\n)\n```\n## Contributing\n\nWe love contributions, but make sure to checkout `CONTRIBUTING.MD` first!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrademe%2Fcovert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrademe%2Fcovert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrademe%2Fcovert/lists"}