├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── example
│ │ └── jiangye
│ │ └── demo
│ │ ├── activity
│ │ ├── CoverActivity.java
│ │ └── ImageMoveActivity.java
│ │ ├── adapter
│ │ └── GyroscopeImageAdapter.java
│ │ ├── bean
│ │ └── ImageVo.java
│ │ └── gyroscope
│ │ ├── GyroscopeImageView.java
│ │ ├── GyroscopeManager.java
│ │ └── GyroscopeTransFormation.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ ├── activity_cover.xml
│ ├── activity_image_move.xml
│ ├── activity_main.xml
│ └── gyroscope_image_item.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── screenshots
├── GyroscopeImageView.gif
└── SmoothlyTransfer.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 | lint.xml
5 | proguard
6 |
7 | #Eclipse
8 | .project
9 | .classpath
10 | .settings
11 | .checkstyle
12 |
13 | #IntelliJ IDEA
14 | .idea
15 | *.iml
16 | *.ipr
17 | *.iws
18 | captures
19 | gen-external-apklibs
20 |
21 | #gradle
22 | .gradle
23 | local.properties
24 | gradlew
25 | gradlew.bat
26 | gradle/
27 | build
28 |
29 |
30 | #vi
31 | *.swp
32 |
33 | #other editors
34 | *.bak
35 |
36 | #Maven
37 | target
38 | release.properties
39 | pom.xml.*
40 |
41 | #Ant
42 | build.xml
43 | ant.properties
44 | proguard.cfg
45 | proguard-project.txt
46 |
47 | #Other
48 | .DS_Store
49 | Thumbs.db
50 | *.tgz
51 | *.lck
52 | com_crashlytics_export_strings.xml
53 |
54 | #review
55 |
56 | #freeline
57 | freeline*
58 |
59 | nuwapatch/
60 |
61 | #plugin
62 | homelink/src/main/assets/plugins/sh*.*
63 | homelink/src/main/assets/plugins/*.md5
64 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GyroscopeImageDemo
2 |
3 | 利用陀螺仪滑动图片的处理,以及针对陀螺仪图片控件的平滑转场动画。
4 |
5 | 我写了博客[《陀螺仪图片控件 & 平滑转场动画的相关解析》](https://www.jianshu.com/p/1d3abe34c895),分享我的想法和思路。
6 |
7 | 欢迎讨论并提出您的宝贵建议。
8 |
9 | ## Use GyroscopeImageView just like ImageView
10 |
11 |
12 |
13 |
14 |
15 | 在使用`GyroscopeImageView`控件时,若用 Picasso 加载图片 ,可利用 `GyroscopeTransFormation`, 传入控件的宽高即可合理地对图像尺寸做处理(当然你也可以自己处理图像的加载和图像的大小):
16 | ```java
17 | //用 Picasso加载图像 可将控件的宽高传入自定义的 TransFormation 来处理图像大小
18 | Picasso.get()
19 | .load(picUrl)
20 | .transform(new GyroscopeTransFormation(width, height))
21 | .into(gyroscopeImageView);
22 | ```
23 |
24 | ## Register the GyroscopeManager in related Activity
25 |
26 | 在相关`Activity`的`onResume`和`onPause`中对陀螺仪传感器进行注册和注销监听:
27 | ```java
28 | @Override protected void onResume() {
29 | super.onResume();
30 | //利用我们的 GyroscopeManager 来注册传感器监听
31 | GyroscopeManager.getInstance().register(this);
32 | }
33 |
34 | @Override protected void onPause() {
35 | super.onPause();
36 | //利用我们的 GyroscopeManager 来注销监听
37 | GyroscopeManager.getInstance().unregister(this);
38 | }
39 | ```
40 |
41 | ## Smoothly Transfer
42 |
43 |
44 |
45 |
46 | 平滑转场:
47 | ```java
48 | CoverActivity.startActivityWithAnimation(ImageMoveActivity.this, PIC_URL, gyroscopeImageView);
49 | ```
50 |
51 | Found this project useful
52 | -------
53 |
:heart: Hope this article can help you. Support by clicking the :star:, or share it with people around you. :heart:
54 |
55 |
56 | ## About me
57 |
58 | email : jiangye39@gmail.com
59 |
60 | blog : [jiangye](https://www.jianshu.com/u/6d9e544ead47)
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | app.iml
3 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "com.example.jiangye.gyroscopeimagedemo"
7 | minSdkVersion 19
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | }
19 |
20 | dependencies {
21 | implementation fileTree(dir: 'libs', include: ['*.jar'])
22 | implementation 'com.android.support:appcompat-v7:27.1.0'
23 | implementation 'com.android.support:recyclerview-v7:27.1.0'
24 | implementation 'com.android.support:support-v4:27.1.0'
25 | implementation 'com.squareup.picasso:picasso:2.71828'
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/activity/CoverActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Matrix;
7 | import android.graphics.Rect;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.Build;
10 | import android.os.Bundle;
11 | import android.support.annotation.Nullable;
12 | import android.transition.AutoTransition;
13 | import android.transition.ChangeImageTransform;
14 | import android.transition.TransitionManager;
15 | import android.transition.TransitionSet;
16 | import android.view.ViewGroup;
17 | import android.widget.FrameLayout;
18 | import android.widget.ImageView;
19 | import com.example.jiangye.demo.R;
20 | import com.example.jiangye.demo.gyroscope.GyroscopeImageView;
21 | import com.example.jiangye.demo.gyroscope.GyroscopeTransFormation;
22 | import com.squareup.picasso.Picasso;
23 | import com.squareup.picasso.Target;
24 |
25 | public class CoverActivity extends Activity {
26 |
27 | private static final String COVER_URL = "cover_url";
28 | private static final String OFFSET_X = "OFFSET_X";
29 | private static final String OFFSET_Y = "OFFSET_Y";
30 | private static final long TRANSITIONS_DURATION = 1000L; //做动画的时长
31 |
32 | /**
33 | * 屏幕宽度和高度
34 | */
35 | private int mScreenWidth;
36 | private int mScreenHeight;
37 |
38 | /**
39 | * 上一个页面 GyroscopeImageView 的宽度和高度
40 | */
41 | private int mOriginWidth;
42 | private int mOriginHeight;
43 |
44 | /**
45 | * Loading 覆盖图
46 | */
47 | private ImageView mIvCover;
48 | private String mCoverUrl;
49 |
50 | /**
51 | * 用于做 Transitions 动画的 ViewGroup
52 | */
53 | private ViewGroup mTransitionsContainer;
54 |
55 | /**
56 | * @param cover_url Loading 图 url
57 | * @param gyroscopeImageView 想要做动画的 GyroscopeImageView
58 | */
59 | public static void startActivityWithAnimation(final Activity activity, String cover_url,
60 | GyroscopeImageView gyroscopeImageView) {
61 | final Intent intent = new Intent(activity, CoverActivity.class);
62 | intent.putExtra(COVER_URL, cover_url);
63 | // 获取控件位置信息
64 | final Rect rect = new Rect();
65 | gyroscopeImageView.getGlobalVisibleRect(rect);
66 | intent.setSourceBounds(rect);
67 | intent.putExtra(OFFSET_X, gyroscopeImageView.getOffsetX());
68 | intent.putExtra(OFFSET_Y, gyroscopeImageView.getOffsetY());
69 | activity.startActivity(intent);
70 | activity.overridePendingTransition(0, 0);
71 | }
72 |
73 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
74 | super.onCreate(savedInstanceState);
75 | setContentView(R.layout.activity_cover);
76 | mCoverUrl = getIntent().getStringExtra(COVER_URL);
77 | mIvCover = findViewById(R.id.iv_cover);
78 | mTransitionsContainer = findViewById(R.id.container_layout);
79 | initial();
80 | }
81 |
82 | /**
83 | * 设置动画最初场景
84 | */
85 | private void initial() {
86 | // 获取上一个界面传入的控件位置信息
87 | Rect rect = getIntent().getSourceBounds();
88 |
89 | if (rect != null) {
90 | // 获取上一个界面中,控件的宽度和高度
91 | mOriginWidth = rect.right - rect.left;
92 | mOriginHeight = rect.bottom - rect.top;
93 |
94 | // 设置 ImageView 的位置,使其和上一个界面中图片的位置重合
95 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mOriginWidth, mOriginHeight);
96 | params.setMargins(rect.left, rect.top, rect.right, rect.bottom);
97 | mIvCover.setLayoutParams(params);
98 | mIvCover.setScaleType(ImageView.ScaleType.MATRIX);
99 |
100 | //拿到上个界面图片的偏移量
101 | final float offsetX = getIntent().getFloatExtra(OFFSET_X, 0);
102 | final float offsetY = getIntent().getFloatExtra(OFFSET_Y, 0);
103 |
104 | Picasso.get()
105 | .load(mCoverUrl)
106 | .transform(new GyroscopeTransFormation(mOriginWidth, mOriginHeight))
107 | .into(new Target() {
108 | @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
109 | mIvCover.setImageBitmap(bitmap);
110 | Matrix matrix = mIvCover.getImageMatrix();
111 | int width = bitmap.getWidth();
112 | int height = bitmap.getHeight();
113 | //保持上个界面图片的偏移量
114 | matrix.setTranslate((int) ((mOriginWidth - width) * 0.5f + 0.5f) + offsetX,
115 | (int) ((mOriginHeight - height) * 0.5f + 0.5f) + offsetY);
116 | mIvCover.setImageMatrix(matrix);
117 | }
118 |
119 | @Override public void onBitmapFailed(Exception e, Drawable errorDrawable) {
120 |
121 | }
122 |
123 | @Override public void onPrepareLoad(Drawable placeHolderDrawable) {
124 | }
125 | });
126 |
127 | //开始入场动画
128 | runEnterAnim();
129 | } else {
130 | //没有动画效果
131 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mScreenWidth, mScreenHeight);
132 | mIvCover.setLayoutParams(params);
133 | mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
134 | Picasso.get().load(mCoverUrl).into(mIvCover);
135 | }
136 | }
137 |
138 | /**
139 | * 获取屏幕尺寸
140 | */
141 | private void getScreenSize() {
142 | mScreenWidth = getResources().getDisplayMetrics().widthPixels;
143 | mScreenHeight = getResources().getDisplayMetrics().heightPixels;
144 | }
145 |
146 | /**
147 | * 模拟入场动画
148 | */
149 | private void runEnterAnim() {
150 | getScreenSize();
151 | mIvCover.post(new Runnable() {
152 | @Override public void run() {
153 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mScreenWidth, mScreenHeight);
154 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
155 | ChangeImageTransform changeImageTransform = new ChangeImageTransform();
156 | AutoTransition autoTransition = new AutoTransition();
157 | changeImageTransform.setDuration(TRANSITIONS_DURATION);
158 | autoTransition.setDuration(TRANSITIONS_DURATION);
159 | TransitionSet transitionSet = new TransitionSet();
160 | transitionSet.addTransition(autoTransition);
161 | transitionSet.addTransition(changeImageTransform);
162 | TransitionManager.beginDelayedTransition(mTransitionsContainer, transitionSet);
163 | mIvCover.setLayoutParams(params);
164 | mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
165 | } else {
166 | mIvCover.setLayoutParams(params);
167 | mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
168 | }
169 | }
170 | });
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/activity/ImageMoveActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.activity;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.DividerItemDecoration;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.View;
9 | import com.example.jiangye.demo.R;
10 | import com.example.jiangye.demo.adapter.GyroscopeImageAdapter;
11 | import com.example.jiangye.demo.bean.ImageVo;
12 | import com.example.jiangye.demo.gyroscope.GyroscopeImageView;
13 | import com.example.jiangye.demo.gyroscope.GyroscopeManager;
14 | import com.example.jiangye.demo.gyroscope.GyroscopeTransFormation;
15 | import com.squareup.picasso.Picasso;
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class ImageMoveActivity extends Activity {
20 |
21 | private static final String PIC1_URL =
22 | "http://wx2.sinaimg.cn/large/6e9ad2bdly1fnih8s6on4j21401401kz.jpg";
23 | private static final String PIC2_URL =
24 | "http://vrlab-public.ljcdn.com//release//vradmin//1000000020129136//images//FF41C450.png";
25 | private static final String PIC3_URL =
26 | "http://wx2.sinaimg.cn/large/6e9ad2bdly1fnih8uqgkuj2140140b2b.jpg";
27 |
28 | private GyroscopeImageView gyroscopeImageView;
29 | private List mData = new ArrayList<>();
30 |
31 | @Override protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_image_move);
34 |
35 | initView();
36 | }
37 |
38 | @Override protected void onResume() {
39 | super.onResume();
40 | GyroscopeManager.getInstance().register(this);
41 | }
42 |
43 | @Override protected void onPause() {
44 | super.onPause();
45 | GyroscopeManager.getInstance().unregister(this);
46 | }
47 |
48 | private void initView() {
49 | gyroscopeImageView = findViewById(R.id.head_image);
50 |
51 | gyroscopeImageView.post(new Runnable() {
52 | @Override public void run() {
53 | //获取控件大小,作为拉伸参数
54 | int width = gyroscopeImageView.getWidth();
55 | int height = gyroscopeImageView.getHeight();
56 |
57 | Picasso.get()
58 | .load(PIC3_URL)
59 | .transform(new GyroscopeTransFormation(width, height))
60 | .into(gyroscopeImageView);
61 | }
62 | });
63 |
64 | RecyclerView recyclerView = findViewById(R.id.rv_image_list);
65 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
66 | initData();
67 | final GyroscopeImageAdapter gyroscopeImageAdapter = new GyroscopeImageAdapter(this, mData);
68 | gyroscopeImageAdapter.setOnGvItemClickListener(
69 | new GyroscopeImageAdapter.OnGvItemClickListener() {
70 | @Override
71 | public void onGvItemClick(GyroscopeImageAdapter.ViewHolder holder, int position) {
72 |
73 | CoverActivity.startActivityWithAnimation(ImageMoveActivity.this,
74 | mData.get(position).mImageUrl, holder.gImg);
75 | }
76 | });
77 | recyclerView.setAdapter(gyroscopeImageAdapter);
78 | recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
79 |
80 | gyroscopeImageView.setOnClickListener(new View.OnClickListener() {
81 | @Override public void onClick(View v) {
82 |
83 | CoverActivity.startActivityWithAnimation(ImageMoveActivity.this, PIC3_URL,
84 | gyroscopeImageView);
85 | }
86 | });
87 | }
88 |
89 | private void initData() {
90 | mData.add(new ImageVo(PIC1_URL, "1"));
91 | mData.add(new ImageVo(PIC2_URL, "2"));
92 | mData.add(new ImageVo(PIC1_URL, "3"));
93 | mData.add(new ImageVo(PIC2_URL, "4"));
94 | mData.add(new ImageVo(PIC1_URL, "5"));
95 | mData.add(new ImageVo(PIC2_URL, "6"));
96 | mData.add(new ImageVo(PIC1_URL, "7"));
97 | mData.add(new ImageVo(PIC2_URL, "8"));
98 | mData.add(new ImageVo(PIC1_URL, "9"));
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/adapter/GyroscopeImageAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 | import com.example.jiangye.demo.R;
11 | import com.example.jiangye.demo.bean.ImageVo;
12 | import com.example.jiangye.demo.gyroscope.GyroscopeImageView;
13 | import com.example.jiangye.demo.gyroscope.GyroscopeTransFormation;
14 | import com.squareup.picasso.Picasso;
15 | import java.util.List;
16 |
17 | /**
18 | * 创建时间: 2018/03/12 21:43
19 | * 作者: jiangye
20 | * 描述:
21 | */
22 | public class GyroscopeImageAdapter extends RecyclerView.Adapter {
23 |
24 | private Context mContext;
25 | private List mItems;
26 | private OnGvItemClickListener mOnGvItemClickListener;
27 |
28 | /**
29 | * 记录 GyroscopeImageView 的宽高,用于进行 TransFormation
30 | */
31 | private int mHeight;
32 | private int mWidth;
33 |
34 | public GyroscopeImageAdapter(Context context, List items) {
35 | mContext = context;
36 | mItems = items;
37 | }
38 |
39 | public void setDatas(List data) {
40 | mItems = data;
41 | }
42 |
43 | @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
44 | View view = LayoutInflater.from(mContext).inflate(R.layout.gyroscope_image_item, parent, false);
45 | ViewHolder holder = new ViewHolder(view);
46 |
47 | ViewGroup.LayoutParams params = holder.gImg.getLayoutParams();
48 | mHeight = params.height;
49 | mWidth = params.width;
50 |
51 | return holder;
52 | }
53 |
54 | @Override public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
55 | holder.imgName.setText(mItems.get(position).mImageName);
56 |
57 | Picasso.get()
58 | .load(mItems.get(position).mImageUrl)
59 | .transform(new GyroscopeTransFormation(mWidth, mHeight))
60 | .into(holder.gImg);
61 |
62 | if (mOnGvItemClickListener != null) {
63 | holder.gImg.setOnClickListener(new View.OnClickListener() {
64 | @Override public void onClick(View v) {
65 | mOnGvItemClickListener.onGvItemClick(holder, holder.getAdapterPosition());
66 | }
67 | });
68 | }
69 | }
70 |
71 | @Override public int getItemCount() {
72 | return mItems != null ? mItems.size() : 0;
73 | }
74 |
75 | public interface OnGvItemClickListener {
76 | void onGvItemClick(ViewHolder holder, int position);
77 | }
78 |
79 | public void setOnGvItemClickListener(OnGvItemClickListener onGvItemClickListener) {
80 | mOnGvItemClickListener = onGvItemClickListener;
81 | }
82 |
83 | public class ViewHolder extends RecyclerView.ViewHolder {
84 | public GyroscopeImageView gImg;
85 | private TextView imgName;
86 |
87 | private ViewHolder(View itemView) {
88 | super(itemView);
89 | this.gImg = itemView.findViewById(R.id.gv_image_view);
90 | this.imgName = itemView.findViewById(R.id.tv_img_name);
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/bean/ImageVo.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.bean;
2 |
3 | /**
4 | * 创建时间: 2018/03/12 21:55
5 | * 作者: jiangye
6 | * 描述:
7 | */
8 |
9 | public class ImageVo {
10 |
11 | public String mImageUrl;
12 |
13 | public String mImageName;
14 |
15 | public ImageVo(String imageUrl, String imageName) {
16 | mImageUrl = imageUrl;
17 | mImageName = imageName;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/gyroscope/GyroscopeImageView.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.gyroscope;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.support.annotation.Nullable;
6 | import android.util.AttributeSet;
7 | import android.widget.ImageView;
8 |
9 | /**
10 | * 创建时间: 2018/01/12 12:13
11 | * 作者: jiangye
12 | * 描述: 可随陀螺仪滑动的自定义 ImageView 控件
13 | */
14 |
15 | public class GyroscopeImageView extends ImageView {
16 |
17 | private double mScaleX;
18 | private double mScaleY;
19 | private float mLenX;
20 | private float mLenY;
21 | protected double mAngleX;
22 | protected double mAngleY;
23 | private float mOffsetX;
24 | private float mOffsetY;
25 |
26 | public GyroscopeImageView(Context context) {
27 | super(context);
28 | init();
29 | }
30 |
31 | public GyroscopeImageView(Context context, @Nullable AttributeSet attrs) {
32 | super(context, attrs);
33 | init();
34 | }
35 |
36 | public GyroscopeImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
37 | super(context, attrs, defStyleAttr);
38 | init();
39 | }
40 |
41 | private void init() {
42 | setScaleType(ScaleType.CENTER);
43 | }
44 |
45 | @Override public void setScaleType(ScaleType scaleType) {
46 | super.setScaleType(ScaleType.CENTER);
47 | }
48 |
49 | public float getOffsetX() {
50 | return mOffsetX;
51 | }
52 |
53 | public float getOffsetY() {
54 | return mOffsetY;
55 | }
56 |
57 | @Override protected void onAttachedToWindow() {
58 | super.onAttachedToWindow();
59 | GyroscopeManager gyroscopeManager = GyroscopeManager.getInstance();
60 | if (gyroscopeManager != null) {
61 | gyroscopeManager.addView(this);
62 | }
63 | }
64 |
65 | @Override protected void onDetachedFromWindow() {
66 | super.onDetachedFromWindow();
67 | GyroscopeManager gyroscopeManager = GyroscopeManager.getInstance();
68 | if (gyroscopeManager != null) {
69 | gyroscopeManager.removeView(this);
70 | }
71 | }
72 |
73 | public void update(double scaleX, double scaleY) {
74 | mScaleX = scaleX;
75 | mScaleY = scaleY;
76 | invalidate();
77 | }
78 |
79 | @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
80 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
81 | int width = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight();
82 | int height = MeasureSpec.getSize(heightMeasureSpec) - getPaddingTop() - getPaddingBottom();
83 | if (getDrawable() != null) {
84 | int drawableWidth = getDrawable().getIntrinsicWidth();
85 | int drawableHeight = getDrawable().getIntrinsicHeight();
86 | mLenX = Math.abs((drawableWidth - width) * 0.5f);
87 | mLenY = Math.abs((drawableHeight - height) * 0.5f);
88 | }
89 | }
90 |
91 | @Override protected void onDraw(Canvas canvas) {
92 | if (getDrawable() == null || isInEditMode()) {
93 | super.onDraw(canvas);
94 | return;
95 | }
96 | mOffsetX = (float) (mLenX * mScaleX);
97 | mOffsetY = (float) (mLenY * mScaleY);
98 | canvas.save();
99 | canvas.translate(mOffsetX, mOffsetY);
100 | super.onDraw(canvas);
101 | canvas.restore();
102 | }
103 |
104 | @Override public boolean equals(Object obj) {
105 | return super.equals(obj);
106 | }
107 |
108 | @Override public int hashCode() {
109 | return super.hashCode();
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/gyroscope/GyroscopeManager.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.gyroscope;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.hardware.Sensor;
6 | import android.hardware.SensorEvent;
7 | import android.hardware.SensorEventListener;
8 | import android.hardware.SensorManager;
9 | import android.view.View;
10 | import java.util.ArrayList;
11 | import java.util.HashMap;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | /**
16 | * 创建时间: 2018/01/12 12:13
17 | * 作者: jiangye
18 | * 描述: GyroscopeImageView的 陀螺仪 控制器
19 | */
20 |
21 | public class GyroscopeManager implements SensorEventListener {
22 |
23 | private static final String TAG = GyroscopeManager.class.getSimpleName();
24 |
25 | /**
26 | * 将纳秒转化为秒
27 | */
28 | private static final float NS2S = 1.0f / 1000000000.0f;
29 |
30 | /**
31 | * 维护 GyroscopeImageView 的 状态, 需要传感器处理的 GyroscopeImageView 其对应的 value 为 true
32 | */
33 | private Map mViewsMap = new HashMap<>(9);
34 |
35 | /**
36 | * 维护需要传感器处理的 Activity
37 | */
38 | private List mActivityList = new ArrayList<>();
39 |
40 | private SensorManager sensorManager;
41 | private long mLastTimestamp;
42 | private double mMaxAngle = Math.PI / 2;
43 |
44 | private GyroscopeManager() {
45 | }
46 |
47 | private static class InstanceHolder {
48 | private static final GyroscopeManager sGyroscopeManager = new GyroscopeManager();
49 | }
50 |
51 | public static GyroscopeManager getInstance() {
52 | return InstanceHolder.sGyroscopeManager;
53 | }
54 |
55 | protected void addView(GyroscopeImageView gyroscopeImageView) {
56 | if (mActivityList.contains(getActivityFromView(gyroscopeImageView))) {
57 | mViewsMap.put(gyroscopeImageView, true);
58 | } else {
59 | mViewsMap.put(gyroscopeImageView, false);
60 | }
61 | }
62 |
63 | protected void removeView(GyroscopeImageView gyroscopeImageView) {
64 | mViewsMap.remove(gyroscopeImageView);
65 | }
66 |
67 | public void register(Activity activity) {
68 | mActivityList.add((activity));
69 | for (GyroscopeImageView view : mViewsMap.keySet()) {
70 | for (Activity a : mActivityList) {
71 | if (getActivityFromView(view) == a) {
72 | mViewsMap.put(view, true);
73 | }
74 | }
75 | }
76 |
77 | if (sensorManager == null) {
78 | sensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
79 | }
80 |
81 | Sensor sensor;
82 |
83 | if (sensorManager != null) {
84 | sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
85 | //灵敏度从快到慢 可选择: SENSOR_DELAY_FASTEST; SENSOR_DELAY_GAME; SENSOR_DELAY_NORMAL; SENSOR_DELAY_UI
86 | sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME);
87 | mLastTimestamp = 0;
88 | }
89 | }
90 |
91 | public void unregister(Activity activity) {
92 | mActivityList.remove((activity));
93 | for (GyroscopeImageView view : mViewsMap.keySet()) {
94 | if (getActivityFromView(view) == activity) {
95 | mViewsMap.put(view, false);
96 | }
97 | }
98 | sensorManager.unregisterListener(this);
99 | sensorManager = null;
100 | }
101 |
102 | @Override public void onSensorChanged(SensorEvent event) {
103 |
104 | if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
105 | if (mLastTimestamp != 0) {
106 | for (Map.Entry entry : mViewsMap.entrySet()) {
107 | //只处理集合中 value 为 true 的 view
108 | if (entry.getValue()) {
109 | entry.getKey().mAngleX +=
110 | event.values[0] * (event.timestamp - mLastTimestamp) * NS2S * 2.0f;
111 | entry.getKey().mAngleY +=
112 | event.values[1] * (event.timestamp - mLastTimestamp) * NS2S * 2.0f;
113 | if (entry.getKey().mAngleX > mMaxAngle) {
114 | entry.getKey().mAngleX = mMaxAngle;
115 | }
116 | if (entry.getKey().mAngleX < -mMaxAngle) {
117 | entry.getKey().mAngleX = -mMaxAngle;
118 | }
119 | if (entry.getKey().mAngleY > mMaxAngle) {
120 | entry.getKey().mAngleY = mMaxAngle;
121 | }
122 | if (entry.getKey().mAngleY < -mMaxAngle) {
123 | entry.getKey().mAngleY = -mMaxAngle;
124 | }
125 | entry.getKey()
126 | .update(entry.getKey().mAngleY / mMaxAngle, entry.getKey().mAngleX / mMaxAngle);
127 | }
128 | }
129 | }
130 | mLastTimestamp = event.timestamp;
131 | }
132 | }
133 |
134 | @Override public void onAccuracyChanged(Sensor sensor, int accuracy) {
135 |
136 | }
137 |
138 | private Activity getActivityFromView(View view) {
139 | return (Activity) view.getContext();
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/jiangye/demo/gyroscope/GyroscopeTransFormation.java:
--------------------------------------------------------------------------------
1 | package com.example.jiangye.demo.gyroscope;
2 |
3 | import android.graphics.Bitmap;
4 | import com.squareup.picasso.Transformation;
5 |
6 | /**
7 | * 创建时间: 2018/01/23 13:27
8 | * 作者: jiangye
9 | * 描述: 根据控件的宽高 来拉伸 支持陀螺仪滚动图片 的 Picasso Transformation
10 | */
11 |
12 | public class GyroscopeTransFormation implements Transformation {
13 |
14 | private int mWidgetWidth; //控件宽度
15 | private int mWidgetHeight; //控件高度
16 | private double mTargetWidth; //目标宽度
17 | private double mTargetHeight; //目标高度
18 |
19 | public GyroscopeTransFormation(int widgetWidth, int widgetHeight) {
20 | mWidgetWidth = widgetWidth;
21 | mWidgetHeight = widgetHeight;
22 | }
23 |
24 | @Override public Bitmap transform(Bitmap source) {
25 |
26 | if (source.getWidth() == 0 || source.getHeight() == 0) {
27 | return source;
28 | }
29 |
30 | mTargetWidth = source.getWidth();
31 | mTargetHeight = source.getHeight();
32 |
33 | double ratio = mTargetWidth / mTargetHeight; //图片的宽高比
34 | int distance; //图片缩放后与控件边的距离
35 |
36 | if (mWidgetHeight <= mWidgetWidth) {
37 | distance = mWidgetHeight / 8;
38 | mTargetWidth = mWidgetWidth + 2 * distance;
39 | mTargetHeight = mTargetWidth / ratio;
40 | } else {
41 | distance = mWidgetWidth / 8;
42 | mTargetHeight = mWidgetHeight + 2 * distance;
43 | mTargetWidth = mTargetHeight * ratio;
44 | }
45 |
46 | int desiredWidth = (int) mTargetWidth;
47 | int desiredHeight = (int) mTargetHeight;
48 |
49 | Bitmap result = Bitmap.createScaledBitmap(source, desiredWidth, desiredHeight, false);
50 |
51 | if (result != source) {
52 | // Same bitmap is returned if sizes are the same
53 | source.recycle();
54 | }
55 | return result;
56 | }
57 |
58 | @Override public String key() {
59 | return "";
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_move.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gyroscope_image_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
15 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GyroscopeImageDemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/screenshots/GyroscopeImageView.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/screenshots/GyroscopeImageView.gif
--------------------------------------------------------------------------------
/screenshots/SmoothlyTransfer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JY39/GyroscopeImageDemo/088220736e3b7e42c4592590bba31e6698177cc5/screenshots/SmoothlyTransfer.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------