├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── HLQ.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cn
│ │ └── hlq
│ │ └── androidcustomview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── cn
│ │ │ └── hlq
│ │ │ └── androidcustomview
│ │ │ ├── MainActivity.java
│ │ │ └── activities
│ │ │ ├── CircleActivity.java
│ │ │ ├── PieChartActivity.java
│ │ │ ├── RectActivity.java
│ │ │ ├── TextActivity.java
│ │ │ └── ViewGroupActivity.java
│ └── res
│ │ ├── layout
│ │ ├── activity_circle.xml
│ │ ├── activity_main.xml
│ │ ├── activity_pie_chart.xml
│ │ ├── activity_rect.xml
│ │ ├── activity_text.xml
│ │ └── activity_view_group.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── cn
│ └── hlq
│ └── androidcustomview
│ └── ExampleUnitTest.java
├── build.gradle
├── customview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cn
│ │ └── hlq
│ │ └── customview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── cn
│ │ │ └── hlq
│ │ │ └── customview
│ │ │ ├── CircleView.java
│ │ │ ├── HLQViewGroup.java
│ │ │ ├── PieChartView.java
│ │ │ ├── RectView.java
│ │ │ ├── TextView.java
│ │ │ ├── bean
│ │ │ └── PieCharBean.java
│ │ │ └── util
│ │ │ └── MathUtil.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── cn
│ └── hlq
│ └── customview
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── 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/HLQ.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Android API 22 Platform
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | Android API 22 Platform
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AndroidCustomView
2 | 博文链接:http://blog.csdn.net/u012400885/article/details/77395604
3 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.0"
6 | defaultConfig {
7 | applicationId "cn.hlq.androidcustomview"
8 | minSdkVersion 21
9 | targetSdkVersion 26
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 project(':customview')
28 | compile 'com.android.support:appcompat-v7:26.+'
29 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/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 F:\HLQJobSoftware-Android\AndroidStudio\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cn/hlq/androidcustomview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cn.hlq.androidcustomview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/hlq/androidcustomview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import cn.hlq.androidcustomview.activities.CircleActivity;
9 | import cn.hlq.androidcustomview.activities.PieChartActivity;
10 | import cn.hlq.androidcustomview.activities.RectActivity;
11 | import cn.hlq.androidcustomview.activities.TextActivity;
12 | import cn.hlq.androidcustomview.activities.ViewGroupActivity;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | private MainActivity selfActivity = MainActivity.this;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 | initView();
23 | }
24 |
25 | @Override
26 | protected void onRestoreInstanceState(Bundle savedInstanceState) {
27 | super.onRestoreInstanceState(savedInstanceState);
28 | }
29 |
30 | private void initView() {
31 | // 绘制圆
32 | findViewById(R.id.btn_circle_view).setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View view) {
35 | startActivity(new Intent(selfActivity, CircleActivity.class));
36 | }
37 | });
38 | // 绘制矩形
39 | findViewById(R.id.btn_rect_view).setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View view) {
42 | startActivity(new Intent(selfActivity, RectActivity.class));
43 | }
44 | });
45 | // 绘制线 扇形 弧度
46 | findViewById(R.id.btn_hlq_view).setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View view) {
49 | startActivity(new Intent(selfActivity, ViewGroupActivity.class));
50 | }
51 | });
52 | // 绘制文字
53 | findViewById(R.id.btn_text_view).setOnClickListener(new View.OnClickListener() {
54 | @Override
55 | public void onClick(View view) {
56 | startActivity(new Intent(selfActivity, TextActivity.class));
57 | }
58 | });
59 | // 绘制饼图
60 | findViewById(R.id.btn_piechart_view).setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View view) {
63 | startActivity(new Intent(selfActivity, PieChartActivity.class));
64 | }
65 | });
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/hlq/androidcustomview/activities/CircleActivity.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview.activities;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import cn.hlq.androidcustomview.R;
7 |
8 | public class CircleActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_circle);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/hlq/androidcustomview/activities/PieChartActivity.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview.activities;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import cn.hlq.androidcustomview.R;
10 | import cn.hlq.customview.PieChartView;
11 | import cn.hlq.customview.bean.PieCharBean;
12 |
13 | public class PieChartActivity extends AppCompatActivity {
14 |
15 | private PieChartView pieChartView;
16 |
17 | private int[] colors={0xFFCCFF00,0xFF6495ED,0xFFE32636,0xFF800000,0xFF808000,0xFFFF8C69,0xFF808080,0xFFE68800,0xFF7CFC00};
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_pie_chart);
23 | initView();
24 | }
25 |
26 | /**
27 | * 模拟获取数据源
28 | * @return
29 | */
30 | private List getPieCharData(){
31 | List pieCharList=new ArrayList<>();
32 | for (int i = 0; i < 9; i++) {
33 | pieCharList.add(new PieCharBean(i+1,colors[i]));
34 | }
35 | return pieCharList;
36 | }
37 |
38 | private void initView() {
39 | pieChartView= (PieChartView) findViewById(R.id.id_pie_chart);
40 | pieChartView.setPieChartData(getPieCharData());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/hlq/androidcustomview/activities/RectActivity.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview.activities;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import cn.hlq.androidcustomview.R;
7 |
8 | public class RectActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_rect);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/hlq/androidcustomview/activities/TextActivity.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview.activities;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import cn.hlq.androidcustomview.R;
7 |
8 | public class TextActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_text);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/hlq/androidcustomview/activities/ViewGroupActivity.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview.activities;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import cn.hlq.androidcustomview.R;
7 |
8 | public class ViewGroupActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_view_group);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pie_chart.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rect.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_view_group.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidCustomView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/cn/hlq/androidcustomview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.androidcustomview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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.3.3'
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 |
--------------------------------------------------------------------------------
/customview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/customview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 21
9 | targetSdkVersion 26
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:26.+'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/customview/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 F:\HLQJobSoftware-Android\AndroidStudio\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/customview/src/androidTest/java/cn/hlq/customview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.customview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cn.hlq.customview.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/customview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/customview/src/main/java/cn/hlq/customview/CircleView.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.customview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.support.annotation.Nullable;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 |
12 | /**
13 | * Created by HLQ on 2017/8/18
14 | * 来个小目标,画些圆玩玩
15 | * 步骤如下:
16 | * 1.继承View,实现构造;
17 | * 2.为了我们调用一个的同时可以调用其它构造,稍微修改下,super改为this;
18 | * 3.添加初始化画笔方法,必需;
19 | * 4.实现onDraw()方法。
20 | */
21 | public class CircleView extends View {
22 |
23 | private Paint paint; // 画笔
24 | private Paint antiAliasPaint; // 抗锯齿画笔
25 | private Paint strokePaint; // 空心圆画笔
26 | private Paint strokeWPaint; // 空心圆宽度画笔
27 |
28 | private RectF rectF;
29 |
30 | public CircleView(Context context) {
31 | this(context, null);
32 | }
33 |
34 | public CircleView(Context context, @Nullable AttributeSet attrs) {
35 | this(context, attrs, 0);
36 | }
37 |
38 | public CircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
39 | super(context, attrs, defStyleAttr);
40 | initPaint();
41 | }
42 |
43 | /**
44 | * 初始化画笔
45 | */
46 | private void initPaint() {
47 | // 画一个普通圆
48 | // 实例化画笔
49 | paint = new Paint();
50 | // 设置画笔颜色
51 | paint.setColor(Color.RED);
52 |
53 | antiAliasPaint = new Paint();
54 | // 设置画笔颜色
55 | antiAliasPaint.setColor(Color.RED);
56 | // 开启抗锯齿
57 | antiAliasPaint.setAntiAlias(true);
58 |
59 | // 来一个空心圆
60 | strokePaint = new Paint();
61 | strokePaint.setColor(Color.BLUE);
62 | strokePaint.setAntiAlias(true);
63 | // 设置空心圆
64 | strokePaint.setStyle(Paint.Style.FILL_AND_STROKE);
65 |
66 | // 设置空心圆边框宽度
67 | strokeWPaint = new Paint();
68 | strokeWPaint.setColor(Color.BLUE);
69 | strokeWPaint.setAntiAlias(true);
70 | strokeWPaint.setStyle(Paint.Style.STROKE);
71 | // 设置边框宽度
72 | strokeWPaint.setStrokeWidth(30);
73 |
74 | }
75 |
76 | @Override
77 | protected void onDraw(Canvas canvas) {
78 | super.onDraw(canvas);
79 | // 参数详解:
80 | // float cx:x轴距离
81 | // float cy:y轴距离
82 | // float radius:半径
83 | // Paint paint:画笔
84 | canvas.drawCircle(0, 0, 100, paint);
85 |
86 | // 指定x,y均为300
87 | canvas.drawCircle(300, 300, 100, antiAliasPaint);
88 |
89 | // 指定绘制空心圆
90 | canvas.drawCircle(700, 300, 100, strokePaint);
91 |
92 | // 指定绘制空心圆并设置边框线宽度
93 | canvas.drawCircle(700, 700, 100, strokeWPaint);
94 |
95 | // 绘制椭圆
96 | rectF=new RectF();
97 | rectF.left=100;
98 | rectF.top=600;
99 | rectF.right=400;
100 | rectF.bottom=800;
101 | canvas.drawOval(rectF,paint);
102 |
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/customview/src/main/java/cn/hlq/customview/HLQViewGroup.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.customview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.support.annotation.Nullable;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 |
12 | /**
13 | * 包含绘制 线 扇形 弧形 Created by HLQ on 2017/8/21
14 | */
15 |
16 | public class HLQViewGroup extends View {
17 |
18 | private Paint paint;
19 |
20 | // 多个坐标集合 一组四个坐标 分别为起始x轴,起始y轴,结束x轴,结束y轴
21 | private float[] pts = {
22 | 100, 200, 100, 600,
23 | 100, 400, 300, 400,
24 | 300, 200, 300, 600};
25 |
26 | private float[] pts1 = {
27 | 400, 100, 400, 200,
28 | 400,100,600,100,
29 | 400,200,600,200};
30 |
31 | private RectF rectF;
32 |
33 | public HLQViewGroup(Context context) {
34 | this(context, null);
35 | }
36 |
37 | public HLQViewGroup(Context context, @Nullable AttributeSet attrs) {
38 | this(context, attrs, 0);
39 | }
40 |
41 | public HLQViewGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
42 | super(context, attrs, defStyleAttr);
43 | initPaint();
44 | }
45 |
46 | private void initPaint() {
47 | paint = new Paint();
48 | paint.setStrokeWidth(5);
49 | paint.setColor(Color.BLACK);
50 |
51 | }
52 |
53 | @Override
54 | protected void onDraw(Canvas canvas) {
55 | super.onDraw(canvas);
56 |
57 | // 画单条线
58 | canvas.drawLine(100, 50, 500, 50, paint);
59 |
60 | // 绘制几条线
61 | canvas.drawLines(pts, paint);
62 |
63 | // 参数说明
64 | // pts:绘制直线的端点数组,每条直线占用4个数据。
65 | // offset:跳过的数据个数,这些数据将不参与绘制过程。
66 | // count:实际参与绘制的数据个数。
67 | // paint:绘制直线所使用的画笔。
68 | canvas.drawLines(pts1,0,12,paint);
69 |
70 | // 绘制弧线 false为弧线 true为扇形
71 | rectF=new RectF();
72 | rectF.left=20;
73 | rectF.top=600;
74 | rectF.right=220;
75 | rectF.bottom=800;
76 | paint.setStyle(Paint.Style.STROKE);
77 | canvas.drawArc(rectF,0,90,false,paint);
78 |
79 | rectF=new RectF();
80 | rectF.left=20;
81 | rectF.top=800;
82 | rectF.right=220;
83 | rectF.bottom=1000;
84 | paint.setStyle(Paint.Style.STROKE);
85 | canvas.drawArc(rectF,0,90,true,paint);
86 |
87 | // 绘制点
88 | canvas.drawPoint(600,500,paint);
89 |
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/customview/src/main/java/cn/hlq/customview/PieChartView.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.customview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.graphics.RectF;
9 | import android.support.annotation.Nullable;
10 | import android.util.AttributeSet;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 |
14 | import java.util.Arrays;
15 | import java.util.List;
16 |
17 | import cn.hlq.customview.bean.PieCharBean;
18 | import cn.hlq.customview.util.MathUtil;
19 |
20 | /**
21 | * 饼图 Created by HLQ on 2017/8/22
22 | * 实现步骤如下:
23 | * 1. 绘制扇形并组合成圆形;
24 | * 2. 绘制中间短线;
25 | * 3. 绘制外侧文本
26 | */
27 | public class PieChartView extends View {
28 |
29 | private Paint mPaint;
30 | private Paint mLinePaint;
31 | private Path mPath;
32 |
33 | private int mWidth; // 屏幕宽
34 | private int mHeight; // 屏幕高
35 | private int mRadius; // 半径
36 | private int mPosition; // 被点击的扇形区域对应的位置
37 | private float mTotalValue; // 总占比
38 |
39 | private List mPieCharList; // 数据源
40 |
41 | private float[] mStartAngles; // 起始角度集合
42 | private RectF mRectF; // 定义扇形的外接矩形
43 | private RectF mTouchmRectF; // 被触摸扇形的外接矩形
44 |
45 | public PieChartView(Context context) {
46 | this(context, null);
47 | }
48 |
49 | public PieChartView(Context context, @Nullable AttributeSet attrs) {
50 | this(context, attrs, 0);
51 | }
52 |
53 | public PieChartView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
54 | super(context, attrs, defStyleAttr);
55 | initPaint();
56 | }
57 |
58 | private void initPaint() {
59 | mPaint = new Paint();
60 | mPaint.setAntiAlias(true); // 开启抗锯齿
61 |
62 | mLinePaint = new Paint();
63 | mLinePaint.setColor(Color.BLACK);
64 | mLinePaint.setAntiAlias(true);
65 | mLinePaint.setStrokeWidth(3);
66 | mLinePaint.setTextSize(30);
67 |
68 | mPath = new Path();
69 |
70 | mRectF = new RectF(); // 实例化扇形的外接矩形
71 | mTouchmRectF = new RectF(); // 实例化被触摸扇形的外接矩形
72 | }
73 |
74 | /**
75 | * 当自定义控件的尺寸已经确定好调用
76 | *
77 | * @param w 宽度
78 | * @param h 高度
79 | * @param oldw
80 | * @param oldh
81 | */
82 | @Override
83 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
84 | super.onSizeChanged(w, h, oldw, oldh);
85 | this.mWidth = w;
86 | this.mHeight = h;
87 | // 防止绘制后View超出屏幕大小,首先获取屏幕宽高的较小值
88 | int min = Math.min(w, h);// 获取到直径
89 | mRadius = (int) (min * 0.7f / 2); // 获取半径
90 |
91 | mRectF.left = -mRadius; // 左
92 | mRectF.top = -mRadius; // 上
93 | mRectF.right = mRadius; // 右
94 | mRectF.bottom = mRadius; // 下
95 |
96 | mTouchmRectF.left = -mRadius-15; // 左
97 | mTouchmRectF.top = -mRadius-15; // 上
98 | mTouchmRectF.right = mRadius+15; // 右
99 | mTouchmRectF.bottom = mRadius+15; // 下
100 | }
101 |
102 | /**
103 | * 设置数据源
104 | *
105 | * @param pieCharList
106 | */
107 | public void setPieChartData(List pieCharList) {
108 | this.mPieCharList = pieCharList;
109 | for(PieCharBean pieCharBean:mPieCharList){
110 | mTotalValue+=pieCharBean.value;
111 | }
112 | mStartAngles=new float[pieCharList.size()];
113 | }
114 |
115 | /**
116 | * 绘制扇形
117 | *
118 | * @param canvas
119 | */
120 | private void drawPieChart(Canvas canvas) {
121 | float startAngle = 0;
122 | for (int i = 0; i < mPieCharList.size(); i++) {
123 | // 移动到0,0点
124 | mPath.moveTo(0,0);
125 | PieCharBean pieCharBean=mPieCharList.get(i);
126 | // 绘制当前扇形区域颜色
127 | mPaint.setColor(mPieCharList.get(i).color);
128 | // 默认绘制扇形
129 | float sweepAngle=pieCharBean.value/mTotalValue*360-1;
130 | if(i==mPosition){
131 | mPath.arcTo(mTouchmRectF,startAngle,sweepAngle);
132 | }else{
133 | mPath.arcTo(mRectF,startAngle,sweepAngle);
134 | }
135 | // 绘制扇形
136 | canvas.drawPath(mPath,mPaint);
137 | // 将角度转换为弧度
138 | double angdeg= Math.toRadians(startAngle+sweepAngle/2);
139 | float startX= (float) (mRadius*Math.cos(angdeg));
140 | float startY=(float) (mRadius*Math.sin(angdeg));
141 | float endX= (float) ((mRadius+30)*Math.cos(angdeg));
142 | float endY=(float) ((mRadius+30)*Math.sin(angdeg));
143 | // 绘制线条
144 | canvas.drawLine(startX,startY,endX,endY,mLinePaint);
145 | // 存储每次开始角度
146 | mStartAngles[i]=startAngle;
147 | // 每个扇形区域的起始点都是上一个扇形区域的终点
148 | startAngle+=sweepAngle+1;
149 | // 绘制扇形后 要对Path进行重置操作 这样可以清除上一次画笔的缓存
150 | mPath.reset();
151 | // 绘制文本
152 | String percent=String.format("%.1f",pieCharBean.value/mTotalValue*100);
153 | percent=percent+"%";
154 | if (startAngle%360.0f>=90.0f&&startAngle%360.0f<=270.0f){
155 | float textWidth=mLinePaint.measureText(percent);
156 | canvas.drawText(percent,endX-textWidth,endY,mLinePaint);
157 | }else{
158 | canvas.drawText(percent,endX,endY,mLinePaint);
159 | }
160 | }
161 | }
162 |
163 | @Override
164 | protected void onDraw(Canvas canvas) {
165 | super.onDraw(canvas);
166 | canvas.save();
167 | // 移动坐标系到屏幕中心点 宽高各取一半
168 | canvas.translate(mWidth / 2, mHeight / 2);
169 | drawPieChart(canvas);
170 | canvas.restore();
171 | }
172 |
173 | /**
174 | * 用户与视图交互时触发
175 | * @param event
176 | * @return
177 | */
178 | @Override
179 | public boolean onTouchEvent(MotionEvent event) {
180 | // 获取用户当前对屏幕的操作
181 | int action=event.getAction();
182 | switch (action){
183 | case MotionEvent.ACTION_DOWN:
184 | // 获取点击区域
185 | // 获取用户点击的位置距当前视图的左边缘距离
186 | float x=event.getX();
187 | // 获取用户点击的位置距当前视图的上边缘距离
188 | float y=event.getY();
189 | // 将点击的xy坐标转化为以饼图为圆心的坐标
190 | x=x-mWidth/2;
191 | y=y-mHeight/2;
192 | // 获取点击的角度
193 | float touchAngle= MathUtil.getTouchAngle(x,y);
194 | // 获取触摸的半径
195 | float toucheRadius= (float) Math.sqrt(x*x+y*y);
196 | // 判断触摸的店距离饼状图<对应的圆心
197 | if(toucheRadius 0) { //1象限
20 | touchAngle += 360;
21 | } else if (y > 0 && x < 0) { //3象限
22 | touchAngle += 180;
23 | }
24 | //Math.atan(y/x) 返回正数值表示相对于 x 轴的逆时针转角,返回负数值则表示顺时针转角。
25 | //返回值乘以 180/π,将弧度转换为角度。
26 | touchAngle += Math.toDegrees(Math.atan(y / x));
27 | if (touchAngle < 0) {
28 | touchAngle = touchAngle + 360;
29 | }
30 | return touchAngle;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/customview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CustomView
3 |
4 |
--------------------------------------------------------------------------------
/customview/src/test/java/cn/hlq/customview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.hlq.customview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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/HLQ-Struggle/AndroidCustomView/813e81efe1d6a2893f0576ac199a93f0f8e2c2cb/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 17 20:54:25 CST 2017
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-3.3-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':customview'
2 |
--------------------------------------------------------------------------------