├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── anim
│ │ │ │ ├── dialog_dismiss.xml
│ │ │ │ └── dialog_show.xml
│ │ │ ├── drawable
│ │ │ │ └── text_circular.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── layout_call_phone.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── sjxz
│ │ │ │ └── logistics_information
│ │ │ │ ├── LogisticsData.java
│ │ │ │ ├── Utils.java
│ │ │ │ ├── CallPhoneDialog.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── LogUtils.java
│ │ │ │ └── LogisticsInformationView.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── sjxz
│ │ │ └── logistics_information
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── sjxz
│ │ └── logistics_information
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── settings.gradle
├── img-holder
├── image.png
├── image2.png
└── image3.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Logistics_information
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/img-holder/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/img-holder/image.png
--------------------------------------------------------------------------------
/img-holder/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/img-holder/image2.png
--------------------------------------------------------------------------------
/img-holder/image3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/img-holder/image3.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wyhnihaook/Logistics_information/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Logistics_information
3 |
4 | 取消
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/dialog_dismiss.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/dialog_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/text_circular.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/test/java/com/sjxz/logistics_information/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/sjxz/logistics_information/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #cccccc
8 | #60cd89
9 |
10 | #FFFFFFFF
11 | #FF000000
12 |
13 | #F4F4F4
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Logistics_information
2 | ## 自定义View物流信息样式
3 | # 作者 #
4 | ---
5 |
6 | WYH_Healer
7 |
8 | >Csdn:[WYH_Healer的博客](http://blog.csdn.net/wyh_healer)
9 |
10 | ---
11 |
12 | ## 
13 | ##### 本文参考了戴定康博主的自定义物流样式 https://github.com/aesion/NodeProgressView ,并在基础上进行修改使显示样式更加精细, 使每一个物流信息的高度自适应(文本内容多的时候高度变高,文本内容少的时候高度变低)更加与淘宝物流详情的物流节点样式相似。
14 | ##### 本文在界面绘制完成的基础上添加手机号码颜色标识以及拨打电话的功能
15 | ## 
16 | ## 
17 | >下载的童鞋希望多多star and fork;
18 |
--------------------------------------------------------------------------------
/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 E:\Android\2.1.1SDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.sjxz.logistics_information"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
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(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.4.0'
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjxz/logistics_information/LogisticsData.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | /**
4 | * @author WYH_Healer
5 | * @email 3425934925@qq.com
6 | * Created by xz on 2017/2/17.
7 | * Role:
8 | */
9 | public class LogisticsData {
10 |
11 | private String context;//内容
12 | private String time;//时间
13 |
14 | public String getContext() {
15 | return context;
16 | }
17 |
18 | public LogisticsData setContext(String context) {
19 | this.context = context;
20 | return this;
21 | }
22 |
23 |
24 | public String getTime() {
25 | return time;
26 | }
27 |
28 | public LogisticsData setTime(String time) {
29 | this.time = time;
30 | return this;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/.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/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjxz/logistics_information/Utils.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.util.DisplayMetrics;
6 |
7 | /**
8 | * @author WYH_Healer
9 | * @email 3425934925@qq.com
10 | * Created by xz on 2017/2/22.
11 | * Role:
12 | */
13 | public class Utils {
14 |
15 | public static int getScreenWidth(Context context){
16 | DisplayMetrics dm = new DisplayMetrics();
17 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
18 | return dm.widthPixels;
19 | }
20 | public static int getScreenHeight(Context context){
21 | DisplayMetrics dm = new DisplayMetrics();
22 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
23 | return dm.heightPixels;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_call_phone.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
21 |
22 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
20 |
21 |
33 |
34 |
38 |
39 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjxz/logistics_information/CallPhoneDialog.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import android.Manifest;
4 | import android.app.Dialog;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.content.res.Configuration;
9 | import android.net.Uri;
10 | import android.support.v4.app.ActivityCompat;
11 | import android.view.Gravity;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.view.Window;
15 | import android.view.WindowManager;
16 | import android.widget.TextView;
17 |
18 | /**
19 | * @author WYH_Healer
20 | * @email 3425934925@qq.com
21 | * Created by xz on 2017/2/22.
22 | * Role:点击手机号码弹出的Dialog用于拨打电话
23 | */
24 | public class CallPhoneDialog extends Dialog implements View.OnClickListener {
25 |
26 | private Context context;
27 |
28 | private String phoneNumber;
29 |
30 | private TextView tv_call_phone;
31 |
32 | private TextView tv_cancle;
33 |
34 | public CallPhoneDialog(Context context, String phoneNumber) {
35 | super(context, R.style.DialogStyle);
36 | this.context = context;
37 | this.phoneNumber = phoneNumber;
38 |
39 | View view = LayoutInflater.from(context).inflate(R.layout.layout_call_phone, null);
40 | setContentView(view);
41 | // 设置窗口大小
42 | Window mWindow = getWindow();
43 | WindowManager.LayoutParams lp = mWindow.getAttributes();
44 | if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {// 竖屏
45 | lp.width = Utils.getScreenWidth(context);
46 | } else {
47 | lp.width = Utils.getScreenHeight(context);
48 | }
49 | mWindow.setAttributes(lp);
50 | // 设置可以动画
51 | mWindow.setWindowAnimations(R.style.dialogAnim);
52 | // 位置设置在底部
53 | mWindow.setGravity(Gravity.BOTTOM);
54 | // 设置可取消
55 | setCancelable(true);
56 | setCanceledOnTouchOutside(true);
57 |
58 | initView();
59 | initData();
60 |
61 | }
62 |
63 |
64 | private void initView() {
65 | tv_call_phone = (TextView) findViewById(R.id.tv_call_phone);
66 | tv_cancle = (TextView) findViewById(R.id.tv_cancle);
67 |
68 | tv_call_phone.setOnClickListener(this);
69 | tv_cancle.setOnClickListener(this);
70 | }
71 |
72 | private void initData() {
73 | tv_call_phone.setText(phoneNumber + "");
74 | }
75 |
76 | public void setPhoneNumber(String phoneNumber) {
77 | this.phoneNumber = phoneNumber;
78 | tv_call_phone.setText(phoneNumber + "");
79 | }
80 |
81 | @Override
82 | public void onClick(View v) {
83 | switch (v.getId()) {
84 | case R.id.tv_call_phone:
85 | //实现拨打电话的操作
86 | Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
87 | + phoneNumber));
88 | if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
89 | return;
90 | }
91 | context.startActivity(intent);
92 | break;
93 | case R.id.tv_cancle:
94 | this.dismiss();
95 | break;
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
14 |
18 |
19 |
20 |
26 |
27 |
31 |
32 |
38 |
39 |
44 |
45 |
46 |
47 |
48 |
53 |
54 |
59 |
60 |
65 |
66 |
67 |
68 |
69 |
70 |
75 |
76 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjxz/logistics_information/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import android.Manifest;
4 | import android.content.pm.PackageManager;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.app.ActivityCompat;
9 | import android.support.v4.content.PermissionChecker;
10 | import android.support.v7.app.AppCompatActivity;
11 | import android.widget.Toast;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 | LogisticsInformationView logistics_InformationView;
19 |
20 | List logisticsDataList;
21 |
22 | CallPhoneDialog callPhoneDialog;
23 |
24 | final int REQUEST_CODE = 0x1001;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main);
30 |
31 | initView();
32 |
33 | initData();
34 | }
35 |
36 | private void initView() {
37 | logistics_InformationView=(LogisticsInformationView)findViewById(R.id.logistics_InformationView);
38 | }
39 |
40 | private void initData() {
41 |
42 | logisticsDataList=new ArrayList<>();
43 | logisticsDataList.add(new LogisticsData().setTime("2017-1-20 07:23:06").setContext("[杭州市]浙江杭州江干公司派件员:吕敬桥 15555555551 正在为您派件正在为您派件正在为您派件正在为您派件正在为您派件正在为您派件正在为您派件"));
44 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 23:11:37").setContext("[杭州市]浙江杭州江干区新杭派公司派件员:吕敬桥 15555555552 正在为您派件"));
45 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 23:08:06").setContext("[杭州市]浙江派件员:吕敬桥 15555555553 正在为您派件"));
46 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 23:08:06").setContext("[杭州市]员:吕敬桥 15555555554 正在为您派件"));
47 | logisticsDataList.add(new LogisticsData().setTime("2017-1-20 11:23:07").setContext("[杭州市]浙江杭州江干区新杭派公司进行签收扫描,快件已被 已签收 签收,感谢使用韵达快递,期待再次为您服务"));
48 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 15:52:43").setContext("[泰州市]韵达快递 江苏靖江市公司收件员 已揽件"));
49 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 12:39:15").setContext("包裹正等待揽件"));
50 | logisticsDataList.add(new LogisticsData().setTime("2016-6-28 15:13:02").setContext("快件在【相城中转仓】装车,正发往【无锡分拨中心】已签收,签收人是【王漾】,签收网点是【忻州原平】"));
51 | logisticsDataList.add(new LogisticsData().setTime("2017-1-20 11:23:07").setContext("[杭州市]浙江杭州江干区新杭派公司进行签收扫描,快件已被 已签收 签收,感谢使用韵达快递,期待再次为您服务"));
52 | logisticsDataList.add(new LogisticsData().setTime("2017-1-20 06:48:37").setContext("到达目的地网点浙江杭州江干区新杭派,快件很快进行派送"));
53 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 23:11:37").setContext("[苏州市]江苏苏州分拨中心 已发出"));
54 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 23:08:06").setContext("[苏州市]快件已到达 江苏苏州分拨中心"));
55 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 15:52:43").setContext("[泰州市]韵达快递 江苏靖江市公司收件员 已揽件"));
56 | logisticsDataList.add(new LogisticsData().setTime("2017-1-19 12:39:15").setContext("菜鸟驿站代收,请及时取件,如有疑问请联系 程先生:18061208980"));
57 |
58 |
59 | logistics_InformationView.setLogisticsDataList(logisticsDataList);
60 |
61 | logistics_InformationView.setOnPhoneClickListener(new LogisticsInformationView.OnPhoneClickListener() {
62 | @Override
63 | public void onPhoneClick(String phoneNumber) {
64 | dialogCreateCall(phoneNumber).show();
65 | }
66 | });
67 |
68 |
69 | initPermissionChecker();
70 | }
71 |
72 | /**
73 | * 当系统为6.0以上都要手动配置权限
74 | * 如果想避免手动配置权限,在gradle中配置targetSdkVersion 23以下即可,不包括23
75 | * */
76 | private void initPermissionChecker() {
77 | if (Build.VERSION.SDK_INT >= 23) {
78 |
79 | //判断有没有拨打电话权限
80 | if (PermissionChecker.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
81 |
82 | //请求拨打电话权限
83 | ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, REQUEST_CODE);
84 |
85 | }
86 |
87 | }
88 | }
89 |
90 | /**
91 | * 请求权限的回调方法
92 | * @param requestCode 请求码
93 | * @param permissions 请求的权限
94 | * @param grantResults 权限的结果
95 | */
96 | @Override
97 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
98 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
99 |
100 | if (requestCode == REQUEST_CODE && PermissionChecker.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
101 | //开启成功
102 | }else{
103 | Toast.makeText(MainActivity.this,"拨打电话授权失败,请在设置中手动开启",Toast.LENGTH_LONG);
104 | }
105 | }
106 |
107 |
108 | private CallPhoneDialog dialogCreateCall(String phoneNumber) {
109 | if (callPhoneDialog == null) {
110 | callPhoneDialog = new CallPhoneDialog(this,phoneNumber);
111 | }else{
112 | callPhoneDialog.setPhoneNumber(phoneNumber);
113 | }
114 |
115 | return callPhoneDialog;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjxz/logistics_information/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import android.text.TextUtils;
4 | import android.util.Log;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * ---------------------------------------------------
10 | * 版 权 : 杭州石谷网络科技有限公司 版权所有 (c) 2015
11 | * 作 者 : Star
12 | * 版 本 : 1.0
13 | * 创建日期 : 2015/10/20 15:51
14 | * 描 述 :
15 | * 1.日志输出控制类 (Description)
16 | * ---------------------------------------------------
17 | */
18 | public class LogUtils {
19 | /**
20 | * 日志输出级别NONE
21 | */
22 | public static final int LEVEL_NONE = 0;
23 | /**
24 | * 日志输出级别V
25 | */
26 | public static final int LEVEL_VERBOSE = 1;
27 | /**
28 | * 日志输出级别D
29 | */
30 | public static final int LEVEL_DEBUG = 2;
31 | /**
32 | * 日志输出级别I
33 | */
34 | public static final int LEVEL_INFO = 3;
35 | /**
36 | * 日志输出级别W
37 | */
38 | public static final int LEVEL_WARN = 4;
39 | /**
40 | * 日志输出级别E
41 | */
42 | public static final int LEVEL_ERROR = 5;
43 | /**
44 | * 日志输出级别 输出所有
45 | */
46 | public static final int LEVEL_ALL = 6;
47 |
48 | /**
49 | * 日志输出时的TAG
50 | */
51 | private static String mTag = "wyh";
52 | /**
53 | * 是否允许输出log
54 | */
55 | private static int mDebuggable = LEVEL_ALL;
56 |
57 | /**
58 | * 用于记时的变量
59 | */
60 | private static long mTimestamp = 0;
61 | /**
62 | * 写文件的锁对象
63 | */
64 | private static final Object mLogLock = new Object();
65 |
66 | /**
67 | * 以级别为 d 的形式输出LOG
68 | */
69 | public static void v(String msg) {
70 | if (mDebuggable >= LEVEL_VERBOSE) {
71 | Log.v(mTag, msg);
72 | }
73 | }
74 |
75 | /**
76 | * 以级别为 d 的形式输出LOG
77 | */
78 | public static void d(String msg) {
79 | if (mDebuggable >= LEVEL_DEBUG) {
80 | Log.d(mTag, msg);
81 | }
82 | }
83 |
84 | /**
85 | * 以级别为 i 的形式输出LOG
86 | */
87 | public static void i(String msg) {
88 | if (mDebuggable >= LEVEL_INFO) {
89 | Log.i(mTag, msg);
90 | }
91 | }
92 |
93 |
94 | /**
95 | * 以级别为 i 的形式输出LOG
96 | */
97 | public static void i(String tag,String msg) {
98 | if (mDebuggable >= LEVEL_INFO) {
99 | Log.i(tag, msg);
100 | }
101 | }
102 |
103 | /**
104 | * 以级别为 w 的形式输出LOG
105 | */
106 | public static void w(String msg) {
107 | if (mDebuggable >= LEVEL_WARN) {
108 | Log.w(mTag, msg);
109 | }
110 | }
111 |
112 | /**
113 | * 以级别为 w 的形式输出Throwable
114 | */
115 | public static void w(Throwable tr) {
116 | if (mDebuggable >= LEVEL_WARN) {
117 | Log.w(mTag, "", tr);
118 | }
119 | }
120 |
121 | /**
122 | * 以级别为 w 的形式输出LOG信息和Throwable
123 | */
124 | public static void w(String msg, Throwable tr) {
125 | if (mDebuggable >= LEVEL_WARN && null != msg) {
126 | Log.w(mTag, msg, tr);
127 | }
128 | }
129 |
130 | /**
131 | * 以级别为 e 的形式输出LOG
132 | */
133 | public static void e(String msg) {
134 | if (mDebuggable >= LEVEL_ERROR) {
135 | Log.e(mTag, msg);
136 | }
137 | }
138 |
139 | /**
140 | * 以级别为 e 的形式输出Throwable
141 | */
142 | public static void e(Throwable tr) {
143 | if (mDebuggable >= LEVEL_ERROR) {
144 | Log.e(mTag, "", tr);
145 | }
146 | }
147 |
148 | /**
149 | * 以级别为 e 的形式输出LOG信息和Throwable
150 | */
151 | public static void e(String msg, Throwable tr) {
152 | if (mDebuggable >= LEVEL_ERROR && null != msg) {
153 | Log.e(mTag, msg, tr);
154 | }
155 | }
156 |
157 | /**
158 | * 把Log存储到文件中
159 | *
160 | * @param log 需要存储的日志
161 | * @param path 存储路径
162 | */
163 | // public static void log2File(String log, String path) {
164 | // log2File(log, path, true);
165 | // }
166 | //
167 | // public static void log2File(String log, String path, boolean append) {
168 | // synchronized (mLogLock) {
169 | // FileUtils.writeFile(log + "\r\n", path, append);
170 | // }
171 | // }
172 |
173 | /**
174 | * 以级别为 e 的形式输出msg信息,附带时间戳,用于输出一个时间段起始点
175 | *
176 | * @param msg 需要输出的msg
177 | */
178 | public static void msgStartTime(String msg) {
179 | mTimestamp = System.currentTimeMillis();
180 | if (!TextUtils.isEmpty(msg)) {
181 | e("[Started:" + mTimestamp + "]" + msg);
182 | }
183 | }
184 |
185 | /**
186 | * 以级别为 e 的形式输出msg信息,附带时间戳,用于输出一个时间段结束点* @param msg 需要输出的msg
187 | */
188 | public static void elapsed(String msg) {
189 | long currentTime = System.currentTimeMillis();
190 | long elapsedTime = currentTime - mTimestamp;
191 | mTimestamp = currentTime;
192 | e("[Elapsed:" + elapsedTime + "]" + msg);
193 | }
194 |
195 | public static void printList(List list) {
196 | if (list == null || list.size() < 1) {
197 | return;
198 | }
199 | int size = list.size();
200 | i("---begin---");
201 | for (int i = 0; i < size; i++) {
202 | i(i + ":" + list.get(i).toString());
203 | }
204 | i("---end---");
205 | }
206 |
207 | public static void printArray(T[] array) {
208 | if (array == null || array.length < 1) {
209 | return;
210 | }
211 | int length = array.length;
212 | i("---begin---");
213 | for (int i = 0; i < length; i++) {
214 | i(i + ":" + array[i].toString());
215 | }
216 | i("---end---");
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjxz/logistics_information/LogisticsInformationView.java:
--------------------------------------------------------------------------------
1 | package com.sjxz.logistics_information;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.text.Layout;
8 | import android.text.StaticLayout;
9 | import android.text.TextPaint;
10 | import android.util.AttributeSet;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.WindowManager;
14 |
15 | import java.util.ArrayList;
16 | import java.util.HashMap;
17 | import java.util.List;
18 |
19 | /**
20 | * @author WYH_Healer
21 | * @email 3425934925@qq.com
22 | * Created by xz on 2017/2/20.
23 | * Role:自定义的物流信息界面
24 | */
25 | public class LogisticsInformationView extends View {
26 |
27 | Context context;
28 |
29 | /**
30 | * 绘制工具:画笔
31 | * */
32 |
33 | Paint paint;
34 | Paint mPaintPhone;
35 | TextPaint textPaintPhone;
36 |
37 | /**
38 | * 绘制参数
39 | * */
40 |
41 | int interval;//间隔:本文中指代物流信息和物流时间的间隔
42 |
43 | float radius;//圆形半径
44 |
45 | int left = 20;//距离左边边距
46 | int top = 20;//距离顶部边距(相当于XML中的Margin或者Padding效果)
47 |
48 | int windowWidth;//获取屏幕的宽高,避免定义数据过长超出屏幕
49 | int windowHeight;
50 |
51 | float width;
52 |
53 | String phoneNumber;//电话号码
54 | int phoneNumberWidth;//11位电话号码宽度是固定的
55 | int phoneNumberHeight;//11位电话号码高度是固定的
56 |
57 | /**
58 | * 绘制界面参数
59 | * */
60 | List logisticsDataList;
61 |
62 | List heightList;//获取每一条文本所占的高度,这里默认时间就占一行
63 |
64 | int heightTotal=0;//获取总高度,用于绘制当前界面所占的高
65 |
66 | /**
67 | * 使用Map记录存在电话号码的坐标用于点击事件的存储
68 | * 起始坐标以及截止坐标的记录
69 | * */
70 | HashMap phoneYNumber= new HashMap();
71 | HashMap stopYX= new HashMap();
72 | List stopYList=new ArrayList<>();//用于快速取出初始化的值
73 |
74 | public LogisticsInformationView(Context context) {
75 | super(context);
76 | this.context = context;
77 | init();
78 | }
79 |
80 | public LogisticsInformationView(Context context, AttributeSet attrs) {
81 | super(context, attrs);
82 | this.context = context;
83 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LogisticsInformationView);
84 | width = typedArray.getDimension(R.styleable.LogisticsInformationView_width, 5);//获取XML中设置的高度(圆形半径)
85 | radius = typedArray.getDimension(R.styleable.LogisticsInformationView_radius, 10);
86 | //程序在运行时维护了一个 TypedArray的池,程序调用时,会向该池中请求一个实例
87 | //用完之后,调用 recycle() 方法来释放该实例,从而使其可被其他模块复用。所以一定要调用
88 |
89 | typedArray.recycle();
90 | init();
91 | }
92 |
93 | public LogisticsInformationView(Context context, AttributeSet attrs, int defStyleAttr) {
94 | super(context, attrs, defStyleAttr);
95 | this.context = context;
96 | init();
97 | }
98 |
99 | /**
100 | * 初始化相关参数
101 | * */
102 | private void init() {
103 | paint = new Paint(Paint.ANTI_ALIAS_FLAG);
104 | paint.setColor(getResources().getColor(R.color.normalColor));
105 |
106 | mPaintPhone = new Paint(Paint.ANTI_ALIAS_FLAG);
107 | mPaintPhone.setColor(getResources().getColor(R.color.colorPrimaryDark));
108 | mPaintPhone.setTextSize(35.0F);
109 |
110 | textPaintPhone= new TextPaint();
111 | textPaintPhone.setColor(getResources().getColor(R.color.colorPrimaryDark));
112 | textPaintPhone.setTextSize(35.0F);
113 | textPaintPhone.setAntiAlias(true);
114 |
115 | interval = dip2px(context,24);
116 |
117 | WindowManager wm = (WindowManager) getContext()
118 | .getSystemService(Context.WINDOW_SERVICE);
119 |
120 | windowWidth = wm.getDefaultDisplay().getWidth();
121 | windowHeight = wm.getDefaultDisplay().getHeight();
122 |
123 |
124 | }
125 |
126 |
127 | /**
128 | *传递相关物流信息对象,这里的对象可以更改为你的自定义的对象
129 | * */
130 | public void setLogisticsDataList( List logisticsDataList){
131 | this.logisticsDataList=logisticsDataList;
132 |
133 | heightList=new ArrayList<>();
134 | TextPaint textPaint=new TextPaint();
135 | textPaint.setTextSize(35.0F);
136 |
137 | //获取模拟电话宽度数据
138 | StaticLayout phoneLayout = new StaticLayout("15555555555", textPaint, (int) (windowWidth * 0.8), Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true);
139 | phoneNumberWidth= (int) phoneLayout.getLineWidth(0);
140 | phoneNumberHeight=phoneLayout.getHeight();
141 | //计算每行字符所占的高度
142 | for(int i=0;iphoneNumberWidth){
332 | phoneYNumber.put((float) ( heightData+(isTop?-10:10)+layoutPhone.getHeight()),phoneNumber);
333 | stopYX.put((float) ( heightData+(isTop?-10:10)+layoutPhone.getHeight()),left * 2 + radius * 2 + 10+(layout.getLineWidth(layout.getLineCount()-1))+phoneNumberWidth);
334 | stopYList.add((float) ( heightData+(isTop?-10:10)+layoutPhone.getHeight()));
335 | mPaintPhone.setColor(getResources().getColor(R.color.colorPrimaryDark));
336 | canvas.drawText(phoneNumber, left * 2 + radius * 2 + 10+(layout.getLineWidth(layout.getLineCount()-1)), layoutFirst+ heightData+(isTop?-10:10), mPaintPhone);
337 | }else{
338 | phoneYNumber.put((float) (layoutFirst+heightData +(isTop?0:top)+layoutPhone.getHeight()),phoneNumber);
339 | stopYX.put((float) (layoutFirst+heightData +(isTop?0:top)+layoutPhone.getHeight()),left * 2 + radius * 2 + 10+phoneNumberWidth);
340 | stopYList.add((float) (layoutFirst+heightData +(isTop?0:top)+layoutPhone.getHeight()));
341 | //5.1获取之前的高度
342 | canvas.save();//很重要,不然会样式出错
343 | canvas.translate(left * 2 + radius * 2 + 10, layoutFirst+heightData +(isTop?0:top));
344 | layoutPhone.draw(canvas);
345 | canvas.restore();//重置
346 | }
347 | }else{
348 | //有后续
349 | //获取最后一段的宽度
350 | StaticLayout layoutLast = new StaticLayout(splitData[1], textPaint, (int) (windowWidth * 0.8), Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true);
351 |
352 | //2.判断是剩下的宽度是否能够容纳手机号码宽度
353 | if((int) (windowWidth * 0.8)-layout.getLineWidth(layout.getLineCount()-1)>phoneNumberWidth){
354 | //3.1.如果是可以容纳的情况
355 | //记录Map坐标轴数据
356 | phoneYNumber.put((float) ( heightData+(isTop?-10:10)+layoutPhone.getHeight()),phoneNumber);
357 | stopYX.put((float) ( heightData+(isTop?-10:10)+layoutPhone.getHeight()),left * 2 + radius * 2 + 10+(layout.getLineWidth(layout.getLineCount()-1))+phoneNumberWidth);
358 | stopYList.add((float) ( heightData+(isTop?-10:10)+layoutPhone.getHeight()));
359 | mPaintPhone.setColor(getResources().getColor(R.color.colorPrimaryDark));
360 | canvas.drawText(phoneNumber, left * 2 + radius * 2 + 10+(layout.getLineWidth(layout.getLineCount()-1)), layoutFirst+ heightData+(isTop?-10:10), mPaintPhone);
361 | if((int) (windowWidth * 0.8)-layout.getLineWidth(layout.getLineCount()-1)-phoneNumberWidth>layoutLast.getLineWidth(0)){
362 | //4.1.如果一行就可以绘制完成
363 | mPaintPhone.setColor(getResources().getColor(isTop?R.color.checkColor:R.color.normalColor));
364 | canvas.drawText(splitData[1], left * 2 + radius * 2 + 10+(layout.getLineWidth(layout.getLineCount()-1)+phoneNumberWidth),layoutFirst+ heightData+(isTop?-10:10), mPaintPhone);
365 | }else{
366 | //4.2.一行不可以完成的情况下继续分割成两份,一份是drawText拼接到最后,一份是StaticLayout另起一行绘制
367 | double percentLast=(((int) (windowWidth * 0.8)-layout.getLineWidth(layout.getLineCount()-1)-phoneNumberWidth));
368 | //获取字符能显示的最大Length
369 | double maxLength=percentLast/35.0F;//这里的35.0是一个中文字体的大小
370 | String lastStringPre=splitData[1].substring(0, (int) maxLength+1);//获取最大数据的长度的字符串拼接
371 | String lastStringLas=splitData[1].substring((int) maxLength+1);
372 | mPaintPhone.setColor(getResources().getColor(isTop?R.color.checkColor:R.color.normalColor));
373 | canvas.drawText(lastStringPre, left * 2 + radius * 2 + 10+(layout.getLineWidth(layout.getLineCount()-1)+phoneNumberWidth),layoutFirst+ heightData+(isTop?-10:10), mPaintPhone);
374 |
375 | //另起一行写剩余的数据
376 |
377 | StaticLayout layoutlastString = new StaticLayout(lastStringLas, textPaint, (int) (windowWidth * 0.8), Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true);
378 | canvas.save();//很重要,不然会样式出错
379 | canvas.translate(left * 2 + radius * 2 + 10,layoutFirst +heightData +(isTop?0:top));
380 | layoutlastString.draw(canvas);
381 | canvas.restore();//重置
382 | }
383 | }else{
384 | //3.2.如果是不可以容纳的情况,现在默认电话号码不可以容纳的情况就另起一行使用StaticLayout绘制
385 | phoneYNumber.put((float) (layoutFirst+heightData +(isTop?0:top)+layoutPhone.getHeight()),phoneNumber);
386 | stopYX.put((float) (layoutFirst+heightData +(isTop?0:top)+layoutPhone.getHeight()),left * 2 + radius * 2 + 10+phoneNumberWidth);
387 | stopYList.add((float) (layoutFirst+heightData +(isTop?0:top)+layoutPhone.getHeight()));
388 | //5.1获取之前的高度
389 | canvas.save();//很重要,不然会样式出错
390 | canvas.translate(left * 2 + radius * 2 + 10, layoutFirst+heightData +(isTop?0:top));
391 | layoutPhone.draw(canvas);
392 | canvas.restore();//重置
393 | if((int) (windowWidth * 0.8)-phoneNumberWidth>layoutLast.getLineWidth(0)){
394 | //4.1.如果一行就可以绘制完成
395 | mPaintPhone.setColor(getResources().getColor(isTop?R.color.checkColor:R.color.normalColor));
396 | canvas.drawText(splitData[1], left * 2 + radius * 2 + 10+phoneNumberWidth, layoutPhone.getHeight()+layoutFirst+heightData+(isTop?-10:10), mPaintPhone);
397 | }else{
398 | //4.2.一行不可以完成的情况下继续分割成两份,一份是drawText拼接到最后,一份是StaticLayout另起一行绘制
399 | double percentLast=(int) (windowWidth * 0.8)-phoneNumberWidth;
400 | //获取字符能显示的最大Length
401 | double maxLength=percentLast/35.0F;//这里的35.0是一个中文字体的大小
402 |
403 | String lastStringPre=splitData[1].substring(0, (int) maxLength+1);//获取最大数据的长度的字符串拼接
404 | String lastStringLas=splitData[1].substring((int) maxLength+1);
405 | mPaintPhone.setColor(getResources().getColor(isTop?R.color.checkColor:R.color.normalColor));
406 | canvas.drawText(lastStringPre, left * 2 + radius * 2 + 10+phoneNumberWidth,layoutPhone.getHeight()+layoutFirst+ heightData+(isTop?-10:10), mPaintPhone);
407 |
408 | //另起一行写剩余的数据
409 |
410 | StaticLayout layoutlastString = new StaticLayout(lastStringLas, textPaint, (int) (windowWidth * 0.8), Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true);
411 | canvas.save();//很重要,不然会样式出错
412 | canvas.translate(left * 2 + radius * 2 + 10,layoutPhone.getHeight()+layoutFirst +heightData +(isTop?0:top));
413 | layoutlastString.draw(canvas);
414 | canvas.restore();//重置
415 | }
416 | }
417 |
418 | }
419 | }
420 |
421 |
422 | /**
423 | * 实现电话号码的点击事件
424 | * */
425 | @Override
426 | public boolean onTouchEvent(MotionEvent event) {
427 | switch (event.getAction()){
428 | case MotionEvent.ACTION_DOWN:
429 | //按下(这里默认点击一下就弹出Dialog样式)
430 | float x = event.getX();
431 | float y = event.getY();
432 | //判断点击的范围类型
433 | for(int i=0;i