├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_common_water_view.xml
│ │ ├── java
│ │ │ └── cxy
│ │ │ │ └── com
│ │ │ │ └── waterviewdemo
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── CommonWaterViewActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── cxy
│ │ │ └── com
│ │ │ └── waterviewdemo
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── cxy
│ │ └── com
│ │ └── waterviewdemo
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── waterviewlib
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── attr.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── cxy
│ │ └── com
│ │ └── waterviewlib
│ │ └── WaterView.java
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── apk
└── app-debug.apk
├── gif
└── waterview.gif
├── .idea
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/waterviewlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':waterviewlib'
2 |
--------------------------------------------------------------------------------
/apk/app-debug.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/apk/app-debug.apk
--------------------------------------------------------------------------------
/gif/waterview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/gif/waterview.gif
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | WaterViewDemo
3 |
4 |
--------------------------------------------------------------------------------
/waterviewlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | WaterViewLib
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LongMaoC/WaterView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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 |
--------------------------------------------------------------------------------
/waterviewlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/cxy/com/waterviewdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cxy.com.waterviewdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/waterviewlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | group='com.github.LongMaoC'
4 |
5 | android {
6 | compileSdkVersion 25
7 | buildToolsVersion '25.0.2'
8 |
9 | defaultConfig {
10 | minSdkVersion 15
11 | targetSdkVersion 24
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | }
26 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\androidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/waterviewlib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\androidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cxy/com/waterviewdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cxy.com.waterviewdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cxy.com.waterviewdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/cxy/com/waterviewdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cxy.com.waterviewdemo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | /**
9 | * Created by cxy on 17-8-1.
10 | */
11 |
12 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
13 |
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 | findViewById(R.id.btn1).setOnClickListener(this);
20 | findViewById(R.id.btn2).setOnClickListener(this);
21 | }
22 |
23 | @Override
24 | public void onClick(View v) {
25 | switch (v.getId()){
26 | case R.id.btn1:
27 | startActivity(new Intent(MainActivity.this,CommonWaterViewActivity.class));
28 | break;
29 | case R.id.btn2:
30 | break;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '25.0.2'
6 | defaultConfig {
7 | applicationId "cxy.com.waterviewdemo"
8 | minSdkVersion 15
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | compileOptions {
21 | sourceCompatibility JavaVersion.VERSION_1_7
22 | targetCompatibility JavaVersion.VERSION_1_7
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(include: ['*.jar'], dir: 'libs')
28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29 | exclude group: 'com.android.support', module: 'support-annotations'
30 | })
31 | compile 'com.android.support:appcompat-v7:24.2.1'
32 | testCompile 'junit:junit:4.12'
33 | compile project(':waterviewlib')
34 | compile 'com.google.android.gms:play-services-appindexing:8.4.0'
35 | }
36 |
--------------------------------------------------------------------------------
/waterviewlib/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WaterView
## 日志
* 新增 : 保持高度的暂停

* [思路](#user-content-思路)
* [使用](#user-content-使用)
* [属性](#user-content-属性)
* [反馈](#user-content-反馈)
## 思路
主要就是sin函数,y = Asin(wx+b)+h ,这个公式里:w影响周期,A影响振幅,h影响y位置,b为初相。根据函数计算出两个波浪的path ,最后进行绘制
## 使用
在root build.gradle中添加
```
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
在app build.gradle中添加
```
compile 'com.github.LongMaoC:WaterView:v1.0'
```
xml
```
```
监听
```
waterView.setListener(new WaterView.Listener() {
@Override
public void finish() {
Toast.makeText(MainActivity.this, "已经满了!!!", Toast.LENGTH_SHORT).show();
}
});
```
### 属性
| 属性 | 说明 |默认值|
| :---------------------------: |:-------------------------------:|:-----------:|
| waterview_paint_color_first | 第一只画笔颜色 |#5353C7|
| waterview_paint_color_second | 第二只画笔颜色 |#9292DA|
| waterview_frame_color | 边框画笔颜色 |#5353C7|
| waterview_frame_width | 边框宽度,为0dp时不显示边框|1|
| waterview_amplitude | 振幅 ,参考值10到100之间 |20|
| waterview_up_velocity | 上升速度上升速度,参考值5 |5 |
| waterview_offset_increment_value | 初项递增值,表示波浪的快慢 ,参考值0.4 |0.4 |
| waterview_sleep_time | 界面更新速度,单位毫秒,参考值100 |100 |
| waterview_isShowFrame | 是否显示边框 |false|
## 反馈
在使用中有任何问题、意见,或者有好的想法,欢迎反馈给我,一起实现~
* 邮件(chenxingyu1112@gmail.com)
* QQ: 1209101049
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/cxy/com/waterviewdemo/CommonWaterViewActivity.java:
--------------------------------------------------------------------------------
1 | package cxy.com.waterviewdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.Toast;
8 |
9 | import cxy.com.waterviewlib.WaterView;
10 |
11 | public class CommonWaterViewActivity extends AppCompatActivity implements View.OnClickListener {
12 |
13 | private WaterView waterView;
14 | private Button btn_start;
15 | private Button btn_reset;
16 | private Button btn_stop;
17 | private Button btn_recover;
18 | private Button btn_keep;
19 |
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_common_water_view);
25 | initViw();
26 |
27 | waterView.setListener(new WaterView.Listener() {
28 | @Override
29 | public void finish() {
30 | Toast.makeText(CommonWaterViewActivity.this, "已经满了!!!", Toast.LENGTH_SHORT).show();
31 | }
32 | });
33 | }
34 |
35 | private void initViw() {
36 | btn_reset = (Button) findViewById(R.id.btn_reset);
37 | btn_start = (Button) findViewById(R.id.btn_start);
38 | btn_stop = (Button) findViewById(R.id.btn_stop);
39 | btn_recover = (Button) findViewById(R.id.btn_recover);
40 | btn_keep= (Button) findViewById(R.id.btn_keep);
41 |
42 | btn_reset.setOnClickListener(this);
43 | btn_start.setOnClickListener(this);
44 | btn_stop.setOnClickListener(this);
45 | btn_recover.setOnClickListener(this);
46 | btn_keep.setOnClickListener(this);
47 |
48 | waterView = (WaterView) findViewById(R.id.waterview);
49 | }
50 |
51 | @Override
52 | public void onClick(View view) {
53 | switch (view.getId()) {
54 | case R.id.btn_start:
55 | waterView.start();
56 | break;
57 | case R.id.btn_recover:
58 | waterView.recover();
59 | break;
60 | case R.id.btn_stop:
61 | waterView.stop();
62 | break;
63 | case R.id.btn_reset:
64 | waterView.reset();
65 | break;
66 | case R.id.btn_keep:
67 | waterView.keepHeight();
68 | break;
69 | }
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_common_water_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
32 |
33 |
37 |
38 |
45 |
46 |
52 |
58 |
59 |
65 |
66 |
67 |
68 |
72 |
73 |
79 |
80 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/waterviewlib/src/main/java/cxy/com/waterviewlib/WaterView.java:
--------------------------------------------------------------------------------
1 | package cxy.com.waterviewlib;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.Path;
9 | import android.graphics.Region;
10 | import android.transition.Explode;
11 | import android.util.AttributeSet;
12 | import android.view.View;
13 | import android.view.ViewDebug;
14 |
15 | /*****************************************
16 | * 水波纹效果
17 | *
18 | * @author cxy
19 | * created at 2016/10/11 10:39
20 | ****************************************/
21 | public class WaterView extends View {
22 |
23 | private boolean isShowFrame;
24 | private int mWidth;
25 | private int mHeight;
26 | private float centerX;
27 | private float centerY;
28 |
29 | private Path canvasPath = new Path();
30 | private Path firstPath = new Path();
31 | private Paint firstPaint;
32 | private Path secondPath = new Path();
33 | private Paint secondPaint;
34 | private Paint framePaint;
35 |
36 | private float sin_cycle = 0.01f;//周期 , 0.01f左右
37 | float sin_offset = 0.0f;//初项,偏移量
38 | float h = 0f;
39 |
40 | private int secondPaintColor = Color.parseColor("#9292DA");
41 | private int firstPaintColor = Color.parseColor("#5353C7");
42 | private int frameColor = Color.parseColor("#5353C7");
43 | private float frameWidth;
44 | private int sin_amplitude = 20;//振幅 ,10到100之间
45 | private float sin_offset_increment_value = 0.4f;//初项递增值,表示波浪的快慢
46 | private int sin_up_velocity = 5;//上升速度,参考值3
47 | private int sleep_time = 100; //休眠时间,参考值100
48 | private boolean isStart = false;
49 | private boolean isStop = false;
50 | private boolean isKeepHeight = false;
51 |
52 |
53 | private int type;
54 | public static final int TYPE_CIRCLE = 1;
55 | public static final int TYPE_RECT = 2;
56 |
57 | public WaterView(Context context) {
58 | this(context, null);
59 | }
60 |
61 | public WaterView(Context context, AttributeSet attrs) {
62 | this(context, attrs, 0);
63 | }
64 |
65 | public WaterView(Context context, AttributeSet attrs, int defStyleAttr) {
66 | super(context, attrs, defStyleAttr);
67 |
68 | // 初始化值
69 | secondPaintColor = Color.parseColor("#9292DA");
70 | firstPaintColor = Color.parseColor("#5353C7");
71 | sin_amplitude = 20;//振幅 ,10到100之间
72 | sin_offset_increment_value = 0.4f;//初项递增值,表示波浪的快慢
73 | sin_up_velocity = 5;//上升速度,参考值3
74 | sleep_time = 100; //休眠时间,参考值100
75 | frameColor = Color.parseColor("#5353C7");
76 | frameWidth = dip2px(context, 2);
77 | type = TYPE_CIRCLE;
78 | isShowFrame = false;
79 |
80 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.WaterView);
81 | firstPaintColor = typedArray.getColor(R.styleable.WaterView_waterview_paint_color_first, firstPaintColor);
82 | secondPaintColor = typedArray.getColor(R.styleable.WaterView_waterview_paint_color_second, secondPaintColor);
83 | sin_amplitude = typedArray.getInt(R.styleable.WaterView_waterview_amplitude, sin_amplitude);
84 | sin_offset_increment_value = typedArray.getFloat(R.styleable.WaterView_waterview_offset_increment_value, sin_offset_increment_value);
85 | sin_up_velocity = typedArray.getInt(R.styleable.WaterView_waterview_up_velocity, sin_up_velocity);
86 | sleep_time = typedArray.getInt(R.styleable.WaterView_waterview_sleep_time, sleep_time);
87 | sleep_time = typedArray.getInt(R.styleable.WaterView_waterview_sleep_time, sleep_time);
88 | frameWidth = typedArray.getDimension(R.styleable.WaterView_waterview_frame_width, frameWidth);
89 | frameColor = typedArray.getColor(R.styleable.WaterView_waterview_frame_color, frameColor);
90 | isShowFrame = typedArray.getBoolean(R.styleable.WaterView_waterview_frame_color, false);
91 | typedArray.recycle();
92 |
93 | if (frameWidth == 0) isShowFrame = false;
94 |
95 | firstPaint = new Paint();
96 | firstPaint.setColor(firstPaintColor);
97 | firstPaint.setAntiAlias(true);
98 | secondPaint = new Paint();
99 | secondPaint.setColor(secondPaintColor);
100 | secondPaint.setAntiAlias(true);
101 | framePaint = new Paint();
102 | framePaint.setStrokeWidth(frameWidth);
103 | framePaint.setAntiAlias(true);
104 | framePaint.setColor(frameColor);
105 | framePaint.setStyle(Paint.Style.STROKE);
106 |
107 | }
108 |
109 |
110 | @Override
111 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
112 | super.onSizeChanged(w, h, oldw, oldh);
113 | this.h = mHeight;
114 | canvasPath.addCircle(centerX, centerY, mHeight / 2, Path.Direction.CCW);
115 | reset();
116 |
117 | }
118 |
119 | @Override
120 | protected void onDraw(Canvas canvas) {
121 | canvas.clipPath(canvasPath, Region.Op.INTERSECT);
122 | if (isShowFrame) canvas.drawCircle(centerX, centerY, mHeight / 2, framePaint);
123 |
124 | if (isStart) {
125 | canvas.drawPath(secondPath(), secondPaint);
126 | canvas.drawPath(firstPath(), firstPaint);
127 | }
128 | }
129 |
130 | //y = Asin(wx+b)+h ,这个公式里:w影响周期,A影响振幅,h影响y位置,b为初相;
131 | private Path firstPath() {
132 | firstPath.reset();
133 | firstPath.moveTo(0, mHeight);// 移动到左下角的点
134 |
135 | for (float x = 0; x <= mWidth; x++) {
136 | float y = (float) (sin_amplitude * Math.sin(sin_cycle * x + sin_offset + 40)) + h;
137 | firstPath.lineTo(x, y);
138 | }
139 | firstPath.lineTo(mWidth, mHeight);
140 | firstPath.lineTo(0, mHeight);
141 | firstPath.close();
142 | return firstPath;
143 | }
144 |
145 | private Path secondPath() {
146 | secondPath.reset();
147 | secondPath.moveTo(0, mHeight);// 移动到左下角的点
148 |
149 | for (float x = 0; x <= mWidth; x++) {
150 | float y = (float) (sin_amplitude * Math.sin(sin_cycle * x + sin_offset)) + h;
151 | secondPath.lineTo(x, y);
152 | }
153 | secondPath.lineTo(mWidth, mHeight);
154 | secondPath.lineTo(0, mHeight);
155 | secondPath.close();
156 | return secondPath;
157 | }
158 |
159 | @Override
160 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
161 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
162 |
163 | /**
164 | * 设置宽度
165 | * 单位 px
166 | */
167 | int specMode = MeasureSpec.getMode(widthMeasureSpec);
168 | int specSize = MeasureSpec.getSize(widthMeasureSpec);
169 |
170 | if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
171 | {
172 | mWidth = specSize;
173 | } else {
174 | mWidth = dip2px(getContext(), 150);
175 | }
176 |
177 | /***
178 | * 设置高度
179 | */
180 | specMode = MeasureSpec.getMode(heightMeasureSpec);
181 | specSize = MeasureSpec.getSize(heightMeasureSpec);
182 | if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
183 | {
184 | mHeight = specSize;
185 | } else {
186 | mHeight = dip2px(getContext(), 150);
187 | }
188 | centerX = mWidth / 2;
189 | centerY = mHeight / 2;
190 |
191 | setMeasuredDimension(mWidth, mHeight);
192 | }
193 |
194 | public int dip2px(Context context, float dpValue) {
195 | final float scale = context.getResources().getDisplayMetrics().density;
196 | return (int) (dpValue * scale + 0.5f);
197 | }
198 |
199 | public void reset() {
200 | if (runThread != null) {
201 | runThread = null;
202 | }
203 | isStart = false;
204 | isStop = false;
205 | isKeepHeight = false;
206 | h = mHeight;
207 | sin_offset = 0;
208 | invalidate();
209 | }
210 |
211 | private RunThread runThread;
212 |
213 | public void start() {
214 | if (!isStart) {
215 | isStart = true;
216 | runThread = new RunThread();
217 | runThread.start();
218 | }
219 | }
220 |
221 | public void stop() {
222 | isStop = true;
223 | isKeepHeight = false;
224 | }
225 |
226 | public void recover() {
227 | isStop = false;
228 | }
229 |
230 | public void keepHeight() {
231 | isStop = true;
232 | isKeepHeight = true;
233 | }
234 |
235 |
236 | private class RunThread extends Thread {
237 |
238 | @Override
239 | public void run() {
240 | while (isStart) {
241 |
242 | if (isStop) {
243 | if (isKeepHeight) {
244 | try {
245 |
246 |
247 | Thread.sleep(sleep_time);
248 | sin_offset += sin_offset_increment_value;
249 | postInvalidate();
250 | } catch (InterruptedException e) {
251 | e.printStackTrace();
252 | }
253 | }
254 | continue;
255 | }
256 | try {
257 | Thread.sleep(sleep_time);
258 | h -= sin_up_velocity;
259 | sin_offset += sin_offset_increment_value;
260 | postInvalidate();
261 | if (h + sin_amplitude < 0) {
262 | if (listener != null) {
263 | WaterView.this.post(new Runnable() {
264 | @Override
265 | public void run() {
266 | listener.finish();
267 | }
268 | });
269 | }
270 | return;
271 | }
272 | } catch (InterruptedException e) {
273 | e.printStackTrace();
274 | }
275 | }
276 | }
277 | }
278 |
279 | Listener listener;
280 |
281 | public interface Listener {
282 | void finish();
283 | }
284 |
285 | public void setListener(Listener listener) {
286 | this.listener = listener;
287 | }
288 | }
289 |
290 |
--------------------------------------------------------------------------------