├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── runConfigurations.xml ├── modules.xml ├── compiler.xml ├── gradle.xml ├── misc.xml └── codeStyles │ └── Project.xml ├── 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 │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── allenliu │ │ │ └── sidebardemo │ │ │ └── SideBarDemoActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── allenliu │ │ │ └── sidebar │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── allenliu │ │ └── sidebar │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── sidebar ├── consumer-rules.pro ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── attrs.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── allenliu │ │ │ └── sidebar │ │ │ ├── ISideBarSelectCallBack.java │ │ │ └── SideBar.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── allenliu │ │ │ └── sidebar │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── allenliu │ │ └── sidebar │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── ui ├── ui1.gif └── ui2.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | SideBar -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sidebar/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sidebar/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':sidebar' 2 | -------------------------------------------------------------------------------- /ui/ui1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/ui/ui1.gif -------------------------------------------------------------------------------- /ui/ui2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/ui/ui2.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SideBar 3 | 4 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /sidebar/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | sidebar 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sidebar/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexLiuSheng/AnimSideBar/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /sidebar/src/main/java/com/allenliu/sidebar/ISideBarSelectCallBack.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebar; 2 | 3 | /** 4 | * Created by Allen Liu on 2016/5/13. 5 | */ 6 | public interface ISideBarSelectCallBack { 7 | void onSelectStr(int index,String selectStr); 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 16 16:33:23 CST 2019 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-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/allenliu/sidebar/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebar; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /sidebar/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/allenliu/sidebar/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebar; 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 | } -------------------------------------------------------------------------------- /sidebar/src/test/java/com/allenliu/sidebar/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebar; 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() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /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:\Eclipse\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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /sidebar/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /sidebar/src/androidTest/java/com/allenliu/sidebar/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebar; 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 | * Instrumented 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() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | 24 | assertEquals("com.allenliu.sidebar.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/allenliu/sidebardemo/SideBarDemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebardemo; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.allenliu.sidebar.ISideBarSelectCallBack; 7 | import com.allenliu.sidebar.SideBar; 8 | 9 | 10 | public class SideBarDemoActivity extends AppCompatActivity { 11 | private SideBar bar; 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | bar= (SideBar) findViewById(R.id.bar); 17 | bar.setOnStrSelectCallBack(new ISideBarSelectCallBack() { 18 | @Override 19 | public void onSelectStr(int index, String selectStr) { 20 | // Toast.makeText(SideBarDemoActivity.this,selectStr,Toast.LENGTH_SHORT).show(); 21 | } 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | applicationId "com.allenliu.sidebardemo" 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | debug { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | testImplementation 'junit:junit:4.12' 28 | implementation 'com.android.support:appcompat-v7:28.0.0' 29 | implementation project(path: ':sidebar') 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidebar/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group='com.github.alexliusheng' 4 | android { 5 | compileSdkVersion 28 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles 'consumer-rules.pro' 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | debug { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(dir: 'libs', include: ['*.jar']) 32 | 33 | implementation 'com.android.support:appcompat-v7:28.0.0' 34 | testImplementation 'junit:junit:4.12' 35 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnimSideBar 2 | A SiderBar base on Android that has a wave anim 3 | # update in 19/12/16 4 | implementation this widget in a new way. 5 | ## effect 6 | 7 | 8 | ## use 9 | ### include: 10 | ``` 11 | dependencies { 12 | implementation 'com.github.AlexLiuSheng:AnimSideBar:1.0.0' 13 | } 14 | ``` 15 | alternatively,you can include it just copy the code into your project. 16 | 17 | ### use 18 | to use,you should write like this in your layout 19 | ``` 20 | 28 | ``` 29 | 30 | after this ,you can add a setOnStrSelectCallBack,like this 31 | 32 | bar.setOnStrSelectCallBack(new ISideBarSelectCallBack() { 33 | @Override 34 | public void onSelectStr(int index, String selectStr) { 35 | Toast.makeText(SideBarDemoActivity.this,selectStr,Toast.LENGTH_SHORT).show(); 36 | } 37 | }); 38 | 39 | 40 | there are some other methods to apply: 41 | 42 | ``` 43 | //text Font scale when scrolling ,defalut :1 44 | // the big text size ,default is 3 times than text size 45 | //the parabola opening size ,defalut 13, 46 | // the size of amplitude,defalut is 100dp 47 | // the distance between BigText and peak,defalut is 50dp 48 | ``` 49 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 |
116 |
-------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 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 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /sidebar/src/main/java/com/allenliu/sidebar/SideBar.java: -------------------------------------------------------------------------------- 1 | package com.allenliu.sidebar; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.util.AttributeSet; 8 | import android.view.MotionEvent; 9 | 10 | /** 11 | * Created by Allen Liu on 2019/12/12. 12 | */ 13 | public class SideBar extends android.support.v7.widget.AppCompatTextView { 14 | private String[] letters = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", 15 | "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", 16 | "W", "X", "Y", "Z", "#"}; 17 | private Paint textPaint; 18 | private Paint bigTextPaint; 19 | 20 | private ISideBarSelectCallBack callBack; 21 | private float eventY; 22 | private float w; 23 | private float sideTextWidth; 24 | /** 25 | * 是否重新测量宽高 26 | */ 27 | private boolean isTouching = false; 28 | private float itemH; 29 | 30 | /** 31 | * 振幅 32 | */ 33 | private float A = dp(100); 34 | /** 35 | * 波峰与bigText之间的距离 36 | */ 37 | private int gapBetweenText = dp(50); 38 | 39 | /** 40 | * 开口数量 41 | */ 42 | private int openCount = 13; 43 | /** 44 | * 字体缩放,基于textSize 45 | */ 46 | private float fontScale = 1; 47 | private float bigTextSize; 48 | 49 | public SideBar(Context context) { 50 | super(context); 51 | init(null); 52 | } 53 | 54 | public SideBar(Context context, AttributeSet attrs) { 55 | super(context, attrs); 56 | init(attrs); 57 | } 58 | 59 | public SideBar(Context context, AttributeSet attrs, int defStyleAttr) { 60 | super(context, attrs, defStyleAttr); 61 | init(attrs); 62 | } 63 | 64 | /** 65 | * set MaxFontScale 66 | * 67 | * @param fontScale 68 | * @return 69 | */ 70 | public SideBar setFontScale(float fontScale) { 71 | this.fontScale = fontScale; 72 | return this; 73 | } 74 | 75 | public void setDataResource(String[] data) { 76 | letters = data; 77 | invalidate(); 78 | } 79 | 80 | public void setOnStrSelectCallBack(ISideBarSelectCallBack callBack) { 81 | this.callBack = callBack; 82 | } 83 | 84 | public SideBar setBigTextSize(float bigTextSize) { 85 | this.bigTextSize = bigTextSize; 86 | bigTextPaint.setTextSize(bigTextSize); 87 | // invalidate(); 88 | return this; 89 | } 90 | 91 | public SideBar setA(float a) { 92 | A = a; 93 | // invalidate(); 94 | return this; 95 | } 96 | 97 | public SideBar setGapBetweenText(int gapBetweenText) { 98 | this.gapBetweenText = gapBetweenText; 99 | // invalidate(); 100 | return this; 101 | } 102 | 103 | public SideBar setOpenCount(int openCount) { 104 | this.openCount = openCount; 105 | // invalidate(); 106 | return this; 107 | } 108 | 109 | private void caculateAW(int height) { 110 | itemH = height * 1.0f / letters.length; 111 | /** 112 | * 开口宽度 113 | */ 114 | float opendWidth = itemH * openCount; 115 | //角速度 2PI/t 周期 116 | w = (float) (Math.PI * 2.0f / (opendWidth * 2)); 117 | } 118 | 119 | 120 | @Override 121 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 122 | int mode = MeasureSpec.getMode(widthMeasureSpec); 123 | int viewWidth = MeasureSpec.getSize(widthMeasureSpec); 124 | caculateAW(MeasureSpec.getSize(heightMeasureSpec)); 125 | if (mode == MeasureSpec.UNSPECIFIED || mode == MeasureSpec.AT_MOST) { 126 | viewWidth = !isTouching ? (int) (sideTextWidth + getPaddingLeft() + getPaddingRight()) : (int) (A + gapBetweenText + getBigTextWidth() + getPaddingLeft() + getPaddingRight()); 127 | } 128 | // CLog.e("width:" + viewWidth + "height:" + MeasureSpec.getSize(heightMeasureSpec)); 129 | setMeasuredDimension(viewWidth, MeasureSpec.getSize(heightMeasureSpec)); 130 | } 131 | 132 | private void init(AttributeSet attrs) { 133 | // setPadding(dp(10), 0, dp(10), 0); 134 | if (attrs != null) { 135 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SideBar); 136 | A = typedArray.getInteger(R.styleable.SideBar_A, dp(100)); 137 | fontScale = typedArray.getFloat(R.styleable.SideBar_fontScale, 1); 138 | bigTextSize = typedArray.getFloat(R.styleable.SideBar_bigTextSize, getTextSize() * 3); 139 | gapBetweenText = typedArray.getInteger(R.styleable.SideBar_gapBetweenText, dp(50)); 140 | openCount = typedArray.getInteger(R.styleable.SideBar_openCount, 13); 141 | } else { 142 | bigTextSize = getTextSize() * 3; 143 | } 144 | textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 145 | textPaint.setColor(getCurrentTextColor()); 146 | textPaint.setTextSize(getTextSize()); 147 | textPaint.setTextAlign(Paint.Align.CENTER); 148 | 149 | bigTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 150 | bigTextPaint.setColor(getCurrentTextColor()); 151 | bigTextPaint.setTextSize(bigTextSize); 152 | bigTextPaint.setTextAlign(Paint.Align.CENTER); 153 | 154 | 155 | float sideTextHeight = textPaint.getFontMetrics().descent - textPaint.getFontMetrics().ascent; 156 | sideTextWidth = textPaint.measureText("W"); 157 | } 158 | 159 | 160 | private int dp(int v) { 161 | final float scale = getContext().getResources().getDisplayMetrics().density; 162 | return (int) (v * scale + 0.5f); 163 | } 164 | 165 | 166 | @Override 167 | public boolean onTouchEvent(MotionEvent event) { 168 | int startTouchX = (int) (getMeasuredWidth() - A); 169 | switch (event.getAction()) { 170 | case MotionEvent.ACTION_DOWN: 171 | case MotionEvent.ACTION_MOVE: 172 | if (event.getX() > startTouchX) { 173 | eventY = event.getY(); 174 | if (!isTouching) { 175 | isTouching = true; 176 | requestLayout(); 177 | } else { 178 | invalidate(); 179 | } 180 | 181 | } else { 182 | if (isTouching) { 183 | resetDefault(); 184 | } 185 | } 186 | return true; 187 | case MotionEvent.ACTION_CANCEL: 188 | case MotionEvent.ACTION_UP: 189 | resetDefault(); 190 | return true; 191 | 192 | } 193 | return super.onTouchEvent(event); 194 | } 195 | 196 | private void resetDefault() { 197 | isTouching = false; 198 | eventY = 0; 199 | requestLayout(); 200 | } 201 | 202 | 203 | @Override 204 | protected void onDraw(Canvas canvas) { 205 | int singleSideCount = openCount / 2; 206 | int index = isTouching && eventY >= 0 && eventY <= getMeasuredHeight() ? (int) Math.floor((eventY / itemH)) : -(singleSideCount + 1); 207 | // index=Math.min(letters.length,index); 208 | // CLog.e("index:" + index + "eventY:" + eventY); 209 | float sideX = sideTextWidth / 2 + getPaddingRight(); 210 | for (int i = 0; i < letters.length; i++) { 211 | //rest textsize 212 | textPaint.setTextSize(getTextSize()); 213 | int y = (int) (itemH * (i + 1)); 214 | int x; 215 | if (Math.abs(i - index) > singleSideCount) { 216 | x = (int) (getMeasuredWidth() - sideX); 217 | } else { 218 | float percent = eventY / itemH; 219 | int t = (int) (i * itemH - eventY); 220 | double v = A * Math.sin(w * t + Math.PI / 2); 221 | 222 | // //如果算出来小于字体宽度 就取字体宽度 223 | v = Math.max(v, sideX); 224 | x = (int) (getMeasuredWidth() - v); 225 | //根据delta缩放字体 226 | if (v == sideX) { 227 | textPaint.setTextSize(getTextSize()); 228 | } else { 229 | float delta = (Math.abs((i - percent)) / singleSideCount); 230 | float textSize = getTextSize() + (1 - delta) * getTextSize() * fontScale; 231 | // textSize=Math.max(textSize,getTextSize()); 232 | textPaint.setTextSize(textSize); 233 | } 234 | 235 | } 236 | canvas.drawText(letters[i], x, y, textPaint); 237 | 238 | } 239 | if (index != -(singleSideCount + 1)) { 240 | canvas.drawText(letters[index], getPaddingLeft() + getBigTextWidth() / 2, (int) (itemH * (index + 1)), bigTextPaint); 241 | if (callBack != null) { 242 | callBack.onSelectStr(index, letters[index]); 243 | 244 | } 245 | } 246 | 247 | } 248 | 249 | private float getBigTextWidth() { 250 | return bigTextPaint.measureText("W"); 251 | } 252 | } --------------------------------------------------------------------------------