{"id":13396434,"url":"https://github.com/yayaa/Rotatable","last_synced_at":"2025-03-13T23:31:08.792Z","repository":{"id":57729881,"uuid":"47608321","full_name":"yayaa/Rotatable","owner":"yayaa","description":"Helper class to make any view rotatable","archived":false,"fork":false,"pushed_at":"2016-02-14T19:36:14.000Z","size":2084,"stargazers_count":305,"open_issues_count":1,"forks_count":62,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-07-31T18:17:27.821Z","etag":null,"topics":["android","android-library","custom-view","rotate","rotation","swap","swipe","swipe-gestures","swipeview"],"latest_commit_sha":null,"homepage":null,"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/yayaa.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}},"created_at":"2015-12-08T08:15:51.000Z","updated_at":"2024-06-08T10:42:07.000Z","dependencies_parsed_at":"2022-09-10T22:22:42.013Z","dependency_job_id":null,"html_url":"https://github.com/yayaa/Rotatable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayaa%2FRotatable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayaa%2FRotatable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayaa%2FRotatable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayaa%2FRotatable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yayaa","download_url":"https://codeload.github.com/yayaa/Rotatable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243499960,"owners_count":20300726,"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","android-library","custom-view","rotate","rotation","swap","swipe","swipe-gestures","swipeview"],"created_at":"2024-07-30T18:00:51.407Z","updated_at":"2025-03-13T23:31:08.368Z","avatar_url":"https://github.com/yayaa.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`","Index"],"sub_categories":[],"readme":"Rotatable\n=========\n\u003ca href=\"http://developer.android.com/index.html\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-android-green.svg\"/\u003e\u003c/a\u003e \u003ca href=\"https://android-arsenal.com/api?level=14\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/API-14%2B-green.svg?style=flat\"/\u003e\u003c/a\u003e \u003ca href=\"http://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat\"/\u003e\u003c/a\u003e \u003ca href=\"http://search.maven.org/#search%7Cga%7C1%7CRotatable\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/maven-central/v/com.yayandroid/Rotatable.svg\"/\u003e\u003c/a\u003e\n\n\u003ca href=\"http://www.methodscount.com/?lib=com.yayandroid%3ARotatable%3A1.1.2\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods count-114-e91e63.svg\"\u003e\u003c/img\u003e\u003c/a\u003e \u003ca href=\"http://www.methodscount.com/?lib=com.yayandroid%3ARotatable%3A1.1.2\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Size-24 KB-e91e63.svg\"\u003e\u003c/img\u003e\u003c/a\u003e \u003ca href=\"http://android-arsenal.com/details/1/3149\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Android%20Arsenal-Rotatable-brightgreen.svg?style=flat\"/\u003e\u003c/a\u003e\n\nThis is a helper class actually, it simplifies having a view as rotatable by setting touch events and handling a lot of boilerplate works! So if you need a component that needs to be able to rotate by touch, you do not have to deal with all these stuff.\n\nSample Video\n============\n[![Rotatable Sample Video](http://yayandroid.com/data/github_library/rotatable/rotatable.gif)](https://www.youtube.com/watch?v=Gkd9QpAZmU8)\n\n# Usage\n\nYou can apply this rotatable class to any view in your xml, just need to pass the required view into Rotatable builder and configure up to your needs. \n\n```java \nRotatable rotatable = new Rotatable.Builder(findViewById(R.id.targetView))\n                .sides(R.id.frontView, R.id.backView) \n                .direction(Rotatable.ROTATE_X)\n                .listener(rotationListener)\n                .rotationCount(floatValue)\n                .rotataionDistance(floatValue)\n                .pivotX(intValue)\n                .pivotY(intValue)\n                .build();\n```\n\n**Rotatable.Builder**\n\n```java\nsides(int frontViewResId, int backViewResId)\n```\n\u003cul\u003e\u003cli\u003e is optional, if you need your view to be rotated and display another view, you simply tell the library which one is front and which one is back -assuming that these two views are already in your rootView, otherwise it will crash- and library will swap them smoothly whenever it suppossed to.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java\nrotationCount(float count)\n``` \n\u003cul\u003e\u003cli\u003e\nLet's assume that you don't want user to swap over and over again your card so you can simply set how many times user can swap the view and library will calculate its maximum distance up to screen's width and height by user's touch and it will be limited to your selected count.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java\nrotataionDistance(float distance)\n``` \n\u003cul\u003e\u003cli\u003e\nYou can also specify distance manually, but be aware of multi screen resolution and calculate carefully if you really need to do it. And important thing is that you cannot have both `rotationCount` and `rotationDistance` defined in your builder, because they have different calculations, so it will crash if you defined both.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java\npivotX(int pivotXValue)\npivotY(int pivotYValue)\n// or \npivot(int pivotXValue, int pivotYValue)\n```\n\u003cul\u003e\u003cli\u003e\nYou may need to change pivot position somehow to do it, you can use above methods or .pivot(intXValue, intYValue) to change both in once.\n\nBut test it carefully! Because this can cause view not being drawn. How? \u0026 Why? Ok, Let's assume that you have a view with width matches screen's and you set pivotX as beginning, while rotating that will cause view's rotated width exceed screen's border and view will not be drawn until you get a point it can be fit to screen and drawn again.\n\u003c/li\u003e\u003c/ul\u003e\n\n**Rotatable Object**\n\nWe have built into Rotatable object, but why do we need that? Rotatable object has some useful methods that you may need to change some of configurations or notify rotatable on configuration changes. Such as:\n\n```java \nrotatable.rotate(int direction, float degree, int duration, Animator.AnimatorListener listener)\n```\n\u003cul\u003e\u003cli\u003e\nSince you have this library implemented, and a rootView already defined into Rotatable object, why bother to create and ObjectAnimator and do your own animation? Simply call this method and library will do it. It has multiple rotate methods with different parameters, so you can call whichever works for you. You do not need to specify duration or listener.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java \nrotatable.setTouchEnable(boolean enable)\nrotatable.isTouchEnable()\n```\n\u003cul\u003e\u003cli\u003e\nYou can enable / disable touch events or check whether touch is enable on rotatable object or not at anytime.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java \nrotatable.setDirection(int direction)\n```\n\u003cul\u003e\u003cli\u003e\nPossible to change rotation direction at runtime as well, but only with defined direction values in Rotatable class otherwise it will crash, so ensure that it is not possible to pass this method any other values except ROTATE_X - ROTATE_Y - ROTATE_BOTH\n\u003c/li\u003e\u003c/ul\u003e\n\n```java \nrotatable.orientationChanged(int newOrientation)\n```\n\u003cul\u003e\u003cli\u003e\nIf your rotatable object needs to calculate its rotationCount or rotationDistance, then it might be tricky while user rotates screen and change orientation. So prevent this, you can listen orientationChanges and notify rotatable object about it, so it can rearrange itself. To do it so, you need to declare `configChanges` in your AndroidManifest.xml as `orientation` but as it is described [here][1] after Android v3.0 it is also required `screenSize` to capture this orientationChange events.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java \nrotatable.drop()\n```\n\u003cul\u003e\u003cli\u003e\nThis method is quite important, especially when you changed any pivot value of the rootView and you wanted to change some configurations of rotatable. So call drop method first, then you rebuild your rotatable object with same view but different configurations.\n\u003c/li\u003e\u003c/ul\u003e\n\n```java \nrotatable.takeAttention()\n```\n\u003cul\u003e\u003cli\u003e\nThis is actually just for fun :) You can call this method where you want user to realize that he/she can move this component around :)\n\u003c/li\u003e\u003c/ul\u003e\n\n## Download\nAdd library dependency to your `build.gradle` file:\n\n```groovy\ndependencies {    \n     compile 'com.yayandroid:Rotatable:1.1.2'\n}\n```\n\n## License\n```\nThe MIT License (MIT)\n\nCopyright (c) 2015 yayandroid\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n\n[1]: http://stackoverflow.com/a/7366101/1171484\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyayaa%2FRotatable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyayaa%2FRotatable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyayaa%2FRotatable/lists"}