{"id":18269786,"url":"https://github.com/sephiroth74/AndroidUIGestureRecognizer","last_synced_at":"2025-04-04T23:31:31.949Z","repository":{"id":13531824,"uuid":"74084602","full_name":"sephiroth74/AndroidUIGestureRecognizer","owner":"sephiroth74","description":"AndroidGestureRecognizer is an Android implementation  of the Apple's UIGestureRecognizer framework","archived":false,"fork":false,"pushed_at":"2024-03-15T07:25:53.000Z","size":11091,"stargazers_count":140,"open_issues_count":1,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-22T09:32:43.305Z","etag":null,"topics":["android","apple-uigesturerecognizer-framework","gesture-changes","gesture-recognizer","rotation","swipe","tap","touches","uigesturerecognizer"],"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/sephiroth74.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-18T01:47:52.000Z","updated_at":"2025-03-03T02:38:32.000Z","dependencies_parsed_at":"2024-11-05T11:51:55.435Z","dependency_job_id":null,"html_url":"https://github.com/sephiroth74/AndroidUIGestureRecognizer","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sephiroth74%2FAndroidUIGestureRecognizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sephiroth74%2FAndroidUIGestureRecognizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sephiroth74%2FAndroidUIGestureRecognizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sephiroth74%2FAndroidUIGestureRecognizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sephiroth74","download_url":"https://codeload.github.com/sephiroth74/AndroidUIGestureRecognizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266476,"owners_count":20910831,"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":["android","apple-uigesturerecognizer-framework","gesture-changes","gesture-recognizer","rotation","swipe","tap","touches","uigesturerecognizer"],"created_at":"2024-11-05T11:37:10.885Z","updated_at":"2025-04-04T23:31:28.152Z","avatar_url":"https://github.com/sephiroth74.png","language":"Kotlin","funding_links":[],"categories":["uigesturerecognizer"],"sub_categories":[],"readme":"# Android UIGestureRecognizer\n\n[![](https://jitpack.io/v/sephiroth74/AndroidUIGestureRecognizer.svg)](https://jitpack.io/#sephiroth74/AndroidUIGestureRecognizer)\n\n\n\u003cbr /\u003e\n\nAndroidGestureRecognizer is an Android implementation of the Apple's UIGestureRecognizer framework (\nReverse engineered).\nhttps://developer.apple.com/reference/uikit/uigesturerecognizer\n\nFor more info about the ui gesture recognizers look this WWDC\nvideo [https://developer.apple.com/videos/play/wwdc2012/233/](https://developer.apple.com/videos/play/wwdc2012/233)\n\n### From Apple API reference:\n\n\u003e UIGestureRecognizer is an abstract base class for concrete gesture-recognizer classes. A\n\u003e gesture-recognizer object—or, simply, a gesture recognizer—decouples the logic for recognizing a\n\u003e gesture and acting on that recognition. When one of these objects recognizes a common gesture or, in\n\u003e some cases, a change in the gesture, it sends an action message to each designated target object.\n\n# Available Recognizers\n\n* [UITapGestureRecognizer](https://developer.apple.com/reference/uikit/uitapgesturerecognizer)\n\n\u003e UIGestureRecognizer that looks for single or multiple taps. For the gesture to be recognized, the\n\u003e specified number of fingers must tap the view a specified number of times.\n\n* [UIPinchGestureRecognizer](https://developer.apple.com/reference/uikit/uipinchgesturerecognizer)\n\n\u003e Pinching is a continuous gesture. The gesture begins (began) when the two touches have moved\n\u003e enough to be considered a pinch gesture. The gesture changes (changed) when a finger moves (with\n\u003e both fingers remaining pressed). The gesture ends (ended) when both fingers lift from the view.\n\n* [UIRotationGestureRecognizer](https://developer.apple.com/reference/uikit/uirotationgesturerecognizer)\n\n\u003e Rotation is a continuous gesture. It begins when two touches have moved enough to be considered a\n\u003e rotation. The gesture changes when a finger moves while the two fingers are down. It ends when both\n\u003e fingers have lifted. At each stage in the gesture, the gesture recognizer sends its action message.\n\n* [UISwipeGestureRecognizer](https://developer.apple.com/reference/uikit/uiswipegesturerecognizer)\n\n\u003e UISwipeGestureRecognizer recognizes a swipe when the specified number of touches (\n\u003e numberOfTouchesRequired) have moved mostly in an allowable direction (direction) far enough to be\n\u003e considered a swipe. Swipes can be slow or fast. A slow swipe requires high directional precision but\n\u003e a small distance; a fast swipe requires low directional precision but a large distance.\n\n* [UIPanGestureRecognizer](https://developer.apple.com/reference/uikit/uipangesturerecognizer)\n\n\u003e A panning gesture is continuous. It begins (began) when the minimum number of fingers allowed (\n\u003e minimumNumberOfTouches) has moved enough to be considered a pan. It changes (changed) when a finger\n\u003e moves while at least the minimum number of fingers are pressed down. It ends (ended) when all\n\u003e fingers are lifted.\n\n* [UIScreenEdgePanGestureRecognizer](https://developer.apple.com/reference/uikit/uiscreenedgepangesturerecognizer)\n\n\u003e A gesture recognizer that looks for panning (dragging) gestures that starts near the edge of the\n\u003e screen.\u003cbr /\u003e\n\u003e The maximum distance between the screen edge can be changed overriding the resource dimension of\n*gestures\\_screen\\_edge\\_limit*.\n\n* [UILongPressGestureRecognizer](https://developer.apple.com/reference/uikit/uilongpressgesturerecognizer)\n\n\u003e Long-press gestures are continuous. The gesture begins (began) when the number of allowable\n\u003e fingers (numberOfTouchesRequired) have been pressed for the specified period (minimumPressDuration)\n\u003e and the touches do not move beyond the allowable range of movement (allowableMovement). The gesture\n\u003e recognizer transitions to the Change state whenever a finger moves, and it ends (ended) when any of\n\u003e the fingers are lifted.\n\n# Discrete vs Continuous\n\n\u003e The gesture interpreted by a gesture recognizer can be either discrete or continuous. A discrete\n\u003e gesture, such as a double tap, occurs but once in a multi-touch sequence and results in a single\n\u003e action sent. However, when a gesture recognizer interprets a continuous gesture such as a rotation\n\u003e gesture, it sends an action message for each incremental change until the multi-touch sequence\n\u003e concludes. \u003csmall\u003e(from https://developer.apple.com/reference/uikit/uigesturerecognizer)\u003c/small\u003e\n\nThere are 2 types of UI GestureRecognizers: **UIContinuousRecognizer** and *\n*UIDiscreteGestureRecognizer**\n\n#### UIDiscreteGestureRecognizer\n\nGesture Recognizers that implement this interface will only fire the `Ended` state change.\nInternally they will switch between `Possible`, `Ended`, `Failed` or `Cancelled` state.\n\n#### UIContinuousRecognizer\n\nA continuous gesture which will dispatch `Began`, `Changed` and `Ended` state changed events (for\ninstance a pinch gesture, or a rotate gesture).\n\n---\n\n# Demo\n\nSingle Tap| Double Tap | Double Tap 2 Fingers\n:---: | :---: | :--: |\n\u003cimg src=\"./media/single_tap.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/double_tap.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/double_tap_2.gif\" width=160 height=160 /\u003e\n\n\u003cbr /\u003e\n\nLogn Press| Long Press Double Tap\n:---: | :---: | \n\u003cimg src=\"./media/long_press_1.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/long_press_double_tap_1.gif\" width=160 height=160 /\u003e\n\n\u003cbr /\u003e\n\nPan 1 Finger| Pan 2 Fingers\n:---: | :---: | \n\u003cimg src=\"./media/pan_1.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/pan_2.gif\" width=160 height=160 /\u003e\n\n\u003cbr /\u003e\n\nPinch|\n:---: |\n\u003cimg src=\"./media/pinch_1.gif\" width=160 height=160 /\u003e |\n\n\u003cbr /\u003e\n\nRotate| Rotate min angle\n:---: | :---: |\n\u003cimg src=\"./media/rotate_1.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/rotate_2.gif\" width=160 height=160 /\u003e |\n\n\u003cbr /\u003e\n\nScreen Edge 1 Finger| Screen Edge 2 Fingers\n:---: | :---: | \n\u003cimg src=\"./media/screen_edge_1.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/screen_edge_2.gif\" width=160 height=160 /\u003e\n\n\u003cbr /\u003e\n\n                  Swipe Left 1 Finger                   | Swipe Left 2 Fingers\n:------------------------------------------------------:| :---: | \n \u003cimg src=\"./media/swipe_1.gif\" width=160 height=160 /\u003e | \u003cimg src=\"./media/swipe_2.gif\" width=160 height=160 /\u003e\n\n---\n\n# Installation\n\n### JitPack\n\n**Step 1.** Add the JitPack repository to your build file:\n\n\tallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n\n**Step 2.** Add the dependency to your project's build.gradle file:\n\n\tdependencies {\n\t        implementation 'com.github.sephiroth74:AndroidUIGestureRecognizer:Tag'\n\t}\n\nTo See the last release version: https://jitpack.io/#sephiroth74/AndroidUIGestureRecognizer/\n\n---\n\n# Example\n\n```java\n    class MainActivity :AppCompatActivity(){\n\n        override fun onCreate(savedInstanceState:Bundle?){\n        ...\n\n        val delegate=UIGestureRecognizerDelegate();\n\n        // single tap gesture\n        val recognizer1=new UITapGestureRecognizer(this)\n        recognizer1.tapsRequired=1\n        recognizer1.touchesRequired=1\n        recognizer1.tag=\"single-tap\";\n        recognizer1.actionListener=actionListener\n\n        // double tap gesture\n        val recognizer2=UITapGestureRecognizer(this)\n        recognizer2.tag=\"double-tap\"\n        recognizer2.tapsRequired=2\n        recognizer2.touchesRequired=1\n        recognizer2.actionListener=actionListener\n\n        // We want to recognize a single tap and a double tap separately. Normally, when the user\n        // performs a double tap, the single tap would be triggered twice.\n        // In this way, however, the single tap will wait until the double tap will fail. So a single tap\n        // and a double tap will be triggered separately.\n        recognizer1.requireFailureOf=recognizer2\n\n        // add both gestures to the delegate\n        delegate.addGestureRecognizer(recognizer)\n        delegate.addGestureRecognizer(recognizer2)\n\n        // forward the touch events to the delegate\n        val rootView=findViewById(R.id.root)\n        rootView.setGestureDelegate(delegate)\n\n        // optional delegate methods\n        delegate.shouldReceiveTouch={recognizer-\u003etrue}\n        delegate.shouldBegin={recognizer-\u003etrue}\n        delegate.shouldRecognizeSimultaneouslyWithGestureRecognizer={recognizer,other-\u003etrue}\n        }\n\n// gesture recognizer actionlistener\nprivate val actionListener={recognizer:UIGestureRecognizer-\u003e\n        // gesture recognized\n        }\n\n```\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsephiroth74%2FAndroidUIGestureRecognizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsephiroth74%2FAndroidUIGestureRecognizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsephiroth74%2FAndroidUIGestureRecognizer/lists"}