{"id":13498265,"url":"https://github.com/klinker24/Android-DragDismissActivity","last_synced_at":"2025-03-29T01:30:20.935Z","repository":{"id":50683707,"uuid":"82388118","full_name":"klinker24/Android-DragDismissActivity","owner":"klinker24","description":"A smooth, easy-to-implement, drag to dismiss Android Activity.","archived":false,"fork":false,"pushed_at":"2020-03-11T07:23:19.000Z","size":10929,"stargazers_count":680,"open_issues_count":7,"forks_count":53,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-31T15:38:44.351Z","etag":null,"topics":["activity","android","dismiss","drag","library"],"latest_commit_sha":null,"homepage":"https://blog.klinkerapps.com/android-drag-dismiss/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klinker24.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-02-18T13:20:21.000Z","updated_at":"2024-07-02T15:48:00.000Z","dependencies_parsed_at":"2022-09-02T03:41:23.381Z","dependency_job_id":null,"html_url":"https://github.com/klinker24/Android-DragDismissActivity","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klinker24%2FAndroid-DragDismissActivity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klinker24%2FAndroid-DragDismissActivity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klinker24%2FAndroid-DragDismissActivity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klinker24%2FAndroid-DragDismissActivity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klinker24","download_url":"https://codeload.github.com/klinker24/Android-DragDismissActivity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246125306,"owners_count":20727406,"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":["activity","android","dismiss","drag","library"],"created_at":"2024-07-31T21:00:21.107Z","updated_at":"2025-03-29T01:30:20.086Z","avatar_url":"https://github.com/klinker24.png","language":"Java","funding_links":[],"categories":["其他","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"![feature graphic](artwork/sample.png)\n\n# Android Drag Dismiss Activity\n\nAnother implementation of the drag-to-dismiss `Activity` pattern. This one is inspired by Nick Butcher's [Plaid](https://github.com/nickbutcher/plaid/blob/master/app/src/main/java/io/plaidapp/ui/widget/ElasticDragDismissFrameLayout.java) implementation.\n\nThe project has a simple API and is a pretty powerful and beautiful implementation of the pattern. This library is used in some of my apps ([Talon for Twitter](https://play.google.com/store/apps/details?id=com.klinker.android.twitter_l) and [Pulse SMS](https://play.google.com/store/apps/details?id=xyz.klinker.messenger)). It has been abstracted from Jacob Klinker and I's [article-android](https://github.com/klinker41/article-android/) library, which is an awesome readability style in-app web browser.\n\nThis library provides an elastic layout that can dismiss an `Activity` with a `RecyclerView` or a regular `Activity`. Whenever the user swipes up or down, from the bottom or the top of the content, the `DragDismissActivity` will finish.\n\n## Including It In Your Project\n\n![animation](artwork/animation.gif)\n\nThis project was designed to be very easy to implement on top of your existing `Activities`.\n\nTo include it in your project, add this to your module's `build.gradle` file:\n\n```groovy\ndependencies {\n\t...\n\tcompile 'com.klinkerapps:drag-dismiss-activity:1.7.0'\n}\n```\n\n*Note: The normal way to implement the drag-dismiss functionality is by extending the two provided `Activities`: `DragDismissActivity` and `DragDismissRecyclerViewActivity`. If you would rather not do that, I have provided a delegate for each of these use-cases, that you can use: `DragDismissDelegate` and `DragDismissRecyclerViewDelegate`. To see an example of the delegate's usage, check out the [AbstractDragDismissActivity](https://github.com/klinker24/Android-DragDismissActivity/blob/master/library/src/main/java/xyz/klinker/android/drag_dismiss/activity/AbstractDragDismissActivity.java).*\n\n### Replacing an Activity\n\nThis library is meant to replace your `AppCompatActivity`. I will set up all the drag-dismiss features for you, and wrap your content in a boilerplate UI that contains a `Toolbar` and a `ScrollView` for your content.\n\n`DragDismissActivity` is easy to implement:\n\n1. Within your `AndroidManifest.xml`, on your `activity` elements replace whatever theme you are currently using with `android:theme=\"@style/DragDismissTheme`.\n2. Instead of extending `AppCompatActivity`, extend the `DragDismissActivity`.\n3. You won't want to override `Activity#onCreate`. Instead, override `DragDismissActivity#onCreateContent`. This method acts a bit like `Fragment#onCreateView`:\n\n```java\n@Override\nprotected View onCreateContent(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {\n    View v = inflater.inflate(R.layout.activity_scrollable, parent, false);\n\n    // do your normal view setup and Activity#onCreate lifecycle actions here,\n    // instead of within the Activity#onCreate.\n\n    return v;\n}\n```\n\nFor a very simple example, please see [DismissableActivityNormalContent Sample](https://github.com/klinker24/Android-DragDismissActivity/blob/master/sample/src/main/java/xyz/klinker/drag_dismiss/DismissableActivityNormalContent.java).\n\n### Replacing an Activity with a RecyclerView\n\nIf you are using an `Activity` that just has a `RecyclerView` in it, then this library can do all the heavy-lifting for you, all you will need to do is set it up with a `RecyclerView.Adapter` and a `LayoutManager`.\n\n`DragDismissRecyclerViewActivity` is easy to implement as well:\n\n1. Within your `AndroidManifest.xml`, on your `activity` elements replace whatever theme you are currently using with `android:theme=\"@style/DragDismissTheme`.\n2. Instead of extending `AppCompatActivity`, extend the `DragDismissRecyclerViewActivity`.\n3. You won't want to override `Activity#onCreate`. Instead, to set up your `RecyclerView`, override `DragDismissRecyclerViewActivity#setupRecyclerView`:\n\n```java\n@Override\nprotected void setupRecyclerView(RecyclerView recyclerView) {\n    recyclerView.setLayoutManager(new LinearLayoutManager(this));\n    recyclerView.setAdapter(new SampleAdapter());\n\n    // do any other RecyclerView or Activity setup that needs to be done\n}\n```\n\nFor a very simple example, please see [DismissableActivityRecyclerView Sample](https://github.com/klinker24/Android-DragDismissActivity/blob/master/sample/src/main/java/xyz/klinker/drag_dismiss/DismissableActivityRecyclerView.java).\n\n### Customizing the Boilerplate UI\n\nAfter implementing the steps above, you will get your old `Activity`, with drag-to-dismiss functionality at the top and the bottom of the layout, great! You probably want to customize it further though.\n\nI have provided a [DragDismissBundleBuilder](https://github.com/klinker24/Android-DragDismissActivity/blob/master/library/src/main/java/xyz/klinker/android/drag_dismiss/DragDismissBundleBuilder.java) that allows you to add customization to the `DragDismissActivity` through extras on an `Intent`:\n\n```java\nIntent dragDismissActivity = new Intent(this, MyDragDismissActivity.class);\n\nnew DragDismissBundleBuilder(context)\n    .setTheme(DragDismissBundleBuilder.Theme.LIGHT)\t// LIGHT (default), DARK, BLACK, DAY_NIGHT, SYSTEM_DEFAULT\n    .setPrimaryColorResource(R.color.colorPrimary)\t// defaults to a semi-transparent black\n    .setToolbarTitle(\"Normal Activity Sample\")\t\t// defaults to null\n    .setShowToolbar(true)\t\t\t\t// defaults to true\n    .setShouldScrollToolbar(true)       // defaults to true\n    .setFullscreenOnTablets(false)      // defaults to false, tablets will have padding on each side\n    .setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL)  // Larger elasticities will make it easier to dismiss.\n    .setDrawUnderStatusBar(false)       // defaults to false. Change to true if you don't want me to handle the content margin for the Activity. Does not apply to the RecyclerView Activities\n    .build(dragDismissActivity);\n\n// do anything else that you want to set up the Intent\n// dragDismissActivity.putBoolean(\"test_bool\", true);\n\nstartActivity(dragDismissActivity);\n```\n\n### Adding a ProgressBar\n\nHave content that won't be loaded immediately? No problem.\n\nWhile content is loading, you can call `DragDismissActivity#showProgessBar` to automatically show the progress indicator. When the content is done loading, just call `DragDismissActivity#hideProgessBar` to remove it.\n\nFor a simple example usage, check out the [DismissableActivityNormalContent](https://github.com/klinker24/Android-DragDismissActivity/blob/master/sample/src/main/java/xyz/klinker/drag_dismiss/DismissableActivityNormalContent.java) sample.\n\n## Contributing\n\nOriginally based off of [klinker41](https://github.com/klinker41)'s work for [article-android](https://github.com/klinker41/article-android).\n\nPlease fork this repository and contribute back using [pull requests](https://github.com/klinker24/Android-DragDismissActivity/pulls). Features can be requested using [issues](https://github.com/klinker24/Android-DragDismissActivity/issues). All code, comments, and critiques are greatly appreciated.\n\n## Changelog\n\nThe full changelog for the library can be found [here](https://github.com/klinker24/Android-DragDismissActivity/blob/master/CHANGELOG.md).\n\n## License\n\n    Copyright 2019 Luke Klinker\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%2Fklinker24%2FAndroid-DragDismissActivity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklinker24%2FAndroid-DragDismissActivity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklinker24%2FAndroid-DragDismissActivity/lists"}