├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── gelitenight │ │ └── waveview │ │ └── library │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── gelitenight │ │ └── waveview │ │ └── library │ │ └── WaveView.java │ └── res │ └── values │ ├── attrs.xml │ └── strings.xml ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── gelitenight │ │ └── waveview │ │ └── sample │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── gelitenight │ │ └── waveview │ │ └── sample │ │ ├── MainActivity.java │ │ └── WaveHelper.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── screenshot.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ### JetBrains template 3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 4 | 5 | *.iml 6 | 7 | ## Directory-based project format: 8 | .idea/ 9 | # if you remove the above rule, at least ignore the following: 10 | 11 | # User-specific stuff: 12 | # .idea/workspace.xml 13 | # .idea/tasks.xml 14 | # .idea/dictionaries 15 | 16 | # Sensitive or high-churn files: 17 | # .idea/dataSources.ids 18 | # .idea/dataSources.xml 19 | # .idea/sqlDataSources.xml 20 | # .idea/dynamic.xml 21 | # .idea/uiDesigner.xml 22 | 23 | # Gradle: 24 | # .idea/gradle.xml 25 | # .idea/libraries 26 | 27 | # Mongo Explorer plugin: 28 | # .idea/mongoSettings.xml 29 | 30 | ## File-based project format: 31 | *.ipr 32 | *.iws 33 | 34 | ## Plugin-specific files: 35 | 36 | # IntelliJ 37 | /out/ 38 | 39 | # mpeltonen/sbt-idea plugin 40 | .idea_modules/ 41 | 42 | # JIRA plugin 43 | atlassian-ide-plugin.xml 44 | 45 | # Crashlytics plugin (for Android Studio and IntelliJ) 46 | com_crashlytics_export_strings.xml 47 | crashlytics.properties 48 | crashlytics-build.properties 49 | ### Android template 50 | # Built application files 51 | *.apk 52 | *.ap_ 53 | 54 | # Files for the Dalvik VM 55 | *.dex 56 | 57 | # Java class files 58 | *.class 59 | 60 | # Generated files 61 | bin/ 62 | gen/ 63 | 64 | # Gradle files 65 | .gradle/ 66 | build/ 67 | 68 | # Local configuration file (sdk path, etc) 69 | local.properties 70 | 71 | # Proguard folder generated by Eclipse 72 | proguard/ 73 | 74 | # Log Files 75 | *.log 76 | 77 | # Android Studio Navigation editor temp files 78 | .navigation/ 79 | 80 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [中文介绍](https://www.jianshu.com/p/e711e22e053e) 2 | 3 | # WaveView 4 | A view to display wave effect. 5 | 6 | ## Screenshot 7 | ![Screenshot](screenshot.gif) 8 | 9 | ## Integration 10 | ``` 11 | implementation 'com.gelitenight.waveview:waveview:1.0.0' 12 | ``` 13 | 14 | Setter methods: 15 | * `setWaveShiftRatio` - Shift the wave horizontally. 16 | * `setWaterLevelRatio` - Set water level. 17 | * `setAmplitudeRatio` - Set vertical size of wave. 18 | * `setWaveLengthRatio` - Set horizontal size of wave. 19 | 20 | You can use [Property Animation](https://developer.android.com/guide/topics/graphics/prop-animation.html) to animate WaveView. 21 | ``` 22 | // horizontal animation. 23 | // wave waves infinitely. 24 | ObjectAnimator waveShiftAnim = ObjectAnimator.ofFloat( 25 | mWaveView, "waveShiftRatio", 0f, 1f); 26 | waveShiftAnim.setRepeatCount(ValueAnimator.INFINITE); 27 | waveShiftAnim.setDuration(1000); 28 | waveShiftAnim.setInterpolator(new LinearInterpolator()); 29 | 30 | // vertical animation. 31 | // water level increases from 0 to center of WaveView 32 | ObjectAnimator waterLevelAnim = ObjectAnimator.ofFloat( 33 | mWaveView, "waterLevelRatio", 0f, 0.5f); 34 | waterLevelAnim.setDuration(10000); 35 | waterLevelAnim.setInterpolator(new DecelerateInterpolator()); 36 | animators.add(waterLevelAnim); 37 | 38 | // amplitude animation. 39 | // wave grows big then grows small, repeatedly 40 | ObjectAnimator amplitudeAnim = ObjectAnimator.ofFloat( 41 | mWaveView, "amplitudeRatio", 0f, 0.05f); 42 | amplitudeAnim.setRepeatCount(ValueAnimator.INFINITE); 43 | amplitudeAnim.setRepeatMode(ValueAnimator.REVERSE); 44 | amplitudeAnim.setDuration(5000); 45 | amplitudeAnim.setInterpolator(new LinearInterpolator()); 46 | animators.add(amplitudeAnim); 47 | ``` 48 | 49 | --- 50 | 51 | ### 打个广告 52 | 美团平台及酒旅事业群招人啦,欢迎加入我们! 53 | 我可以帮忙内推,简历请发到我邮箱 54 | >【美团网】高级Android开发工程师 55 | > 工作内容: 负责美团酒店、旅游产品 Android 客户端的设计、开发与改进。 56 | > 1. 3年以上工作经验,2年以上Android开发经验; 57 | > 2. 熟悉Android系统,熟悉Android软件的开发、测试、分发流程; 58 | > 3. 良好的编程风格,扎实的编程基础和数据结构算法基础; 59 | > 4. 熟悉移动网络的特性,对网络编程和常用网络协议有较深刻理解和经验; 60 | > 5. 有一定的架构设计能力,良好的编码能力,编写文档能力; 61 | > 6. 热爱互联网和新技术,具有极强的快速学习能力; 62 | > 7. 有以下特征优先考虑: 63 | > * 有开源作品或技术博客(需原创技术文章); 64 | > * 熟悉Socket编程。 65 | 66 | 北京、上海、厦门、成都都有职位,更多职位请见[职位列表](https://job.meituan.com/job-list?city=001001&department=5&jobFamily=26&pageNo=1)。 67 | -------------------------------------------------------------------------------- /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.2.2' 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 | -------------------------------------------------------------------------------- /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/gelitenight/WaveView/09e223e5b38679caa4946ad1abad64f9c0f6bd3e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 27 16:08:42 CST 2016 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.14.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 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | PUBLISH_GROUP_ID = 'com.gelitenight.waveview' 5 | PUBLISH_ARTIFACT_ID = 'waveview' 6 | PUBLISH_VERSION = '1.0.0' 7 | } 8 | 9 | android { 10 | compileSdkVersion 25 11 | buildToolsVersion "25.0.1" 12 | 13 | defaultConfig { 14 | minSdkVersion 14 15 | targetSdkVersion 25 16 | versionCode 1 17 | versionName "1.0.0" 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(dir: 'libs', include: ['*.jar']) 29 | compile 'com.android.support:appcompat-v7:25.1.0' 30 | } 31 | 32 | apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle' 33 | -------------------------------------------------------------------------------- /library/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:\app\android-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 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/gelitenight/waveview/library/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.gelitenight.waveview.library; 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 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /library/src/main/java/com/gelitenight/waveview/library/WaveView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, gelitenight(gelitenight@gmail.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.gelitenight.waveview.library; 17 | 18 | import android.content.Context; 19 | import android.graphics.Bitmap; 20 | import android.graphics.BitmapShader; 21 | import android.graphics.Canvas; 22 | import android.graphics.Color; 23 | import android.graphics.Matrix; 24 | import android.graphics.Paint; 25 | import android.graphics.Paint.Style; 26 | import android.graphics.Shader; 27 | import android.util.AttributeSet; 28 | import android.view.View; 29 | 30 | public class WaveView extends View { 31 | /** 32 | * +------------------------+ 33 | * |<--wave length-> |______ 34 | * | /\ | /\ | | 35 | * | / \ | / \ | amplitude 36 | * | / \ | / \ | | 37 | * |/ \ |/ \|__|____ 38 | * | \ / | | 39 | * | \ / | | 40 | * | \ / | | 41 | * | \/ | water level 42 | * | | | 43 | * | | | 44 | * +------------------------+__|____ 45 | */ 46 | private static final float DEFAULT_AMPLITUDE_RATIO = 0.05f; 47 | private static final float DEFAULT_WATER_LEVEL_RATIO = 0.5f; 48 | private static final float DEFAULT_WAVE_LENGTH_RATIO = 1.0f; 49 | private static final float DEFAULT_WAVE_SHIFT_RATIO = 0.0f; 50 | 51 | public static final int DEFAULT_BEHIND_WAVE_COLOR = Color.parseColor("#28FFFFFF"); 52 | public static final int DEFAULT_FRONT_WAVE_COLOR = Color.parseColor("#3CFFFFFF"); 53 | public static final ShapeType DEFAULT_WAVE_SHAPE = ShapeType.CIRCLE; 54 | 55 | public enum ShapeType { 56 | CIRCLE, 57 | SQUARE 58 | } 59 | 60 | // if true, the shader will display the wave 61 | private boolean mShowWave; 62 | 63 | // shader containing repeated waves 64 | private BitmapShader mWaveShader; 65 | // shader matrix 66 | private Matrix mShaderMatrix; 67 | // paint to draw wave 68 | private Paint mViewPaint; 69 | // paint to draw border 70 | private Paint mBorderPaint; 71 | 72 | private float mDefaultAmplitude; 73 | private float mDefaultWaterLevel; 74 | private float mDefaultWaveLength; 75 | private double mDefaultAngularFrequency; 76 | 77 | private float mAmplitudeRatio = DEFAULT_AMPLITUDE_RATIO; 78 | private float mWaveLengthRatio = DEFAULT_WAVE_LENGTH_RATIO; 79 | private float mWaterLevelRatio = DEFAULT_WATER_LEVEL_RATIO; 80 | private float mWaveShiftRatio = DEFAULT_WAVE_SHIFT_RATIO; 81 | 82 | private int mBehindWaveColor = DEFAULT_BEHIND_WAVE_COLOR; 83 | private int mFrontWaveColor = DEFAULT_FRONT_WAVE_COLOR; 84 | private ShapeType mShapeType = DEFAULT_WAVE_SHAPE; 85 | 86 | public WaveView(Context context) { 87 | super(context); 88 | init(); 89 | } 90 | 91 | public WaveView(Context context, AttributeSet attrs) { 92 | super(context, attrs); 93 | init(attrs); 94 | } 95 | 96 | public WaveView(Context context, AttributeSet attrs, int defStyle) { 97 | super(context, attrs, defStyle); 98 | init(attrs); 99 | } 100 | 101 | private void init() { 102 | mShaderMatrix = new Matrix(); 103 | mViewPaint = new Paint(); 104 | mViewPaint.setAntiAlias(true); 105 | } 106 | 107 | private void init(AttributeSet attrs) { 108 | init(); 109 | 110 | TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, 111 | R.styleable.WaveView, 0, 0); 112 | 113 | mAmplitudeRatio = typedArray.getFloat(R.styleable.WaveView_amplitudeRatio, DEFAULT_AMPLITUDE_RATIO); 114 | mWaterLevelRatio = typedArray.getFloat(R.styleable.WaveView_waveWaterLevel, DEFAULT_WATER_LEVEL_RATIO); 115 | mWaveLengthRatio = typedArray.getFloat(R.styleable.WaveView_waveLengthRatio, DEFAULT_WAVE_LENGTH_RATIO); 116 | mWaveShiftRatio = typedArray.getFloat(R.styleable.WaveView_waveShiftRatio, DEFAULT_WAVE_SHIFT_RATIO); 117 | mFrontWaveColor = typedArray.getColor(R.styleable.WaveView_frontWaveColor, DEFAULT_FRONT_WAVE_COLOR); 118 | mBehindWaveColor = typedArray.getColor(R.styleable.WaveView_behindWaveColor, DEFAULT_BEHIND_WAVE_COLOR); 119 | mShapeType = typedArray.getInt(R.styleable.WaveView_waveShape, 0) == 0 ? ShapeType.CIRCLE : ShapeType.SQUARE; 120 | mShowWave = typedArray.getBoolean(R.styleable.WaveView_showWave, true); 121 | 122 | typedArray.recycle(); 123 | 124 | } 125 | 126 | public float getWaveShiftRatio() { 127 | return mWaveShiftRatio; 128 | } 129 | 130 | /** 131 | * Shift the wave horizontally according to waveShiftRatio. 132 | * 133 | * @param waveShiftRatio Should be 0 ~ 1. Default to be 0. 134 | * Result of waveShiftRatio multiples width of WaveView is the length to shift. 135 | */ 136 | public void setWaveShiftRatio(float waveShiftRatio) { 137 | if (mWaveShiftRatio != waveShiftRatio) { 138 | mWaveShiftRatio = waveShiftRatio; 139 | invalidate(); 140 | } 141 | } 142 | 143 | public float getWaterLevelRatio() { 144 | return mWaterLevelRatio; 145 | } 146 | 147 | /** 148 | * Set water level according to waterLevelRatio. 149 | * 150 | * @param waterLevelRatio Should be 0 ~ 1. Default to be 0.5. 151 | * Ratio of water level to WaveView height. 152 | */ 153 | public void setWaterLevelRatio(float waterLevelRatio) { 154 | if (mWaterLevelRatio != waterLevelRatio) { 155 | mWaterLevelRatio = waterLevelRatio; 156 | invalidate(); 157 | } 158 | } 159 | 160 | public float getAmplitudeRatio() { 161 | return mAmplitudeRatio; 162 | } 163 | 164 | /** 165 | * Set vertical size of wave according to amplitudeRatio 166 | * 167 | * @param amplitudeRatio Default to be 0.05. Result of amplitudeRatio + waterLevelRatio should be less than 1. 168 | * Ratio of amplitude to height of WaveView. 169 | */ 170 | public void setAmplitudeRatio(float amplitudeRatio) { 171 | if (mAmplitudeRatio != amplitudeRatio) { 172 | mAmplitudeRatio = amplitudeRatio; 173 | invalidate(); 174 | } 175 | } 176 | 177 | public float getWaveLengthRatio() { 178 | return mWaveLengthRatio; 179 | } 180 | 181 | /** 182 | * Set horizontal size of wave according to waveLengthRatio 183 | * 184 | * @param waveLengthRatio Default to be 1. 185 | * Ratio of wave length to width of WaveView. 186 | */ 187 | public void setWaveLengthRatio(float waveLengthRatio) { 188 | mWaveLengthRatio = waveLengthRatio; 189 | } 190 | 191 | public boolean isShowWave() { 192 | return mShowWave; 193 | } 194 | 195 | public void setShowWave(boolean showWave) { 196 | mShowWave = showWave; 197 | } 198 | 199 | public void setBorder(int width, int color) { 200 | if (mBorderPaint == null) { 201 | mBorderPaint = new Paint(); 202 | mBorderPaint.setAntiAlias(true); 203 | mBorderPaint.setStyle(Style.STROKE); 204 | } 205 | mBorderPaint.setColor(color); 206 | mBorderPaint.setStrokeWidth(width); 207 | 208 | invalidate(); 209 | } 210 | 211 | public void setWaveColor(int behindWaveColor, int frontWaveColor) { 212 | mBehindWaveColor = behindWaveColor; 213 | mFrontWaveColor = frontWaveColor; 214 | 215 | if (getWidth() > 0 && getHeight() > 0) { 216 | // need to recreate shader when color changed 217 | mWaveShader = null; 218 | createShader(); 219 | invalidate(); 220 | } 221 | } 222 | 223 | public void setShapeType(ShapeType shapeType) { 224 | mShapeType = shapeType; 225 | invalidate(); 226 | } 227 | 228 | @Override 229 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 230 | super.onSizeChanged(w, h, oldw, oldh); 231 | 232 | createShader(); 233 | } 234 | 235 | /** 236 | * Create the shader with default waves which repeat horizontally, and clamp vertically 237 | */ 238 | private void createShader() { 239 | mDefaultAngularFrequency = 2.0f * Math.PI / DEFAULT_WAVE_LENGTH_RATIO / getWidth(); 240 | mDefaultAmplitude = getHeight() * DEFAULT_AMPLITUDE_RATIO; 241 | mDefaultWaterLevel = getHeight() * DEFAULT_WATER_LEVEL_RATIO; 242 | mDefaultWaveLength = getWidth(); 243 | 244 | Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); 245 | Canvas canvas = new Canvas(bitmap); 246 | 247 | Paint wavePaint = new Paint(); 248 | wavePaint.setStrokeWidth(2); 249 | wavePaint.setAntiAlias(true); 250 | 251 | // Draw default waves into the bitmap 252 | // y=Asin(ωx+φ)+h 253 | final int endX = getWidth() + 1; 254 | final int endY = getHeight() + 1; 255 | 256 | float[] waveY = new float[endX]; 257 | 258 | wavePaint.setColor(mBehindWaveColor); 259 | for (int beginX = 0; beginX < endX; beginX++) { 260 | double wx = beginX * mDefaultAngularFrequency; 261 | float beginY = (float) (mDefaultWaterLevel + mDefaultAmplitude * Math.sin(wx)); 262 | canvas.drawLine(beginX, beginY, beginX, endY, wavePaint); 263 | 264 | waveY[beginX] = beginY; 265 | } 266 | 267 | wavePaint.setColor(mFrontWaveColor); 268 | final int wave2Shift = (int) (mDefaultWaveLength / 4); 269 | for (int beginX = 0; beginX < endX; beginX++) { 270 | canvas.drawLine(beginX, waveY[(beginX + wave2Shift) % endX], beginX, endY, wavePaint); 271 | } 272 | 273 | // use the bitamp to create the shader 274 | mWaveShader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); 275 | mViewPaint.setShader(mWaveShader); 276 | } 277 | 278 | @Override 279 | protected void onDraw(Canvas canvas) { 280 | // modify paint shader according to mShowWave state 281 | if (mShowWave && mWaveShader != null) { 282 | // first call after mShowWave, assign it to our paint 283 | if (mViewPaint.getShader() == null) { 284 | mViewPaint.setShader(mWaveShader); 285 | } 286 | 287 | // sacle shader according to mWaveLengthRatio and mAmplitudeRatio 288 | // this decides the size(mWaveLengthRatio for width, mAmplitudeRatio for height) of waves 289 | mShaderMatrix.setScale( 290 | mWaveLengthRatio / DEFAULT_WAVE_LENGTH_RATIO, 291 | mAmplitudeRatio / DEFAULT_AMPLITUDE_RATIO, 292 | 0, 293 | mDefaultWaterLevel); 294 | // translate shader according to mWaveShiftRatio and mWaterLevelRatio 295 | // this decides the start position(mWaveShiftRatio for x, mWaterLevelRatio for y) of waves 296 | mShaderMatrix.postTranslate( 297 | mWaveShiftRatio * getWidth(), 298 | (DEFAULT_WATER_LEVEL_RATIO - mWaterLevelRatio) * getHeight()); 299 | 300 | // assign matrix to invalidate the shader 301 | mWaveShader.setLocalMatrix(mShaderMatrix); 302 | 303 | float borderWidth = mBorderPaint == null ? 0f : mBorderPaint.getStrokeWidth(); 304 | switch (mShapeType) { 305 | case CIRCLE: 306 | if (borderWidth > 0) { 307 | canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, 308 | (getWidth() - borderWidth) / 2f - 1f, mBorderPaint); 309 | } 310 | float radius = getWidth() / 2f - borderWidth; 311 | canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, radius, mViewPaint); 312 | break; 313 | case SQUARE: 314 | if (borderWidth > 0) { 315 | canvas.drawRect( 316 | borderWidth / 2f, 317 | borderWidth / 2f, 318 | getWidth() - borderWidth / 2f - 0.5f, 319 | getHeight() - borderWidth / 2f - 0.5f, 320 | mBorderPaint); 321 | } 322 | canvas.drawRect(borderWidth, borderWidth, getWidth() - borderWidth, 323 | getHeight() - borderWidth, mViewPaint); 324 | break; 325 | } 326 | } else { 327 | mViewPaint.setShader(null); 328 | } 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | library 3 | 4 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.gelitenight.waveview.sample" 9 | minSdkVersion 14 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(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:25.1.0' 25 | compile 'com.android.support:support-v4:25.1.0' 26 | compile project(":library") 27 | } 28 | -------------------------------------------------------------------------------- /sample/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:\app\android-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 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/gelitenight/waveview/sample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.gelitenight.waveview.sample; 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 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/java/com/gelitenight/waveview/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.gelitenight.waveview.sample; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v4.widget.CompoundButtonCompat; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.widget.RadioButton; 8 | import android.widget.RadioGroup; 9 | import android.widget.SeekBar; 10 | 11 | import com.gelitenight.waveview.library.WaveView; 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | 15 | private WaveHelper mWaveHelper; 16 | 17 | private int mBorderColor = Color.parseColor("#44FFFFFF"); 18 | private int mBorderWidth = 10; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | final WaveView waveView = (WaveView) findViewById(R.id.wave); 26 | waveView.setBorder(mBorderWidth, mBorderColor); 27 | 28 | mWaveHelper = new WaveHelper(waveView); 29 | 30 | ((RadioGroup) findViewById(R.id.shapeChoice)) 31 | .setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { 32 | @Override 33 | public void onCheckedChanged(RadioGroup radioGroup, int i) { 34 | switch (i) { 35 | case R.id.shapeCircle: 36 | waveView.setShapeType(WaveView.ShapeType.CIRCLE); 37 | break; 38 | case R.id.shapeSquare: 39 | waveView.setShapeType(WaveView.ShapeType.SQUARE); 40 | break; 41 | default: 42 | break; 43 | } 44 | } 45 | }); 46 | 47 | ((SeekBar) findViewById(R.id.seekBar)) 48 | .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 49 | @Override 50 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) { 51 | mBorderWidth = i; 52 | waveView.setBorder(mBorderWidth, mBorderColor); 53 | } 54 | 55 | @Override 56 | public void onStartTrackingTouch(SeekBar seekBar) { 57 | 58 | } 59 | 60 | @Override 61 | public void onStopTrackingTouch(SeekBar seekBar) { 62 | 63 | } 64 | }); 65 | 66 | CompoundButtonCompat.setButtonTintList( 67 | (RadioButton) findViewById(R.id.colorDefault), 68 | getResources().getColorStateList(android.R.color.white)); 69 | CompoundButtonCompat.setButtonTintList( 70 | (RadioButton) findViewById(R.id.colorRed), 71 | getResources().getColorStateList(R.color.red)); 72 | CompoundButtonCompat.setButtonTintList( 73 | (RadioButton) findViewById(R.id.colorGreen), 74 | getResources().getColorStateList(R.color.green)); 75 | CompoundButtonCompat.setButtonTintList( 76 | (RadioButton) findViewById(R.id.colorBlue), 77 | getResources().getColorStateList(R.color.blue)); 78 | 79 | ((RadioGroup) findViewById(R.id.colorChoice)) 80 | .setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { 81 | @Override 82 | public void onCheckedChanged(RadioGroup radioGroup, int i) { 83 | switch (i) { 84 | case R.id.colorRed: 85 | waveView.setWaveColor( 86 | Color.parseColor("#28f16d7a"), 87 | Color.parseColor("#3cf16d7a")); 88 | mBorderColor = Color.parseColor("#44f16d7a"); 89 | waveView.setBorder(mBorderWidth, mBorderColor); 90 | break; 91 | case R.id.colorGreen: 92 | waveView.setWaveColor( 93 | Color.parseColor("#40b7d28d"), 94 | Color.parseColor("#80b7d28d")); 95 | mBorderColor = Color.parseColor("#B0b7d28d"); 96 | waveView.setBorder(mBorderWidth, mBorderColor); 97 | break; 98 | case R.id.colorBlue: 99 | waveView.setWaveColor( 100 | Color.parseColor("#88b8f1ed"), 101 | Color.parseColor("#b8f1ed")); 102 | mBorderColor = Color.parseColor("#b8f1ed"); 103 | waveView.setBorder(mBorderWidth, mBorderColor); 104 | break; 105 | default: 106 | waveView.setWaveColor( 107 | WaveView.DEFAULT_BEHIND_WAVE_COLOR, 108 | WaveView.DEFAULT_FRONT_WAVE_COLOR); 109 | mBorderColor = Color.parseColor("#44FFFFFF"); 110 | waveView.setBorder(mBorderWidth, mBorderColor); 111 | break; 112 | } 113 | } 114 | }); 115 | } 116 | 117 | @Override 118 | protected void onPause() { 119 | super.onPause(); 120 | mWaveHelper.cancel(); 121 | } 122 | 123 | @Override 124 | protected void onResume() { 125 | super.onResume(); 126 | mWaveHelper.start(); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /sample/src/main/java/com/gelitenight/waveview/sample/WaveHelper.java: -------------------------------------------------------------------------------- 1 | package com.gelitenight.waveview.sample; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorSet; 5 | import android.animation.ObjectAnimator; 6 | import android.animation.ValueAnimator; 7 | import android.view.animation.DecelerateInterpolator; 8 | import android.view.animation.LinearInterpolator; 9 | 10 | import com.gelitenight.waveview.library.WaveView; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class WaveHelper { 16 | private WaveView mWaveView; 17 | 18 | private AnimatorSet mAnimatorSet; 19 | 20 | public WaveHelper(WaveView waveView) { 21 | mWaveView = waveView; 22 | initAnimation(); 23 | } 24 | 25 | public void start() { 26 | mWaveView.setShowWave(true); 27 | if (mAnimatorSet != null) { 28 | mAnimatorSet.start(); 29 | } 30 | } 31 | 32 | private void initAnimation() { 33 | List animators = new ArrayList<>(); 34 | 35 | // horizontal animation. 36 | // wave waves infinitely. 37 | ObjectAnimator waveShiftAnim = ObjectAnimator.ofFloat( 38 | mWaveView, "waveShiftRatio", 0f, 1f); 39 | waveShiftAnim.setRepeatCount(ValueAnimator.INFINITE); 40 | waveShiftAnim.setDuration(1000); 41 | waveShiftAnim.setInterpolator(new LinearInterpolator()); 42 | animators.add(waveShiftAnim); 43 | 44 | // vertical animation. 45 | // water level increases from 0 to center of WaveView 46 | ObjectAnimator waterLevelAnim = ObjectAnimator.ofFloat( 47 | mWaveView, "waterLevelRatio", 0f, 0.5f); 48 | waterLevelAnim.setDuration(10000); 49 | waterLevelAnim.setInterpolator(new DecelerateInterpolator()); 50 | animators.add(waterLevelAnim); 51 | 52 | // amplitude animation. 53 | // wave grows big then grows small, repeatedly 54 | ObjectAnimator amplitudeAnim = ObjectAnimator.ofFloat( 55 | mWaveView, "amplitudeRatio", 0.0001f, 0.05f); 56 | amplitudeAnim.setRepeatCount(ValueAnimator.INFINITE); 57 | amplitudeAnim.setRepeatMode(ValueAnimator.REVERSE); 58 | amplitudeAnim.setDuration(5000); 59 | amplitudeAnim.setInterpolator(new LinearInterpolator()); 60 | animators.add(amplitudeAnim); 61 | 62 | mAnimatorSet = new AnimatorSet(); 63 | mAnimatorSet.playTogether(animators); 64 | } 65 | 66 | public void cancel() { 67 | if (mAnimatorSet != null) { 68 | // mAnimatorSet.cancel(); 69 | mAnimatorSet.end(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | 20 | 21 | 34 | 35 | 42 | 43 | 49 | 50 | 58 | 59 | 65 | 66 | 72 | 73 | 74 | 81 | 82 | 88 | 89 | 95 | 96 | 103 | 104 | 111 | 112 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelitenight/WaveView/09e223e5b38679caa4946ad1abad64f9c0f6bd3e/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelitenight/WaveView/09e223e5b38679caa4946ad1abad64f9c0f6bd3e/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelitenight/WaveView/09e223e5b38679caa4946ad1abad64f9c0f6bd3e/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelitenight/WaveView/09e223e5b38679caa4946ad1abad64f9c0f6bd3e/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #f16d7a 4 | #b7d28d 5 | #b8f1ed 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | WaveView 3 | 4 | Hello world! 5 | Settings 6 | Border 7 | Shape 8 | Circle 9 | Square 10 | Color 11 | Red 12 | Green 13 | Blue 14 | Default 15 | 16 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelitenight/WaveView/09e223e5b38679caa4946ad1abad64f9c0f6bd3e/screenshot.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library' 2 | --------------------------------------------------------------------------------