├── .gitignore
├── LICENSE
├── README.md
├── android-pathview
├── .gitignore
├── build.gradle
├── config
│ ├── checkstyle
│ │ └── checkstyle.xml
│ └── formatter
│ │ └── formatter.xml
├── libs
│ └── androidsvg-1.2.1.jar
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── eftimoff
│ │ └── androipathview
│ │ ├── PathView.java
│ │ └── SvgUtils.java
│ └── res
│ └── values
│ └── attrs.xml
├── art
├── fill-after-resize-new.gif
├── path.gif
└── settings.gif
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── eftimoff
│ │ └── empty
│ │ ├── IssuesFragment.java
│ │ ├── LogoutFragment.java
│ │ ├── MainActivity.java
│ │ ├── SecondActivity.java
│ │ └── SettingsFragment.java
│ └── res
│ ├── drawable
│ └── ic_launcher.png
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_second.xml
│ ├── fragment_issues.xml
│ ├── fragment_logout.xml
│ └── fragment_settings.xml
│ ├── raw
│ ├── flag_usa.svg
│ ├── ironman.svg
│ ├── ironman_white.svg
│ ├── issues.svg
│ ├── linecap.svg
│ ├── logout.svg
│ ├── map_usa
│ ├── monitor.svg
│ └── settings.svg
│ └── values
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
8 | # Built application files
9 | *.apk
10 | *.ap_
11 |
12 | # Files for the Dalvik VM
13 | *.dex
14 |
15 | # Java class files
16 | *.class
17 |
18 | # Generated files
19 | bin/
20 | gen/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 | .classpath
36 | .project
37 | .settings
38 | eclipsebin
39 |
40 | bin
41 | gen
42 | build
43 | out
44 | lib
45 |
46 | target
47 | pom.xml.*
48 | release.properties
49 |
50 | .idea
51 | *.iml
52 | *.ipr
53 | *.iws
54 | classes
55 |
56 | obj
57 |
58 | .DS_Store
59 |
--------------------------------------------------------------------------------
/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 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## android-pathview
2 |
3 | [](https://gitter.im/geftimov/android-pathview?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://android-arsenal.com/details/1/1421) [](https://maven-badges.herokuapp.com/maven-central/com.eftimoff/android-pathview)
4 |
5 | You want to animate svg or normal Paths?
6 | Change the color, pathWidth or add svg.
7 | Animate the "procentage" property to make the animation.
8 |
9 | ### There are two types of paths :
10 |
11 | #### 1. From Svg
12 | ```xml
13 |
21 | ```
22 |
23 | Result
24 |
25 | 
26 |
27 | #### 2. From Path
28 | ```xml
29 |
36 | ```
37 |
38 | In Code
39 |
40 | ```java
41 | final Path path = new Path();
42 | path.moveTo(0.0f, 0.0f);
43 | path.lineTo(length / 4f, 0.0f);
44 | path.lineTo(length, height / 2.0f);
45 | path.lineTo(length / 4f, height);
46 | path.lineTo(0.0f, height);
47 | path.lineTo(length * 3f / 4f, height / 2f);
48 | path.lineTo(0.0f, 0.0f);
49 | path.close();
50 |
51 | pathView.setPath(path);
52 | ```
53 |
54 | Result
55 |
56 | 
57 |
58 | #### Use the animator for parallel animation
59 | ```java
60 | pathView.getPathAnimator()
61 | .delay(100)
62 | .duration(500)
63 | .listenerStart(new AnimationListenerStart())
64 | .listenerEnd(new AnimationListenerEnd())
65 | .interpolator(new AccelerateDecelerateInterpolator())
66 | .start();
67 | ```
68 |
69 | #### Use the animator for sequential animation
70 | ```java
71 | pathView.getSequentialPathAnimator()
72 | .delay(100)
73 | .duration(500)
74 | .listenerStart(new AnimationListenerStart())
75 | .listenerEnd(new AnimationListenerEnd())
76 | .interpolator(new AccelerateDecelerateInterpolator())
77 | .start();
78 | ```
79 | #### If you want to use the svg colors.
80 | ```java
81 | pathView.useNaturalColors();
82 | ```
83 | #### If you want to draw the real SVG after the path animation.
84 | It is in still in development.
85 | ```java
86 | pathView.setFillAfter(true);
87 | ```
88 | 
89 |
90 | #### TODO
91 |
92 | 1. Make persistent "percentage" field on orientation change.
93 |
94 | ##### Limitations
95 |
96 | When working with SVGs you can not WRAP_CONTENT your views.
97 |
98 | ##### Used in apps
99 |
100 | * https://play.google.com/store/apps/details?id=com.eftimoff.fonts
101 |
102 | Message me if you want to be included in this list.
103 |
104 | ##### Thanks to
105 |
106 | * https://github.com/romainguy/road-trip
107 | * http://www.curious-creature.com/2013/12/21/android-recipe-4-path-tracing/
108 | * https://github.com/matthewrkula/AnimatedPathView
109 |
110 | ##### Contributors
111 |
112 | I want to update this library and make it better. So any help will be appreciated.
113 | Make and pull - request and we can discuss it.
114 |
115 | ##### Download
116 | ```groovy
117 | dependencies {
118 | compile 'com.eftimoff:android-pathview:1.0.8@aar'
119 | }
120 | ```
121 | ##### Changelog
122 |
123 | 1.0.8
124 |
125 | [Fix] Removed not properly used android:allowBackup.
126 |
127 | 1.0.7
128 |
129 | [Feature] Sequential path animation.
130 | [Fix] Use dimensions instead of float for pathWidth.
131 |
132 | ##### Licence
133 |
134 | Copyright 2016 Georgi Eftimov
135 |
136 | Licensed under the Apache License, Version 2.0 (the "License");
137 | you may not use this file except in compliance with the License.
138 | You may obtain a copy of the License at
139 |
140 | http://www.apache.org/licenses/LICENSE-2.0
141 |
142 | Unless required by applicable law or agreed to in writing, software
143 | distributed under the License is distributed on an "AS IS" BASIS,
144 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145 | See the License for the specific language governing permissions and
146 | limitations under the License.
147 |
--------------------------------------------------------------------------------
/android-pathview/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
8 | # Built application files
9 | *.apk
10 | *.ap_
11 |
12 | # Files for the Dalvik VM
13 | *.dex
14 |
15 | # Java class files
16 | *.class
17 |
18 | # Generated files
19 | bin/
20 | gen/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 |
36 | .classpath
37 | .project
38 | .settings
39 | eclipsebin
40 |
41 | bin
42 | gen
43 | build
44 | out
45 | lib
46 |
47 | target
48 | pom.xml.*
49 | release.properties
50 |
51 | .idea
52 | *.iml
53 | *.ipr
54 | *.iws
55 | classes
56 |
57 | obj
58 |
59 | .DS_Store
--------------------------------------------------------------------------------
/android-pathview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'maven'
3 | apply plugin: 'signing'
4 |
5 | version = "1.0.8"
6 | group = "com.eftimoff"
7 |
8 | android {
9 | compileSdkVersion 21
10 | buildToolsVersion "21.1.2"
11 |
12 | defaultConfig {
13 | minSdkVersion 9
14 | targetSdkVersion 21
15 | versionCode 1
16 | versionName "1.0"
17 | }
18 | }
19 |
20 | configurations {
21 | archives {
22 | extendsFrom configurations.default
23 | }
24 | }
25 |
26 | signing {
27 | required { has("release") && gradle.taskGraph.hasTask("uploadArchives") }
28 | sign configurations.archives
29 | }
30 |
31 | uploadArchives {
32 | configuration = configurations.archives
33 | repositories.mavenDeployer {
34 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
35 |
36 | repository(url: sonatypeRepo) {
37 | authentication(userName: sonatypeUsername,
38 | password: sonatypePassword)
39 | }
40 |
41 | pom.project {
42 | name 'Android Path View Library'
43 | packaging 'aar'
44 | description 'Android view that animate the both path from constructed path or from svg'
45 | url 'https://github.com/geftimov/android-pathview'
46 |
47 | scm {
48 | url 'scm:git@github.com:geftimov/android-pathview.git'
49 | connection 'scm:git@github.com:geftimov/android-pathview.git'
50 | developerConnection 'scm:git@github.com:geftimov/android-pathview.git'
51 | }
52 |
53 | licenses {
54 | license {
55 | name 'The Apache Software License, Version 2.0'
56 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
57 | distribution 'repo'
58 | }
59 | }
60 |
61 | developers {
62 | developer {
63 | id 'geftimov'
64 | name 'Georgi Eftimov'
65 | email 'jokatavr@gmail.com'
66 | }
67 | }
68 | }
69 | }
70 | }
71 |
72 | dependencies {
73 | compile files('libs/androidsvg-1.2.1.jar')
74 | compile 'com.nineoldandroids:library:2.4.0'
75 | }
76 |
--------------------------------------------------------------------------------
/android-pathview/config/checkstyle/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/android-pathview/config/formatter/formatter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
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 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
--------------------------------------------------------------------------------
/android-pathview/libs/androidsvg-1.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geftimov/android-pathview/81b316be165dfc2f0067279b104e3f45dc071182/android-pathview/libs/androidsvg-1.2.1.jar
--------------------------------------------------------------------------------
/android-pathview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android-pathview/src/main/java/com/eftimoff/androipathview/PathView.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.androipathview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.Path;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.View;
13 | import android.view.animation.Interpolator;
14 |
15 | import com.eftimoff.mylibrary.R;
16 | import com.nineoldandroids.animation.Animator;
17 | import com.nineoldandroids.animation.ObjectAnimator;
18 | import com.nineoldandroids.animation.AnimatorSet;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | /**
24 | * PathView is a View that animates paths.
25 | */
26 | @SuppressWarnings("unused")
27 | public class PathView extends View implements SvgUtils.AnimationStepListener {
28 | /**
29 | * Logging tag.
30 | */
31 | public static final String LOG_TAG = "PathView";
32 | /**
33 | * The paint for the path.
34 | */
35 | private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
36 | /**
37 | * Utils to catch the paths from the svg.
38 | */
39 | private final SvgUtils svgUtils = new SvgUtils(paint);
40 | /**
41 | * All the paths provided to the view. Both from Path and Svg.
42 | */
43 | private List paths = new ArrayList<>();
44 | /**
45 | * This is a lock before the view is redrawn
46 | * or resided it must be synchronized with this object.
47 | */
48 | private final Object mSvgLock = new Object();
49 | /**
50 | * Thread for working with the object above.
51 | */
52 | private Thread mLoader;
53 |
54 | /**
55 | * The svg image from the raw directory.
56 | */
57 | private int svgResourceId;
58 | /**
59 | * Object that builds the animation for the path.
60 | */
61 | private AnimatorBuilder animatorBuilder;
62 | /**
63 | * Object that builds the animation set for the path.
64 | */
65 | private AnimatorSetBuilder animatorSetBuilder;
66 | /**
67 | * The progress of the drawing.
68 | */
69 | private float progress = 0f;
70 |
71 | /**
72 | * If the used colors are from the svg or from the set color.
73 | */
74 | private boolean naturalColors;
75 | /**
76 | * If the view is filled with its natural colors after path drawing.
77 | */
78 | private boolean fillAfter;
79 | /**
80 | * The view will be filled and showed as default without any animation.
81 | */
82 | private boolean fill;
83 | /**
84 | * The solid color used for filling svg when fill is true
85 | */
86 | private int fillColor;
87 | /**
88 | * The width of the view.
89 | */
90 | private int width;
91 | /**
92 | * The height of the view.
93 | */
94 | private int height;
95 | /**
96 | * Will be used as a temporary surface in each onDraw call for more control over content are
97 | * drawing.
98 | */
99 | private Bitmap mTempBitmap;
100 | /**
101 | * Will be used as a temporary Canvas for mTempBitmap for drawing content on it.
102 | */
103 | private Canvas mTempCanvas;
104 |
105 |
106 | /**
107 | * Default constructor.
108 | *
109 | * @param context The Context of the application.
110 | */
111 | public PathView(Context context) {
112 | this(context, null);
113 | }
114 |
115 | /**
116 | * Default constructor.
117 | *
118 | * @param context The Context of the application.
119 | * @param attrs attributes provided from the resources.
120 | */
121 | public PathView(Context context, AttributeSet attrs) {
122 | this(context, attrs, 0);
123 | }
124 |
125 | /**
126 | * Default constructor.
127 | *
128 | * @param context The Context of the application.
129 | * @param attrs attributes provided from the resources.
130 | * @param defStyle Default style.
131 | */
132 | public PathView(Context context, AttributeSet attrs, int defStyle) {
133 | super(context, attrs, defStyle);
134 | paint.setStyle(Paint.Style.STROKE);
135 | getFromAttributes(context, attrs);
136 | }
137 |
138 | /**
139 | * Get all the fields from the attributes .
140 | *
141 | * @param context The Context of the application.
142 | * @param attrs attributes provided from the resources.
143 | */
144 | private void getFromAttributes(Context context, AttributeSet attrs) {
145 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PathView);
146 | try {
147 | if (a != null) {
148 | paint.setColor(a.getColor(R.styleable.PathView_pathColor, 0xff00ff00));
149 | paint.setStrokeWidth(a.getDimensionPixelSize(R.styleable.PathView_pathWidth, 8));
150 | svgResourceId = a.getResourceId(R.styleable.PathView_svg, 0);
151 | naturalColors = a.getBoolean(R.styleable.PathView_naturalColors, false);
152 | fill = a.getBoolean(R.styleable.PathView_fill,false);
153 | fillColor = a.getColor(R.styleable.PathView_fillColor,Color.argb(0,0,0,0));
154 | }
155 | } finally {
156 | if (a != null) {
157 | a.recycle();
158 | }
159 | //to draw the svg in first show , if we set fill to true
160 | invalidate();
161 | }
162 | }
163 |
164 | /**
165 | * Set paths to be drawn and animated.
166 | *
167 | * @param paths - Paths that can be drawn.
168 | */
169 | public void setPaths(final List paths) {
170 | for (Path path : paths) {
171 | this.paths.add(new SvgUtils.SvgPath(path, paint));
172 | }
173 | synchronized (mSvgLock) {
174 | updatePathsPhaseLocked();
175 | }
176 | }
177 |
178 | /**
179 | * Set path to be drawn and animated.
180 | *
181 | * @param path - Paths that can be drawn.
182 | */
183 | public void setPath(final Path path) {
184 | paths.add(new SvgUtils.SvgPath(path, paint));
185 | synchronized (mSvgLock) {
186 | updatePathsPhaseLocked();
187 | }
188 | }
189 |
190 | /**
191 | * Animate this property. It is the percentage of the path that is drawn.
192 | * It must be [0,1].
193 | *
194 | * @param percentage float the percentage of the path.
195 | */
196 | public void setPercentage(float percentage) {
197 | if (percentage < 0.0f || percentage > 1.0f) {
198 | throw new IllegalArgumentException("setPercentage not between 0.0f and 1.0f");
199 | }
200 | progress = percentage;
201 | synchronized (mSvgLock) {
202 | updatePathsPhaseLocked();
203 | }
204 | invalidate();
205 | }
206 |
207 | /**
208 | * This refreshes the paths before draw and resize.
209 | */
210 | private void updatePathsPhaseLocked() {
211 | final int count = paths.size();
212 | for (int i = 0; i < count; i++) {
213 | SvgUtils.SvgPath svgPath = paths.get(i);
214 | svgPath.path.reset();
215 | svgPath.measure.getSegment(0.0f, svgPath.length * progress, svgPath.path, true);
216 | // Required only for Android 4.4 and earlier
217 | svgPath.path.rLineTo(0.0f, 0.0f);
218 | }
219 | }
220 |
221 | @Override
222 | protected void onDraw(Canvas canvas) {
223 | super.onDraw(canvas);
224 |
225 | if(mTempBitmap==null || (mTempBitmap.getWidth()!=canvas.getWidth()||mTempBitmap.getHeight()!=canvas.getHeight()) )
226 | {
227 | mTempBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
228 | mTempCanvas = new Canvas(mTempBitmap);
229 | }
230 |
231 | mTempBitmap.eraseColor(0);
232 | synchronized (mSvgLock) {
233 | mTempCanvas.save();
234 | mTempCanvas.translate(getPaddingLeft(), getPaddingTop());
235 | fill(mTempCanvas);
236 | final int count = paths.size();
237 | for (int i = 0; i < count; i++) {
238 | final SvgUtils.SvgPath svgPath = paths.get(i);
239 | final Path path = svgPath.path;
240 | final Paint paint1 = naturalColors ? svgPath.paint : paint;
241 | mTempCanvas.drawPath(path, paint1);
242 | }
243 |
244 | fillAfter(mTempCanvas);
245 |
246 | mTempCanvas.restore();
247 |
248 | applySolidColor(mTempBitmap);
249 |
250 | canvas.drawBitmap(mTempBitmap,0,0,null);
251 | }
252 | }
253 | /**
254 | * If there is svg , the user called setFillAfter(true) and the progress is finished.
255 | *
256 | * @param canvas Draw to this canvas.
257 | */
258 | private void fillAfter(final Canvas canvas) {
259 | if (svgResourceId != 0 && fillAfter && Math.abs(progress - 1f) < 0.00000001) {
260 | svgUtils.drawSvgAfter(canvas, width, height);
261 | }
262 | }
263 |
264 | /**
265 | * If there is svg , the user called setFill(true).
266 | *
267 | * @param canvas Draw to this canvas.
268 | */
269 | private void fill(final Canvas canvas) {
270 | if (svgResourceId != 0 && fill) {
271 | svgUtils.drawSvgAfter(canvas, width, height);
272 | }
273 | }
274 |
275 | /**
276 | * If fillColor had value before then we replace untransparent pixels of bitmap by solid color
277 | *
278 | * @param bitmap Draw to this canvas.
279 | */
280 | private void applySolidColor(final Bitmap bitmap) {
281 | if(fill && fillColor!=Color.argb(0,0,0,0) )
282 | if (bitmap != null) {
283 | for(int x=0;x animators = new ArrayList<>();
669 | /**
670 | * Listener called before the animation.
671 | */
672 | private AnimatorBuilder.ListenerStart listenerStart;
673 | /**
674 | * Listener after the animation.
675 | */
676 | private AnimatorBuilder.ListenerEnd animationEnd;
677 | /**
678 | * Animation listener.
679 | */
680 | private AnimatorSetBuilder.PathViewAnimatorListener pathViewAnimatorListener;
681 | /**
682 | * The animator that can animate paths sequentially
683 | */
684 | private AnimatorSet animatorSet = new AnimatorSet();
685 | /**
686 | * The list of paths to be animated.
687 | */
688 | private List paths;
689 |
690 | /**
691 | * Default constructor.
692 | *
693 | * @param pathView The view that must be animated.
694 | */
695 | public AnimatorSetBuilder(final PathView pathView) {
696 | paths = pathView.paths;
697 | for (SvgUtils.SvgPath path : paths) {
698 | path.setAnimationStepListener(pathView);
699 | ObjectAnimator animation = ObjectAnimator.ofFloat(path, "length", 0.0f, path.getLength());
700 | animators.add(animation);
701 | }
702 | animatorSet.playSequentially(animators);
703 | }
704 |
705 | /**
706 | * Sets the duration of the animation. Since the AnimatorSet sets the duration for each
707 | * Animator, we have to divide it by the number of paths.
708 | *
709 | * @param duration - The duration of the animation.
710 | * @return AnimatorSetBuilder.
711 | */
712 | public AnimatorSetBuilder duration(final int duration) {
713 | this.duration = duration / paths.size();
714 | return this;
715 | }
716 |
717 | /**
718 | * Set the Interpolator.
719 | *
720 | * @param interpolator - Interpolator.
721 | * @return AnimatorSetBuilder.
722 | */
723 | public AnimatorSetBuilder interpolator(final Interpolator interpolator) {
724 | this.interpolator = interpolator;
725 | return this;
726 | }
727 |
728 | /**
729 | * The delay before the animation.
730 | *
731 | * @param delay - int the delay
732 | * @return AnimatorSetBuilder.
733 | */
734 | public AnimatorSetBuilder delay(final int delay) {
735 | this.delay = delay;
736 | return this;
737 | }
738 |
739 | /**
740 | * Set a listener before the start of the animation.
741 | *
742 | * @param listenerStart an interface called before the animation
743 | * @return AnimatorSetBuilder.
744 | */
745 | public AnimatorSetBuilder listenerStart(final AnimatorBuilder.ListenerStart listenerStart) {
746 | this.listenerStart = listenerStart;
747 | if (pathViewAnimatorListener == null) {
748 | pathViewAnimatorListener = new PathViewAnimatorListener();
749 | animatorSet.addListener(pathViewAnimatorListener);
750 | }
751 | return this;
752 | }
753 |
754 | /**
755 | * Set a listener after of the animation.
756 | *
757 | * @param animationEnd an interface called after the animation
758 | * @return AnimatorSetBuilder.
759 | */
760 | public AnimatorSetBuilder listenerEnd(final AnimatorBuilder.ListenerEnd animationEnd) {
761 | this.animationEnd = animationEnd;
762 | if (pathViewAnimatorListener == null) {
763 | pathViewAnimatorListener = new PathViewAnimatorListener();
764 | animatorSet.addListener(pathViewAnimatorListener);
765 | }
766 | return this;
767 | }
768 |
769 | /**
770 | * Starts the animation.
771 | */
772 | public void start() {
773 | resetAllPaths();
774 | animatorSet.cancel();
775 | animatorSet.setDuration(duration);
776 | animatorSet.setInterpolator(interpolator);
777 | animatorSet.setStartDelay(delay);
778 | animatorSet.start();
779 | }
780 |
781 | /**
782 | * Sets the length of all the paths to 0.
783 | */
784 | private void resetAllPaths() {
785 | for (SvgUtils.SvgPath path : paths) {
786 | path.setLength(0);
787 | }
788 | }
789 |
790 | /**
791 | * Animation listener to be able to provide callbacks for the caller.
792 | */
793 | private class PathViewAnimatorListener implements Animator.AnimatorListener {
794 |
795 | @Override
796 | public void onAnimationStart(Animator animation) {
797 | if (listenerStart != null)
798 | listenerStart.onAnimationStart();
799 | }
800 |
801 | @Override
802 | public void onAnimationEnd(Animator animation) {
803 | if (animationEnd != null)
804 | animationEnd.onAnimationEnd();
805 | }
806 |
807 | @Override
808 | public void onAnimationCancel(Animator animation) {
809 |
810 | }
811 |
812 | @Override
813 | public void onAnimationRepeat(Animator animation) {
814 |
815 | }
816 | }
817 | }
818 | }
819 |
--------------------------------------------------------------------------------
/android-pathview/src/main/java/com/eftimoff/androipathview/SvgUtils.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.androipathview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Canvas;
7 | import android.graphics.DrawFilter;
8 | import android.graphics.Matrix;
9 | import android.graphics.Paint;
10 | import android.graphics.Path;
11 | import android.graphics.PathMeasure;
12 | import android.graphics.Rect;
13 | import android.graphics.RectF;
14 | import android.graphics.Region;
15 | import android.util.Log;
16 |
17 | import com.caverock.androidsvg.PreserveAspectRatio;
18 | import com.caverock.androidsvg.SVG;
19 | import com.caverock.androidsvg.SVGParseException;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | /**
25 | * Util class to init and get paths from svg.
26 | */
27 | public class SvgUtils {
28 | /**
29 | * It is for logging purposes.
30 | */
31 | private static final String LOG_TAG = "SVGUtils";
32 | /**
33 | * All the paths with their attributes from the svg.
34 | */
35 | private final List mPaths = new ArrayList<>();
36 | /**
37 | * The paint provided from the view.
38 | */
39 | private final Paint mSourcePaint;
40 | /**
41 | * The init svg.
42 | */
43 | private SVG mSvg;
44 |
45 | /**
46 | * Init the SVGUtils with a paint for coloring.
47 | *
48 | * @param sourcePaint - the paint for the coloring.
49 | */
50 | public SvgUtils(final Paint sourcePaint) {
51 | mSourcePaint = sourcePaint;
52 | }
53 |
54 | /**
55 | * Loading the svg from the resources.
56 | *
57 | * @param context Context object to get the resources.
58 | * @param svgResource int resource id of the svg.
59 | */
60 | public void load(Context context, int svgResource) {
61 | if (mSvg != null)
62 | return;
63 | try {
64 | mSvg = SVG.getFromResource(context, svgResource);
65 | mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
66 | } catch (SVGParseException e) {
67 | Log.e(LOG_TAG, "Could not load specified SVG resource", e);
68 | }
69 | }
70 |
71 | /**
72 | * Draw the svg to the canvas.
73 | *
74 | * @param canvas The canvas to be drawn.
75 | * @param width The width of the canvas.
76 | * @param height The height of the canvas.
77 | */
78 | public void drawSvgAfter(final Canvas canvas, final int width, final int height) {
79 | final float strokeWidth = mSourcePaint.getStrokeWidth();
80 | rescaleCanvas(width, height, strokeWidth, canvas);
81 | }
82 |
83 | /**
84 | * Render the svg to canvas and catch all the paths while rendering.
85 | *
86 | * @param width - the width to scale down the view to,
87 | * @param height - the height to scale down the view to,
88 | * @return All the paths from the svg.
89 | */
90 | public List getPathsForViewport(final int width, final int height) {
91 | final float strokeWidth = mSourcePaint.getStrokeWidth();
92 | Canvas canvas = new Canvas() {
93 | private final Matrix mMatrix = new Matrix();
94 |
95 | @Override
96 | public int getWidth() {
97 | return width;
98 | }
99 |
100 | @Override
101 | public int getHeight() {
102 | return height;
103 | }
104 |
105 | @Override
106 | public void drawPath(Path path, Paint paint) {
107 | Path dst = new Path();
108 |
109 | //noinspection deprecation
110 | getMatrix(mMatrix);
111 | path.transform(mMatrix, dst);
112 | paint.setAntiAlias(true);
113 | paint.setStyle(Paint.Style.STROKE);
114 | paint.setStrokeWidth(strokeWidth);
115 | mPaths.add(new SvgPath(dst, paint));
116 | }
117 | };
118 |
119 | rescaleCanvas(width, height, strokeWidth, canvas);
120 |
121 | return mPaths;
122 | }
123 |
124 | /**
125 | * Rescale the canvas with specific width and height.
126 | *
127 | * @param width The width of the canvas.
128 | * @param height The height of the canvas.
129 | * @param strokeWidth Width of the path to add to scaling.
130 | * @param canvas The canvas to be drawn.
131 | */
132 | private void rescaleCanvas(int width, int height, float strokeWidth, Canvas canvas) {
133 | if (mSvg == null)
134 | return;
135 | final RectF viewBox = mSvg.getDocumentViewBox();
136 |
137 | final float scale = Math.min(width
138 | / (viewBox.width() + strokeWidth),
139 | height / (viewBox.height() + strokeWidth));
140 |
141 | canvas.translate((width - viewBox.width() * scale) / 2.0f,
142 | (height - viewBox.height() * scale) / 2.0f);
143 | canvas.scale(scale, scale);
144 |
145 | mSvg.renderToCanvas(canvas);
146 | }
147 |
148 | /**
149 | * Path with bounds for scalling , length and paint.
150 | */
151 | public static class SvgPath {
152 |
153 | /**
154 | * Region of the path.
155 | */
156 | private static final Region REGION = new Region();
157 | /**
158 | * This is done for clipping the bounds of the path.
159 | */
160 | private static final Region MAX_CLIP =
161 | new Region(Integer.MIN_VALUE, Integer.MIN_VALUE,
162 | Integer.MAX_VALUE, Integer.MAX_VALUE);
163 | /**
164 | * The path itself.
165 | */
166 | final Path path;
167 | /**
168 | * The paint to be drawn later.
169 | */
170 | final Paint paint;
171 | /**
172 | * The length of the path.
173 | */
174 | float length;
175 | /**
176 | * Listener to notify that an animation step has happened.
177 | */
178 | AnimationStepListener animationStepListener;
179 | /**
180 | * The bounds of the path.
181 | */
182 | final Rect bounds;
183 | /**
184 | * The measure of the path, we can use it later to get segment of it.
185 | */
186 | final PathMeasure measure;
187 |
188 | /**
189 | * Constructor to add the path and the paint.
190 | *
191 | * @param path The path that comes from the rendered svg.
192 | * @param paint The result paint.
193 | */
194 | SvgPath(Path path, Paint paint) {
195 | this.path = path;
196 | this.paint = paint;
197 |
198 | measure = new PathMeasure(path, false);
199 | this.length = measure.getLength();
200 |
201 | REGION.setPath(path, MAX_CLIP);
202 | bounds = REGION.getBounds();
203 | }
204 |
205 | /**
206 | * Sets the animation step listener.
207 | *
208 | * @param animationStepListener AnimationStepListener.
209 | */
210 | public void setAnimationStepListener(AnimationStepListener animationStepListener) {
211 | this.animationStepListener = animationStepListener;
212 | }
213 |
214 | /**
215 | * Sets the length of the path.
216 | *
217 | * @param length The length to be set.
218 | */
219 | public void setLength(float length) {
220 | path.reset();
221 | measure.getSegment(0.0f, length, path, true);
222 | path.rLineTo(0.0f, 0.0f);
223 |
224 | if (animationStepListener != null) {
225 | animationStepListener.onAnimationStep();
226 | }
227 | }
228 |
229 | /**
230 | * @return The length of the path.
231 | */
232 | public float getLength() {
233 | return length;
234 | }
235 | }
236 |
237 | public interface AnimationStepListener {
238 |
239 | /**
240 | * Called when an animation step happens.
241 | */
242 | void onAnimationStep();
243 | }
244 | }
245 |
--------------------------------------------------------------------------------
/android-pathview/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/art/fill-after-resize-new.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geftimov/android-pathview/81b316be165dfc2f0067279b104e3f45dc071182/art/fill-after-resize-new.gif
--------------------------------------------------------------------------------
/art/path.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geftimov/android-pathview/81b316be165dfc2f0067279b104e3f45dc071182/art/path.gif
--------------------------------------------------------------------------------
/art/settings.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geftimov/android-pathview/81b316be165dfc2f0067279b104e3f45dc071182/art/settings.gif
--------------------------------------------------------------------------------
/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 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:1.3.0'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | mavenCentral()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/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/geftimov/android-pathview/81b316be165dfc2f0067279b104e3f45dc071182/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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-2.2.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
8 | # Built application files
9 | *.apk
10 | *.ap_
11 |
12 | # Files for the Dalvik VM
13 | *.dex
14 |
15 | # Java class files
16 | *.class
17 |
18 | # Generated files
19 | bin/
20 | gen/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 |
36 | .classpath
37 | .project
38 | .settings
39 | eclipsebin
40 |
41 | bin
42 | gen
43 | build
44 | out
45 | lib
46 |
47 | target
48 | pom.xml.*
49 | release.properties
50 |
51 | .idea
52 | *.iml
53 | *.ipr
54 | *.iws
55 | classes
56 |
57 | obj
58 |
59 | .DS_Store
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "com.eftimoff.empty"
9 | minSdkVersion 14
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | }
15 |
16 | dependencies {
17 | compile 'com.android.support:appcompat-v7:21.0.3'
18 | // compile 'com.eftimoff:android-pathview:1.0.5@aar'
19 | compile project(':android-pathview')
20 | }
21 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/eftimoff/empty/IssuesFragment.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.empty;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | public class IssuesFragment extends Fragment {
10 |
11 | @Override
12 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
13 | Bundle savedInstanceState) {
14 | return inflater.inflate(R.layout.fragment_issues, container, false);
15 | }
16 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/eftimoff/empty/LogoutFragment.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.empty;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | public class LogoutFragment extends Fragment {
10 |
11 | @Override
12 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
13 | Bundle savedInstanceState) {
14 | return inflater.inflate(R.layout.fragment_logout, container, false);
15 | }
16 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/eftimoff/empty/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.empty;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.ActionBarActivity;
9 | import android.view.View;
10 |
11 | import com.eftimoff.androipathview.PathView;
12 |
13 |
14 | public class MainActivity extends ActionBarActivity {
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | final ViewPager viewpager = (ViewPager) findViewById(R.id.viewpager);
21 | final ScreenSlidePagerAdapter screenSlidePagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
22 | viewpager.setAdapter(screenSlidePagerAdapter);
23 | viewpager.setPageTransformer(true, new CustomTransformer());
24 | }
25 |
26 | private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
27 | public ScreenSlidePagerAdapter(FragmentManager fm) {
28 | super(fm);
29 | }
30 |
31 | @Override
32 | public Fragment getItem(int position) {
33 | if (position == 0) {
34 | return new SettingsFragment();
35 | }
36 | if (position == 1) {
37 | return new IssuesFragment();
38 | }
39 | if (position == 2) {
40 | return new LogoutFragment();
41 | }
42 | return new SettingsFragment();
43 | }
44 |
45 | @Override
46 | public int getCount() {
47 | return 3;
48 | }
49 | }
50 |
51 | private class CustomTransformer implements ViewPager.PageTransformer {
52 |
53 |
54 | @Override
55 | public void transformPage(View page, float position) {
56 | if (position < -1 || position > 1) { // [-Infinity,-1)
57 | // This page is way off-screen to the left.
58 | page.setAlpha(0);
59 | return;
60 | }
61 | final float abs = 1 - Math.abs(position);
62 | final PathView pathView = (PathView) page.findViewById(R.id.pathView);
63 | pathView.setPercentage(abs);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/eftimoff/empty/SecondActivity.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.empty;
2 |
3 | import android.graphics.Path;
4 | import android.os.Bundle;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.view.View;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 |
9 | import com.eftimoff.androipathview.PathView;
10 |
11 |
12 | public class SecondActivity extends ActionBarActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_second);
18 | final PathView pathView = (PathView) findViewById(R.id.pathView);
19 | // final Path path = makeConvexArrow(50, 100);
20 | // pathView.setPath(path);
21 | // pathView.setFillAfter(true);
22 | // pathView.useNaturalColors();
23 | pathView.setOnClickListener(new View.OnClickListener() {
24 | @Override
25 | public void onClick(View v) {
26 | pathView.getPathAnimator().
27 | //pathView.getSequentialPathAnimator().
28 | delay(100).
29 | duration(1500).
30 | interpolator(new AccelerateDecelerateInterpolator()).
31 | start();
32 | }
33 | });
34 | }
35 |
36 | private Path makeConvexArrow(float length, float height) {
37 | final Path path = new Path();
38 | path.moveTo(0.0f, 0.0f);
39 | path.lineTo(length / 4f, 0.0f);
40 | path.lineTo(length, height / 2.0f);
41 | path.lineTo(length / 4f, height);
42 | path.lineTo(0.0f, height);
43 | path.lineTo(length * 3f / 4f, height / 2f);
44 | path.lineTo(0.0f, 0.0f);
45 | path.close();
46 | return path;
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/eftimoff/empty/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package com.eftimoff.empty;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | public class SettingsFragment extends Fragment {
10 |
11 | @Override
12 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
13 | Bundle savedInstanceState) {
14 | return inflater.inflate(R.layout.fragment_settings, container, false);
15 | }
16 | }
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geftimov/android-pathview/81b316be165dfc2f0067279b104e3f45dc071182/sample/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_issues.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_logout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/flag_usa.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/ironman.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/ironman_white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/issues.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
21 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/linecap.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/logout.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
27 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/map_usa:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/monitor.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/src/main/res/raw/settings.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PathView
5 |
6 |
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':android-pathview'
2 |
--------------------------------------------------------------------------------