{"id":13642466,"url":"https://github.com/loopeer/itemtouchhelper-extension","last_synced_at":"2025-04-13T07:50:00.230Z","repository":{"id":108437710,"uuid":"66570238","full_name":"loopeer/itemtouchhelper-extension","owner":"loopeer","description":"Extension for itemtouchhelper with swipe settling,recover and no conflict with recyclerview","archived":false,"fork":false,"pushed_at":"2018-04-26T08:29:28.000Z","size":658,"stargazers_count":1037,"open_issues_count":14,"forks_count":146,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-13T07:49:58.776Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loopeer.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,"governance":null}},"created_at":"2016-08-25T15:28:14.000Z","updated_at":"2025-03-31T20:42:51.000Z","dependencies_parsed_at":"2023-06-01T02:15:23.879Z","dependency_job_id":null,"html_url":"https://github.com/loopeer/itemtouchhelper-extension","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopeer%2Fitemtouchhelper-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopeer%2Fitemtouchhelper-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopeer%2Fitemtouchhelper-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopeer%2Fitemtouchhelper-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loopeer","download_url":"https://codeload.github.com/loopeer/itemtouchhelper-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"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-08-02T01:01:31.784Z","updated_at":"2025-04-13T07:50:00.208Z","avatar_url":"https://github.com/loopeer.png","language":"Java","funding_links":[],"categories":["滑动删除"],"sub_categories":[],"readme":"# itemtouchhelper-extension\nThis library add something for swipe item settling, recover base on the [Itemtouchhelper](https://developer.android.com/reference/android/support/v7/widget/helper/ItemTouchHelper.html).\n\nThis used in the repo [code-reader](https://github.com/loopeer/code-reader)\n\n[Download Sample](https://github.com/loopeer/itemtouchhelper-extension/releases/tag/1.0.0)\n\nScreenshot\n====\n### item swipe with spring  \n\n![](/screenshot/itemtouch_spring.gif)   \n\n### item swipe with no spring  \n\n![](/screenshot/itemtouch_nospring.gif)  \n### item swipe with recycler view width  \n\n![](/screenshot/itemtouch_recycler_width.gif)   \n\nInstallation\n====\n```groovy\ndependencies {\n    compile 'com.loopeer.library:itemtouchhelperextension:1.0.6'\n}\n```\nUsages\n====\n```java\nmCallback = new ItemTouchHelperCallback();\nmItemTouchHelper = new ItemTouchHelperExtension(mCallback);\nmItemTouchHelper.attachToRecyclerView(mRecyclerView);\n```\n\nItemTouchHelperCallback just set as Itemtouchhelper. Set your swipe content view **translationX** by moving in method **onChildDraw**\n```java\npublic class ItemTouchHelperCallback extends ItemTouchHelperExtension.Callback {\n\n    @Override\n    public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {\n        return makeMovementFlags(0, ItemTouchHelper.START);\n    }\n\n    @Override\n    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {\n        return false;\n    }\n    \n    ...\n\n    @Override\n    public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {\n        MainRecyclerAdapter.ItemBaseViewHolder holder = (MainRecyclerAdapter.ItemBaseViewHolder) viewHolder;\n        holder.mViewContent.setTranslationX(dX);\n    }\n}\n```\nAt last you can let your **viewholder implements Extension** to set swipe settling width\n```java\n@Override\npublic float getActionWidth() {\n    return mActionContainer.getWidth();\n}\n```\nThis will use whole recyclerview width when you do not add the width\n\nAdditional Drag Feature\n====\nIf you want to add drag item feature.You just do **super.onChildDraw** in method onChildDraw of the class **ItemTouchHelperCallback**. Just like bottom:\n```java\n  @Override\n    public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {\n        if (dY != 0 \u0026\u0026 dX == 0) super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);\n       ...\n    }\n```\n\nClick Action Button To Close Opened\n====\nIf you want to close item after click action btn in the swipe item. You show add\n```java\n    mItemTouchHelperExtension.closeOpened();\n```\n\nLicense\n====\n\u003cpre\u003e\nCopyright 2016 Loopeer\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopeer%2Fitemtouchhelper-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floopeer%2Fitemtouchhelper-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopeer%2Fitemtouchhelper-extension/lists"}