├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── exmple
│ │ └── miclockview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── exmple
│ │ │ └── miclockview
│ │ │ ├── MIClockView.kt
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.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
│ └── test
│ └── java
│ └── com
│ └── exmple
│ └── miclockview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── image
├── aa.gif
├── bb.png
├── cc.png
├── code.jpg
├── dd.png
├── ee.png
├── ff.png
├── gg.png
├── hh.png
└── ii.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/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 | ### 引言
2 | 今天玩小米mix2的时候看到了小米的时间控件效果真的很棒。有各种动画效果,3d触摸效果,然后就想着自己能不能也实现一个这样的时间控件,那就开始行动绘制一个简易版本的小米时间控件吧o((≧▽≦o)
3 | ### 效果图
4 |
5 | * 首先来看看小米的效果是这个样子的
6 |
7 | 
8 |
9 |
10 | * 再来看看我的效果
11 |
12 | 
13 |
14 |
15 | ### 具体实现过程
16 | 我们都知道自定控件的绘制有很多种,继承view,继承viewgroup,还有继承已有的控件,但是无非就几个步骤:
17 |
18 | * measure(): 测量,用来控制控件的大小,final 不建议复写
19 | * layout(): 布局,用来控制控件摆放的位置,继承view不需要
20 | * draw(): 绘制,用来控制控件的样子
21 | * ontouch();touch事件
22 |
23 |
24 | 其中最重要的就是draw()方法,这个3d触摸效果是采用了Camera与Matrix现实,话不多说,开始理一下自己绘制的思路,我设想的绘制思路如下:
25 |
26 | * 1,先画最外层的圆弧和文字
27 | * 2,再画里面刻度盘
28 | * 3,再画秒表三角形
29 | * 4,画时针和分针
30 | * 5,画中间小球
31 | * 6,3d触摸效果
32 |
33 | 既然思路已经明确了,二话不说,那就开始搞吧
34 |
35 |
36 | #### **绘制前的准备工作**
37 | 首先需要初始化各种画笔,kotlin提供了一个init方法,就是拿来初始化的,不用像以前那样每个构造够一个init方法了,简单快捷
38 |
39 | ```
40 | init {
41 | mPaintOutCircle.color = color_halfWhite
42 | mPaintOutCircle.strokeWidth = dp2px(1f)
43 | mPaintOutCircle.style = Paint.Style.STROKE
44 |
45 | mPaintOutText.color = color_halfWhite
46 | mPaintOutText.strokeWidth = dp2px(1f)
47 | mPaintOutText.style = Paint.Style.STROKE
48 | mPaintOutText.textSize = sp2px(10f).toFloat()
49 | mPaintOutText.textAlign = Paint.Align.CENTER
50 |
51 | mPaintProgressBg.color = color_halfWhite
52 | mPaintProgressBg.strokeWidth = dp2px(2f)
53 | mPaintProgressBg.style = Paint.Style.STROKE
54 |
55 | mPaintProgress.color = color_halfWhite
56 | mPaintProgress.strokeWidth = dp2px(2f)
57 | mPaintProgress.style = Paint.Style.STROKE
58 |
59 | mPaintTriangle.color = color_white
60 | mPaintTriangle.style = Paint.Style.FILL
61 |
62 | mPaintHour.color = color_halfWhite
63 | mPaintHour.style = Paint.Style.FILL
64 |
65 | mPaintMinute.color = color_white
66 | mPaintMinute.strokeWidth = dp2px(3f)
67 | mPaintMinute.style = Paint.Style.STROKE
68 | mPaintMinute.strokeCap = Paint.Cap.ROUND
69 |
70 | mPaintBall.color = Color.parseColor("#836FFF")
71 | mPaintBall.style = Paint.Style.FILL
72 | }
73 | ```
74 | 接下来我们来看一下onmeasure方法,这个是测量控件的方法,一般情况下我们是不需要复写的,但是这个是个**正方形**的控件,所以是需要复写的,不能随便设置宽高,宽高需要保持一致;来看下代码
75 |
76 | ```
77 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
78 | val width = View.MeasureSpec.getSize(widthMeasureSpec)
79 | val height = View.MeasureSpec.getSize(heightMeasureSpec)
80 | //设置为正方形
81 | val imageSize = if (width < height) width else height
82 | setMeasuredDimension(imageSize, imageSize)
83 | }
84 | ```
85 | 然后我们就开始绘制了,就复写ondraw方法就行了,在绘制之前我们需要把cavans画板平移到view的中心,这样有利于下面绘制时候的旋转绘制,这里说明一下,我采用的是**旋转画布**的绘制方式,当然你也可以采用**三角函数进行计算具体的位置进行绘制**,道理差不多,我只是觉得计算麻烦一点;
86 |
87 | 我们来看一下实现,首先需要在onSizeChanged()方法拿到宽高,这个方法调用的时候代表已经测量结束,所以是可以拿到宽高的;
88 |
89 | ```
90 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
91 | super.onSizeChanged(w, h, oldw, oldh)
92 | mWidth = w
93 | mHeight = h
94 | mCenterX = mWidth / 2
95 | mCenterY = mHeight / 2
96 | }
97 |
98 | ```
99 | 然后画布平移
100 |
101 | ```
102 | override fun onDraw(canvas: Canvas) {
103 | //平移到视图中心
104 | canvas.translate(mCenterX.toFloat(), mCenterY.toFloat())
105 | }
106 | ```
107 | 好了绘制前的准备工作已经做好了接下来开始进行绘制
108 |
109 | #### **绘制外边缘4个弧度**
110 | 按照我之前的绘制思路,已经是首先绘制外边缘的4个弧度,每个弧度我设置为80°,弧度的位置分别是是
111 | **5-85,95-175,185 -265,275-355;**
112 |
113 | ```
114 | private fun drawArcCircle(canvas: Canvas) {
115 | val min = Math.min(width, mHeight)
116 | val rect = RectF(-(min - paddingOut) / 2, -(min - paddingOut) / 2, (min - paddingOut) / 2, (min - paddingOut) / 2)
117 | canvas.drawArc(rect, 5f, 80f, false, mPaintOutCircle)
118 | canvas.drawArc(rect, 95f, 80f, false, mPaintOutCircle)
119 | canvas.drawArc(rect, 185f, 80f, false, mPaintOutCircle)
120 | canvas.drawArc(rect, 275f, 80f, false, mPaintOutCircle)
121 |
122 | }
123 | ```
124 | 看下效果
125 |
126 | 
127 |
128 | #### **绘制外边缘4个文字**
129 | 然后绘制4个文字刻度:3,6,9,12,文字绘制主要是要把握到文字的具体位置,这里还是有点麻烦滴,你要知道具体的文字画笔几个属性是什么意思,如下图
130 |
131 | 
132 |
133 | 上代码
134 | ```
135 | private fun drawOutText(canvas: Canvas) {
136 | val min = Math.min(width, mHeight)
137 | val textRadius = (min - paddingOut) / 2
138 | val fm = mPaintOutText.getFontMetrics()
139 | //文字的高度
140 | val mTxtHeight = Math.ceil((fm.leading - fm.ascent).toDouble()).toInt()
141 | canvas.drawText("3", textRadius, (mTxtHeight / 2).toFloat(), mPaintOutText)
142 | canvas.drawText("9", -textRadius, (mTxtHeight / 2).toFloat(), mPaintOutText)
143 | canvas.drawText("6", 0f, textRadius + mTxtHeight / 2, mPaintOutText)
144 | canvas.drawText("12", 0f, -textRadius + mTxtHeight / 2, mPaintOutText)
145 | }
146 | ```
147 | 效果图
148 |
149 | 
150 |
151 | #### **绘制刻度**
152 | 刻度就很简单了,每个2°绘制一个刻度,也就是有180个刻度
153 |
154 | ```
155 | private fun drawCalibrationLine(canvas: Canvas) {
156 | val min = Math.min(width, mHeight) / 2
157 | for (i in 0 until 360 step 2) {
158 | canvas.save()
159 | canvas.rotate(i.toFloat())
160 | canvas.drawLine(min.toFloat() * 3 / 4, 0f, min * 3 / 4 + dp2px(10f), 0f, mPaintProgressBg);
161 | canvas.restore()
162 | }
163 | }
164 | ```
165 | 如图
166 |
167 | 
168 |
169 | #### **绘制秒**
170 | 这个是最有难度的一个地方,三角形通过旋转画布实现,知道秒表走的角度就可以了
171 |
172 | ```
173 | private fun drawSecond(canvas: Canvas) {
174 | //先绘制秒针的三角形
175 | canvas.save()
176 | canvas.rotate(mSecondMillsDegress)
177 | val path = Path()
178 | path.moveTo(0f, -width * 3f / 8 + dp2px(5f))
179 | path.lineTo(dp2px(8f), -width * 3f / 8 + dp2px(20f))
180 | path.lineTo(-dp2px(8f), -width * 3f / 8 + dp2px(20f))
181 | path.close()
182 | canvas.drawPath(path, mPaintTriangle)
183 | canvas.restore()
184 |
185 | //绘制渐变刻度
186 | val min = Math.min(width, mHeight) / 2
187 | for (i in 0..90 step 2) {
188 | //第一个参数设置透明度,实现渐变效果,从255到0
189 | canvas.save()
190 | mPaintProgress.setARGB((255 - 2.7 * i).toInt(), 255, 255, 255)
191 |
192 | //这里的先减去90°,是为了旋转到开始角度,因为开始角度是y轴的负方向
193 | canvas.rotate(((mSecondDegress - 90 - i).toFloat()))
194 | canvas.drawLine(min.toFloat() * 3 / 4, 0f, min * 3 / 4 + dp2px(10f), 0f, mPaintProgress);
195 | canvas.restore()
196 | }
197 | }
198 | ```
199 | 如图
200 |
201 | 
202 |
203 | #### **绘制分针和时针**
204 | 分针是一阶贝塞尔就是画线,时针是画path,也是旋转角度,这两个都差不多,就是绘制path
205 |
206 | ```
207 | private fun drawMinute(canvas: Canvas) {
208 | canvas.save()
209 | canvas.rotate(mMinuteDegress.toFloat())
210 | canvas.drawLine(0f, 0f, 0f, -(width / 3).toFloat(), mPaintMinute)
211 | canvas.restore()
212 | }
213 |
214 | private fun drawHour(canvas: Canvas) {
215 | canvas.save()
216 | canvas.rotate(mHourDegress.toFloat())
217 | canvas.drawCircle(0f, 0f, innerRadius, mPaintTriangle)
218 | val path = Path()
219 | path.moveTo(-innerRadius / 2, 0f)
220 | path.lineTo(innerRadius / 2, 0f)
221 | path.lineTo(innerRadius / 6, -(width / 4).toFloat())
222 | path.lineTo(-innerRadius / 6, -(width / 4).toFloat())
223 | path.close()
224 | canvas.drawPath(path, mPaintHour)
225 | canvas.restore()
226 | }
227 | ```
228 | #### **绘制中间小球**
229 |
230 | 这个就不用多说了
231 | ```
232 | private fun drawBall(canvas: Canvas) {
233 | canvas.drawCircle(0f, 0f, innerRadius / 2, mPaintBall)
234 |
235 | }
236 | ```
237 | 绘制就结束了,接下来是如何让时间走起来
238 | 如图
239 |
240 | 
241 |
242 | #### **让时间走起来**
243 |
244 | 我才用的方法就是直接采用延时任务的方式,每隔150毫秒去刷新一次时间数据
245 | 首先要获取到具体的当前时间数据
246 |
247 | ```
248 | private fun calculateDegree() {
249 | val mCalendar = Calendar.getInstance()
250 | mCalendar.timeInMillis = System.currentTimeMillis()
251 | val minute = mCalendar.get(Calendar.MINUTE)
252 | val secondMills = mCalendar.get(Calendar.MILLISECOND)
253 | val second = mCalendar.get(Calendar.SECOND)
254 | val hour = mCalendar.get(Calendar.HOUR)
255 | mHourDegress = hour * 30
256 | mMinuteDegress = minute * 6
257 | mSecondMillsDegress = second * 6 + secondMills * 0.006f
258 | mSecondDegress = second * 6
259 | val mills = secondMills * 0.006f
260 | //因为是没2°旋转一个刻度,所以这里要根据毫秒值来进行计算
261 | when (mills) {
262 | in 2 until 4 -> {
263 | mSecondDegress +=2
264 | }
265 | in 4 until 6 -> {
266 | mSecondDegress += 4
267 | }
268 | }
269 | }
270 |
271 | ```
272 | 然后开始运动
273 |
274 | ```
275 | // 指针转动的方法
276 | fun startTick() {
277 | // 一秒钟刷新一次
278 | postDelayed(mRunnable, 150)
279 | }
280 |
281 | private val mRunnable = Runnable {
282 | calculateDegree()
283 | invalidate()
284 | startTick()
285 | }
286 | ```
287 | 最后跟window进行视图绑定
288 |
289 | ```
290 |
291 | /**
292 | * 调用时机:onAttachedToWindow是在第一次onDraw前调用的,只调用一次
293 | */
294 | override fun onAttachedToWindow() {
295 | super.onAttachedToWindow()
296 | startTick()
297 | }
298 |
299 | /**
300 | * 调用时机:我们销毁View的时候。我们写的这个View不再显示。
301 | */
302 | override fun onDetachedFromWindow() {
303 | super.onDetachedFromWindow()
304 | removeCallbacks(mRunnable)
305 | }
306 |
307 | ```
308 | #### **3d触效果**
309 | 3d效果主要涉及到两个类
310 |
311 | ```
312 | 一个是android.graphics.Camera:3D开发,不是android.hardware.Camera:别倒错包了
313 | 还有一个是矩阵Matrix
314 | ```
315 | 一个照相机实例可以被用于计算3D变换,生成一个可以被使用的Matrix矩阵,一个实例,用在画布上。
316 | 其实Camera内部机制实际上还是opengl,只不过大大简化了使用。这样有利于开发者进行开发
317 |
318 | Camera的坐标系是左手坐标系。当手机平整的放在桌面上,X轴是手机的水平方向,Y轴是手机的竖直方向,Z轴是垂直于手机向里的那个方向。
319 |
320 | 
321 |
322 |
323 | 这个控件首先要touch事件中获取到具体的旋转角度,也就是说我们在触摸的时候计算出我们需要旋转的角度,然后设置给camera,然后camera在设置给Matrix,最后关联cavans
324 |
325 | 主要代码([部分代码参考自定义View练习(五)高仿小米时钟](https://blog.csdn.net/qq_31715429/article/details/54668668))
326 |
327 | ```
328 | private fun setCameraRotate() {
329 | mCameraMatrix.reset()
330 | mCamera.save()
331 | mCamera.rotateX(mCameraRotateX)//绕x轴旋转角度
332 | mCamera.rotateY(mCameraRotateY)//绕y轴旋转角度
333 | mCamera.getMatrix(mCameraMatrix)//相关属性设置到matrix中
334 | mCamera.restore()
335 | mCanvas.concat(mCameraMatrix)//matrix与canvas相关联
336 | }
337 | ```
338 |
339 | touch事件的处理
340 |
341 | ```
342 | override fun onTouchEvent(event: MotionEvent): Boolean {
343 | when (event.action) {
344 | MotionEvent.ACTION_DOWN -> {
345 | mShakeAnim?.let {
346 | if (it.isRunning) {
347 | it.cancel()
348 | }
349 | }
350 | getCameraRotate(event)
351 | getCanvasTranslate(event)
352 | }
353 | MotionEvent.ACTION_MOVE -> {
354 | //根据手指坐标计算camera应该旋转的大小
355 | getCameraRotate(event)
356 | getCanvasTranslate(event)
357 | }
358 | MotionEvent.ACTION_UP ->
359 | //松开手指,时钟复原并伴随晃动动画
360 | startShakeAnim()
361 | }
362 | return true
363 | }
364 | ```
365 |
366 | ```
367 | private fun getCameraRotate(event: MotionEvent) {
368 | val rotateX = -(event.y - height / 2)
369 | val rotateY = event.x - width / 2
370 | //求出此时旋转的大小与半径之比
371 | val percentArr = getPercent(rotateX, rotateY)
372 | //最终旋转的大小按比例匀称改变
373 | mCameraRotateX = percentArr[0] * mMaxCameraRotate
374 | mCameraRotateY = percentArr[1] * mMaxCameraRotate
375 | }
376 |
377 | /**
378 | * 当拨动时钟时,会发现时针、分针、秒针和刻度盘会有一个较小的偏移量,形成近大远小的立体偏移效果
379 | * 一开始我打算使用 matrix 和 camera 的 mCamera.translate(x, y, z) 方法改变 z 的值
380 | */
381 | private fun getCanvasTranslate(event: MotionEvent) {
382 | val translateX = event.x - width / 2
383 | val translateY = event.y - height / 2
384 | //求出此时位移的大小与半径之比
385 | val percentArr = getPercent(translateX, translateY)
386 | //最终位移的大小按比例匀称改变
387 | mCanvasTranslateX = percentArr[0] * mMaxCanvasTranslate
388 | mCanvasTranslateY = percentArr[1] * mMaxCanvasTranslate
389 | }
390 | /**
391 | * 获取一个操作旋转或位移大小的比例
392 | * @return 装有xy比例的float数组
393 | */
394 | private fun getPercent(x: Float, y: Float): FloatArray {
395 | val percentArr = FloatArray(2)
396 | var percentX = x / mRadius
397 | var percentY = y / mRadius
398 | if (percentX > 1) {
399 | percentX = 1f
400 | } else if (percentX < -1) {
401 | percentX = -1f
402 | }
403 | if (percentY > 1) {
404 | percentY = 1f
405 | } else if (percentY < -1) {
406 | percentY = -1f
407 | }
408 | percentArr[0] = percentX
409 | percentArr[1] = percentY
410 | return percentArr
411 | }
412 | ```
413 |
414 | 就这样一个小米时间控件绘制完成了
415 | 当然我也传了一个demo到github,如果有需要可以去下载玩玩
416 | 地址:[github地址](https://github.com/mouxuefei/MIClockView)
417 |
418 | 如果大家喜欢,请关注我的公众号,感谢大家支持,地址如下:
419 |
420 | 
421 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'//kotlin扩展
4 | apply plugin: 'kotlin-kapt'//
5 |
6 | android {
7 | compileSdkVersion 27
8 | defaultConfig {
9 | applicationId "com.exmple.miclockview"
10 | minSdkVersion 15
11 | targetSdkVersion 27
12 | versionCode 1
13 | versionName "1.0"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation fileTree(dir: 'libs', include: ['*.jar'])
26 | implementation 'com.android.support:appcompat-v7:27.1.1'
27 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
28 | testImplementation 'junit:junit:4.12'
29 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
32 | }
33 |
--------------------------------------------------------------------------------
/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/androidTest/java/com/exmple/miclockview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.exmple.miclockview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.exmple.miclockview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/exmple/miclockview/MIClockView.kt:
--------------------------------------------------------------------------------
1 | package com.exmple.miclockview
2 |
3 | import android.animation.PropertyValuesHolder
4 | import android.animation.TimeInterpolator
5 | import android.animation.ValueAnimator
6 | import android.content.Context
7 | import android.graphics.*
8 | import android.util.AttributeSet
9 | import android.view.MotionEvent
10 | import android.view.View
11 | import java.util.*
12 |
13 | class MIClockView @JvmOverloads
14 | constructor(
15 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
16 | ) : View(context, attrs, defStyleAttr) {
17 | //画边缘的线
18 | private val mPaintOutCircle = Paint(Paint.ANTI_ALIAS_FLAG)
19 | //画边缘的文字
20 | private val mPaintOutText = Paint(Paint.ANTI_ALIAS_FLAG)
21 | //画进度条
22 | private val mPaintProgressBg = Paint(Paint.ANTI_ALIAS_FLAG)
23 | private val mPaintProgress = Paint(Paint.ANTI_ALIAS_FLAG)
24 | //画三角形
25 | private val mPaintTriangle = Paint(Paint.ANTI_ALIAS_FLAG)
26 | //画时针
27 | private val mPaintHour = Paint(Paint.ANTI_ALIAS_FLAG)
28 | //画分针
29 | private val mPaintMinute = Paint(Paint.ANTI_ALIAS_FLAG)
30 | //画中间小圆球
31 | private val mPaintBall = Paint(Paint.ANTI_ALIAS_FLAG)
32 | //半透明的白色
33 | private val color_halfWhite: Int = Color.argb(255 - 180, 255, 255, 255)
34 | //纯白色
35 | private val color_white: Int = Color.parseColor("#FFFFFF")
36 | // 宽高
37 | private var mWidth: Int = 0
38 | private var mHeight: Int = 0
39 | //中心的坐标
40 | private var mCenterX: Int = 0
41 | private var mCenterY: Int = 0
42 | private val paddingOut: Float = dp2px(25f)
43 | private val innerRadius: Float = dp2px(6f)
44 | private var mHourDegress: Int = 0
45 | private var mMinuteDegress: Int = 0
46 | private var mSecondMillsDegress: Float = 0f
47 | private var mSecondDegress: Int = 0
48 |
49 | /* 时钟半径,不包括padding值 */
50 | private var mRadius: Float = 0.toFloat()
51 | /* 手指松开时时钟晃动的动画 */
52 | private var mShakeAnim: ValueAnimator? = null
53 | /* 触摸时作用在Camera的矩阵 */
54 | private val mCameraMatrix: Matrix by lazy { Matrix() }
55 | /* 照相机,用于旋转时钟实现3D效果 */
56 | private val mCamera: Camera by lazy { Camera() }
57 | /* camera绕X轴旋转的角度 */
58 | private var mCameraRotateX: Float = 0f
59 | /* camera绕Y轴旋转的角度 */
60 | private var mCameraRotateY: Float = 0f
61 | /* camera旋转的最大角度 */
62 | private val mMaxCameraRotate = 10f
63 | /* 指针的在x轴的位移 */
64 | private var mCanvasTranslateX: Float = 0f
65 | /* 指针的在y轴的位移 */
66 | private var mCanvasTranslateY: Float = 0f
67 | /* 指针的最大位移 */
68 | private var mMaxCanvasTranslate: Float = 0f
69 | /* 画布 */
70 | private lateinit var mCanvas: Canvas
71 |
72 | init {
73 | mPaintOutCircle.color = color_halfWhite
74 | mPaintOutCircle.strokeWidth = dp2px(1f)
75 | mPaintOutCircle.style = Paint.Style.STROKE
76 |
77 | mPaintOutText.color = color_halfWhite
78 | mPaintOutText.strokeWidth = dp2px(1f)
79 | mPaintOutText.style = Paint.Style.STROKE
80 | mPaintOutText.textSize = sp2px(11f).toFloat()
81 | mPaintOutText.textAlign = Paint.Align.CENTER
82 |
83 | mPaintProgressBg.color = color_halfWhite
84 | mPaintProgressBg.strokeWidth = dp2px(2f)
85 | mPaintProgressBg.style = Paint.Style.STROKE
86 |
87 | mPaintProgress.color = color_halfWhite
88 | mPaintProgress.strokeWidth = dp2px(2f)
89 | mPaintProgress.style = Paint.Style.STROKE
90 |
91 | mPaintTriangle.color = color_white
92 | mPaintTriangle.style = Paint.Style.FILL
93 |
94 | mPaintHour.color = color_halfWhite
95 | mPaintHour.style = Paint.Style.FILL
96 |
97 | mPaintMinute.color = color_white
98 | mPaintMinute.strokeWidth = dp2px(3f)
99 | mPaintMinute.style = Paint.Style.STROKE
100 | mPaintMinute.strokeCap = Paint.Cap.ROUND
101 |
102 | mPaintBall.color = Color.parseColor("#4169E1")
103 | mPaintBall.style = Paint.Style.FILL
104 |
105 | }
106 |
107 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
108 | val width = View.MeasureSpec.getSize(widthMeasureSpec)
109 | val height = View.MeasureSpec.getSize(heightMeasureSpec)
110 | //设置为正方形
111 | val imageSize = if (width < height) width else height
112 | setMeasuredDimension(imageSize, imageSize)
113 |
114 | }
115 |
116 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
117 | super.onSizeChanged(w, h, oldw, oldh)
118 | mWidth = w
119 | mHeight = h
120 | mCenterX = mWidth / 2
121 | mCenterY = mHeight / 2
122 | mRadius = (Math.min(w - paddingLeft - paddingRight,
123 | h - paddingTop - paddingBottom) / 2).toFloat()
124 |
125 | mMaxCanvasTranslate = 0.02f * mRadius
126 | }
127 |
128 | override fun onDraw(canvas: Canvas) {
129 | mCanvas = canvas
130 | //平移到视图中心
131 | canvas.translate(mCenterX.toFloat(), mCenterY.toFloat())
132 | setCameraRotate()
133 | drawArcCircle(canvas)
134 | drawOutText(canvas)
135 | drawCalibrationLine(canvas)
136 | drawSecond(canvas)
137 | drawMinute(canvas)
138 | drawHour(canvas)
139 | drawBall(canvas)
140 | }
141 |
142 | /**
143 | * 绘制中间的小球
144 | */
145 | private fun drawBall(canvas: Canvas) {
146 | canvas.drawCircle(0f, 0f, innerRadius / 2, mPaintBall)
147 | }
148 |
149 | /**
150 | * 绘制分
151 | */
152 | private fun drawMinute(canvas: Canvas) {
153 | canvas.save()
154 | canvas.rotate(mMinuteDegress.toFloat())
155 | canvas.drawLine(0f, 0f, 0f, -(width / 3).toFloat(), mPaintMinute)
156 | canvas.restore()
157 | }
158 |
159 | /**
160 | * 绘制时
161 | */
162 | private fun drawHour(canvas: Canvas) {
163 | canvas.save()
164 | canvas.rotate(mHourDegress.toFloat())
165 | canvas.drawCircle(0f, 0f, innerRadius, mPaintTriangle)
166 | val path = Path()
167 | path.moveTo(-innerRadius / 2, 0f)
168 | path.lineTo(innerRadius / 2, 0f)
169 | path.lineTo(innerRadius / 6, -(width / 4).toFloat())
170 | path.lineTo(-innerRadius / 6, -(width / 4).toFloat())
171 | path.close()
172 | canvas.drawPath(path, mPaintHour)
173 | canvas.restore()
174 | }
175 |
176 | /**
177 | * 绘制秒
178 | */
179 | private fun drawSecond(canvas: Canvas) {
180 | //先绘制秒针的三角形
181 | canvas.save()
182 | canvas.rotate(mSecondMillsDegress)
183 | val path = Path()
184 | path.moveTo(0f, -width * 3f / 8 + dp2px(5f))
185 | path.lineTo(dp2px(8f), -width * 3f / 8 + dp2px(20f))
186 | path.lineTo(-dp2px(8f), -width * 3f / 8 + dp2px(20f))
187 | path.close()
188 | canvas.drawPath(path, mPaintTriangle)
189 | canvas.restore()
190 |
191 | //绘制渐变刻度
192 | val min = Math.min(width, mHeight) / 2
193 | for (i in 0..90 step 2) {
194 | //第一个参数设置透明度,实现渐变效果,从255到0
195 | canvas.save()
196 | mPaintProgress.setARGB((255 - 2.7 * i).toInt(), 255, 255, 255)
197 |
198 | //这里的先减去90°,是为了旋转到开始角度,因为开始角度是y轴的负方向
199 | canvas.rotate(((mSecondDegress - 90 - i).toFloat()))
200 | canvas.drawLine(min.toFloat() * 3 / 4, 0f, min * 3 / 4 + dp2px(10f), 0f, mPaintProgress);
201 | canvas.restore()
202 | }
203 | }
204 |
205 | /**
206 | * 绘制刻度线
207 | * desc:每个2°绘制一个刻度,也就是有180个刻度
208 | */
209 | private fun drawCalibrationLine(canvas: Canvas) {
210 | val min = Math.min(width, mHeight) / 2
211 | for (i in 0 until 360 step 2) {
212 | canvas.save()
213 | canvas.rotate(i.toFloat())
214 | canvas.drawLine(min.toFloat() * 3 / 4, 0f, min * 3 / 4 + dp2px(10f), 0f, mPaintProgressBg);
215 | canvas.restore()
216 | }
217 | }
218 |
219 | /**
220 | * 然后绘制4个文字刻度:3,6,9,12
221 | */
222 | private fun drawOutText(canvas: Canvas) {
223 | val min = Math.min(width, mHeight)
224 | val textRadius = (min - paddingOut) / 2
225 | val fm = mPaintOutText.fontMetrics
226 | //文字的高度
227 | val mTxtHeight = Math.ceil((fm.leading - fm.ascent).toDouble()).toInt()
228 | canvas.drawText("3", textRadius, (mTxtHeight / 2).toFloat(), mPaintOutText)
229 | canvas.drawText("9", -textRadius, (mTxtHeight / 2).toFloat(), mPaintOutText)
230 | canvas.drawText("6", 0f, textRadius + mTxtHeight / 2, mPaintOutText)
231 | canvas.drawText("12", 0f, -textRadius + mTxtHeight / 2, mPaintOutText)
232 | }
233 |
234 | /**
235 | * 首先画外边缘的弧度,分成四个弧度,假设每个弧度中间的间隔是6个弧度
236 | * 那么弧度的位置是 5-85,95-175,185 -265,275-355;
237 | */
238 | private fun drawArcCircle(canvas: Canvas) {
239 | val min = Math.min(width, mHeight)
240 | val rect = RectF(-(min - paddingOut) / 2, -(min - paddingOut) / 2, (min - paddingOut) / 2, (min - paddingOut) / 2)
241 | canvas.drawArc(rect, 5f, 80f, false, mPaintOutCircle)
242 | canvas.drawArc(rect, 95f, 80f, false, mPaintOutCircle)
243 | canvas.drawArc(rect, 185f, 80f, false, mPaintOutCircle)
244 | canvas.drawArc(rect, 275f, 80f, false, mPaintOutCircle)
245 |
246 | }
247 |
248 | // 指针转动的方法
249 | private fun startTick() {
250 | // 一秒钟刷新一次
251 | postDelayed(mRunnable, 150)
252 | }
253 |
254 | private val mRunnable = Runnable {
255 | calculateDegree()
256 | invalidate()
257 | startTick()
258 | }
259 |
260 | private fun calculateDegree() {
261 | val mCalendar = Calendar.getInstance()
262 | mCalendar.timeInMillis = System.currentTimeMillis()
263 | val minute = mCalendar.get(Calendar.MINUTE)
264 | val secondMills = mCalendar.get(Calendar.MILLISECOND)
265 | val second = mCalendar.get(Calendar.SECOND)
266 | val hour = mCalendar.get(Calendar.HOUR)
267 | mHourDegress = hour * 30
268 | mMinuteDegress = minute * 6
269 | mSecondMillsDegress = second * 6 + secondMills * 0.006f
270 | mSecondDegress = second * 6
271 | val mills = secondMills * 0.006f
272 | //因为是没2°旋转一个刻度,所以这里要根据毫秒值来进行计算
273 | when (mills) {
274 | in 2 until 4 -> {
275 | mSecondDegress += 2
276 | }
277 | in 4 until 6 -> {
278 | mSecondDegress += 4
279 | }
280 | }
281 | }
282 |
283 | /**
284 | * 调用时机:onAttachedToWindow是在第一次onDraw前调用的,只调用一次
285 | */
286 | override fun onAttachedToWindow() {
287 | super.onAttachedToWindow()
288 | startTick()
289 | }
290 |
291 | /**
292 | * 调用时机:我们销毁View的时候。我们写的这个View不再显示。
293 | */
294 | override fun onDetachedFromWindow() {
295 | super.onDetachedFromWindow()
296 | removeCallbacks(mRunnable)
297 | }
298 |
299 | override fun onTouchEvent(event: MotionEvent): Boolean {
300 | when (event.action) {
301 | MotionEvent.ACTION_DOWN -> {
302 | mShakeAnim?.let {
303 | if (it.isRunning) {
304 | it.cancel()
305 | }
306 | }
307 | getCameraRotate(event)
308 | getCanvasTranslate(event)
309 | }
310 | MotionEvent.ACTION_MOVE -> {
311 | //根据手指坐标计算camera应该旋转的大小
312 | getCameraRotate(event)
313 | getCanvasTranslate(event)
314 | }
315 | MotionEvent.ACTION_UP ->
316 | //松开手指,时钟复原并伴随晃动动画
317 | startShakeAnim()
318 | }
319 | return true
320 | }
321 |
322 | /**
323 | * 设置3D时钟效果,触摸矩阵的相关设置、照相机的旋转大小
324 | * 应用在绘制图形之前,否则无效
325 | * desc:Camera的坐标系是左手坐标系。当手机平整的放在桌面上,X轴是手机的水平方向,Y轴是手机的竖直方向,Z轴是垂直于手机向里的那个方向。
326 | * Camera内部机制实际上还是opengl,不过大大简化了使用。
327 | */
328 | private fun setCameraRotate() {
329 | mCameraMatrix.reset()
330 | mCamera.save()
331 | mCamera.rotateX(mCameraRotateX)//绕x轴旋转角度
332 | mCamera.rotateY(mCameraRotateY)//绕y轴旋转角度
333 | mCamera.getMatrix(mCameraMatrix)//相关属性设置到matrix中
334 | mCamera.restore()
335 | mCanvas.concat(mCameraMatrix)//matrix与canvas相关联
336 | }
337 |
338 | /**
339 | * 时钟晃动动画
340 | */
341 | private fun startShakeAnim() {
342 | val cameraRotateXName = "cameraRotateX"
343 | val cameraRotateYName = "cameraRotateY"
344 | val canvasTranslateXName = "canvasTranslateX"
345 | val canvasTranslateYName = "canvasTranslateY"
346 | val cameraRotateXHolder = PropertyValuesHolder.ofFloat(cameraRotateXName, mCameraRotateX, 0f)
347 | val cameraRotateYHolder = PropertyValuesHolder.ofFloat(cameraRotateYName, mCameraRotateY, 0f)
348 | val canvasTranslateXHolder = PropertyValuesHolder.ofFloat(canvasTranslateXName, mCanvasTranslateX, 0f)
349 | val canvasTranslateYHolder = PropertyValuesHolder.ofFloat(canvasTranslateYName, mCanvasTranslateY, 0f)
350 | mShakeAnim = ValueAnimator.ofPropertyValuesHolder(cameraRotateXHolder,
351 | cameraRotateYHolder, canvasTranslateXHolder, canvasTranslateYHolder)
352 | mShakeAnim?.interpolator = TimeInterpolator { input ->
353 | //http://inloop.github.io/interpolator/
354 | val f = 0.571429f
355 | (Math.pow(2.0, (-2 * input).toDouble()) * Math.sin((input - f / 4) * (2 * Math.PI) / f) + 1).toFloat()
356 | }
357 | mShakeAnim?.duration = 1000
358 | mShakeAnim?.addUpdateListener({ animation ->
359 | mCameraRotateX = animation.getAnimatedValue(cameraRotateXName) as Float
360 | mCameraRotateY = animation.getAnimatedValue(cameraRotateYName) as Float
361 | mCanvasTranslateX = animation.getAnimatedValue(canvasTranslateXName) as Float
362 | mCanvasTranslateY = animation.getAnimatedValue(canvasTranslateYName) as Float
363 | })
364 | mShakeAnim?.start()
365 | }
366 |
367 | /**
368 | * 获取camera旋转的大小
369 | *
370 | * @param event motionEvent
371 | */
372 | private fun getCameraRotate(event: MotionEvent) {
373 | val rotateX = -(event.y - height / 2)
374 | val rotateY = event.x - width / 2
375 | //求出此时旋转的大小与半径之比
376 | val percentArr = getPercent(rotateX, rotateY)
377 | //最终旋转的大小按比例匀称改变
378 | mCameraRotateX = percentArr[0] * mMaxCameraRotate
379 | mCameraRotateY = percentArr[1] * mMaxCameraRotate
380 | }
381 |
382 | /**
383 | * 当拨动时钟时,会发现时针、分针、秒针和刻度盘会有一个较小的偏移量,形成近大远小的立体偏移效果
384 | * 一开始我打算使用 matrix 和 camera 的 mCamera.translate(x, y, z) 方法改变 z 的值
385 | */
386 | private fun getCanvasTranslate(event: MotionEvent) {
387 | val translateX = event.x - width / 2
388 | val translateY = event.y - height / 2
389 | //求出此时位移的大小与半径之比
390 | val percentArr = getPercent(translateX, translateY)
391 | //最终位移的大小按比例匀称改变
392 | mCanvasTranslateX = percentArr[0] * mMaxCanvasTranslate
393 | mCanvasTranslateY = percentArr[1] * mMaxCanvasTranslate
394 | }
395 |
396 | /**
397 | * 获取一个操作旋转或位移大小的比例
398 | * @return 装有xy比例的float数组
399 | */
400 | private fun getPercent(x: Float, y: Float): FloatArray {
401 | val percentArr = FloatArray(2)
402 | var percentX = x / mRadius
403 | var percentY = y / mRadius
404 | if (percentX > 1) {
405 | percentX = 1f
406 | } else if (percentX < -1) {
407 | percentX = -1f
408 | }
409 | if (percentY > 1) {
410 | percentY = 1f
411 | } else if (percentY < -1) {
412 | percentY = -1f
413 | }
414 | percentArr[0] = percentX
415 | percentArr[1] = percentY
416 | return percentArr
417 | }
418 | }
419 |
420 | /**
421 | * dp转px
422 | */
423 | fun View.dp2px(dipValue: Float): Float {
424 | return (dipValue * this.resources.displayMetrics.density + 0.5f)
425 | }
426 |
427 | /**
428 | * px转dp
429 | */
430 | fun View.px2dp(pxValue: Float): Float {
431 | return (pxValue / this.resources.displayMetrics.density + 0.5f)
432 | }
433 |
434 | /**
435 | * sp转px
436 | */
437 | fun View.sp2px(spValue: Float): Float {
438 | return (spValue * this.resources.displayMetrics.scaledDensity + 0.5f)
439 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/exmple/miclockview/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.exmple.miclockview
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 |
6 | class MainActivity : AppCompatActivity() {
7 |
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | setContentView(R.layout.activity_main)
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/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_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
--------------------------------------------------------------------------------
/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/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/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 | MIClockView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/exmple/miclockview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.exmple.miclockview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.31'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.3'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
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 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 25 12:18:27 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/image/aa.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/aa.gif
--------------------------------------------------------------------------------
/image/bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/bb.png
--------------------------------------------------------------------------------
/image/cc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/cc.png
--------------------------------------------------------------------------------
/image/code.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/code.jpg
--------------------------------------------------------------------------------
/image/dd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/dd.png
--------------------------------------------------------------------------------
/image/ee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/ee.png
--------------------------------------------------------------------------------
/image/ff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/ff.png
--------------------------------------------------------------------------------
/image/gg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/gg.png
--------------------------------------------------------------------------------
/image/hh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/hh.png
--------------------------------------------------------------------------------
/image/ii.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mouxuefei/MIClockView/c361769c97f7326ff7ea75e4f490c4a39b1aaf71/image/ii.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------