├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── libraries
│ ├── animated_vector_drawable_25_3_1.xml
│ ├── appcompat_v7_25_3_1.xml
│ ├── espresso_core_2_2_2.xml
│ ├── espresso_idling_resource_2_2_2.xml
│ ├── exposed_instrumentation_api_publish_0_5.xml
│ ├── hamcrest_core_1_3.xml
│ ├── hamcrest_integration_1_3.xml
│ ├── hamcrest_library_1_3.xml
│ ├── javawriter_2_1_1.xml
│ ├── javax_annotation_api_1_2.xml
│ ├── javax_inject_1.xml
│ ├── jsr305_2_0_1.xml
│ ├── junit_4_12.xml
│ ├── rules_0_5.xml
│ ├── runner_0_5.xml
│ ├── support_annotations_25_3_1.xml
│ ├── support_compat_25_3_1.xml
│ ├── support_core_ui_25_3_1.xml
│ ├── support_core_utils_25_3_1.xml
│ ├── support_fragment_25_3_1.xml
│ ├── support_media_compat_25_3_1.xml
│ ├── support_v4_25_3_1.xml
│ └── support_vector_drawable_25_3_1.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hzn
│ │ └── easypath
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hzn
│ │ │ └── easypath
│ │ │ ├── MainActivity.java
│ │ │ └── RepeatActivity.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── activity_repeat.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── hzn
│ └── easypath
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hzn
│ │ └── lib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hzn
│ │ │ └── lib
│ │ │ ├── EasyPathParser.java
│ │ │ └── EasyPathView.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── hzn
│ └── lib
│ └── ExampleUnitTest.java
├── screenshots
├── easy_path_repeat.gif
├── easy_path_separate.gif
├── easy_path_together.gif
├── icons1.gif
└── icons2.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | EasyPath
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/animated_vector_drawable_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/appcompat_v7_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/espresso_core_2_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/espresso_idling_resource_2_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/hamcrest_core_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/hamcrest_integration_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/hamcrest_library_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/javawriter_2_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/javax_annotation_api_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/javax_inject_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/jsr305_2_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/junit_4_12.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/rules_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/runner_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_annotations_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/support_compat_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_core_ui_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_core_utils_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_fragment_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_media_compat_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/support_vector_drawable_25_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/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 | # EasyPath
2 | Including a light PathParser tool and animated PathView for Android, which is based on vector. PathParser is easy to EXTEND, welcome and have fun!
3 |
4 | ## ScreenShots
5 | ### Icons
6 | 
7 |
8 | 
9 | ### Separate
10 | 
11 | ### Together
12 | 
13 | ### Dynamic&Repeat
14 | 
15 |
16 | ## Gradle
17 | Add to your root build.gradle:
18 | ```xml
19 | allprojects {
20 | repositories {
21 | ...
22 | maven { url 'https://jitpack.io' }
23 | }
24 | }
25 | ```
26 |
27 | Add the dependency:
28 | ```xml
29 | dependencies {
30 | compile 'com.github.huzenan:EasyPath:v1.0.2'
31 | }
32 | ```
33 |
34 | ## Usage
35 | ### Step 1
36 | Define your path string like this:
37 | ```xml
38 |
39 | m100,300 c130,20,470,20,500,300 m500,300
40 | l500,525 100,525 100,300 500,300
41 | m200,180 o215,180,10,1 m400,180 o385,180,10,2
42 | m200,105 l175,75 m400,105 l425,75
43 |
44 | ```
45 | ### Step 2
46 | > layout
47 |
48 | ```xml
49 |
63 | ```
64 | > Activity
65 |
66 | ```java
67 | easyPathView.starDraw(true); // true if repeat
68 | ...
69 | easyPathView.starErase();
70 | ...
71 | easyPathView.stopRepeat();
72 | ...
73 | easyPathView.setAnimProgress(0.66f);
74 | ...
75 | easyPathView.addOnAnimatorListener(new EasyPathView.OnAnimatorListener() {
76 | @Override
77 | protected void onAnimStart(int state) {
78 | // your codes
79 | }
80 |
81 | @Override
82 | protected void onAnimEnd(int state) {
83 | // your codes
84 | }
85 |
86 | @Override
87 | protected void onAnimRepeat(int state) {
88 | // your codes
89 | }
90 | });
91 | ```
92 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '25.0.3'
6 |
7 | defaultConfig {
8 | applicationId "com.hzn.easypath"
9 | minSdkVersion 15
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:25.3.1'
26 | compile project(':lib')
27 | }
28 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\AndroidSDK\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hzn/easypath/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.hzn.easypath;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hzn/easypath/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.hzn.easypath;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.SeekBar;
8 |
9 | import com.hzn.lib.EasyPathView;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | private EasyPathView epv1;
14 | private EasyPathView epv2;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 |
21 |
22 | // separate
23 | epv1 = (EasyPathView) findViewById(R.id.view);
24 | Button btnDraw1 = (Button) findViewById(R.id.btn_draw1);
25 | btnDraw1.setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View v) {
28 | if (epv1.getState() == EasyPathView.STATE_HIDE)
29 | epv1.startDraw();
30 | }
31 | });
32 | Button btnErase1 = (Button) findViewById(R.id.btn_erase1);
33 | btnErase1.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View v) {
36 | if (epv1.getState() == EasyPathView.STATE_SHOW)
37 | epv1.startErase();
38 | }
39 | });
40 | SeekBar sb1 = (SeekBar) findViewById(R.id.sb1);
41 | sb1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
42 | @Override
43 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
44 | epv1.setAnimProgress(progress / 100.0f);
45 | }
46 |
47 | @Override
48 | public void onStartTrackingTouch(SeekBar seekBar) {
49 |
50 | }
51 |
52 | @Override
53 | public void onStopTrackingTouch(SeekBar seekBar) {
54 |
55 | }
56 | });
57 |
58 |
59 | // together
60 | epv2 = (EasyPathView) findViewById(R.id.view2);
61 | Button btnDraw2 = (Button) findViewById(R.id.btn_draw2);
62 | btnDraw2.setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | if (epv2.getState() == EasyPathView.STATE_HIDE)
66 | epv2.startDraw();
67 | }
68 | });
69 | Button btnErase2 = (Button) findViewById(R.id.btn_erase2);
70 | btnErase2.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | if (epv2.getState() == EasyPathView.STATE_SHOW)
74 | epv2.startErase();
75 | }
76 | });
77 | SeekBar sb2 = (SeekBar) findViewById(R.id.sb2);
78 | sb2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
79 | @Override
80 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
81 | epv2.setAnimProgress(progress / 100.0f);
82 | }
83 |
84 | @Override
85 | public void onStartTrackingTouch(SeekBar seekBar) {
86 |
87 | }
88 |
89 | @Override
90 | public void onStopTrackingTouch(SeekBar seekBar) {
91 |
92 | }
93 | });
94 |
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hzn/easypath/RepeatActivity.java:
--------------------------------------------------------------------------------
1 | package com.hzn.easypath;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.FragmentActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import com.hzn.lib.EasyPathView;
10 |
11 | public class RepeatActivity extends FragmentActivity {
12 |
13 | private EasyPathView epv;
14 |
15 | @Override
16 | protected void onCreate(@Nullable Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_repeat);
19 | initViews();
20 | }
21 |
22 | private void initViews() {
23 | epv = (EasyPathView) findViewById(R.id.view);
24 |
25 | Button btnRepeat = (Button) findViewById(R.id.btn_repeat);
26 | btnRepeat.setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View v) {
29 | epv.startDraw(true);
30 | }
31 | });
32 |
33 | Button btnStop = (Button) findViewById(R.id.btn_stop);
34 | btnStop.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | epv.stopRepeat();
38 | }
39 | });
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
33 |
34 |
40 |
41 |
48 |
49 |
56 |
57 |
58 |
62 |
63 |
79 |
80 |
86 |
87 |
94 |
95 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_repeat.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
33 |
34 |
40 |
41 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #09991c
4 | #09991c
5 | #09991c
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyPath
3 |
4 |
5 | m100,300 c130,20,470,20,500,300 m500,300 l500,525 100,525 100,300 500,300
6 | m200,180 o215,180,10,1 m400,180 o385,180,10,2
7 | m200,105 l175,75 m400,105 l425,75
8 |
9 |
10 |
11 | o50,50,40,1 m30,30 l70,70 m30,70 l70,30
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hzn/easypath/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hzn.easypath;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Aug 05 13:40:57 CST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '25.0.3'
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:25.3.1'
30 | testCompile 'junit:junit:4.12'
31 | }
--------------------------------------------------------------------------------
/lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/lib/src/androidTest/java/com/hzn/lib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.hzn.lib;
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 | * Instrumentation 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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.hzn.lib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lib/src/main/java/com/hzn/lib/EasyPathParser.java:
--------------------------------------------------------------------------------
1 | package com.hzn.lib;
2 |
3 | import android.graphics.Path;
4 | import android.graphics.RectF;
5 | import android.view.View;
6 |
7 | import java.text.ParseException;
8 |
9 | /**
10 | * 路径解析类,用于生成路径对象Path
11 | * Created by huzn on 2016/12/19.
12 | */
13 | public class EasyPathParser {
14 |
15 | private String pathString;
16 | private int len;
17 | private int curIndex;
18 | private char last = '!'; // 标志开头
19 |
20 | private int argNum;
21 | private int curNum;
22 |
23 | private float[] args = new float[6];
24 |
25 | private volatile static EasyPathParser instance;
26 |
27 | private EasyPathParser() {
28 | }
29 |
30 | public static EasyPathParser getInstance() {
31 | if (null == instance) {
32 | synchronized (EasyPathParser.class) {
33 | if (null == instance) {
34 | instance = new EasyPathParser();
35 | }
36 | }
37 | }
38 | return instance;
39 | }
40 |
41 | /**
42 | * 解析一段路径字符串并返回一个路径对象Path
43 | * 目前支持的指令有:
44 | * m、M:相当于执行Path.moveTo,后面带2个参数,分别为x和y坐标;例如:"m50,50"
45 | * l、L:相当于执行Path.lineTo,后面带2个参数,分别为x和y坐标;例如:"l28.8,33.3"
46 | * a、A:相当于执行Path.addArc,后面带6个参数,分别为left,top,right,bottom,startAngle和sweepAngle;例如:"a-50,-50,50,50,45,359.9"
47 | * o、O:相当于执行Path.addCircle,后面带4个参数,分别为圆心的x和y坐标、半径、方向,方向为1表示CW,2表示CCW(详见{@link android.graphics.Path.Direction});例如:"l30,30"
48 | * q、Q:相当于执行Path.quadTo,二次贝塞尔曲线,后面带4个参数,(详见{@link Path#quadTo(float, float, float, float)});例如:"q50,50,100,0"
49 | * c、C:相当于执行Path.cubicTo,三次贝塞尔曲线,后面带6个参数,(详见{@link Path#cubicTo(float, float, float, float, float, float)});例如:"q50,50,100,0"
50 | * z、Z:相当于执行Path.close,不带参数,例如:"z"
51 | * 其中,指令为小写时的坐标为相对于父容器原点的坐标,大写时为绝对坐标;当parent参数为空时,按绝对坐标解析。
52 | *
53 | * @param str 要解析的路径字符串,每一种指令之间用空格来间隔,相同指令之间无需再指定指令字符,例如:"m100,100 l150,150 100,150 z"
54 | * @param parent 父容器视图对象
55 | * @param factor 实际大小与指定大小的比例,用于正确生成路径位置,例如实际绘制大小为600x400,指定大小为300x200,此时factor为2
56 | * @return Path 解析完成后返回的路径对象
57 | * @throws ParseException 发生解析错误时抛出的异常
58 | */
59 | public Path parsePath(String str, View parent, float factor) throws ParseException {
60 | Path path = new Path();
61 | pathString = str.trim();
62 | len = pathString.length();
63 |
64 | curIndex = 0;
65 | while (curIndex < len) {
66 | curNum = 0;
67 | char ch = pathString.charAt(curIndex);
68 |
69 | // 跳过空格
70 | while (ch == ' ') {
71 | if (++curIndex < len)
72 | ch = pathString.charAt(curIndex);
73 | }
74 |
75 | // 是否为同一个指令
76 | if (last != '!' && ('0' <= ch && ch <= '9' || ch == '-')) {
77 | ch = last;
78 | --curIndex;
79 | }
80 |
81 | switch (ch) {
82 | // moveTo
83 | case 'M':
84 | case 'm':
85 | argNum = 2;
86 | last = 'm';
87 | nextToken();
88 | if (ch == 'M' && null != parent) {
89 | last = 'M';
90 | args[0] -= parent.getX();
91 | args[1] -= parent.getY();
92 | }
93 | path.moveTo(args[0] * factor, args[1] * factor);
94 | break;
95 |
96 | // lineTo
97 | case 'L':
98 | case 'l':
99 | argNum = 2;
100 | last = 'l';
101 | nextToken();
102 | if (ch == 'L' && null != parent) {
103 | last = 'L';
104 | args[0] -= parent.getX();
105 | args[1] -= parent.getY();
106 | }
107 | path.lineTo(args[0] * factor, args[1] * factor);
108 | break;
109 |
110 | // addArc
111 | case 'A':
112 | case 'a':
113 | argNum = 6;
114 | last = 'a';
115 | nextToken();
116 | if (ch == 'A' && null != parent) {
117 | last = 'A';
118 | args[0] -= parent.getX();
119 | args[1] -= parent.getY();
120 | args[2] -= parent.getX();
121 | args[3] -= parent.getY();
122 | }
123 | RectF oval = new RectF();
124 | oval.left = args[0] * factor;
125 | oval.top = args[1] * factor;
126 | oval.right = args[2] * factor;
127 | oval.bottom = args[3] * factor;
128 | path.addArc(oval, args[4], args[5]);
129 | break;
130 |
131 | // addCircle
132 | case 'O':
133 | case 'o':
134 | argNum = 4;
135 | last = 'o';
136 | nextToken();
137 | if (ch == 'O' && null != parent) {
138 | last = 'O';
139 | args[0] -= parent.getX();
140 | args[1] -= parent.getY();
141 | }
142 | Path.Direction dir = args[3] == 1 ? Path.Direction.CW : Path.Direction.CCW;
143 | path.addCircle(args[0] * factor, args[1] * factor, args[2] * factor, dir);
144 | break;
145 |
146 | // quadTo
147 | case 'Q':
148 | case 'q':
149 | argNum = 4;
150 | last = 'q';
151 | nextToken();
152 | if (ch == 'Q' && null != parent) {
153 | last = 'Q';
154 | args[0] -= parent.getX();
155 | args[1] -= parent.getY();
156 | args[2] -= parent.getX();
157 | args[3] -= parent.getY();
158 | }
159 | path.quadTo(args[0] * factor, args[1] * factor, args[2] * factor, args[3] * factor);
160 | break;
161 |
162 | // cubicTo
163 | case 'C':
164 | case 'c':
165 | argNum = 6;
166 | last = 'c';
167 | nextToken();
168 | if (ch == 'C' && null != parent) {
169 | last = 'C';
170 | args[0] -= parent.getX();
171 | args[1] -= parent.getY();
172 | args[2] -= parent.getX();
173 | args[3] -= parent.getY();
174 | args[4] -= parent.getX();
175 | args[5] -= parent.getY();
176 | }
177 | path.cubicTo(args[0] * factor, args[1] * factor, args[2] * factor, args[3] * factor, args[4] * factor, args[5] * factor);
178 | break;
179 |
180 | // close
181 | case 'Z':
182 | case 'z':
183 | last = 'z';
184 | ++curIndex;
185 | path.close();
186 | break;
187 |
188 | default:
189 | throw new ParseException("expected command character", curIndex);
190 | }
191 | }
192 |
193 | return path;
194 | }
195 |
196 | private void nextToken() throws java.text.ParseException {
197 | boolean isStart = true;
198 | boolean seenDot = false;
199 | StringBuilder num = new StringBuilder();
200 |
201 | ++curIndex;
202 | while (curIndex < len) {
203 | char ch = pathString.charAt(curIndex);
204 | if (ch == '-' && !isStart)
205 | throw new ParseException("unexpected '-'", curIndex);
206 | else if (ch == '.' && (isStart || seenDot))
207 | throw new ParseException("unexpected '.'", curIndex);
208 |
209 | isStart = false;
210 | if ('0' <= ch && ch <= '9' || ch == '-') {
211 | num.append(ch);
212 | } else if (!seenDot && ch == '.') {
213 | seenDot = true;
214 | num.append(ch);
215 | } else {
216 | consumeNum(num.toString());
217 | isStart = true;
218 | seenDot = false;
219 | num = new StringBuilder();
220 |
221 | if (curNum == argNum)
222 | break;
223 |
224 | if (ch != ',')
225 | throw new ParseException("expected ','", curIndex);
226 | }
227 | ++curIndex;
228 | }
229 |
230 | if (curIndex == len)
231 | consumeNum(num.toString());
232 | }
233 |
234 | private void consumeNum(String num) {
235 | ++curNum;
236 | args[curNum - 1] = Float.valueOf(num);
237 | }
238 | }
239 |
--------------------------------------------------------------------------------
/lib/src/main/java/com/hzn/lib/EasyPathView.java:
--------------------------------------------------------------------------------
1 | package com.hzn.lib;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ValueAnimator;
5 | import android.content.Context;
6 | import android.content.res.TypedArray;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.graphics.Path;
11 | import android.graphics.PathMeasure;
12 | import android.text.TextUtils;
13 | import android.util.AttributeSet;
14 | import android.util.TypedValue;
15 | import android.view.View;
16 |
17 | import java.text.ParseException;
18 |
19 | /**
20 | * 带动画的路径视图,将通过设置的路径pathString,自动按顺序生成路径动画,包括绘制动画与清除动画(反方向);
21 | * 其中fixedWidth和fixedHeight属性必选,用于设置相对于所提供的pathString的固定宽高,以保证在任何实际测量出的宽高中,路径位置正确;
22 | * strokeFixedWidth属性可选,用于设置相对于所提供的pathString的固定线段宽度,以保证在任何实际测量的宽高中,绘制路径的线段宽度显示比例一致;
23 | * Created by huzn on 2016/12/21.
24 | */
25 | public class EasyPathView extends View {
26 |
27 | // 相对于所提供路径的固定的宽,默认为0
28 | private int fixedWidth;
29 | // 相对于所提供路径的固定的高,默认为0
30 | private int fixedHeight;
31 | // 需要解析的路径
32 | private String pathString;
33 | // 线段颜色,默认Color.BLACK
34 | private int strokeColor;
35 | // 线段宽度,默认1dp
36 | private int strokeWidth;
37 | // 相对于所提供路径的固定的线段宽度,提供该参数时,无视strokeWidth参数,默认为-1
38 | private float strokeFixedWidth;
39 | // 线段是否平滑,默认false
40 | private boolean strokeIsRound;
41 | // 动画时间长度集,单位ms,默认为全部500
42 | private String animDurations;
43 | // 动画播放模式,为ANIM_MODE_TOGETHER或ANIM_MODE_SEPARATE,默认为ANIM_MODE_TOGETHER
44 | private int animMode;
45 | // 状态,为STATE_SHOW或STATE_HIDE,默认为STATE_SHOW
46 | private int state;
47 | // 是否为动态的,设置为动态时,将只显示绘制过的路径,不显示路径本身,默认为false
48 | private boolean dynamic;
49 | // 最大线段数,默认为10
50 | private int maxPathCount;
51 |
52 | public static final int STATE_NONE = -1;
53 | public static final int STATE_SHOW = 0;
54 | public static final int STATE_HIDE = 1;
55 | public static final int STATE_ANIM_SHOW = 2;
56 | public static final int STATE_ANIM_HIDE = 3;
57 |
58 | public static final int ANIM_MODE_TOGETHER = 0;
59 | public static final int ANIM_MODE_SEPARATE = 1;
60 |
61 | private int pathCount;
62 | private static final int MAX_PATH_COUNT = 10;
63 | private Path pathDst;
64 | private Path[] pathDstList;
65 | private PathMeasure pm;
66 | private PathMeasure[] pmList;
67 | private Paint paint;
68 | private float factor;
69 |
70 | // 用于在EditMode下Preview
71 | private Path path;
72 |
73 | // 当animMode为ANIM_MODE_SEPARATE时,记录当前播放的动画
74 | private int curAnimIndex;
75 | // 动画时间长度集
76 | private long animDurationArr[];
77 | // 动画时间占比集
78 | private float animDurationRatioArr[];
79 | // 动画默认播放时长
80 | private static final long ANIM_DURATION_DEFAULT = 500;
81 | // 动画是否循环
82 | private boolean isAnimRepeat;
83 |
84 | private ValueAnimator.AnimatorUpdateListener updateListener;
85 | private float animatorValue;
86 |
87 | public EasyPathView(Context context) {
88 | this(context, null);
89 | }
90 |
91 | public EasyPathView(Context context, AttributeSet attrs) {
92 | this(context, attrs, 0);
93 | }
94 |
95 | public EasyPathView(Context context, AttributeSet attrs, int defStyleAttr) {
96 | super(context, attrs, defStyleAttr);
97 |
98 | TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EasyPathView, defStyleAttr, 0);
99 | fixedWidth = a.getInteger(R.styleable.EasyPathView_epvFixedWidth, 0);
100 | fixedHeight = a.getInteger(R.styleable.EasyPathView_epvFixedHeight, 0);
101 | pathString = a.getString(R.styleable.EasyPathView_epvPathString);
102 | strokeColor = a.getColor(R.styleable.EasyPathView_epvStrokeColor, Color.BLACK);
103 | strokeWidth = a.getDimensionPixelOffset(R.styleable.EasyPathView_epvStrokeWidth, (int) TypedValue.applyDimension(
104 | TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
105 | strokeFixedWidth = a.getFloat(R.styleable.EasyPathView_epvStrokeFixedWidth, -1.0f);
106 | strokeIsRound = a.getBoolean(R.styleable.EasyPathView_epvStrokeIsRound, false);
107 | animDurations = a.getString(R.styleable.EasyPathView_epvAnimDurations);
108 | animMode = a.getInteger(R.styleable.EasyPathView_epvAnimMode, ANIM_MODE_TOGETHER);
109 | state = a.getInteger(R.styleable.EasyPathView_epvState, STATE_SHOW);
110 | dynamic = a.getBoolean(R.styleable.EasyPathView_epvDynamic, false);
111 | maxPathCount = a.getInteger(R.styleable.EasyPathView_epvMaxPathCount, MAX_PATH_COUNT);
112 | a.recycle();
113 |
114 | initPath();
115 | initPaint();
116 | initListener();
117 | initDuration();
118 | }
119 |
120 | private void initPath() {
121 | pathCount = 0;
122 |
123 | pathDst = new Path();
124 | pathDstList = new Path[maxPathCount];
125 | for (int i = 0; i < maxPathCount; i++)
126 | pathDstList[i] = new Path();
127 |
128 | pm = new PathMeasure();
129 | pmList = new PathMeasure[maxPathCount];
130 | for (int i = 0; i < maxPathCount; i++)
131 | pmList[i] = new PathMeasure();
132 | }
133 |
134 | private void initPaint() {
135 | paint = new Paint();
136 | paint.setAntiAlias(true);
137 | paint.setStrokeWidth(strokeWidth);
138 | paint.setColor(strokeColor);
139 | paint.setStyle(Paint.Style.STROKE);
140 | if (strokeIsRound) {
141 | paint.setStrokeCap(Paint.Cap.ROUND);
142 | paint.setStrokeJoin(Paint.Join.ROUND);
143 | }
144 | }
145 |
146 | private void initListener() {
147 | updateListener = new ValueAnimator.AnimatorUpdateListener() {
148 | @Override
149 | public void onAnimationUpdate(ValueAnimator animation) {
150 | animatorValue = (float) animation.getAnimatedValue();
151 | invalidate();
152 | }
153 | };
154 | }
155 |
156 | private void initDuration() {
157 | if (TextUtils.isEmpty(animDurations))
158 | animDurations = String.valueOf(ANIM_DURATION_DEFAULT);
159 |
160 | // 获取动画时间长度集
161 | String[] splitDur = animDurations.split(",");
162 | animDurationArr = new long[maxPathCount];
163 | int splitLen = Math.min(splitDur.length, maxPathCount);
164 | for (int i = 0; i < splitLen; i++)
165 | animDurationArr[i] = Long.parseLong(splitDur[i]);
166 | for (int i = splitLen; i < maxPathCount; i++)
167 | animDurationArr[i] = ANIM_DURATION_DEFAULT;
168 |
169 | animDurationRatioArr = new float[maxPathCount];
170 |
171 | isAnimRepeat = false;
172 | }
173 |
174 | @Override
175 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
176 | rebuildPathData();
177 | }
178 |
179 | @Override
180 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
181 | int width = MeasureSpec.getSize(widthMeasureSpec);
182 | int mode = MeasureSpec.getMode(widthMeasureSpec);
183 | width = width + getPaddingLeft() + getPaddingRight();
184 | if (mode != MeasureSpec.EXACTLY) { // wrap_content
185 | width = fixedWidth;
186 | }
187 |
188 | int height = MeasureSpec.getSize(heightMeasureSpec);
189 | mode = MeasureSpec.getMode(heightMeasureSpec);
190 | height = height + getPaddingTop() + getPaddingBottom();
191 | if (mode != MeasureSpec.EXACTLY) { // wrap_content
192 | height = fixedHeight;
193 | }
194 |
195 | // 得到实际测量大小与指定大小的比例factor,当宽、高计算出的比例不同时,使用较小值
196 | float f1 = 1.0f * width / fixedWidth;
197 | float f2 = 1.0f * height / fixedHeight;
198 | factor = Math.min(f1, f2);
199 |
200 | if (strokeFixedWidth != -1)
201 | paint.setStrokeWidth(strokeFixedWidth * factor);
202 |
203 | rebuildPathData();
204 |
205 | setMeasuredDimension(width, height);
206 | }
207 |
208 | @Override
209 | protected void onDraw(Canvas canvas) {
210 | if (state == STATE_NONE)
211 | return;
212 |
213 | // 支持预览
214 | if (isInEditMode()) {
215 | canvas.drawPath(path, paint);
216 | return;
217 | }
218 |
219 | float startRatio = 0.27f * animatorValue * animatorValue + 0.73f;
220 |
221 | if (animMode == ANIM_MODE_TOGETHER) {
222 | float startD = 0.0f;
223 | for (int i = 0; i < pathCount; i++) {
224 | if (dynamic)
225 | startD = pmList[i].getLength() * animatorValue * startRatio;
226 |
227 | pathDst.reset();
228 | pathDst.rLineTo(0, 0); // 兼容KITKAT的硬件加速,详见PathMeasure.getSegment()的注释
229 | pmList[i].getSegment(startD, pmList[i].getLength() * animatorValue, pathDst, true);
230 | canvas.drawPath(pathDst, paint);
231 | }
232 | } else if (animMode == ANIM_MODE_SEPARATE) {
233 | if (!dynamic) {
234 | if (state == STATE_SHOW || state == STATE_ANIM_SHOW) {
235 | // 绘制已经完成动画的路径
236 | for (int i = 0; i < curAnimIndex; i++)
237 | canvas.drawPath(pathDstList[i], paint);
238 | } else if (state == STATE_HIDE || state == STATE_ANIM_HIDE) {
239 | // 绘制未播放动画的路径
240 | for (int i = curAnimIndex - 1; i >= 0; i--)
241 | canvas.drawPath(pathDstList[i], paint);
242 | }
243 | }
244 |
245 | // 绘制正在播放动画的路径
246 | if (0 <= curAnimIndex && curAnimIndex < pathCount) {
247 | float startD = 0.0f;
248 | if (dynamic)
249 | startD = pmList[curAnimIndex].getLength() * animatorValue * startRatio;
250 |
251 | pathDst.reset();
252 | pathDst.rLineTo(0, 0); // 兼容KITKAT的硬件加速,详见PathMeasure.getSegment()的注释
253 | pmList[curAnimIndex].getSegment(startD, pmList[curAnimIndex].getLength() * animatorValue, pathDst, true);
254 | canvas.drawPath(pathDst, paint);
255 | }
256 | }
257 | }
258 |
259 | private void rebuildPathData() {
260 | try {
261 | pathCount = 0;
262 |
263 | path = EasyPathParser.getInstance().parsePath(pathString, this, factor);
264 | pm.setPath(path, false);
265 | while (pm.nextContour()) {
266 | ++pathCount;
267 | if (pathCount > maxPathCount) {
268 | pathCount = maxPathCount;
269 | break;
270 | }
271 |
272 | // 存储所有轮廓
273 | pathDstList[pathCount - 1].reset();
274 | pathDstList[pathCount - 1].rLineTo(0, 0); // 兼容KITKAT
275 | pm.getSegment(0, pm.getLength(), pathDstList[pathCount - 1], true);
276 | pmList[pathCount - 1].setPath(pathDstList[pathCount - 1], false);
277 | }
278 |
279 | if (state == STATE_SHOW)
280 | animatorValue = 1.0f;
281 |
282 | if (animMode == ANIM_MODE_SEPARATE)
283 | curAnimIndex = pathCount;
284 |
285 | // 计算动画时间占比集
286 | long totalDuration = 0L;
287 | for (int i = 0; i < pathCount; i++)
288 | totalDuration += animDurationArr[i];
289 | for (int i = 0; i < pathCount; i++)
290 | animDurationRatioArr[i] = 1.0f * animDurationArr[i] / totalDuration;
291 |
292 | } catch (ParseException e) {
293 | e.printStackTrace();
294 |
295 | pathCount = 0;
296 | pm = null;
297 | pathDstList = null;
298 | pmList = null;
299 |
300 | state = STATE_NONE;
301 | animatorValue = 0.0f;
302 | curAnimIndex = 0;
303 | }
304 | }
305 |
306 | private ValueAnimator getDrawAnimator() {
307 | ValueAnimator drawAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
308 | drawAnimator.addUpdateListener(updateListener);
309 | drawAnimator.addListener(new Animator.AnimatorListener() {
310 | @Override
311 | public void onAnimationStart(Animator animation) {
312 | if (null != onAnimatorListener)
313 | onAnimatorListener.onAnimStart(state);
314 | }
315 |
316 | @Override
317 | public void onAnimationEnd(Animator animation) {
318 | if (animMode == ANIM_MODE_SEPARATE) {
319 | if (curAnimIndex < pathCount) {
320 | ++curAnimIndex;
321 | getDrawAnimator().setDuration(animDurationArr[curAnimIndex]).start();
322 | } else {
323 | if (isAnimRepeat) {
324 | if (null != onAnimatorListener)
325 | onAnimatorListener.onAnimRepeat(state);
326 | startDraw();
327 | } else {
328 | state = STATE_SHOW;
329 | }
330 | }
331 | } else if (animMode == ANIM_MODE_TOGETHER) {
332 | if (isAnimRepeat) {
333 | if (null != onAnimatorListener)
334 | onAnimatorListener.onAnimRepeat(state);
335 | startDraw();
336 | } else {
337 | state = STATE_SHOW;
338 | }
339 | }
340 |
341 | if (null != onAnimatorListener)
342 | onAnimatorListener.onAnimEnd(state);
343 | }
344 |
345 | @Override
346 | public void onAnimationCancel(Animator animation) {
347 | }
348 |
349 | @Override
350 | public void onAnimationRepeat(Animator animation) {
351 | }
352 | });
353 | return drawAnimator;
354 | }
355 |
356 | private ValueAnimator getEraseAnimator() {
357 | ValueAnimator eraseAnimator = ValueAnimator.ofFloat(1.0f, 0.0f);
358 | eraseAnimator.addUpdateListener(updateListener);
359 | eraseAnimator.addListener(new Animator.AnimatorListener() {
360 | @Override
361 | public void onAnimationStart(Animator animation) {
362 | if (null != onAnimatorListener)
363 | onAnimatorListener.onAnimStart(state);
364 | }
365 |
366 | @Override
367 | public void onAnimationEnd(Animator animation) {
368 | if (animMode == ANIM_MODE_SEPARATE) {
369 | if (curAnimIndex > 0) {
370 | --curAnimIndex;
371 | getEraseAnimator().setDuration(animDurationArr[curAnimIndex]).start();
372 | } else {
373 | if (isAnimRepeat) {
374 | if (null != onAnimatorListener)
375 | onAnimatorListener.onAnimRepeat(state);
376 | startErase();
377 | } else {
378 | state = STATE_HIDE;
379 | }
380 | }
381 | } else if (animMode == ANIM_MODE_TOGETHER) {
382 | if (isAnimRepeat) {
383 | if (null != onAnimatorListener)
384 | onAnimatorListener.onAnimRepeat(state);
385 | startErase();
386 | } else {
387 | state = STATE_HIDE;
388 | }
389 | }
390 |
391 | if (null != onAnimatorListener)
392 | onAnimatorListener.onAnimEnd(state);
393 | }
394 |
395 | @Override
396 | public void onAnimationCancel(Animator animation) {
397 | }
398 |
399 | @Override
400 | public void onAnimationRepeat(Animator animation) {
401 | }
402 | });
403 | return eraseAnimator;
404 | }
405 |
406 | /**
407 | * 开始绘制路径
408 | */
409 | public void startDraw() {
410 | state = STATE_ANIM_SHOW;
411 |
412 | if (animMode == ANIM_MODE_SEPARATE)
413 | curAnimIndex = 0;
414 |
415 | getDrawAnimator().setDuration(animDurationArr[curAnimIndex]).start();
416 | }
417 |
418 | /**
419 | * 开始绘制路径
420 | *
421 | * @param repeat 动画是否循环绘制
422 | */
423 | public void startDraw(boolean repeat) {
424 | isAnimRepeat = repeat;
425 | startDraw();
426 | }
427 |
428 | /**
429 | * 开始清除路径
430 | */
431 | public void startErase() {
432 | state = STATE_ANIM_HIDE;
433 |
434 | if (animMode == ANIM_MODE_SEPARATE)
435 | curAnimIndex = pathCount - 1;
436 |
437 | getEraseAnimator().setDuration(animDurationArr[curAnimIndex]).start();
438 | }
439 |
440 | public void startErase(boolean repeat) {
441 | isAnimRepeat = true;
442 | startErase();
443 | }
444 |
445 | /**
446 | * 停止循环绘制
447 | */
448 | public void stopRepeat() {
449 | isAnimRepeat = false;
450 | }
451 |
452 | /**
453 | * 设置路径动画当前的进度
454 | *
455 | * @param progress 路径动画当前的进度,范围0.0f~1.0f
456 | */
457 | public void setAnimProgress(float progress) {
458 | if (progress < 0.0f)
459 | progress = 0.0f;
460 | else if (progress > 1.0f)
461 | progress = 1.0f;
462 |
463 | if (animMode == ANIM_MODE_TOGETHER) {
464 | animatorValue = progress;
465 | invalidate();
466 | } else if (animMode == ANIM_MODE_SEPARATE) {
467 | float curTotal = 0.0f;
468 | for (int i = 0; i < pathCount; i++) {
469 | curTotal += animDurationRatioArr[i];
470 | if (progress <= curTotal) {
471 | curAnimIndex = i;
472 | animatorValue = 1.0f - (curTotal - progress) / animDurationRatioArr[i];
473 | invalidate();
474 | break;
475 | }
476 | }
477 | }
478 | }
479 |
480 | /**
481 | * 重置,在修改参数后,startDraw之前需要调用此方法
482 | */
483 | public void reset() {
484 | initPath();
485 | initPaint();
486 | initListener();
487 | initDuration();
488 |
489 | requestLayout();
490 | invalidate();
491 | }
492 |
493 | // getters and setters
494 | public int getFixedWidth() {
495 | return fixedWidth;
496 | }
497 |
498 | public void setFixedWidth(int fixedWidth) {
499 | this.fixedWidth = fixedWidth;
500 | }
501 |
502 | public int getFixedHeight() {
503 | return fixedHeight;
504 | }
505 |
506 | public void setFixedHeight(int fixedHeight) {
507 | this.fixedHeight = fixedHeight;
508 | }
509 |
510 | public String getPathString() {
511 | return pathString;
512 | }
513 |
514 | public void setPathString(String pathString) {
515 | this.pathString = pathString;
516 | }
517 |
518 | public int getStrokeColor() {
519 | return strokeColor;
520 | }
521 |
522 | public void setStrokeColor(int strokeColor) {
523 | this.strokeColor = strokeColor;
524 | }
525 |
526 | public int getStrokeWidth() {
527 | return strokeWidth;
528 | }
529 |
530 | public void setStrokeWidth(int strokeWidth) {
531 | this.strokeWidth = strokeWidth;
532 | }
533 |
534 | public float getStrokeFixedWidth() {
535 | return strokeFixedWidth;
536 | }
537 |
538 | public void setStrokeFixedWidth(float strokeFixedWidth) {
539 | this.strokeFixedWidth = strokeFixedWidth;
540 | }
541 |
542 | public boolean getStrokeIsRound() {
543 | return strokeIsRound;
544 | }
545 |
546 | public void setStrokeIsRound(boolean strokeIsRound) {
547 | this.strokeIsRound = strokeIsRound;
548 | }
549 |
550 | public String getAnimDurations() {
551 | return animDurations;
552 | }
553 |
554 | public void setAnimDurations(String animDurations) {
555 | this.animDurations = animDurations;
556 | }
557 |
558 | public int getAnimMode() {
559 | return animMode;
560 | }
561 |
562 | public void setAnimMode(int animMode) {
563 | this.animMode = animMode;
564 | }
565 |
566 | public boolean isDynamic() {
567 | return dynamic;
568 | }
569 |
570 | public void setDynamic(boolean dynamic) {
571 | this.dynamic = dynamic;
572 | }
573 |
574 | /**
575 | * 获取当前状态
576 | *
577 | * @return 返回当前状态,包括STATE_NONE,STATE_SHOW,STATE_HIDE,STATE_ANIM_SHOW和STATE_ANIM_HIDE
578 | */
579 | public int getState() {
580 | return state;
581 | }
582 |
583 | /**
584 | * 用于监听路径动画,可选择监听哪些动画状态
585 | */
586 | public static abstract class OnAnimatorListener {
587 | /**
588 | * 动画开始时回调
589 | *
590 | * @param state 当前动画状态,包括STATE_SHOW,STATE_HIDE,STATE_ANIM_SHOW和STATE_ANIM_HIDE
591 | */
592 | protected void onAnimStart(int state) {
593 | }
594 |
595 | /**
596 | * 动画结束时回调
597 | *
598 | * @param state 当前动画状态,包括STATE_SHOW,STATE_HIDE,STATE_ANIM_SHOW和STATE_ANIM_HIDE
599 | */
600 | protected void onAnimEnd(int state) {
601 | }
602 |
603 | /**
604 | * 动画重复时回调,紧接着会回调onAnimStart
605 | *
606 | * @param state 当前动画状态,包括STATE_SHOW,STATE_HIDE,STATE_ANIM_SHOW和STATE_ANIM_HIDE
607 | */
608 | protected void onAnimRepeat(int state) {
609 | }
610 | }
611 |
612 | private OnAnimatorListener onAnimatorListener;
613 |
614 | /**
615 | * 添加监听路径动画执行的接口
616 | *
617 | * @param onAnimatorListener 用于监听路径动画
618 | */
619 | public void addOnAnimatorListener(OnAnimatorListener onAnimatorListener) {
620 | this.onAnimatorListener = onAnimatorListener;
621 | }
622 | }
623 |
--------------------------------------------------------------------------------
/lib/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/lib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | lib
3 |
4 |
--------------------------------------------------------------------------------
/lib/src/test/java/com/hzn/lib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hzn.lib;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/screenshots/easy_path_repeat.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/screenshots/easy_path_repeat.gif
--------------------------------------------------------------------------------
/screenshots/easy_path_separate.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/screenshots/easy_path_separate.gif
--------------------------------------------------------------------------------
/screenshots/easy_path_together.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/screenshots/easy_path_together.gif
--------------------------------------------------------------------------------
/screenshots/icons1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/screenshots/icons1.gif
--------------------------------------------------------------------------------
/screenshots/icons2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huzenan/EasyPath/128e15efad244544f8d1f318dbc61900b013bae3/screenshots/icons2.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lib'
2 |
--------------------------------------------------------------------------------