├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── KongLingHuaShi.xml
├── encodings.xml
├── gradle.xml
├── modules.xml
└── runConfigurations.xml
├── Demo.png
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── felix
│ │ └── zhimafen
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── felix
│ │ │ └── zhimafen
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.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
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── felix
│ └── zhimafen
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── felix
│ │ └── library
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── felix
│ │ │ └── library
│ │ │ └── ScoreTrend.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── felix
│ └── library
│ └── ExampleUnitTest.java
└── settings.gradle
/.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/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/KongLingHuaShi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/Demo.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ####支付宝芝麻分曲线图
2 | ####效果图:
3 |
4 | 
5 |
6 |
7 |
8 | ####使用:
9 | ####XML
10 |
11 |
17 |
18 | ####attrs
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | -- 暂时只有这些属性,因为没有上传到jcenter,所需需要拓展或者修改功能直接修改源码吧
28 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "24.0.1"
6 | defaultConfig {
7 | applicationId "com.felix.zhimafen"
8 | minSdkVersion 15
9 | targetSdkVersion 25
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 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.0.0'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':library')
30 | }
31 |
--------------------------------------------------------------------------------
/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 /Users/felix/Library/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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/felix/zhimafen/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.felix.zhimafen;
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 | {
20 | @Test
21 | public void useAppContext() throws Exception
22 | {
23 | // Context of the app under test.
24 | Context appContext = InstrumentationRegistry.getTargetContext();
25 |
26 | assertEquals("com.felix.zhimafen", appContext.getPackageName());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/felix/zhimafen/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.felix.zhimafen;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import com.felix.library.ScoreTrend;
7 |
8 | import java.util.Random;
9 |
10 | public class MainActivity extends AppCompatActivity
11 | {
12 |
13 | ScoreTrend scoreTrend;
14 | int score[] = new int[6];
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState)
18 | {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 | scoreTrend = (ScoreTrend) findViewById(R.id.scoreTrend);
22 |
23 | int max = 700;
24 | int min = 650;
25 |
26 | Random ramdom = new Random();
27 | for(int i = 0; i < 6; i++)
28 | {
29 | score[i] = ramdom.nextInt(max) % (max - min + 1) + min;
30 | }
31 | scoreTrend.setScore(score);
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ZhiMaFen
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/felix/zhimafen/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.felix.zhimafen;
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 | {
14 | @Test
15 | public void addition_isCorrect() throws Exception
16 | {
17 | assertEquals(4, 2 + 2);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FelixLee0527/ZhiMaScoreCurve/7ad78369cb84451e6798ef1418cf0c010b3c105d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:25.0.0'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/felix/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/felix/library/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.felix.library;
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 | {
20 | @Test
21 | public void useAppContext() throws Exception
22 | {
23 | // Context of the app under test.
24 | Context appContext = InstrumentationRegistry.getTargetContext();
25 |
26 | assertEquals("com.felix.library.test", appContext.getPackageName());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/library/src/main/java/com/felix/library/ScoreTrend.java:
--------------------------------------------------------------------------------
1 | package com.felix.library;
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.DashPathEffect;
8 | import android.graphics.Paint;
9 | import android.graphics.Path;
10 | import android.graphics.Point;
11 | import android.graphics.RectF;
12 | import android.util.AttributeSet;
13 | import android.util.Log;
14 | import android.view.MotionEvent;
15 | import android.view.View;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | /**
21 | * Created by felix on 2016/11/10.
22 | * Company :IV-Tech
23 | * Website :www.iv-tech.com
24 | * 芝麻分趋势图
25 | */
26 |
27 | public class ScoreTrend extends View
28 | {
29 | private float viewWith;
30 | private float viewHeight;
31 |
32 | private float brokenLineWith = 0.5f;
33 |
34 | private int brokenLineColor = 0xff02bbb7;
35 | private int straightLineColor = 0xffe2e2e2;//0xffeaeaea
36 | private int textNormalColor = 0xff7e7e7e;
37 |
38 | private int maxScore = 700;
39 | private int minScore = 650;
40 |
41 | private int monthCount = 6;
42 | private int selectMonth = 6;//选中的月份
43 |
44 | private String[] monthText = new String[]{"6月", "7月", "8月", "9月", "10月", "11月"};
45 | private int[] score = new int[]{660, 663, 669, 678, 682, 689};
46 |
47 | private List scorePoints;
48 |
49 | private int textSize = dipToPx(15);
50 |
51 | private Paint brokenPaint;
52 | private Paint straightPaint;
53 | private Paint dottedPaint;
54 | private Paint textPaint;
55 |
56 | private Path brokenPath;
57 |
58 | public ScoreTrend(Context context)
59 | {
60 | super(context);
61 | initConfig(context,null);
62 | init();
63 | }
64 |
65 | public ScoreTrend(Context context, AttributeSet attrs)
66 | {
67 | super(context, attrs);
68 | initConfig(context,attrs);
69 | init();
70 | }
71 |
72 | public ScoreTrend(Context context, AttributeSet attrs, int defStyleAttr)
73 | {
74 | super(context, attrs, defStyleAttr);
75 | initConfig(context,attrs);
76 | init();
77 |
78 | }
79 |
80 | /**
81 | * 初始化布局配置
82 | *
83 | * @param context
84 | * @param attrs
85 | */
86 | private void initConfig(Context context, AttributeSet attrs)
87 | {
88 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScoreTrend);
89 |
90 | maxScore=a.getInt(R.styleable.ScoreTrend_max_score,700);
91 | minScore=a.getInt(R.styleable.ScoreTrend_min_score,650);
92 | brokenLineColor=a.getColor(R.styleable.ScoreTrend_broken_line_color,brokenLineColor);
93 |
94 | a.recycle();
95 |
96 | }
97 |
98 | private void init()
99 | {
100 | brokenPath = new Path();
101 |
102 | brokenPaint = new Paint();
103 | brokenPaint.setAntiAlias(true);
104 | brokenPaint.setStyle(Paint.Style.STROKE);
105 | brokenPaint.setStrokeWidth(dipToPx(brokenLineWith));
106 | brokenPaint.setStrokeCap(Paint.Cap.ROUND);
107 |
108 | straightPaint = new Paint();
109 | straightPaint.setAntiAlias(true);
110 | straightPaint.setStyle(Paint.Style.STROKE);
111 | straightPaint.setStrokeWidth(brokenLineWith);
112 | straightPaint.setColor((straightLineColor));
113 | straightPaint.setStrokeCap(Paint.Cap.ROUND);
114 |
115 | dottedPaint = new Paint();
116 | dottedPaint.setAntiAlias(true);
117 | dottedPaint.setStyle(Paint.Style.STROKE);
118 | dottedPaint.setStrokeWidth(brokenLineWith);
119 | dottedPaint.setColor((straightLineColor));
120 | dottedPaint.setStrokeCap(Paint.Cap.ROUND);
121 |
122 | textPaint = new Paint();
123 | textPaint.setAntiAlias(true);
124 | textPaint.setTextAlign(Paint.Align.CENTER);
125 | textPaint.setStyle(Paint.Style.FILL);
126 | textPaint.setColor((textNormalColor));
127 | textPaint.setTextSize(dipToPx(15));
128 |
129 |
130 | }
131 |
132 | private void initData()
133 | {
134 | scorePoints = new ArrayList<>();
135 | float maxScoreYCoordinate = viewHeight * 0.15f;
136 | float minScoreYCoordinate = viewHeight * 0.4f;
137 |
138 | Log.v("ScoreTrend", "initData: " + maxScoreYCoordinate);
139 |
140 | float newWith = viewWith - (viewWith * 0.15f) * 2;//分隔线距离最左边和最右边的距离是0.15倍的viewWith
141 | int coordinateX;
142 |
143 | for(int i = 0; i < score.length; i++)
144 | {
145 | Log.v("ScoreTrend", "initData: " + score[i]);
146 | Point point = new Point();
147 | coordinateX = (int) (newWith * ((float) (i) / (monthCount - 1)) + (viewWith * 0.15f));
148 | point.x = coordinateX;
149 | if(score[i] > maxScore)
150 | {
151 | score[i] = maxScore;
152 | }
153 | else if(score[i] < minScore)
154 | {
155 | score[i] = minScore;
156 | }
157 | point.y = (int) (((float) (maxScore - score[i]) / (maxScore - minScore)) * (minScoreYCoordinate - maxScoreYCoordinate) + maxScoreYCoordinate);
158 | scorePoints.add(point);
159 | }
160 | }
161 |
162 | @Override
163 | protected void onSizeChanged(int w, int h, int oldw, int oldh)
164 | {
165 | super.onSizeChanged(w, h, oldw, oldh);
166 | viewWith = w;
167 | viewHeight = h;
168 | initData();
169 | }
170 |
171 | @Override
172 | protected void onDraw(Canvas canvas)
173 | {
174 | super.onDraw(canvas);
175 | drawDottedLine(canvas, viewWith * 0.15f, viewHeight * 0.15f, viewWith, viewHeight * 0.15f);
176 | drawDottedLine(canvas, viewWith * 0.15f, viewHeight * 0.4f, viewWith, viewHeight * 0.4f);
177 | drawText(canvas);
178 | drawMonthLine(canvas);
179 | drawBrokenLine(canvas);
180 | drawPoint(canvas);
181 |
182 | }
183 |
184 |
185 | @Override
186 | public boolean onTouchEvent(MotionEvent event)
187 | {
188 | this.getParent().requestDisallowInterceptTouchEvent(true);//一旦底层View收到touch的action后调用这个方法那么父层View就不会再调用onInterceptTouchEvent了,也无法截获以后的action
189 |
190 | switch(event.getAction())
191 | {
192 | case MotionEvent.ACTION_DOWN:
193 | break;
194 | case MotionEvent.ACTION_MOVE:
195 | break;
196 | case MotionEvent.ACTION_UP:
197 | onActionUpEvent(event);
198 | this.getParent().requestDisallowInterceptTouchEvent(false);
199 | break;
200 | case MotionEvent.ACTION_CANCEL:
201 | this.getParent().requestDisallowInterceptTouchEvent(false);
202 | break;
203 | }
204 | return true;
205 | }
206 |
207 | private void onActionUpEvent(MotionEvent event)
208 | {
209 | boolean isValidTouch = validateTouch(event.getX(), event.getY());
210 |
211 | if(isValidTouch)
212 | {
213 | invalidate();
214 | }
215 | }
216 |
217 | //是否是有效的触摸范围
218 | private boolean validateTouch(float x, float y)
219 | {
220 |
221 | //曲线触摸区域
222 | for(int i = 0; i < scorePoints.size(); i++)
223 | {
224 | // dipToPx(8)乘以2为了适当增大触摸面积
225 | if(x > (scorePoints.get(i).x - dipToPx(8) * 2) && x < (scorePoints.get(i).x + dipToPx(8) * 2))
226 | {
227 | if(y > (scorePoints.get(i).y - dipToPx(8) * 2) && y < (scorePoints.get(i).y + dipToPx(8) * 2))
228 | {
229 | selectMonth = i + 1;
230 | return true;
231 | }
232 | }
233 | }
234 |
235 | //月份触摸区域
236 | //计算每个月份X坐标的中心点
237 | float monthTouchY = viewHeight * 0.7f - dipToPx(3);//减去dipToPx(3)增大触摸面积
238 |
239 | float newWith = viewWith - (viewWith * 0.15f) * 2;//分隔线距离最左边和最右边的距离是0.15倍的viewWith
240 | float validTouchX[] = new float[monthText.length];
241 | for(int i = 0; i < monthText.length; i++)
242 | {
243 | validTouchX[i] = newWith * ((float) (i) / (monthCount - 1)) + (viewWith * 0.15f);
244 | }
245 |
246 | if(y > monthTouchY)
247 | {
248 | for(int i = 0; i < validTouchX.length; i++)
249 | {
250 | Log.v("ScoreTrend", "validateTouch: validTouchX:" + validTouchX[i]);
251 | if(x < validTouchX[i] + dipToPx(8) && x > validTouchX[i] - dipToPx(8))
252 | {
253 | Log.v("ScoreTrend", "validateTouch: " + (i + 1));
254 | selectMonth = i + 1;
255 | return true;
256 | }
257 | }
258 | }
259 |
260 | return false;
261 | }
262 |
263 |
264 | //绘制折线穿过的点
265 | protected void drawPoint(Canvas canvas)
266 | {
267 | if(scorePoints == null)
268 | {
269 | return;
270 | }
271 | brokenPaint.setStrokeWidth(dipToPx(1));
272 | for(int i = 0; i < scorePoints.size(); i++)
273 | {
274 | brokenPaint.setColor(brokenLineColor);
275 | brokenPaint.setStyle(Paint.Style.STROKE);
276 | canvas.drawCircle(scorePoints.get(i).x, scorePoints.get(i).y, dipToPx(3), brokenPaint);
277 | brokenPaint.setColor(Color.WHITE);
278 | brokenPaint.setStyle(Paint.Style.FILL);
279 | if(i == selectMonth - 1)
280 | {
281 | brokenPaint.setColor(0xffd0f3f2);
282 | canvas.drawCircle(scorePoints.get(i).x, scorePoints.get(i).y, dipToPx(8f), brokenPaint);
283 | brokenPaint.setColor(0xff81dddb);
284 | canvas.drawCircle(scorePoints.get(i).x, scorePoints.get(i).y, dipToPx(5f), brokenPaint);
285 |
286 | //绘制浮动文本背景框
287 | drawFloatTextBackground(canvas, scorePoints.get(i).x, scorePoints.get(i).y - dipToPx(8f));
288 |
289 | textPaint.setColor(0xffffffff);
290 | //绘制浮动文字
291 | canvas.drawText(String.valueOf(score[i]), scorePoints.get(i).x, scorePoints.get(i).y - dipToPx(5f) - textSize, textPaint);
292 | }
293 | brokenPaint.setColor(0xffffffff);
294 | canvas.drawCircle(scorePoints.get(i).x, scorePoints.get(i).y, dipToPx(1.5f), brokenPaint);
295 | brokenPaint.setStyle(Paint.Style.STROKE);
296 | brokenPaint.setColor(brokenLineColor);
297 | canvas.drawCircle(scorePoints.get(i).x, scorePoints.get(i).y, dipToPx(2.5f), brokenPaint);
298 | }
299 | }
300 |
301 | //绘制月份的直线(包括刻度)
302 | private void drawMonthLine(Canvas canvas)
303 | {
304 | straightPaint.setStrokeWidth(dipToPx(1));
305 | canvas.drawLine(0, viewHeight * 0.7f, viewWith, viewHeight * 0.7f, straightPaint);
306 |
307 | float newWith = viewWith - (viewWith * 0.15f) * 2;//分隔线距离最左边和最右边的距离是0.15倍的viewWith
308 | float coordinateX;//分隔线X坐标
309 | for(int i = 0; i < monthCount; i++)
310 | {
311 | coordinateX = newWith * ((float) (i) / (monthCount - 1)) + (viewWith * 0.15f);
312 | canvas.drawLine(coordinateX, viewHeight * 0.7f, coordinateX, viewHeight * 0.7f + dipToPx(4), straightPaint);
313 | }
314 | }
315 |
316 | //绘制折线
317 | private void drawBrokenLine(Canvas canvas)
318 | {
319 | brokenPath.reset();
320 | brokenPaint.setColor(brokenLineColor);
321 | brokenPaint.setStyle(Paint.Style.STROKE);
322 | if(score.length == 0)
323 | {
324 | return;
325 | }
326 | Log.v("ScoreTrend", "drawBrokenLine: " + scorePoints.get(0));
327 | brokenPath.moveTo(scorePoints.get(0).x, scorePoints.get(0).y);
328 | for(int i = 0; i < scorePoints.size(); i++)
329 | {
330 | brokenPath.lineTo(scorePoints.get(i).x, scorePoints.get(i).y);
331 | }
332 | canvas.drawPath(brokenPath, brokenPaint);
333 |
334 | }
335 |
336 | //绘制文本
337 | private void drawText(Canvas canvas)
338 | {
339 | textPaint.setTextSize(dipToPx(12));
340 | textPaint.setColor(textNormalColor);
341 |
342 | canvas.drawText(String.valueOf(maxScore), viewWith * 0.1f - dipToPx(10), viewHeight * 0.15f + textSize * 0.25f, textPaint);
343 | canvas.drawText(String.valueOf(minScore), viewWith * 0.1f - dipToPx(10), viewHeight * 0.4f + textSize * 0.25f, textPaint);
344 |
345 | textPaint.setColor(0xff7c7c7c);
346 |
347 | float newWith = viewWith - (viewWith * 0.15f) * 2;//分隔线距离最左边和最右边的距离是0.15倍的viewWith
348 | float coordinateX;//分隔线X坐标
349 | textPaint.setTextSize(dipToPx(12));
350 | textPaint.setStyle(Paint.Style.FILL);
351 | textPaint.setColor(textNormalColor);
352 | textSize = (int) textPaint.getTextSize();
353 | for(int i = 0; i < monthText.length; i++)
354 | {
355 | coordinateX = newWith * ((float) (i) / (monthCount - 1)) + (viewWith * 0.15f);
356 |
357 | if(i == selectMonth - 1)
358 | {
359 |
360 | textPaint.setStyle(Paint.Style.STROKE);
361 | textPaint.setColor(brokenLineColor);
362 | RectF r2 = new RectF();
363 | r2.left = coordinateX - textSize - dipToPx(4);
364 | r2.top = viewHeight * 0.7f + dipToPx(4) + textSize / 2;
365 | r2.right = coordinateX + textSize + dipToPx(4);
366 | r2.bottom = viewHeight * 0.7f + dipToPx(4) + textSize + dipToPx(8);
367 | canvas.drawRoundRect(r2, 10, 10, textPaint);
368 |
369 | }
370 | //绘制月份
371 | canvas.drawText(monthText[i], coordinateX, viewHeight * 0.7f + dipToPx(4) + textSize + dipToPx(5), textPaint);
372 |
373 | textPaint.setColor(textNormalColor);
374 |
375 | }
376 |
377 | }
378 |
379 | //绘制显示浮动文字的背景
380 | private void drawFloatTextBackground(Canvas canvas, int x, int y)
381 | {
382 | brokenPath.reset();
383 | brokenPaint.setColor(brokenLineColor);
384 | brokenPaint.setStyle(Paint.Style.FILL);
385 |
386 | //P1
387 | Point point = new Point(x, y);
388 | brokenPath.moveTo(point.x, point.y);
389 |
390 | //P2
391 | point.x = point.x + dipToPx(5);
392 | point.y = point.y - dipToPx(5);
393 | brokenPath.lineTo(point.x, point.y);
394 |
395 | //P3
396 | point.x = point.x + dipToPx(12);
397 | brokenPath.lineTo(point.x, point.y);
398 |
399 | //P4
400 | point.y = point.y - dipToPx(17);
401 | brokenPath.lineTo(point.x, point.y);
402 |
403 | //P5
404 | point.x = point.x - dipToPx(34);
405 | brokenPath.lineTo(point.x, point.y);
406 |
407 | //P6
408 | point.y = point.y + dipToPx(17);
409 | brokenPath.lineTo(point.x, point.y);
410 |
411 | //P7
412 | point.x = point.x + dipToPx(12);
413 | brokenPath.lineTo(point.x, point.y);
414 |
415 | //最后一个点连接到第一个点
416 | brokenPath.lineTo(x, y);
417 |
418 | canvas.drawPath(brokenPath, brokenPaint);
419 | }
420 |
421 | /**
422 | * 画虚线
423 | *
424 | * @param canvas 画布
425 | * @param startX 起始点X坐标
426 | * @param startY 起始点Y坐标
427 | * @param stopX 终点X坐标
428 | * @param stopY 终点Y坐标
429 | */
430 | private void drawDottedLine(Canvas canvas, float startX, float startY, float stopX, float stopY)
431 | {
432 | dottedPaint.setPathEffect(new DashPathEffect(new float[]{20, 10}, 4));
433 | dottedPaint.setStrokeWidth(1);
434 | // 实例化路径
435 | Path mPath = new Path();
436 | mPath.reset();
437 | // 定义路径的起点
438 | mPath.moveTo(startX, startY);
439 | mPath.lineTo(stopX, stopY);
440 | canvas.drawPath(mPath, dottedPaint);
441 |
442 | }
443 |
444 |
445 | public int[] getScore()
446 | {
447 | return score;
448 | }
449 |
450 | public void setScore(int[] score)
451 | {
452 | this.score = score;
453 | initData();
454 | }
455 |
456 | public void setMaxScore(int maxScore)
457 | {
458 | this.maxScore = maxScore;
459 | }
460 |
461 | public void setMinScore(int minScore)
462 | {
463 | this.minScore = minScore;
464 | }
465 |
466 | /**
467 | * dip 转换成px
468 | *
469 | * @param dip
470 | * @return
471 | */
472 | private int dipToPx(float dip)
473 | {
474 | float density = getContext().getResources().getDisplayMetrics().density;
475 | return (int) (dip * density + 0.5f * (dip >= 0 ? 1 : -1));
476 | }
477 |
478 | }
479 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/com/felix/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.felix.library;
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 | {
14 | @Test
15 | public void addition_isCorrect() throws Exception
16 | {
17 | assertEquals(4, 2 + 2);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------