{"id":13642482,"url":"https://github.com/chthai64/SwipeRevealLayout","last_synced_at":"2025-04-20T16:32:32.945Z","repository":{"id":37335171,"uuid":"56091751","full_name":"chthai64/SwipeRevealLayout","owner":"chthai64","description":"Easy, flexible and powerful Swipe Layout for Android","archived":false,"fork":false,"pushed_at":"2019-09-10T20:14:38.000Z","size":4450,"stargazers_count":1561,"open_issues_count":78,"forks_count":381,"subscribers_count":50,"default_branch":"master","last_synced_at":"2024-08-02T01:16:01.165Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chthai64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-12T19:28:34.000Z","updated_at":"2024-07-28T04:01:02.000Z","dependencies_parsed_at":"2022-07-12T11:55:07.658Z","dependency_job_id":null,"html_url":"https://github.com/chthai64/SwipeRevealLayout","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chthai64%2FSwipeRevealLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chthai64%2FSwipeRevealLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chthai64%2FSwipeRevealLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chthai64%2FSwipeRevealLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chthai64","download_url":"https://codeload.github.com/chthai64/SwipeRevealLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223833126,"owners_count":17210787,"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:32.013Z","updated_at":"2024-11-09T13:32:04.081Z","avatar_url":"https://github.com/chthai64.png","language":"Java","funding_links":[],"categories":["滑动删除","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"## SwipeRevealLayout\nA layout that you can swipe/slide to show another layout.\n\n### Demo\n##### Overview\n![Demo all](https://raw.githubusercontent.com/chthai64/SwipeRevealLayout/master/art/demo_all.gif)\n\n##### Drag mode\n\nDrag mode normal:   \n![Demo normal](https://raw.githubusercontent.com/chthai64/SwipeRevealLayout/master/art/demo_normal.gif)\n\nDrag mode same_level:   \n![Demo same](https://raw.githubusercontent.com/chthai64/SwipeRevealLayout/master/art/demo_same.gif)\n\n### Features\n* Flexible, easy to use with RecyclerView, ListView or any view that requires view binding.\n* Four drag edges (left, right, top, bottom).\n* Two drag modes:\n  * Normal (the secondary view is underneath the main view).\n  * Same level (the secondary view sticks to the edge of the main view).\n* Able to open one row at a time.\n* Minimum api level 9.\n\n### Usage\n#### Dependencies\n```groovy\ndependencies {\n    compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'\n}\n```\n\n#### Layout file\n```xml\n\u003ccom.chauthai.swipereveallayout.SwipeRevealLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        app:mode=\"same_level\"\n        app:dragEdge=\"left\"\u003e\n\n        \u003c!-- Your secondary layout here --\u003e\n        \u003cFrameLayout\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"match_parent\" /\u003e\n\n        \u003c!-- Your main layout here --\u003e\n        \u003cFrameLayout\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\" /\u003e\n            \n\u003c/com.chauthai.swipereveallayout.SwipeRevealLayout\u003e\n```\n```app:mode``` can be ```normal``` or ```same_level```\n\n```app:dragEdge``` can be ```left```, ```right```, ```top``` or ```bottom```\n\n#### Use with RecyclerView, ListView, GridView...\n##### In your Adapter class:\n```java\npublic class Adapter extends RecyclerView.Adapter {\n  // This object helps you save/restore the open/close state of each view\n  private final ViewBinderHelper viewBinderHelper = new ViewBinderHelper();\n  \n  public Adapter() {\n    // uncomment the line below if you want to open only one row at a time\n    // viewBinderHelper.setOpenOnlyOne(true);\n  }\n  \n  @Override\n  public void onBindViewHolder(ViewHolder holder, int position) {\n    // get your data object first.\n    YourDataObject dataObject = mDataSet.get(position); \n    \n    // Save/restore the open/close state.\n    // You need to provide a String id which uniquely defines the data object.\n    viewBinderHelper.bind(holder.swipeRevealLayout, dataObject.getId()); \n\n    // do your regular binding stuff here\n  }\n}\n```\n\n##### Optional, to restore/save the open/close state when the device's orientation is changed:\n##### Adapter class:\n```java\npublic class YourAdapter extends RecyclerView.Adapter {\n  ...\n\n  public void saveStates(Bundle outState) {\n      viewBinderHelper.saveStates(outState);\n  }\n\n  public void restoreStates(Bundle inState) {\n      viewBinderHelper.restoreStates(inState);\n  }  \n}\n```\n##### Activity class:\n```java\npublic class YourActivity extends Activity {\n  ...\n  \n  @Override\n  protected void onSaveInstanceState(Bundle outState) {\n      super.onSaveInstanceState(outState);\n      if (adapter != null) {\n          adapter.saveStates(outState);\n      }\n  }\n\n  @Override\n  protected void onRestoreInstanceState(Bundle savedInstanceState) {\n      super.onRestoreInstanceState(savedInstanceState);\n      if (adapter != null) {\n          adapter.restoreStates(savedInstanceState);\n      }\n  }\n}\n```\n\n#### Useful Methods/Attributes\n```app:minDistRequestDisallowParent```: The minimum distance (in px or dp) to the closest drag edge that the SwipeRevealLayout will disallow the parent to intercept touch event. It basically means the minimum distance to swipe until a RecyclerView (or something similar) cannot be scrolled.\n\n```setSwipeListener(SwipeListener swipeListener)```: set the listener for the layout. You can use the full interface ```SwipeListener``` or a simplified listener class ```SimpleSwipeListener```\n\n```open(boolean animation)```, ```close(boolean animation)```: open/close the layout. If ```animation``` is set to false, the listener will not be called.\n\n```isOpened()```, ```isClosed()```: check if the layout is fully opened or closed.\n\n```setMinFlingVelocity(int velocity)```: set the minimum fling velocity (dp/sec) to cause the layout to open/close.\n\n```setDragEdge(int edge)```: Change the edge where the layout can be dragged from.\n\n```setLockDrag(boolean lock)```: If set to true, the user cannot drag/swipe the layout.\n\n```viewBinderHelper.lockSwipe(String... id), viewBinderHelper.unlockSwipe(String... id)```: Lock/unlock layouts which are binded to the binderHelper.\n\n```viewBinderHelper.setOpenOnlyOne(boolean openOnlyOne)```: If ```openOnlyOne``` is set to true, you can only open one row at a time.\n\n```viewBinderHelper.openLayout(String id)```: Open a layout. ```id``` is the id of the data object which is bind to the layout.\n\n```viewBinderHelper.closeLayout(String id)```: Close a layout. ```id``` is the id of the data object which is bind to the layout.\n\n### License\n```\n The MIT License (MIT)\n\n Copyright (c) 2016 Chau Thai\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchthai64%2FSwipeRevealLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchthai64%2FSwipeRevealLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchthai64%2FSwipeRevealLayout/lists"}