diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..39fb081
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..5d6f65c
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml
new file mode 100644
index 0000000..940cf28
--- /dev/null
+++ b/.idea/markdown-navigator.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown-navigator/profiles_settings.xml b/.idea/markdown-navigator/profiles_settings.xml
new file mode 100644
index 0000000..57927c5
--- /dev/null
+++ b/.idea/markdown-navigator/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..aeca25b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Android
+
+
+ Android > Lint > Correctness
+
+
+ Java
+
+
+ Java language level migration aidsJava
+
+
+
+
+ Android
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..7e78688
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GIF.gif b/GIF.gif
new file mode 100644
index 0000000..1436e35
Binary files /dev/null and b/GIF.gif differ
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..16c1fae
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,25 @@
+
+ The MIT License (MIT)
+ Copyright (c) 2017 Jenly Yu
+ https://github.com/jenly1314
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2a229e1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,123 @@
+# RadarView
+[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/RadarView/master/app/app-release.apk)
+[![](https://jitpack.io/v/jenly1314/RadarView.svg)](https://jitpack.io/#jenly1314/RadarView)
+[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/mit-license.php)
+[![Blog](https://img.shields.io/badge/blog-Jenly-9933CC.svg)](http://blog.csdn.net/jenly121)
+
+RadarView for Android 是一个雷达扫描动画后,然后展示得分效果的控件。
+
+## Gif 展示
+![Image](GIF.gif)
+
+## 引入
+
+### Maven:
+```maven
+
+ com.king.view
+ radarview
+ 1.0.0
+ pom
+
+```
+### Gradle:
+```gradle
+compile 'com.king.view:radarview:1.0.0'
+```
+### Lvy:
+```lvy
+
+
+
+```
+
+###### 如果Gradle出现compile失败的情况,可以在Project的build.gradle里面添加如下:(也可以使用上面的GitPack来complie)
+```gradle
+allprojects {
+ repositories {
+ //...
+ maven { url 'https://dl.bintray.com/jenly/maven' }
+ }
+}
+```
+
+## 示例
+
+布局
+```Xml
+
+```
+
+自定义属性
+```Xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+代码示例(核心调用代码)
+```Java
+//开始雷达扫描
+radarView.start();
+//停止雷达扫描
+radarView.stop();
+//设置雷达扫描区域的颜色,传多个色值表示渐变
+radarView.setScanColor(int... colors);
+/**
+ * 显示分数
+ * @param from 初始值
+ * @param to 目标值(最终分数)
+ * @param duration 从初始值到目标值的动画持续时间
+ * @param format
+ * @param isShowAnim 是否显示动画
+ */
+radarView.showScore(float from, float to, int duration, final String format,boolean isShowAnim);
+
+```
+
+
+## 关于我
+ Name: Jenly
+
+ Email: jenly1314@gmail.com / jenly1314@vip.qq.com
+
+ CSDN: http://blog.csdn.net/jenly121
+
+ Github: https://github.com/jenly1314
+
+ 微信公众号:
+
+ ![公众号](http://olambmg9j.bkt.clouddn.com/jenly666.jpg)
+
+ 加入QQ群: [20867961](http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1411582c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad)
+
+
+
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/app-release.apk b/app/app-release.apk
new file mode 100644
index 0000000..6cacfef
Binary files /dev/null and b/app/app-release.apk differ
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..e99e147
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+ defaultConfig {
+ applicationId "com.king.radar"
+ minSdkVersion 11
+ 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'
+ }
+ }
+
+ lintOptions {
+ checkReleaseBuilds false
+ abortOnError false
+ }
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ 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'
+ compile 'com.android.support.constraint:constraint-layout:1.0.2'
+ testCompile 'junit:junit:4.12'
+ compile project(':lib')
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..e0476cf
--- /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 D:\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/androidTest/java/com/king/radar/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/king/radar/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..5138893
--- /dev/null
+++ b/app/src/androidTest/java/com/king/radar/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.king.radar;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.king.radar", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..499f440
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/king/radar/MainActivity.java b/app/src/main/java/com/king/radar/MainActivity.java
new file mode 100644
index 0000000..29d8d41
--- /dev/null
+++ b/app/src/main/java/com/king/radar/MainActivity.java
@@ -0,0 +1,61 @@
+package com.king.radar;
+
+import android.graphics.Color;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+
+import com.king.view.radarview.RadarView;
+
+public class MainActivity extends AppCompatActivity implements View.OnClickListener {
+
+ RadarView rv;
+
+ Button btnStyle,btnRadar,btnScore;
+
+ private boolean isAll;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ rv = (RadarView)findViewById(R.id.rv);
+
+ btnStyle = (Button)findViewById(R.id.btnStyle);
+ btnRadar = (Button)findViewById(R.id.btnRadar);
+ btnScore = (Button)findViewById(R.id.btnScore);
+
+// btnStyle.setVisibility(View.GONE);
+
+ btnStyle.setOnClickListener(this);
+ btnRadar.setOnClickListener(this);
+ btnScore.setOnClickListener(this);
+ }
+
+ private void clickStyle(){
+ if(isAll){
+ rv.setScanColor(new int[]{Color.TRANSPARENT,Color.TRANSPARENT,rv.getCircleColor()});
+ }else{
+ rv.setScanColor(new int[]{Color.TRANSPARENT,rv.getCircleColor()});
+ }
+ isAll = !isAll;
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()){
+ case R.id.btnStyle:
+ clickStyle();
+ break;
+ case R.id.btnRadar:
+ rv.start();
+ break;
+ case R.id.btnScore:
+ rv.showScore(98f);
+ break;
+ }
+ }
+}
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..c45c14e
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
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..b6254df
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ RadarView
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..daa2a5c
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/app/src/test/java/com/king/radar/ExampleUnitTest.java b/app/src/test/java/com/king/radar/ExampleUnitTest.java
new file mode 100644
index 0000000..36dd718
--- /dev/null
+++ b/app/src/test/java/com/king/radar/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.king.radar;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..c7016f7
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,32 @@
+// 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'
+ classpath 'com.novoda:bintray-release:0.4.0'
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
+
+allprojects {
+ tasks.withType(Javadoc) {
+ options{
+ encoding "UTF-8"
+ charSet 'UTF-8'
+ links "http://docs.oracle.com/javase/8/docs/api"
+ }
+ }
+}
\ No newline at end of file
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..c02658e
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Aug 01 16:20:34 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 100644
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/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/lib/build.gradle b/lib/build.gradle
new file mode 100644
index 0000000..2c296c7
--- /dev/null
+++ b/lib/build.gradle
@@ -0,0 +1,47 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.novoda.bintray-release'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+
+ defaultConfig {
+ minSdkVersion 11
+ 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'
+ }
+ }
+
+ lintOptions {
+ abortOnError false
+ }
+}
+
+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'
+ })
+ provided 'com.android.support:appcompat-v7:25.3.1'
+ testCompile 'junit:junit:4.12'
+}
+
+
+//添加
+publish {
+ userOrg = 'jenly'//bintray.com用户名
+ groupId = 'com.king.view'//jcenter上的路径
+ artifactId = 'radarview'//项目名称
+ publishVersion = '1.0.0'//版本号
+ desc = 'RadarView for Android'//描述
+ website = 'https://github.com/jenly1314/RadarView'//网站
+}
\ No newline at end of file
diff --git a/lib/proguard-rules.pro b/lib/proguard-rules.pro
new file mode 100644
index 0000000..e0476cf
--- /dev/null
+++ b/lib/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 D:\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/lib/src/androidTest/java/com/king/view/radarview/ExampleInstrumentedTest.java b/lib/src/androidTest/java/com/king/view/radarview/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..e9d0c9b
--- /dev/null
+++ b/lib/src/androidTest/java/com/king/view/radarview/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.king.view.radarview;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.king.view.radarview.test", appContext.getPackageName());
+ }
+}
diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..aa2d2a5
--- /dev/null
+++ b/lib/src/main/AndroidManifest.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
diff --git a/lib/src/main/java/com/king/view/radarview/RadarView.java b/lib/src/main/java/com/king/view/radarview/RadarView.java
new file mode 100644
index 0000000..f41a9a4
--- /dev/null
+++ b/lib/src/main/java/com/king/view/radarview/RadarView.java
@@ -0,0 +1,720 @@
+/*
+ The MIT License (MIT)
+ Copyright (c) 2017 Jenly Yu
+ https://github.com/jenly1314
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+package com.king.view.radarview;
+
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Shader;
+import android.graphics.SweepGradient;
+import android.graphics.Typeface;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.view.View;
+
+/**
+ * @author Jenly Jenly
+ */
+
+public class RadarView extends View {
+
+ public static final String DEFAULT_FORMAT = "%1$.0f";
+
+ /**
+ * 是否是扫描状态
+ */
+ private boolean mIsScaning = false;
+ /**
+ * 是否显示雷达界面(有雷达和分数两种界面效果)
+ */
+ private boolean mIsRadar = false;
+
+ /**
+ * 画笔
+ */
+ private Paint mPaint;
+
+ /**
+ * 内圆环笔画宽度
+ */
+ private float mInsideStrokeWidth;
+ /**
+ * 外圆环笔画宽度
+ */
+ private float mOutsideStrokeWidth;
+ /**
+ * 对角线笔画宽度
+ */
+ private float mLineStrokeWidth;
+
+ /**
+ * 圆心坐标
+ */
+ private float mCircleCenterX,mCircleCenterY;
+
+ /**
+ * 外圆半径
+ */
+ private float mRadius;
+
+ /**
+ * 内圆半径
+ */
+ private float mInsideRadius;
+ /**
+ * 雷达扫描圆环的颜色
+ */
+ private int mCircleColor = Color.parseColor("#52fff9");
+ /**
+ * 对角线的颜色
+ */
+ private int mLineColor = Color.parseColor("#1ecdf4");
+
+ /**
+ * 分数界面外边框的颜色
+ */
+ private int mSideColor = Color.parseColor("#52fff9");
+ /**
+ * 分数界面外圆环的颜色
+ */
+ private int mOutsideBackgroundColor = Color.parseColor("#1bb8f2");
+ /**
+ * 分数界面内圆环的颜色
+ */
+ private int mInsideBackgroundColor = Color.WHITE;
+
+ /**
+ * 分数文本颜色
+ */
+ private int mTextColor = Color.parseColor("#01b0f1");
+ /**
+ * 分数标签文本颜色
+ */
+ private int mLabelTextColor = Color.parseColor("#01b0f1");
+
+ /**
+ * 显示分数文本的字体大小
+ */
+ private float mTextSize;
+ /**
+ * 显示分数文本标签的字体大小
+ */
+ private float mLabelTextSize;
+
+ /**
+ * 用于绘制雷达圆环的着色器
+ */
+ private Shader mCircleShader;
+ /**
+ * 用于绘制雷达扫描区域的着色器
+ */
+ private Shader mScanShader;
+
+ private Matrix mMatrix;
+
+ /**
+ * 雷达扫描旋转的角度
+ */
+ private int mRotate;
+
+ /**
+ * 是否显示对角线
+ */
+ private boolean mIsShowLine = true;
+
+ /**
+ * 文本里圆心的Y轴偏移量
+ */
+ private float mTextOffsetY;
+ /**
+ * 标签里圆心的Y轴偏移量
+ */
+ private float mLabelTextOffseY;
+
+ private String mFormat = DEFAULT_FORMAT;
+
+ private boolean mIsShowLabel = true;
+
+ private boolean mIsShowText = true;
+
+ /**
+ * 是否显示动画(显示分数时)
+ */
+ private boolean mIsShowAnim = true;
+
+ private String mLabelText;
+ /**
+ * 分数值
+ */
+ private float mValue;
+
+ /**
+ * 文本
+ */
+ private String mText;
+
+ /**
+ * 显示分数动画持续时间
+ */
+ private int mDuration = 500;
+
+ /**
+ * 扫描延迟时间(扫描旋转隔时间,默认2毫秒旋转一度)
+ */
+ private int mScanTime = 2;
+ /**
+ * 最后扫描刷新时间
+ */
+ private float mLastTime;
+
+ public RadarView(Context context) {
+ this(context,null);
+ }
+
+ public RadarView(Context context, @Nullable AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public RadarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context,attrs);
+ }
+
+ private void init(Context context,AttributeSet attrs) {
+
+ mPaint = new Paint();
+ mMatrix = new Matrix();
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RadarView);
+
+ mTextSize = a.getDimension(R.styleable.RadarView_android_textSize,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,40,getDisplayMetrics()));
+ mTextColor = a.getColor(R.styleable.RadarView_android_textColor,mTextColor);
+ mText = a.getString(R.styleable.RadarView_android_text);
+
+ mLabelTextSize = a.getDimension(R.styleable.RadarView_labelTextSize,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,16,getDisplayMetrics()));
+ mLabelTextColor = a.getColor(R.styleable.RadarView_labelTextColor,mTextColor);
+ mLabelText = a.getString(R.styleable.RadarView_labelText);
+ mFormat = a.getString(R.styleable.RadarView_format);
+ if(TextUtils.isEmpty(mFormat)){
+ mFormat = DEFAULT_FORMAT;
+ }
+
+ mSideColor = a.getColor(R.styleable.RadarView_sideColor,mSideColor);
+ mOutsideBackgroundColor = a.getColor(R.styleable.RadarView_outsideBackgroundColor,mOutsideBackgroundColor);
+ mInsideBackgroundColor = a.getColor(R.styleable.RadarView_insideBackgroundColor,mInsideBackgroundColor);
+
+ mDuration = a.getInt(R.styleable.RadarView_duration,mDuration);
+
+ mTextOffsetY = a.getDimension(R.styleable.RadarView_textOffsetY,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,12,getDisplayMetrics()));
+ mLabelTextOffseY = a.getDimension(R.styleable.RadarView_labelTextOffsetY,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,getDisplayMetrics()));
+ mCircleColor = a.getColor(R.styleable.RadarView_circleColor,mCircleColor);
+ mLineColor = a.getColor(R.styleable.RadarView_lineColor,mLineColor);
+ mRotate = a.getInt(R.styleable.RadarView_rotate,mRotate);
+ mIsShowLine = a.getBoolean(R.styleable.RadarView_showLine,mIsShowLine);
+ mIsShowText = a.getBoolean(R.styleable.RadarView_showText,mIsShowText);
+ mIsShowLabel = a.getBoolean(R.styleable.RadarView_showLabel,mIsShowLabel);
+ mScanTime = a.getInt(R.styleable.RadarView_scanTime,mScanTime);
+
+ mInsideStrokeWidth = a.getDimension(R.styleable.RadarView_insideStrokeWidth,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,3,getDisplayMetrics()));
+ mOutsideStrokeWidth = a.getDimension(R.styleable.RadarView_outsideStrokeWidth,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,8,getDisplayMetrics()));
+ mLineStrokeWidth = a.getDimension(R.styleable.RadarView_lineStrokeWidth,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,0.3f,getDisplayMetrics()));
+ a.recycle();
+ }
+
+
+ private DisplayMetrics getDisplayMetrics(){
+ return getResources().getDisplayMetrics();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ //默认值
+ int defaultValue = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,200,getDisplayMetrics());
+ //默认宽高
+ int defaultWidth = defaultValue + getPaddingLeft() + getPaddingRight();
+ int defaultHeight = defaultValue + getPaddingTop() + getPaddingBottom();
+
+ int width = measureHandler(widthMeasureSpec,defaultWidth);
+ int height = measureHandler(heightMeasureSpec,defaultHeight);
+
+ setMeasuredDimension(width,height);
+ //圆心坐标
+ mCircleCenterX = (getWidth() + getPaddingLeft() - getPaddingRight())/ 2.0f;
+ mCircleCenterY = (getHeight() + getPaddingTop() - getPaddingBottom())/ 2.0f;
+
+ //外圆半径
+ mRadius = (getWidth()- getPaddingLeft() - getPaddingRight() - mOutsideStrokeWidth) / 2.0f;
+ //内院的半径 为外援半径的1/3
+ mInsideRadius = mRadius / 3;
+
+ }
+
+ private int measureHandler(int measureSpec,int defaultSize){
+
+ int result = defaultSize;
+ int measureMode = MeasureSpec.getMode(measureSpec);
+ int measureSize = MeasureSpec.getSize(measureSpec);
+ if(measureMode == MeasureSpec.EXACTLY){
+ result = measureSize;
+ }else if(measureMode == MeasureSpec.AT_MOST){
+ result = Math.min(defaultSize,measureSize);
+ }
+ return result;
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ if(mIsRadar){
+ drawRadar(canvas);
+ }else{
+ drawScore(canvas);
+ }
+ }
+
+ /**
+ * 绘制雷达扫描图
+ * @param canvas
+ */
+ private void drawRadar(Canvas canvas){
+
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setStyle(Paint.Style.STROKE);
+
+ if(mIsShowLine){//是否绘制对角线和斜对角线
+ mPaint.setColor(mLineColor);
+ mPaint.setStrokeWidth(mLineStrokeWidth);
+
+ //对角线的半径
+ float lineRadius = mRadius - mOutsideStrokeWidth/2;
+ // 根据角度绘制对角线
+ float startX, startY, endX, endY;
+ double radian;
+
+ // 绘制0°~180°对角线
+ canvas.drawLine(mCircleCenterX - lineRadius, mCircleCenterY, mCircleCenterX + lineRadius, mCircleCenterY, mPaint);
+ // 绘制90°~270°对角线
+ canvas.drawLine(mCircleCenterX, mCircleCenterY - lineRadius, mCircleCenterX, mCircleCenterY + lineRadius, mPaint);
+
+
+ // 绘制45°~225°对角线
+ // 计算开始位置x/y坐标点
+ radian = Math.toRadians(45f);
+ startX = (float) (mCircleCenterX + lineRadius * Math.cos(radian));
+ startY = (float) (mCircleCenterY + lineRadius * Math.sin(radian));
+ // 计算结束位置x/y坐标点
+ radian = Math.toRadians(45f + 180f);
+ endX = (float) (mCircleCenterX + lineRadius * Math.cos(radian));
+ endY = (float) (mCircleCenterY + lineRadius * Math.sin(radian));
+ canvas.drawLine(startX, startY, endX, endY, mPaint);
+
+ // 绘制135°~315°对角线
+ // 计算开始位置x/y坐标点
+ radian = Math.toRadians(135f);
+ startX = (float) (mCircleCenterX + lineRadius * Math.cos(radian));
+ startY = (float) (mCircleCenterY + lineRadius * Math.sin(radian));
+ // 计算结束位置x/y坐标点
+ radian = Math.toRadians(135f + 180f);
+ endX = (float) (mCircleCenterX + lineRadius * Math.cos(radian));
+ endY = (float) (mCircleCenterY + lineRadius * Math.sin(radian));
+ canvas.drawLine(startX, startY, endX, endY, mPaint);
+ }
+ //为矩阵设置旋转坐标
+ mMatrix.setRotate(mRotate, mCircleCenterX, mCircleCenterY);
+
+ //绘制圆环的渐变着色器
+ if (mCircleShader == null) {
+ mCircleShader = new SweepGradient(mCircleCenterX, mCircleCenterY, Color.TRANSPARENT, mCircleColor);
+ }
+ mCircleShader.setLocalMatrix(mMatrix);
+ mPaint.setShader(mCircleShader);
+
+ mPaint.setStrokeWidth(mInsideStrokeWidth);
+ mPaint.setColor(mCircleColor);
+ //绘制内框圆
+ canvas.drawCircle(mCircleCenterX,mCircleCenterY,mInsideRadius,mPaint);
+ canvas.drawCircle(mCircleCenterX,mCircleCenterY,mInsideRadius * 2,mPaint);
+
+ //绘制外框圆
+ mPaint.setStrokeWidth(mOutsideStrokeWidth);
+ canvas.drawCircle(mCircleCenterX,mCircleCenterY,mRadius,mPaint);
+
+ //绘制圆扫描区域的渐变着色器
+ if (mScanShader == null){
+ mScanShader = new SweepGradient(mCircleCenterX, mCircleCenterY,new int[] {Color.TRANSPARENT,Color.TRANSPARENT, mCircleColor},null);
+ }
+ mScanShader.setLocalMatrix(mMatrix);
+ mPaint.setShader(mScanShader);
+ mPaint.setStyle(Paint.Style.FILL);
+
+ //绘制扫面区域
+ float radius = mRadius + mOutsideStrokeWidth/2;
+ canvas.drawCircle(mCircleCenterX, mCircleCenterX, radius, mPaint);
+ }
+
+
+ /**
+ * 绘制扫描结果分数图
+ * @param canvas
+ */
+ private void drawScore(Canvas canvas){
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setStyle(Paint.Style.STROKE);
+
+ mPaint.setStrokeWidth(mInsideStrokeWidth);
+ mPaint.setColor(mSideColor);
+
+ //绘制外框圆
+ canvas.drawCircle(mCircleCenterX,mCircleCenterY,mRadius,mPaint);
+
+ mPaint.setStyle(Paint.Style.FILL);
+ mPaint.setColor(mOutsideBackgroundColor);
+ canvas.drawCircle(mCircleCenterX,mCircleCenterY,mRadius,mPaint);
+
+ //绘制内框圆
+ mPaint.setColor(mInsideBackgroundColor);
+ canvas.drawCircle(mCircleCenterX,mCircleCenterY,mInsideRadius * 2,mPaint);
+
+
+ mPaint.setTypeface(Typeface.DEFAULT);
+ mPaint.setTextAlign(Paint.Align.CENTER);
+
+ if(mIsShowLabel && !TextUtils.isEmpty(mLabelText)){//绘制标签文本逻辑
+ mPaint.setColor(mLabelTextColor);
+ mPaint.setTextSize(mLabelTextSize);
+ float x = mCircleCenterX;
+ float y = mCircleCenterY + mLabelTextOffseY;
+ canvas.drawText(mLabelText,x,y,mPaint);
+ }
+
+ if(mIsShowText && !TextUtils.isEmpty(mText)){//绘制文本逻辑
+ mPaint.setColor(mTextColor);
+ mPaint.setTextSize(mTextSize);
+ mPaint.setFakeBoldText(true);
+ float x = mCircleCenterX;
+ float y = mCircleCenterY + mTextOffsetY;
+ canvas.drawText(mText,x,y,mPaint);
+ }
+
+ }
+
+ private String getFormatText(float value,String format){
+ if(TextUtils.isEmpty(format)){
+ return String.valueOf(value);
+ }
+ return String.format(format,value);
+ }
+
+ /**
+ * 显示分数
+ * @param value 目标值(最终分数)
+ */
+ public void showScore(float value){
+ showScore(value,mDuration);
+ }
+
+ /**
+ * 显示分数
+ * @param value 目标值(最终分数)
+ * @param duration 从初始值到目标值的动画持续时间
+ */
+ public void showScore(float value,int duration){
+ showScore(0,value,duration);
+ }
+
+ /**
+ * 显示分数
+ * @param from 初始值
+ * @param to 目标值(最终分数)
+ * @param duration 从初始值到目标值的动画持续时间
+ */
+ public void showScore(float from,float to,int duration){
+ showScore(from,to,duration,mIsShowAnim);
+ }
+
+ /**
+ * 显示分数
+ * @param from 初始值
+ * @param to 目标值(最终分数)
+ * @param duration 从初始值到目标值的动画持续时间
+ * @param isShowAnim 是否显示动画
+ */
+ public void showScore(float from,float to,int duration,boolean isShowAnim){
+ showScore(from,to,duration,mFormat,isShowAnim);
+ }
+
+ /**
+ * 显示分数
+ * @param from 初始值
+ * @param to 目标值(最终分数)
+ * @param duration 从初始值到目标值的动画持续时间
+ * @param format
+ * @param isShowAnim 是否显示动画
+ */
+ public void showScore(float from, float to, int duration, final String format,boolean isShowAnim){
+ this.mIsRadar = false;
+ this.mDuration = duration;
+ this.mFormat = (format == null ? DEFAULT_FORMAT : format);
+ this.mIsShowAnim = isShowAnim;
+ if(mIsShowAnim){
+ ValueAnimator valueAnimator = ValueAnimator.ofFloat(from,to);
+ valueAnimator.setDuration(duration);
+ valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ mValue = (float)animation.getAnimatedValue();
+ setText(mValue,format);
+ }
+ });
+
+ valueAnimator.start();
+ }else{
+ mValue = to;
+ setText(mValue,format);
+ }
+
+ }
+
+ public void setText(@StringRes int resId){
+ this.mText = getResources().getString(resId);
+ if(!mIsRadar){
+ invalidate();
+ }
+ }
+
+ public void setText(String text){
+ this.mText = text;
+ if(!mIsRadar){
+ invalidate();
+ }
+ }
+
+ /**
+ * 设置分数文本
+ * @param value
+ * @param format
+ */
+ public void setText(float value,String format){
+ this.mValue = value;
+ this.mFormat = (TextUtils.isEmpty(format) ? DEFAULT_FORMAT : format);
+ this.mText = getFormatText(value,format);
+ if(!mIsRadar){
+ invalidate();
+ }
+ }
+
+ public void setLabelText(@StringRes int resId){
+ this.mLabelText = getResources().getString(resId);
+ if(!mIsRadar){
+ invalidate();
+ }
+ }
+
+ public void setLabelText(String text){
+ this.mLabelText = text;
+ if(!mIsRadar){
+ invalidate();
+ }
+ }
+
+ /**
+ * 开始扫描动画
+ */
+ public void start(){
+ mIsRadar = true;
+ mIsScaning = true;
+ updateScan();
+
+ }
+
+ /**
+ * 更新雷达扫描区域
+ */
+ private void updateScan(){
+ float curTime = System.currentTimeMillis();
+ if(curTime>=mLastTime + mScanTime && mIsScaning){
+ mLastTime = curTime;
+ removeCallbacks(mRunnable);
+ postDelayed(mRunnable,mScanTime);
+ }
+
+ }
+
+ private Runnable mRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mRotate++;
+ if(mRotate>=360){
+ mRotate = 0;
+ }
+ invalidate();
+ updateScan();
+ }
+ };
+
+ /**
+ * 停止扫描动画
+ */
+ public void stop(){
+ mIsScaning = false;
+ }
+
+ public void setInsideStrokeWidth(float insideStrokeWidth) {
+ this.mInsideStrokeWidth = insideStrokeWidth;
+ }
+
+ public void setOutsideStrokeWidth(float outsideStrokeWidth) {
+ this.mOutsideStrokeWidth = outsideStrokeWidth;
+ }
+
+ public void setLineStrokeWidth(float lineStrokeWidth) {
+ this.mLineStrokeWidth = lineStrokeWidth;
+ }
+
+ public void setCircleColor(int circleColor) {
+ this.mCircleColor = circleColor;
+ }
+
+ public void setLineColor(int lineColor) {
+ this.mLineColor = lineColor;
+ }
+
+ public void setSideColor(int sideColor) {
+ this.mSideColor = sideColor;
+ }
+
+ public void setOutsideColor(int outsideColor) {
+ this.mOutsideBackgroundColor = outsideColor;
+ }
+
+ public void setInsideColor(int insideColor) {
+ this.mInsideBackgroundColor = insideColor;
+ }
+
+ public void setTextColor(int textColor) {
+ this.mTextColor = textColor;
+ }
+
+ public void setLabelTextColor(int labelTextColor) {
+ this.mLabelTextColor = labelTextColor;
+ }
+
+ public void setTextSize(float textSize) {
+ this.mTextSize = textSize;
+ }
+
+ public void setLabelTextSize(float labelTextSize) {
+ this.mLabelTextSize = labelTextSize;
+ }
+
+ public void setRotate(int rotate) {
+ this.mRotate = rotate;
+ }
+
+ public void setShowLine(boolean isShowLine) {
+ this.mIsShowLine = isShowLine;
+ }
+
+ public void setTextOffsetY(float textOffsetY) {
+ this.mTextOffsetY = textOffsetY;
+ }
+
+ public void setShowLabel(boolean showLabel) {
+ mIsShowLabel = showLabel;
+ }
+
+ public void setShowText(boolean showText) {
+ mIsShowText = showText;
+ }
+
+ public void setShowAnim(boolean isShowAnim) {
+ this.mIsShowAnim = isShowAnim;
+ }
+
+ public void setDuration(int duration) {
+ this.mDuration = duration;
+ }
+
+ public void setScanTime(int scanTime) {
+ this.mScanTime = scanTime;
+ }
+
+ public boolean isRadar() {
+ return mIsRadar;
+ }
+
+ public int getCircleColor() {
+ return mCircleColor;
+ }
+
+ public int getLineColor() {
+ return mLineColor;
+ }
+
+ public int getSideColor() {
+ return mSideColor;
+ }
+
+ public int getOutsideColor() {
+ return mOutsideBackgroundColor;
+ }
+
+ public int getInsideColor() {
+ return mInsideBackgroundColor;
+ }
+
+ public int getTextColor() {
+ return mTextColor;
+ }
+
+ public int getLabelTextColor() {
+ return mLabelTextColor;
+ }
+
+ /**
+ * 雷达扫描区域的着色器色值
+ * @param colors 传多个色值表示渐变
+ */
+ public void setScanColor(int... colors){
+ mScanShader = new SweepGradient(mCircleCenterX, mCircleCenterY,colors,null);
+ }
+
+ /**
+ * 雷达内外圆环的着色器色值
+ * @param colors 传多个色值表示渐变
+ */
+ public void setCircleColor(int... colors){
+ mCircleShader = new SweepGradient(mCircleCenterX, mCircleCenterY,colors,null);
+ }
+}
diff --git a/lib/src/main/res/values/attrs.xml b/lib/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..8b176ce
--- /dev/null
+++ b/lib/src/main/res/values/attrs.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/src/main/res/values/strings.xml b/lib/src/main/res/values/strings.xml
new file mode 100644
index 0000000..b6254df
--- /dev/null
+++ b/lib/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ RadarView
+
diff --git a/lib/src/test/java/com/king/view/radarview/ExampleUnitTest.java b/lib/src/test/java/com/king/view/radarview/ExampleUnitTest.java
new file mode 100644
index 0000000..e11cde2
--- /dev/null
+++ b/lib/src/test/java/com/king/view/radarview/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.king.view.radarview;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..3cbe249
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app', ':lib'