diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..58e06d4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,59 @@
+
+### Android template
+# Built application files
+*.apk
+*.ap_
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+androidTest/
+test/
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/dictionaries
+.idea/libraries
+
+# Keystore files
+*.jks
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..4fb78b8
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,33 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+ defaultConfig {
+ applicationId "jaygoo.wavelineview"
+ minSdkVersion 16
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ testCompile 'junit:junit:4.12'
+ compile project(path: ':library')
+ compile 'com.github.Jay-Goo:AndroidMP3Recorder:v1.0.7'
+ //内存泄漏检测
+ debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
+ releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
+ testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..7e3f83c
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/mac/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..f9d1c81
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/jaygoo/wavelineview/App.java b/app/src/main/java/jaygoo/wavelineview/App.java
new file mode 100644
index 0000000..80fb9dc
--- /dev/null
+++ b/app/src/main/java/jaygoo/wavelineview/App.java
@@ -0,0 +1,25 @@
+package jaygoo.wavelineview;
+
+import android.app.Application;
+
+import com.squareup.leakcanary.LeakCanary;
+
+
+/**
+ * ================================================
+ * 作 者:JayGoo
+ * 版 本:
+ * 创建日期:2017/7/28
+ * 描 述:
+ * ================================================
+ */
+public class App extends Application {
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ if (LeakCanary.isInAnalyzerProcess(this)) {
+ return;
+ }
+ LeakCanary.install(this);
+ }
+}
diff --git a/app/src/main/java/jaygoo/wavelineview/MainActivity.java b/app/src/main/java/jaygoo/wavelineview/MainActivity.java
new file mode 100644
index 0000000..9231e2b
--- /dev/null
+++ b/app/src/main/java/jaygoo/wavelineview/MainActivity.java
@@ -0,0 +1,60 @@
+package jaygoo.wavelineview;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+
+import jaygoo.widget.wlv.WaveLineView;
+
+public class MainActivity extends AppCompatActivity {
+
+ private WaveLineView waveLineView;
+ private WaveMp3Recorder waveMp3Recorder;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+// waveLineView = (WaveLineView) findViewById(R.id.waveLineView);
+ waveMp3Recorder = (WaveMp3Recorder) findViewById(R.id.waveLineView);
+ findViewById(R.id.startBtn).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (!waveMp3Recorder.isRecording()){
+ waveMp3Recorder.startRecord();
+ }
+ }
+ });
+
+ findViewById(R.id.stopBtn).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (waveMp3Recorder.isRecording()){
+ waveMp3Recorder.stopRecord(true);
+ }
+ }
+ });
+ }
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+// waveLineView.onResume(true);
+ waveMp3Recorder.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+// waveLineView.onPause();
+ waveMp3Recorder.onPause();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+// waveLineView.release();
+// waveMp3Recorder.release();
+ }
+}
diff --git a/app/src/main/java/jaygoo/wavelineview/WaveMp3Recorder.java b/app/src/main/java/jaygoo/wavelineview/WaveMp3Recorder.java
new file mode 100644
index 0000000..637e4b9
--- /dev/null
+++ b/app/src/main/java/jaygoo/wavelineview/WaveMp3Recorder.java
@@ -0,0 +1,176 @@
+package jaygoo.wavelineview;
+
+import android.content.Context;
+import android.os.Environment;
+import android.os.Handler;
+import android.util.AttributeSet;
+import android.util.Log;
+
+import com.czt.mp3recorder.MP3Recorder;
+
+import java.io.File;
+
+import jaygoo.widget.wlv.WaveLineView;
+
+/**
+ * ================================================
+ * 作 者:JayGoo
+ * 版 本:
+ * 创建日期:2017/7/18
+ * 描 述:
+ * ================================================
+ */
+public class WaveMp3Recorder extends WaveLineView {
+ private String RECORD_FILE_DIR = Environment.getExternalStorageDirectory()+"/";
+ private String recordFileName = "WaveLineViewTest.mp3";
+ private MP3Recorder mp3Recorder;
+ private long maxRecordTime = 1000 * 60 * 60 * 24;
+ private long recordTime = 0;
+ private int UPDATE_TIME = 200;
+ private OnRecordStateChangeListener mOnRecordStateChangeListener;
+ private Handler mHandler = new Handler();
+
+ public WaveMp3Recorder(Context context) {
+ this(context,null);
+ }
+
+ public WaveMp3Recorder(Context context, AttributeSet attrs) {
+ this(context, attrs,0);
+ }
+
+ public WaveMp3Recorder(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ initRecorder();
+ }
+
+ private void updateRecordingUI(){
+ if (mp3Recorder != null) {
+ setVolume(100 * mp3Recorder.getVolume() / mp3Recorder.getMaxVolume());
+ }
+ }
+
+ private void updateStopRecordUI(){
+ stopAnim();
+ }
+
+ private void updateStartRecordUI(){
+ startAnim();
+ }
+
+ /**
+ * 录音更新进度条
+ */
+ private Runnable mRecordProgressTask = new Runnable() {
+ public void run() {
+
+ //录音时间超出最大时间,自动停止
+ if (recordTime > maxRecordTime){
+ stopRecord(true);
+ }else {
+ updateRecordingUI();
+ if (mHandler != null) {
+ mHandler.postDelayed(mRecordProgressTask, UPDATE_TIME);
+ }
+ }
+ }
+ };
+
+ public void initRecorder(){
+ File recordFile = new File(RECORD_FILE_DIR, recordFileName);
+ mp3Recorder = new MP3Recorder(recordFile);
+ mp3Recorder.setDefaultLameMp3BitRate(96);
+ }
+
+ public void startRecording(){
+ try {
+ mp3Recorder.start();
+ if (mHandler != null) {
+ mHandler.post(mRecordProgressTask);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ //停止录音按钮状态
+ public void stopRecord(boolean isFromUser){
+ if (mHandler != null) {
+ mHandler.removeCallbacksAndMessages(null);
+ }
+ try {
+ recordTime = 0;
+ updateStopRecordUI();
+ if (mp3Recorder != null) {
+ mp3Recorder.stop();
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+
+
+ if (mOnRecordStateChangeListener != null){
+ mOnRecordStateChangeListener.onStopRecord(getRecordFile(),isFromUser);
+ }
+ }
+
+ public void stopRecord(){
+ stopRecord(false);
+ }
+
+ //开始录音
+ public void startRecord(){
+ updateStartRecordUI();
+ try {
+ mp3Recorder.start();
+ if (mHandler != null) {
+ mHandler.post(mRecordProgressTask);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (mOnRecordStateChangeListener != null){
+ mOnRecordStateChangeListener.onStartRecord();
+ }
+ }
+
+ //是否在录音
+ public boolean isRecording(){
+ if (mp3Recorder != null){
+ return mp3Recorder.isRecording();
+ }
+ return false;
+ }
+
+ //设置录音的最大时间
+ public void setMaxRecordTime(long millis){
+ maxRecordTime = millis;
+ }
+
+ //获取录音文件
+ public File getRecordFile(){
+ return new File(RECORD_FILE_DIR, recordFileName);
+ }
+
+ public String getRecordFilePath(){
+ return RECORD_FILE_DIR + "/"+recordFileName;
+ }
+
+ public MP3Recorder getMp3Recorder(){
+ return mp3Recorder;
+ }
+
+
+ //录音状态监听
+ public interface OnRecordStateChangeListener{
+ void onStartRecord();
+ void onStopRecord(File recordFile, boolean isFromUser);
+ }
+
+ public void setOnRecordStateChangeListener(OnRecordStateChangeListener listener){
+ mOnRecordStateChangeListener = listener;
+ }
+
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..4c19277
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..9a078e3
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..efc028a
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..3af2608
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..9bec2e6
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..34947cd
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..1942e62
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ WaveLineView
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..5885930
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..1be9f26
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,24 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.3.3'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ maven { url 'https://jitpack.io' }
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..aac7c9b
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..2b0d318
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Jul 21 11:25:55 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 0000000..04222cc
--- /dev/null
+++ b/library/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+
+ defaultConfig {
+ minSdkVersion 16
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ testCompile 'junit:junit:4.12'
+}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
new file mode 100644
index 0000000..7e3f83c
--- /dev/null
+++ b/library/proguard-rules.pro
@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/mac/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..f32cced
--- /dev/null
+++ b/library/src/main/AndroidManifest.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/library/src/main/java/jaygoo/widget/wlv/RenderView.java b/library/src/main/java/jaygoo/widget/wlv/RenderView.java
new file mode 100755
index 0000000..24de4f9
--- /dev/null
+++ b/library/src/main/java/jaygoo/widget/wlv/RenderView.java
@@ -0,0 +1,221 @@
+package jaygoo.widget.wlv;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+
+import java.util.List;
+
+public abstract class RenderView extends SurfaceView implements SurfaceHolder.Callback {
+
+ private boolean isAutoStartAnim = false;
+
+ public RenderView(Context context) {
+ this(context, null);
+ }
+
+ public RenderView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public RenderView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ getHolder().addCallback(this);
+ }
+
+ /*回调/线程*/
+
+ private class RenderThread extends Thread {
+
+ private static final long SLEEP_TIME = 16;
+
+ private SurfaceHolder surfaceHolder;
+ private boolean running = false;
+ private boolean destoryed = false;
+ private boolean isPause = false;
+ public RenderThread(SurfaceHolder holder) {
+ super("RenderThread");
+ surfaceHolder = holder;
+ }
+
+ @Override
+ public void run() {
+ long startAt = System.currentTimeMillis();
+ while (true) {
+ synchronized (surfaceLock) {
+
+ if (destoryed){
+ return;
+ }
+
+ //这里并没有真正的结束Thread,防止部分手机连续调用同一Thread出错
+ while (isPause){
+ try {
+ surfaceLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (running) {
+ Canvas canvas = surfaceHolder.lockCanvas();
+ if (canvas != null) {
+ render(canvas, System.currentTimeMillis() - startAt); //这里做真正绘制的事情
+ surfaceHolder.unlockCanvasAndPost(canvas);
+ }
+ }
+ try {
+ Thread.sleep(SLEEP_TIME);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void setRun(boolean isRun) {
+ this.running = isRun;
+ }
+
+ }
+
+ private final Object surfaceLock = new Object();
+ private RenderThread renderThread;
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ renderer = onCreateRenderer();
+ if (renderer != null && renderer.isEmpty()) {
+ throw new IllegalStateException();
+ }
+
+ renderThread = new RenderThread(holder);
+ }
+
+ /**
+ * 解锁暂停,继续执行绘制任务
+ * 默认当Resume时不自动启动动画
+ */
+ public void onResume(){
+ synchronized (surfaceLock){
+ if (renderThread != null) {
+ renderThread.isPause = false;
+ surfaceLock.notifyAll();
+ }
+ }
+ }
+
+
+ /**
+ * 解锁暂停,继续执行绘制任务
+ * @param isAutoStartAnim 是否当Resume时自动启动动画
+ */
+ public void onResume(boolean isAutoStartAnim){
+ synchronized (surfaceLock){
+ this.isAutoStartAnim = isAutoStartAnim;
+ if (renderThread != null) {
+ renderThread.isPause = false;
+ surfaceLock.notifyAll();
+ }
+ }
+ }
+
+ //假暂停,并没有结束Thread
+ public void onPause(){
+ synchronized (surfaceLock){
+ if (renderThread != null) {
+ renderThread.isPause = true;
+ }
+ }
+ }
+
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ //这里可以获取SurfaceView的宽高等信息
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ synchronized (surfaceLock) { //这里需要加锁,否则doDraw中有可能会crash
+ renderThread.setRun(false);
+ renderThread.destoryed = true;
+ }
+ }
+
+ public void onWindowFocusChanged(boolean hasFocus) {
+ if (hasFocus && isAutoStartAnim){
+ startAnim();
+ }
+ }
+ /*绘图*/
+
+ public interface IRenderer {
+ void onRender(Canvas canvas, long millisPassed);
+ }
+
+ private List renderer;
+
+ protected List onCreateRenderer() {
+ return null;
+ }
+
+ private void render(Canvas canvas, long millisPassed) {
+ if (renderer != null) {
+ for (int i = 0, size = renderer.size(); i < size; i++) {
+ renderer.get(i).onRender(canvas, millisPassed);
+ }
+ } else {
+ onRender(canvas, millisPassed);
+ }
+ }
+
+ /**
+ * 渲染surfaceView的回调方法。
+ *
+ * @param canvas 画布
+ */
+ protected void onRender(Canvas canvas, long millisPassed) {
+ }
+
+ public void startAnim(){
+
+ if (renderThread != null && !renderThread.running) {
+ renderThread.setRun(true);
+ try {
+ if (renderThread.getState() == Thread.State.NEW) {
+ renderThread.start();
+ }
+
+ }catch (RuntimeException e){
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public void stopAnim(){
+ if (renderThread != null && renderThread.running) {
+ renderThread.setRun(false);
+ renderThread.interrupt();
+ }
+ }
+
+ public boolean isRunning(){
+ if (renderThread != null) {
+ return renderThread.running;
+ }
+ return false;
+ }
+
+ //释放相关资源,防止内存泄漏
+ public void release(){
+ if (getHolder() != null && getHolder().getSurface() != null) {
+ getHolder().getSurface().release();
+ getHolder().removeCallback(this);
+ }
+ }
+}
diff --git a/library/src/main/java/jaygoo/widget/wlv/WaveLineView.java b/library/src/main/java/jaygoo/widget/wlv/WaveLineView.java
new file mode 100644
index 0000000..9537044
--- /dev/null
+++ b/library/src/main/java/jaygoo/widget/wlv/WaveLineView.java
@@ -0,0 +1,393 @@
+package jaygoo.widget.wlv;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.util.AttributeSet;
+import android.util.SparseArray;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ================================================
+ * 作 者:JayGoo
+ * 版 本:
+ * 创建日期:2017/7/21
+ * 描 述:
+ * ================================================
+ */
+public class WaveLineView extends RenderView {
+
+ private final int DEFAULT_SAMPLING_SIZE = 64;
+ private final float DEFAULT_OFFSET_SPEED = 250F;
+ private final int DEFAULT_SENSIBILITY = 5;
+
+ //采样点的数量,越高越精细,但是高于一定限度肉眼很难分辨,越高绘制效率越低
+ private int samplingSize;
+
+ //控制向右偏移速度,越小偏移速度越快
+ private float offsetSpeed;
+ //平滑改变的音量值
+ private float volume = 0;
+
+ //用户设置的音量,[0,100]
+ private int targetVolume = 50;
+
+ //每次平滑改变的音量单元
+ private float perVolume;
+
+ //灵敏度,越大越灵敏[1,10]
+ private int sensibility;
+
+ //背景色
+ private int backGroundColor = Color.WHITE;
+
+ //波浪线颜色
+ private int lineColor;
+ //粗线宽度
+ private int thickLineWidth;
+ //细线宽度
+ private int fineLineWidth;
+
+ private final Paint paint = new Paint();
+
+ {
+ //防抖动
+ paint.setDither(true);
+ //抗锯齿,降低分辨率,提高绘制效率
+ paint.setAntiAlias(true);
+ }
+
+ private List paths = new ArrayList<>();
+ {
+ for (int i = 0; i < 4; i++) {
+ paths.add(new Path());
+ }
+ }
+
+ //不同函数曲线系数
+ private float[] pathFuncs = {
+ 0.6f, 0.35f, 0.1f, -0.1f
+ };
+
+ //采样点X坐标
+ private float[] samplingX;
+ //采样点位置映射到[-2,2]之间
+ private float[] mapX;
+ //画布宽高
+ private int width,height;
+ //画布中心的高度
+ private int centerHeight;
+ //振幅
+ private float amplitude;
+ //存储衰变系数
+ private SparseArray recessionFuncs = new SparseArray<>();
+ //连线动画结束标记
+ private boolean isPrepareLineAnimEnd = false;
+ //连线动画位移
+ private int lineAnimX = 0;
+ //渐入动画结束标记
+ private boolean isPrepareAlphaAnimEnd = false;
+ //渐入动画百分比值[0,1f]
+ private float prepareAlpha = 0f;
+ //是否开启准备动画
+ private boolean isOpenPrepareAnim = false;
+
+ public WaveLineView(Context context) {
+ this(context, null);
+ }
+
+ public WaveLineView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public WaveLineView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ initAttr(attrs);
+ }
+
+ private void initAttr(AttributeSet attrs) {
+ TypedArray t = getContext().obtainStyledAttributes(attrs,R.styleable.WaveLineView);
+ backGroundColor = t.getColor(R.styleable.WaveLineView_backgroundColor, Color.WHITE);
+ samplingSize = t.getInt(R.styleable.WaveLineView_samplingSize, DEFAULT_SAMPLING_SIZE);
+ lineColor = t.getColor(R.styleable.WaveLineView_lineColor, Color.parseColor("#2ED184"));
+ thickLineWidth = (int)t.getDimension(R.styleable.WaveLineView_thickLineWidth, 6);
+ fineLineWidth = (int)t.getDimension(R.styleable.WaveLineView_fineLineWidth, 2);
+ offsetSpeed = t.getFloat(R.styleable.WaveLineView_moveSpeed, DEFAULT_OFFSET_SPEED);
+ sensibility = t.getInt(R.styleable.WaveLineView_sensibility, DEFAULT_SENSIBILITY);
+ t.recycle();
+ checkVolumeValue();
+ checkSensibilityValue();
+ }
+
+ @Override
+ protected void onRender(Canvas canvas, long millisPassed) {
+ super.onRender(canvas, millisPassed);
+ float offset = millisPassed / offsetSpeed;
+
+ if (null == samplingX){
+ initDraw(canvas);
+ }
+
+ //绘制背景
+ canvas.drawColor(backGroundColor);
+ if (lineAnim(canvas)) {
+ resetPaths();
+ softerChangeVolume();
+
+ //波形函数的值
+ float curY;
+ for (int i = 0; i <= samplingSize; i++) {
+ float x = samplingX[i];
+ curY = (float) (amplitude * calcValue(mapX[i], offset));
+ for (int n = 0; n < paths.size(); n++) {
+ //四条线分别乘以不同的函数系数
+ float realY = curY * pathFuncs[n] * volume * 0.01f;
+ paths.get(n).lineTo(x, centerHeight + realY);
+ }
+ }
+
+ //连线至终点
+ for (int i = 0; i < paths.size(); i++) {
+ paths.get(i).moveTo(width, centerHeight);
+ }
+
+ //绘制曲线
+ for (int n = 0; n < paths.size(); n++) {
+
+ if (n == 0) {
+ paint.setStrokeWidth(thickLineWidth);
+ paint.setAlpha((int)(255 * alphaInAnim()));
+ } else {
+ paint.setStrokeWidth(fineLineWidth);
+ paint.setAlpha((int)(100 * alphaInAnim()));
+ }
+ canvas.drawPath(paths.get(n), paint);
+ }
+
+ }
+
+ }
+
+ //检查音量是否合法
+ private void checkVolumeValue(){
+ if (targetVolume > 100)targetVolume = 100;
+ }
+
+ //检查灵敏度值是否合法
+ private void checkSensibilityValue(){
+ if (sensibility > 10)sensibility = 10;
+ if (sensibility < 1)sensibility = 1;
+ }
+
+ /**
+ * 使曲线振幅有较大改变时动画过渡自然
+ */
+ private void softerChangeVolume(){
+ //这里减去perVolume是为了防止volume频繁在targetVolume上下抖动
+ if (volume < targetVolume - perVolume){
+ volume += perVolume;
+ }else if (volume > targetVolume + perVolume){
+ if (volume < perVolume * 2){
+ volume = perVolume * 2;
+ }else {
+ volume -= perVolume;
+ }
+ }else {
+ volume = targetVolume;
+ }
+
+ }
+
+ /**
+ * 渐入动画
+ * @return progress of animation
+ */
+ private float alphaInAnim() {
+ if (!isOpenPrepareAnim)return 1;
+ if (prepareAlpha < 1f){
+ prepareAlpha += 0.02f;
+ }else {
+ prepareAlpha = 1;
+ }
+ return prepareAlpha;
+ }
+
+ /**
+ * 连线动画
+ * @param canvas
+ * @return whether animation is end
+ */
+ private boolean lineAnim(Canvas canvas) {
+ if (isPrepareLineAnimEnd || !isOpenPrepareAnim)return true;
+ paths.get(0).moveTo(0, centerHeight);
+ paths.get(1).moveTo(width, centerHeight);
+
+ for (int i = 1; i <= samplingSize; i++) {
+ float x = i * lineAnimX / samplingSize;
+ paths.get(0).lineTo(x, centerHeight);
+ paths.get(1).lineTo(width - x, centerHeight);
+
+ }
+
+ paths.get(0).moveTo(width/2, centerHeight);
+ paths.get(1).moveTo(width/2, centerHeight);
+
+ lineAnimX += width / 60;
+ canvas.drawPath(paths.get(0), paint);
+ canvas.drawPath(paths.get(1), paint);
+
+ if (lineAnimX > width / 2){
+ isPrepareLineAnimEnd = true;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 重置path
+ */
+ private void resetPaths(){
+ for (int i = 0; i < paths.size(); i++) {
+ paths.get(i).rewind();
+ paths.get(i).moveTo(0, centerHeight);
+ }
+ }
+
+ //初始化参数
+ private void initParameters(){
+ lineAnimX = 0;
+ prepareAlpha = 0f;
+ isPrepareLineAnimEnd = false;
+ isPrepareAlphaAnimEnd = false;
+ samplingX = null;
+ }
+
+ @Override
+ public void startAnim() {
+ initParameters();
+ super.startAnim();
+ }
+
+ @Override
+ public void stopAnim() {
+ super.stopAnim();
+// clearDraw();
+ }
+
+ //清空画布所有内容
+ public void clearDraw(){
+ Canvas canvas = null;
+ try{
+ canvas = getHolder().lockCanvas(null);
+ canvas.drawColor(backGroundColor);
+ resetPaths();
+ for (int i=0; i< paths.size(); i++){
+ canvas.drawPath(paths.get(i),paint);
+ }
+ }catch(Exception e){
+ }finally{
+ if(canvas != null){
+ getHolder().unlockCanvasAndPost(canvas);
+ }
+ }
+ }
+
+ //初始化绘制参数
+ private void initDraw(Canvas canvas) {
+
+ width = canvas.getWidth();
+ height = canvas.getHeight();
+ centerHeight = height >> 1;
+ //振幅为高度的1/4
+ amplitude = height / 3.0f;
+
+ //适合View的理论最大音量值,和音量不属于同一概念
+ perVolume = sensibility * 0.35f;
+
+ //初始化采样点及映射
+ //这里因为包括起点和终点,所以需要+1
+ samplingX = new float[samplingSize + 1];
+ mapX = new float[samplingSize + 1];
+ //确定采样点之间的间距
+ float gap = width / (float)samplingSize;
+ //采样点的位置
+ float x;
+ for (int i = 0; i <= samplingSize; i++){
+ x = i * gap;
+ samplingX[i] = x;
+ //将采样点映射到[-2,2]
+ mapX[i] = (x / (float)width) * 4 - 2;
+ }
+
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setColor(lineColor);
+ paint.setStrokeWidth(thickLineWidth);
+ }
+
+ /**
+ * 计算波形函数中x对应的y值
+ *
+ * 使用稀疏矩阵进行暂存计算好的衰减系数值,下次使用时直接查找,减少计算量
+ * @param mapX 换算到[-2,2]之间的x值
+ * @param offset 偏移量
+ * @return [-1, 1]
+ */
+ private double calcValue(float mapX, float offset) {
+ int keyX = (int) (mapX * 1000);
+ offset %= 2;
+ double sinFunc = Math.sin(Math.PI * mapX - offset * Math.PI);
+ double recessionFunc;
+ if(recessionFuncs.indexOfKey(keyX) >= 0 ){
+ recessionFunc = recessionFuncs.get(keyX);
+ }else {
+ recessionFunc = Math.pow(4 / (4 + Math.pow(mapX, 4)), 1);
+ recessionFuncs.put(keyX,recessionFunc);
+ }
+ return sinFunc * recessionFunc ;
+ }
+
+ /**
+ * the wave line animation move speed from left to right
+ * you can use negative number to make the animation from right to left
+ * the default value is 290F,the smaller, the faster
+ * @param moveSpeed
+ */
+ public void setMoveSpeed(float moveSpeed) {
+ this.offsetSpeed = moveSpeed;
+ }
+
+
+ /**
+ * User set volume, [0,100]
+ * @param volume
+ */
+ public void setVolume(int volume) {
+ if (Math.abs(targetVolume - volume) > perVolume) {
+ this.targetVolume = volume;
+ checkVolumeValue();
+ }
+ }
+
+ public void setBackGroundColor(int backGroundColor) {
+ this.backGroundColor = backGroundColor;
+ }
+
+ public void setLineColor(int lineColor) {
+ this.lineColor = lineColor;
+ }
+
+ /**
+ * Sensitivity, the bigger the more sensitive [1,10]
+ the default value is 5
+ * @param sensibility
+ */
+ public void setSensibility(int sensibility) {
+ this.sensibility = sensibility;
+ checkSensibilityValue();
+ }
+}
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..00164ba
--- /dev/null
+++ b/library/src/main/res/values/attrs.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
new file mode 100644
index 0000000..6d51856
--- /dev/null
+++ b/library/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Library
+
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..3306997
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app', ':library'