├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── licheng │ │ └── android │ │ └── expressview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── licheng │ │ │ └── android │ │ │ └── expressview │ │ │ ├── MainActivity.java │ │ │ ├── entity │ │ │ └── ExpressMessageBean.java │ │ │ ├── expressview │ │ │ ├── ExpressView.java │ │ │ ├── ExpressViewAdapter.java │ │ │ └── ExpressViewData.java │ │ │ └── utils │ │ │ ├── DeviceUtils.java │ │ │ ├── JsonUtils.java │ │ │ ├── TimeUtils.java │ │ │ └── ToastUtil.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── licheng │ └── android │ └── expressview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── screen └── express.gif └── 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 物流状态控件 2 | 3 | ------ 4 | 5 | ## 介绍 6 | 一款简单的物流状态进度展示自定义View,仅供参考学习 7 | 8 | ## **效果图** 9 | ![image](https://github.com/xiaomanzijia/ExpressView/blob/master/screen/express.gif) 10 | 11 | ## **使用方法** 12 | 13 | **布局文件** 14 | ```java 15 | 29 | ``` 30 | 31 | **控件属性介绍** 32 | 33 | ```java 34 | firstExpressCircleMarginLeft 第一个物流状态点距离父控件坐边的间距 35 | firstExpressCircleMarginTop 第一个物流状态点距离父控件上边的间距 36 | expressCircleRadius 物流状态点内圈半径 37 | expressCircleOuterRadius 物流状态点外圈半径 38 | circleToTextMargin 物流状态提示圈到文字背景的距离 39 | expressTextMargin 文字距离背景边距 40 | expressTextVecPadding 每个物流信息竖直方向的间距 41 | expressTextSize 文字大小 42 | expressTimeTextSize 时间文字大小 43 | isTimeButtonVisible 是否显示时间和文字按钮 44 | ``` 45 | 46 | **客户端** 47 | ```java 48 | //数据源 49 | final List list = new ArrayList<>(); 50 | ExpressMessageBean bean = new ExpressMessageBean(); 51 | bean.setFlowState(1); 52 | bean.setFlowStateBtRight("购买流程"); 53 | bean.setCreateTime(1487259871184l); 54 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259871184l)); 55 | bean.setOpContent("您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 189****2298"); 56 | list.add(bean); 57 | bean = new ExpressMessageBean(); 58 | bean.setFlowState(4); 59 | bean.setFlowStateBtLeft("同意退款"); //设置左右按钮文字 60 | bean.setFlowStateBtRight("拒绝退款"); 61 | bean.setCreateTime(1487259991260l); 62 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 63 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 64 | list.add(bean); 65 | bean = new ExpressMessageBean(); 66 | bean.setFlowState(5); 67 | bean.setCreateTime(1487259871184l); 68 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259871184l)); 69 | bean.setOpContent("您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 189****2298"); 70 | list.add(bean); 71 | bean = new ExpressMessageBean(); 72 | bean.setFlowState(1); 73 | bean.setFlowStateBtRight("购买流程"); //设置右按钮文字 74 | bean.setCreateTime(1487259991260l); 75 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 76 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 77 | list.add(bean); 78 | //数据源适配 79 | ExpressViewAdapter adapter = new ExpressViewAdapter(list) { 80 | @Override 81 | public ExpressViewData bindData(ExpressView expressView, int position, ExpressMessageBean expressMessageBean) { 82 | ExpressViewData data = new ExpressViewData(); 83 | data.setContent(expressMessageBean.getOpContent()); 84 | data.setTime(expressMessageBean.getCreateTimeFormat()); 85 | data.setLeftBtnText(expressMessageBean.getFlowStateBtLeft()); 86 | data.setRightBtnText(expressMessageBean.getFlowStateBtRight()); 87 | return data; 88 | } 89 | }; 90 | expressView.setAdapter(adapter); 91 | adapter.notifyDataChanged(); 92 | //处理点击事件 93 | expressView.setOnExpressItemButtonClickListener(new ExpressView.OnExpressItemButtonClickListener() { 94 | @Override 95 | public void onExpressItemButtonClick(int position, int status) { 96 | switch (list.get(position).getFlowState()){ 97 | case 1: 98 | if(status == 1){ //购买流程 99 | ToastUtil.ToastBottow(TestActivity.this, list.get(position).getFlowStateBtRight()); 100 | } 101 | break; 102 | case 4: 103 | if(status == 0) { //同意退款 104 | ToastUtil.ToastBottow(TestActivity.this, list.get(position).getFlowStateBtLeft()); 105 | } else if(status == 1){ //拒绝退款 106 | ToastUtil.ToastBottow(TestActivity.this, list.get(position).getFlowStateBtRight()); 107 | } 108 | break; 109 | default: 110 | break; 111 | } 112 | } 113 | }); 114 | ``` 115 | 116 | ## 待完善 117 | 118 | ```java 119 | 1、处理滑动冲突 120 | 2、处理滑动到顶部和到底部停止滑动的逻辑 121 | 3、实现弹性滑动的效果 122 | ``` 123 | 124 | 125 | ## 博客文章介绍 126 | [http://www.jianshu.com/p/2d87f62d5d27](http://www.jianshu.com/p/2d87f62d5d27) 127 | 128 | 129 | ## License 130 | 131 | Copyright 2017 LiCheng 132 | 133 | Licensed under the Apache License, Version 2.0 (the "License"); 134 | you may not use this file except in compliance with the License. 135 | You may obtain a copy of the License at 136 | 137 | http://www.apache.org/licenses/LICENSE-2.0 138 | 139 | Unless required by applicable law or agreed to in writing, software 140 | distributed under the License is distributed on an "AS IS" BASIS, 141 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142 | See the License for the specific language governing permissions and 143 | limitations under the License. 144 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.licheng.android.expressview" 8 | minSdkVersion 14 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.2.0' 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.google.code.gson:gson:2.6.2' 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/licheng/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/licheng/android/expressview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview; 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("com.licheng.android.expressview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | import com.licheng.android.expressview.entity.ExpressMessageBean; 7 | import com.licheng.android.expressview.expressview.ExpressView; 8 | import com.licheng.android.expressview.expressview.ExpressViewAdapter; 9 | import com.licheng.android.expressview.expressview.ExpressViewData; 10 | import com.licheng.android.expressview.utils.TimeUtils; 11 | import com.licheng.android.expressview.utils.ToastUtil; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class MainActivity extends AppCompatActivity { 17 | 18 | private ExpressViewAdapter adapter; 19 | 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main); 25 | 26 | ExpressView expressView = (ExpressView) findViewById(R.id.expressview); 27 | 28 | 29 | final List list = new ArrayList<>(); 30 | ExpressMessageBean bean = new ExpressMessageBean(); 31 | bean.setFlowState(1); 32 | bean.setFlowStateBtRight("购买流程"); 33 | bean.setCreateTime(1487259871184l); 34 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259871184l)); 35 | bean.setOpContent("您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 18827065959"); 36 | list.add(bean); 37 | bean = new ExpressMessageBean(); 38 | bean.setFlowState(2); 39 | bean.setCreateTime(1487259991260l); 40 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 41 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 42 | list.add(bean); 43 | bean = new ExpressMessageBean(); 44 | bean.setFlowState(3); 45 | bean.setCreateTime(1487259871184l); 46 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259871184l)); 47 | bean.setOpContent("您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 18827065959"); 48 | list.add(bean); 49 | bean = new ExpressMessageBean(); 50 | bean.setFlowState(4); 51 | bean.setFlowStateBtLeft("同意退款"); //设置左右按钮文字 52 | bean.setFlowStateBtRight("拒绝退款"); 53 | bean.setCreateTime(1487259991260l); 54 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 55 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 56 | list.add(bean); 57 | bean = new ExpressMessageBean(); 58 | bean.setFlowState(5); 59 | bean.setCreateTime(1487259871184l); 60 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259871184l)); 61 | bean.setOpContent("您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 18827065959"); 62 | list.add(bean); 63 | bean = new ExpressMessageBean(); 64 | bean.setFlowState(6); 65 | bean.setCreateTime(1487259991260l); 66 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 67 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 68 | list.add(bean); 69 | bean = new ExpressMessageBean(); 70 | bean.setFlowState(7); 71 | bean.setCreateTime(1487259871184l); 72 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259871184l)); 73 | bean.setOpContent("您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 18827065959"); 74 | list.add(bean); 75 | bean = new ExpressMessageBean(); 76 | bean.setFlowState(1); 77 | bean.setFlowStateBtRight("购买流程"); //设置右按钮文字 78 | bean.setCreateTime(1487259991260l); 79 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 80 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 81 | list.add(bean); 82 | 83 | adapter = new ExpressViewAdapter(list) { 84 | @Override 85 | public ExpressViewData bindData(ExpressView expressView, int position, ExpressMessageBean expressMessageBean) { 86 | ExpressViewData data = new ExpressViewData(); 87 | data.setContent(expressMessageBean.getOpContent()); 88 | data.setTime(expressMessageBean.getCreateTimeFormat()); 89 | data.setLeftBtnText(expressMessageBean.getFlowStateBtLeft()); 90 | data.setRightBtnText(expressMessageBean.getFlowStateBtRight()); 91 | return data; 92 | } 93 | }; 94 | 95 | expressView.setAdapter(adapter); 96 | adapter.notifyDataChanged(); 97 | 98 | //延迟4秒添加2条数据 99 | expressView.postDelayed(new Runnable() { 100 | @Override 101 | public void run() { 102 | ExpressMessageBean bean = new ExpressMessageBean(); 103 | bean.setFlowState(1); 104 | bean.setFlowStateBtRight("购买流程"); //设置右按钮文字 105 | bean.setCreateTime(1487259991260l); 106 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 107 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 108 | list.add(bean); 109 | bean = new ExpressMessageBean(); 110 | bean.setFlowState(1); 111 | bean.setFlowStateBtRight("购买流程"); //设置右按钮文字 112 | bean.setCreateTime(1487259991260l); 113 | bean.setCreateTimeFormat(TimeUtils.millis2String(1487259991260l)); 114 | bean.setOpContent("天空套 0.1200 1个-申请退款"); 115 | list.add(bean); 116 | adapter.notifyDataChanged(); 117 | } 118 | }, 4000); 119 | 120 | //处理点击事件 121 | expressView.setOnExpressItemButtonClickListener(new ExpressView.OnExpressItemButtonClickListener() { 122 | @Override 123 | public void onExpressItemButtonClick(int position, int status) { 124 | switch (list.get(position).getFlowState()){ 125 | case 1: 126 | if(status == 1){ //购买流程 127 | ToastUtil.ToastBottow(MainActivity.this, list.get(position).getFlowStateBtRight()); 128 | } 129 | break; 130 | case 4: 131 | if(status == 0) { //同意退款 132 | ToastUtil.ToastBottow(MainActivity.this, list.get(position).getFlowStateBtLeft()); 133 | } else if(status == 1){ //拒绝退款 134 | ToastUtil.ToastBottow(MainActivity.this, list.get(position).getFlowStateBtRight()); 135 | } 136 | break; 137 | default: 138 | break; 139 | } 140 | } 141 | }); 142 | 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/entity/ExpressMessageBean.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.entity; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * 订单物流状态 7 | * Created by licheng on 22/2/17. 8 | */ 9 | 10 | public class ExpressMessageBean { 11 | 12 | 13 | /** 14 | * id : 493876 15 | * orderId : MOTZH170216000000013_1375 16 | * goodsId : MZH170215000000004 17 | * opContent : 您已付款0.1200元,购买 地下城与勇士/广东区/广东1区帐号,请联系卖家卡罗特将密保手机绑定您的手机号 18827065959 18 | * buyerId : 502 19 | * isRead : false 20 | * createTime : 1487259871184 21 | * msgType : 2 22 | * flowState : 1 23 | * isFlowMsg : true 24 | * dataType : 1 25 | */ 26 | 27 | @SerializedName("id") 28 | private int id; 29 | @SerializedName("orderId") 30 | private String orderId; 31 | @SerializedName("goodsId") 32 | private String goodsId; 33 | @SerializedName("opContent") 34 | private String opContent; 35 | @SerializedName("buyerId") 36 | private int buyerId; 37 | @SerializedName("isRead") 38 | private boolean isRead; 39 | @SerializedName("createTime") 40 | private long createTime; 41 | @SerializedName("msgType") 42 | private int msgType; 43 | @SerializedName("flowState") 44 | private int flowState; 45 | @SerializedName("isFlowMsg") 46 | private boolean isFlowMsg; 47 | @SerializedName("dataType") 48 | private int dataType; 49 | 50 | private String createTimeFormat; 51 | private String flowStateBtLeft;//左边按钮文字 52 | private String flowStateBtRight;//右边按钮文字 53 | 54 | public String getFlowStateBtLeft() { 55 | return flowStateBtLeft; 56 | } 57 | 58 | public void setFlowStateBtLeft(String flowStateBtLeft) { 59 | this.flowStateBtLeft = flowStateBtLeft; 60 | } 61 | 62 | public String getFlowStateBtRight() { 63 | return flowStateBtRight; 64 | } 65 | 66 | public void setFlowStateBtRight(String flowStateBtRight) { 67 | this.flowStateBtRight = flowStateBtRight; 68 | } 69 | 70 | public String getCreateTimeFormat() { 71 | return createTimeFormat; 72 | } 73 | 74 | public void setCreateTimeFormat(String createTimeFormat) { 75 | this.createTimeFormat = createTimeFormat; 76 | } 77 | 78 | public int getId() { 79 | return id; 80 | } 81 | 82 | public void setId(int id) { 83 | this.id = id; 84 | } 85 | 86 | public String getOrderId() { 87 | return orderId; 88 | } 89 | 90 | public void setOrderId(String orderId) { 91 | this.orderId = orderId; 92 | } 93 | 94 | public String getGoodsId() { 95 | return goodsId; 96 | } 97 | 98 | public void setGoodsId(String goodsId) { 99 | this.goodsId = goodsId; 100 | } 101 | 102 | public String getOpContent() { 103 | return opContent; 104 | } 105 | 106 | public void setOpContent(String opContent) { 107 | this.opContent = opContent; 108 | } 109 | 110 | public int getBuyerId() { 111 | return buyerId; 112 | } 113 | 114 | public void setBuyerId(int buyerId) { 115 | this.buyerId = buyerId; 116 | } 117 | 118 | public boolean isIsRead() { 119 | return isRead; 120 | } 121 | 122 | public void setIsRead(boolean isRead) { 123 | this.isRead = isRead; 124 | } 125 | 126 | public long getCreateTime() { 127 | return createTime; 128 | } 129 | 130 | public void setCreateTime(long createTime) { 131 | this.createTime = createTime; 132 | } 133 | 134 | public int getMsgType() { 135 | return msgType; 136 | } 137 | 138 | public void setMsgType(int msgType) { 139 | this.msgType = msgType; 140 | } 141 | 142 | public int getFlowState() { 143 | return flowState; 144 | } 145 | 146 | public void setFlowState(int flowState) { 147 | this.flowState = flowState; 148 | } 149 | 150 | public boolean isIsFlowMsg() { 151 | return isFlowMsg; 152 | } 153 | 154 | public void setIsFlowMsg(boolean isFlowMsg) { 155 | this.isFlowMsg = isFlowMsg; 156 | } 157 | 158 | public int getDataType() { 159 | return dataType; 160 | } 161 | 162 | public void setDataType(int dataType) { 163 | this.dataType = dataType; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/expressview/ExpressView.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.expressview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.Point; 9 | import android.text.Layout; 10 | import android.text.StaticLayout; 11 | import android.text.TextPaint; 12 | import android.text.TextUtils; 13 | import android.util.AttributeSet; 14 | import android.util.Log; 15 | import android.view.MotionEvent; 16 | import android.view.View; 17 | import android.view.ViewConfiguration; 18 | 19 | import com.licheng.android.expressview.R; 20 | import com.licheng.android.expressview.utils.DeviceUtils; 21 | import com.licheng.android.expressview.utils.JsonUtils; 22 | 23 | import java.util.HashMap; 24 | import java.util.Iterator; 25 | import java.util.Map; 26 | 27 | /** 28 | * 物流状态View 29 | * Created by licheng on 19/2/17. 30 | */ 31 | 32 | public class ExpressView extends View implements ExpressViewAdapter.OnDataChangedListener { 33 | 34 | 35 | private int screenWidth; 36 | private int screenHeight; 37 | private int width, height; //当前View宽高 38 | private int viewWidth, viewHeight; //当前View宽高 39 | private int firstExpressCircleMarginLeft = DeviceUtils.dipToPx(getContext(), 16); 40 | private int firstExpressCircleMarginTop = DeviceUtils.dipToPx(getContext(), 40); 41 | 42 | private int expressCircleRadius = DeviceUtils.dipToPx(getContext(), 6);//物流状态提示圈半径 43 | private int expressCircleCurrentRadius = DeviceUtils.dipToPx(getContext(), 3);//物流状态提示圈半径 44 | private int expressCircleOuterRadius = DeviceUtils.dipToPx(getContext(), 8);//物流状态提示圈外半径 45 | 46 | private int circleToTextMargin = DeviceUtils.dipToPx(getContext(), 12);//物流状态提示圈到文字背景的距离 47 | 48 | private int expressTextBackgroundWidth; //文字背景宽 49 | private int expressTextMargin = DeviceUtils.dipToPx(getContext(), 8); //文字距离背景边距 50 | 51 | private int expressTextVecPadding = DeviceUtils.dipToPx(getContext(), 5); //每个物流信息竖直方向的间距 52 | 53 | private int expressTextToTimeTextPadding = DeviceUtils.dipToPx(getContext(), 6); //物流文字距离时间文字的间距 54 | 55 | private int expressButtonTextHeight; //按钮文字高度 56 | 57 | private boolean isTimeButtonVisible = false; //是否需要显示时间和按钮 58 | 59 | private Paint expressCirclePaint; //物流状态提示圈 60 | private Paint expressTextBackgroundPaint; //文字背景 61 | private TextPaint expressTextPaint; //文字 62 | private TextPaint timeTextPaint; //时间文字 63 | private TextPaint buttonTextPaint; //按钮文字 64 | private Paint bgPaint; 65 | private Paint expressLinePaint;//物流线条 66 | private int expressTextSize;//文字大小 67 | private int expressTimeTextSize;//时间文字大小 68 | 69 | private int contentDrawHeight; //根据内容绘制的高度 70 | 71 | private Map buttonTopPositionMap; //用于存储点击按钮左上角坐标 72 | private int firstButtonPositionY; //记录第一个按钮位置坐标 73 | 74 | // private int[] location = new int[2]; 75 | 76 | private ExpressViewAdapter mAdapter; 77 | 78 | public ExpressView(Context context) { 79 | super(context); 80 | initPaint(context); 81 | } 82 | 83 | public ExpressView(Context context, AttributeSet attrs) { 84 | super(context, attrs); 85 | initTypeArray(context, attrs); 86 | initPaint(context); 87 | } 88 | 89 | public ExpressView(Context context, AttributeSet attrs, int defStyleAttr) { 90 | super(context, attrs, defStyleAttr); 91 | initTypeArray(context, attrs); 92 | initPaint(context); 93 | } 94 | 95 | 96 | private void initTypeArray(Context context, AttributeSet attrs) { 97 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ExpressView); 98 | firstExpressCircleMarginLeft = (int) array.getDimension(R.styleable.ExpressView_firstExpressCircleMarginLeft, 16); 99 | firstExpressCircleMarginTop = (int) array.getDimension(R.styleable.ExpressView_firstExpressCircleMarginTop, 16); 100 | expressCircleRadius = (int) array.getDimension(R.styleable.ExpressView_expressCircleRadius, 6); 101 | expressCircleOuterRadius = (int) array.getDimension(R.styleable.ExpressView_expressCircleOuterRadius, 8); 102 | circleToTextMargin = (int) array.getDimension(R.styleable.ExpressView_circleToTextMargin, 12); 103 | expressTextMargin = (int) array.getDimension(R.styleable.ExpressView_expressTextMargin, 8); 104 | expressTextVecPadding = (int) array.getDimension(R.styleable.ExpressView_expressTextVecPadding, 5); 105 | expressTextSize = (int) array.getDimension(R.styleable.ExpressView_expressTextSize, 16); 106 | expressTimeTextSize = (int) array.getDimension(R.styleable.ExpressView_expressTimeTextSize, 16); 107 | isTimeButtonVisible = array.getBoolean(R.styleable.ExpressView_isTimeButtonVisible, false); 108 | array.recycle(); 109 | 110 | buttonTopPositionMap = new HashMap<>(); 111 | buttonTopPositionMap.put(0, new Point(0, 0)); //设置初始值 112 | } 113 | 114 | private void initPaint(Context context) { 115 | 116 | touchDistance = ViewConfiguration.get(context).getScaledTouchSlop(); 117 | 118 | screenHeight = DeviceUtils.getScreenHeight(context); 119 | screenWidth = DeviceUtils.getScreenWidth(context); 120 | 121 | //物流状态提示圈 122 | expressCirclePaint = new Paint(); 123 | expressCirclePaint.setColor(Color.parseColor("#969696")); 124 | expressCirclePaint.setStyle(Paint.Style.FILL); 125 | expressCirclePaint.setAntiAlias(true); 126 | expressCirclePaint.setStrokeWidth(DeviceUtils.dipToPx(getContext(), 2)); 127 | 128 | expressTextBackgroundPaint = new Paint(); 129 | expressTextBackgroundPaint.setAntiAlias(true); 130 | expressTextBackgroundPaint.setColor(Color.WHITE); 131 | expressTextBackgroundPaint.setStyle(Paint.Style.FILL); 132 | expressCirclePaint.setStrokeWidth(DeviceUtils.dipToPx(getContext(), 2)); 133 | 134 | expressTextPaint = new TextPaint(); 135 | expressTextPaint.setAntiAlias(true); 136 | expressTextPaint.setColor(Color.BLACK); 137 | expressTextPaint.setTextSize(expressTextSize); 138 | expressTextPaint.setStyle(Paint.Style.FILL); 139 | 140 | timeTextPaint = new TextPaint(); 141 | timeTextPaint.setAntiAlias(true); 142 | timeTextPaint.setColor(Color.parseColor("#969696")); 143 | timeTextPaint.setTextSize(expressTimeTextSize); 144 | timeTextPaint.setStyle(Paint.Style.FILL); 145 | 146 | buttonTextPaint = new TextPaint(); 147 | buttonTextPaint.setAntiAlias(true); 148 | buttonTextPaint.setColor(Color.parseColor("#4682B4")); 149 | buttonTextPaint.setTextSize(expressTextSize); 150 | buttonTextPaint.setStyle(Paint.Style.FILL); 151 | 152 | 153 | expressLinePaint = new Paint(); 154 | expressLinePaint.setAntiAlias(true); 155 | expressLinePaint.setColor(Color.parseColor("#969696")); 156 | expressLinePaint.setStyle(Paint.Style.FILL); 157 | expressLinePaint.setStrokeWidth(DeviceUtils.dipToPx(getContext(), 1)); 158 | 159 | bgPaint = new Paint(); 160 | bgPaint.setAntiAlias(true); 161 | bgPaint.setAlpha(30); 162 | bgPaint.setColor(Color.parseColor("#969696")); 163 | bgPaint.setStyle(Paint.Style.STROKE); 164 | 165 | } 166 | 167 | 168 | @Override 169 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 170 | width = w; 171 | height = h; 172 | Log.e("ExpressView", "当前View的width " + width + " height " + height); 173 | 174 | // getLocationOnScreen(location); 175 | // Log.e("ExpressViewOnScreen", location[0] + " " + location[1]); 176 | 177 | } 178 | 179 | @Override 180 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 181 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 182 | 183 | int sizeWidth = MeasureSpec.getSize(widthMeasureSpec); 184 | int sizeHeight = MeasureSpec.getSize(heightMeasureSpec); 185 | int modeWidth = MeasureSpec.getMode(widthMeasureSpec); 186 | int modeHeight = MeasureSpec.getMode(heightMeasureSpec); 187 | 188 | Log.e("ExpressView", "屏幕宽高 " + screenWidth + " " + screenHeight); 189 | 190 | if (modeWidth == MeasureSpec.EXACTLY) { 191 | viewWidth = sizeWidth; 192 | Log.e("ExpressView", "精确测量宽 " + viewWidth); 193 | } else { 194 | viewWidth = width; 195 | Log.e("ExpressView", "粗略测量宽 " + viewWidth); 196 | } 197 | 198 | if (modeHeight == MeasureSpec.EXACTLY) { 199 | viewHeight = sizeHeight; 200 | Log.e("ExpressView", "精确测量高 " + viewHeight); 201 | } else { 202 | viewHeight = height; 203 | Log.e("ExpressView", "粗略测量高 " + viewHeight); 204 | } 205 | 206 | 207 | viewWidth = viewWidth > screenWidth ? screenWidth : viewWidth; 208 | viewHeight = viewHeight > screenHeight ? screenHeight : viewHeight; 209 | 210 | setMeasuredDimension(viewWidth, viewHeight); 211 | 212 | expressTextBackgroundWidth = viewWidth - 2 * (firstExpressCircleMarginLeft - expressCircleRadius) - 2 * circleToTextMargin; 213 | Log.e("ExpressView", "View宽度 " + viewWidth + "绘制的文字背景宽度 " + expressTextBackgroundWidth); 214 | 215 | } 216 | 217 | @Override 218 | protected void onDraw(Canvas canvas) { 219 | 220 | 221 | int expressTextBgHeightSum = 0; 222 | int firstCirclePoint = 0, lastCirclePoint = 0; //记录第一个绘制和最后一个绘制的点位置 223 | 224 | if (isAdapterNull()) { 225 | 226 | for (int i = 0; i < mAdapter.getCount(); i++) { 227 | //物流文字高度测量 228 | 229 | ExpressViewData expressViewData = mAdapter.bindData(this, i, mAdapter.getItem(i)); 230 | 231 | String text = expressViewData.getContent(); 232 | StaticLayout layout = new StaticLayout(text, expressTextPaint, expressTextBackgroundWidth - 2 * expressTextMargin, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true); 233 | int textHeight = layout.getHeight();//计算文字高度 234 | int expressTextBgHeight = textHeight + 2 * expressTextMargin; 235 | 236 | //时间文字高度测量 237 | String timeText = "2017-02-16 23:44:31"; 238 | StaticLayout timeLayout = new StaticLayout(timeText, timeTextPaint, (expressTextBackgroundWidth - 2 * expressTextMargin) / 2, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true); 239 | int timeTextHeight = timeLayout.getHeight(); 240 | String timeShowText = expressViewData.getTime(); 241 | 242 | //按钮文字高度测量 243 | String buttonLeft = expressViewData.getLeftBtnText(); 244 | String buttonRight = expressViewData.getRightBtnText(); 245 | String buttoTxt = "立即购买"; 246 | 247 | StaticLayout buttonLayout = new StaticLayout(buttoTxt, buttonTextPaint, (expressTextBackgroundWidth - 2 * expressTextMargin) / 4, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true); 248 | int buttonTextHeight = buttonLayout.getHeight(); 249 | int buttonTextWidth = buttonLayout.getWidth(); 250 | 251 | expressButtonTextHeight = buttonTextHeight; 252 | timeTextHeight = Math.max(timeTextHeight, buttonTextHeight); 253 | 254 | 255 | if (!isTimeButtonVisible) { 256 | timeTextHeight = 0; 257 | expressTextToTimeTextPadding = 0; 258 | } 259 | 260 | 261 | //绘制提示圆圈 262 | canvas.save(); 263 | if (i == 0) { 264 | expressCirclePaint.setColor(Color.parseColor("#D2691E")); 265 | canvas.drawCircle(firstExpressCircleMarginLeft, 266 | firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i, 267 | expressCircleOuterRadius, 268 | expressCirclePaint); 269 | expressCirclePaint.setColor(Color.parseColor("#ffffff")); 270 | canvas.drawCircle(firstExpressCircleMarginLeft, 271 | firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i, 272 | expressCircleCurrentRadius, 273 | expressCirclePaint); 274 | } else { 275 | expressCirclePaint.setColor(Color.parseColor("#969696")); 276 | canvas.drawCircle(firstExpressCircleMarginLeft, 277 | firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i, 278 | expressCircleRadius, 279 | expressCirclePaint); 280 | } 281 | canvas.restore(); 282 | 283 | //获取第一个提示点和最后一个提示点坐标 284 | if (i == 0) 285 | firstCirclePoint = firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i; 286 | if (i == mAdapter.getCount() - 1) 287 | lastCirclePoint = firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i; 288 | 289 | //绘制文字背景 290 | canvas.save(); 291 | if (i == 0) { 292 | canvas.translate(firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius, 293 | firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i); 294 | expressTextBackgroundPaint.setColor(Color.parseColor("#D2691E")); 295 | canvas.drawRect(0, 0, expressTextBackgroundWidth, expressTextBgHeight + expressTextToTimeTextPadding + timeTextHeight, expressTextBackgroundPaint); 296 | expressTextBackgroundPaint.setColor(Color.parseColor("#ffffff")); 297 | canvas.drawRect(2, 2, expressTextBackgroundWidth - 2, expressTextBgHeight + expressTextToTimeTextPadding + timeTextHeight - 2, expressTextBackgroundPaint); 298 | } else { 299 | canvas.translate(firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius, 300 | firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i); 301 | expressTextBackgroundPaint.setColor(Color.parseColor("#ffffff")); 302 | canvas.drawRect(0, 0, expressTextBackgroundWidth, expressTextBgHeight + expressTextToTimeTextPadding + timeTextHeight, expressTextBackgroundPaint); 303 | } 304 | 305 | if (i == mAdapter.getCount() - 1) { //记录最后一个文字背景的坐标位置 306 | contentDrawHeight = firstExpressCircleMarginTop + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i + expressTextBgHeight + expressTextToTimeTextPadding + timeTextHeight + expressTextVecPadding; 307 | Log.e("ExpressView", "最后一个文字背景坐标 " + contentDrawHeight); 308 | } 309 | 310 | canvas.restore(); 311 | 312 | //绘制物流文字 313 | drawLeftButton(canvas, layout, firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius + expressTextMargin, firstExpressCircleMarginTop + expressTextMargin + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i); 314 | 315 | if (isTimeButtonVisible) { 316 | //绘制时间文字 317 | if (!TextUtils.isEmpty(timeShowText)) { 318 | StaticLayout tl = new StaticLayout(timeShowText, timeTextPaint, (expressTextBackgroundWidth - 2 * expressTextMargin) / 2, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true); 319 | drawLeftButton(canvas, tl, firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius + expressTextMargin, firstExpressCircleMarginTop + expressTextMargin + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i + textHeight + expressTextToTimeTextPadding); 320 | } 321 | 322 | //绘制左边按钮 323 | if (!TextUtils.isEmpty(buttonLeft)) { 324 | StaticLayout sll = new StaticLayout(buttonLeft, buttonTextPaint, (expressTextBackgroundWidth - 2 * expressTextMargin) / 4, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true); 325 | drawLeftButton(canvas, sll, firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius + (expressTextBackgroundWidth - 2 * expressTextMargin) * 8 / 15, firstExpressCircleMarginTop + expressTextMargin + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i + textHeight + expressTextToTimeTextPadding); 326 | } 327 | 328 | //绘制右边按钮 329 | if (!TextUtils.isEmpty(buttonRight)) { 330 | StaticLayout sll = new StaticLayout(buttonRight, buttonTextPaint, (expressTextBackgroundWidth - 2 * expressTextMargin) / 4, Layout.Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true); 331 | drawRightButton(canvas, expressTextBgHeightSum, i, textHeight, sll, buttonTextWidth); 332 | } 333 | } 334 | 335 | if (i == 0) 336 | firstButtonPositionY = firstExpressCircleMarginTop + expressTextMargin + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i + textHeight + expressTextToTimeTextPadding; //记录第一按钮位置坐标 337 | 338 | //存储左边按钮坐标 339 | Point point = new Point(); 340 | point.set(firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius + (expressTextBackgroundWidth - 2 * expressTextMargin) * 8 / 15, firstExpressCircleMarginTop + expressTextMargin + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i + textHeight + expressTextToTimeTextPadding); 341 | buttonTopPositionMap.put(i, point); 342 | 343 | expressTextBgHeightSum += (expressTextBgHeight + timeTextHeight); 344 | 345 | } 346 | 347 | } 348 | 349 | 350 | if (isAdapterNull()) { 351 | canvas.save(); 352 | canvas.drawLine(firstExpressCircleMarginLeft, firstCirclePoint + expressCircleOuterRadius, firstExpressCircleMarginLeft, lastCirclePoint, expressLinePaint); 353 | canvas.restore(); 354 | } 355 | 356 | Log.e("ExpressView", "按钮位置信息 " + JsonUtils.objectToString(buttonTopPositionMap, Map.class)); 357 | } 358 | 359 | //绘制左边边按钮 360 | private void drawLeftButton(Canvas canvas, StaticLayout buttonLayout, int dx, int dy) { 361 | canvas.save(); 362 | canvas.translate(dx, dy); 363 | buttonLayout.draw(canvas); 364 | canvas.restore(); 365 | } 366 | 367 | //绘制右边按钮 368 | private void drawRightButton(Canvas canvas, int expressTextBgHeightSum, int i, int textHeight, StaticLayout buttonLayout, int buttonTextWidth) { 369 | drawLeftButton(canvas, buttonLayout, firstExpressCircleMarginLeft + circleToTextMargin + expressCircleRadius + (expressTextBackgroundWidth - 2 * expressTextMargin) * 8 / 15 + buttonTextWidth, firstExpressCircleMarginTop + expressTextMargin + expressTextBgHeightSum + (expressTextVecPadding + expressTextToTimeTextPadding) * i + textHeight + expressTextToTimeTextPadding); 370 | } 371 | 372 | /** 373 | * 判断适配器是否为null 374 | * 375 | * @return 376 | */ 377 | private boolean isAdapterNull() { 378 | return null != mAdapter; 379 | } 380 | 381 | int downY = 0; 382 | int lastY = 0; 383 | int lastMoveY = 0; 384 | int transDistance; //累计滑动距离 385 | int touchDistance; //系统判定滑动的最小距离 386 | boolean isMoving = false; //是否滑动 387 | 388 | @Override 389 | public boolean onTouchEvent(MotionEvent event) { 390 | 391 | this.getParent().requestDisallowInterceptTouchEvent(true); 392 | switch (event.getAction()) { 393 | case MotionEvent.ACTION_DOWN: 394 | downY = (int) event.getY(); 395 | lastY = downY; 396 | lastMoveY = downY; 397 | isMoving = false; 398 | 399 | break; 400 | case MotionEvent.ACTION_MOVE: 401 | downY = (int) event.getY(); 402 | int transY = downY - lastY; 403 | int transMoveY = downY - lastMoveY; //每次手指按下到滑动停止的滑动距离 404 | isMoving = Math.abs(transMoveY) > touchDistance ? true : false; //判定是否滑动 405 | Log.e("ExpressViewTouch", "当前滑动距离 " + Math.abs(transMoveY) + " 是否滑动 " + isMoving); 406 | if (isMoving) { 407 | transDistance += transY; 408 | Log.e("ExpressViewOnScreen", "滑动距离" + transDistance); 409 | scrollBy(0, -transY); 410 | // if (Math.abs(transDistance) <= contentDrawHeight - screenHeight + location[1] && Math.abs(transDistance) > 0) { 411 | // scrollBy(0, -transY); 412 | // } else if (Math.abs(transDistance) == 0) { 413 | // Log.e("ExpressViewOnScreen", "底部"); 414 | // } else { 415 | // Log.e("ExpressViewOnScreen", "顶部"); 416 | // } 417 | } 418 | lastY = downY; 419 | break; 420 | case MotionEvent.ACTION_UP: 421 | if (isTimeButtonVisible) { 422 | Log.e("ExpressViewTouch", "累计滑动总距离 " + transDistance); 423 | if (isMoving || (!isMoving && (buttonTopPositionMap.get(0).y == firstButtonPositionY))) { 424 | Iterator> it = buttonTopPositionMap.entrySet().iterator(); 425 | while (it.hasNext()) { 426 | Map.Entry entry = it.next(); 427 | entry.getValue().y += transDistance; 428 | } 429 | } 430 | Log.e("ExpressViewTouch", "手指离开屏幕位置信息 " + JsonUtils.objectToString(buttonTopPositionMap, Map.class)); 431 | onActionUpEvent(isMoving, event, buttonTopPositionMap); 432 | this.getParent().requestDisallowInterceptTouchEvent(false); 433 | } 434 | break; 435 | case MotionEvent.ACTION_CANCEL: 436 | this.getParent().requestDisallowInterceptTouchEvent(false); 437 | break; 438 | } 439 | return true; 440 | } 441 | 442 | private void onActionUpEvent(boolean isMoving, MotionEvent event, Map maps) { 443 | int touchX = (int) event.getX(); 444 | int touchY = (int) event.getY(); 445 | 446 | Iterator> it = maps.entrySet().iterator(); 447 | while (it.hasNext()) { 448 | Map.Entry entry = it.next(); 449 | if (!isMoving) { //只有点击事件才检验点击是否有效并响应点击事件 450 | if (isBooleanXY1(touchX, touchY, entry)) { 451 | onExpressItemButtonClickListener.onExpressItemButtonClick(entry.getKey(), 0); 452 | } else if (isBooleanXY2(touchX, touchY, entry)) { 453 | onExpressItemButtonClickListener.onExpressItemButtonClick(entry.getKey(), 1); 454 | } 455 | } 456 | } 457 | } 458 | 459 | public void setTimeButtonVisible(boolean timeButtonVisible) { 460 | isTimeButtonVisible = timeButtonVisible; 461 | } 462 | 463 | private boolean isBooleanXY1(int touchX, int touchY, Map.Entry entry) { 464 | return isBooleanX1(touchX, entry) && isBooleanY(touchY, entry); 465 | } 466 | 467 | private boolean isBooleanY(int touchY, Map.Entry entry) { 468 | return touchY > entry.getValue().y && touchY < entry.getValue().y + expressButtonTextHeight; 469 | } 470 | 471 | private boolean isBooleanX1(int touchX, Map.Entry entry) { 472 | return touchX > entry.getValue().x && touchX < entry.getValue().x + (expressTextBackgroundWidth - 2 * expressTextMargin) / 4; 473 | } 474 | 475 | private boolean isBooleanXY2(int touchX, int touchY, Map.Entry entry) { 476 | return isBooleanX2(touchX, entry) && isBooleanY(touchY, entry); 477 | } 478 | 479 | private boolean isBooleanX2(int touchX, Map.Entry entry) { 480 | return touchX > entry.getValue().x + (expressTextBackgroundWidth - 2 * expressTextMargin) / 4 && touchX < entry.getValue().x + 2 * ((expressTextBackgroundWidth - 2 * expressTextMargin) / 4); 481 | } 482 | 483 | 484 | @Override 485 | public void onDataChanged() { 486 | invalidate(); 487 | } 488 | 489 | public interface OnExpressItemButtonClickListener { 490 | void onExpressItemButtonClick(int position, int status); 491 | } 492 | 493 | private OnExpressItemButtonClickListener onExpressItemButtonClickListener; 494 | 495 | 496 | public void setOnExpressItemButtonClickListener(OnExpressItemButtonClickListener onExpressItemButtonClickListener) { 497 | this.onExpressItemButtonClickListener = onExpressItemButtonClickListener; 498 | } 499 | 500 | public void setAdapter(ExpressViewAdapter adapter){ 501 | mAdapter = adapter; 502 | mAdapter.setOnDataChangedListener(this); 503 | } 504 | } 505 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/expressview/ExpressViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.expressview; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by licheng on 19/3/17. 7 | */ 8 | 9 | public abstract class ExpressViewAdapter { 10 | 11 | private OnDataChangedListener onDataChangedListener; 12 | 13 | private List dataList; 14 | 15 | public ExpressViewAdapter(List dataList) { 16 | this.dataList = dataList; 17 | } 18 | 19 | public int getCount(){ 20 | return dataList == null ? 0 : dataList.size(); 21 | } 22 | 23 | public T getItem(int position){ 24 | return dataList == null ? null : dataList.get(position); 25 | } 26 | 27 | public abstract ExpressViewData bindData(ExpressView expressView, int position, T t); 28 | 29 | public void notifyDataChanged(){ 30 | onDataChangedListener.onDataChanged(); 31 | } 32 | 33 | public interface OnDataChangedListener { 34 | void onDataChanged(); 35 | } 36 | 37 | public void setOnDataChangedListener(OnDataChangedListener onDataChangedListener) { 38 | this.onDataChangedListener = onDataChangedListener; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/expressview/ExpressViewData.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.expressview; 2 | 3 | /** 4 | * 物流控件数据接口 5 | * Created by licheng on 19/3/17. 6 | */ 7 | 8 | public class ExpressViewData { 9 | private String content; //内容 10 | private String time; //时间 11 | private String leftBtnText; //左按钮文字 12 | private String rightBtnText; //右按钮文字 13 | 14 | 15 | 16 | @Override 17 | public String toString() { 18 | return "ExpressViewData{" + 19 | "content='" + content + '\'' + 20 | ", time='" + time + '\'' + 21 | ", leftBtnText='" + leftBtnText + '\'' + 22 | ", rightBtnText='" + rightBtnText + '\'' + 23 | '}'; 24 | } 25 | 26 | public String getContent() { 27 | return content; 28 | } 29 | 30 | public void setContent(String content) { 31 | this.content = content; 32 | } 33 | 34 | public String getLeftBtnText() { 35 | return leftBtnText; 36 | } 37 | 38 | public void setLeftBtnText(String leftBtnText) { 39 | this.leftBtnText = leftBtnText; 40 | } 41 | 42 | public String getRightBtnText() { 43 | return rightBtnText; 44 | } 45 | 46 | public void setRightBtnText(String rightBtnText) { 47 | this.rightBtnText = rightBtnText; 48 | } 49 | 50 | public String getTime() { 51 | return time; 52 | } 53 | 54 | public void setTime(String time) { 55 | this.time = time; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/utils/DeviceUtils.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.utils; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.graphics.Point; 7 | import android.os.Build; 8 | import android.util.DisplayMetrics; 9 | import android.view.Display; 10 | import android.view.WindowManager; 11 | 12 | import java.lang.reflect.Field; 13 | 14 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 15 | public class DeviceUtils { 16 | // 手机网络类型 17 | public static final int NETTYPE_WIFI = 0x01; 18 | public static final int NETTYPE_CMWAP = 0x02; 19 | public static final int NETTYPE_CMNET = 0x03; 20 | 21 | public static boolean GTE_HC; 22 | public static boolean GTE_ICS; 23 | public static boolean PRE_HC; 24 | private static Boolean _hasBigScreen = null; 25 | private static Boolean _hasCamera = null; 26 | private static Boolean _isTablet = null; 27 | private static Integer _loadFactor = null; 28 | public static float displayDensity = 0.0F; 29 | 30 | static { 31 | GTE_ICS = Build.VERSION.SDK_INT >= 14; 32 | GTE_HC = Build.VERSION.SDK_INT >= 11; 33 | PRE_HC = Build.VERSION.SDK_INT < 11; 34 | } 35 | 36 | public DeviceUtils() { 37 | } 38 | 39 | /** 40 | * dp转px 41 | * 42 | * @param context 43 | * @param dp 44 | * @return 45 | */ 46 | public static float dpToPixel(Context context, float dp) { 47 | return dp * (getDisplayMetrics(context).densityDpi / 160F); 48 | } 49 | 50 | /** 51 | * px转dp 52 | * 53 | * @param context 54 | * @param f 55 | * @return 56 | */ 57 | public static float pixelsToDp(Context context, float f) { 58 | return f / (getDisplayMetrics(context).densityDpi / 160F); 59 | } 60 | 61 | public static int dipToPx(Context context, float dip) 62 | { 63 | float density = context.getResources().getDisplayMetrics().density; 64 | return (int) (dip * density + 0.5f * (dip >= 0 ? 1 : -1)); 65 | } 66 | 67 | public static int getDefaultLoadFactor(Context context) { 68 | if (_loadFactor == null) { 69 | Integer integer = Integer.valueOf(0xf & context 70 | .getResources().getConfiguration().screenLayout); 71 | _loadFactor = integer; 72 | _loadFactor = Integer.valueOf(Math.max(integer.intValue(), 1)); 73 | } 74 | return _loadFactor.intValue(); 75 | } 76 | 77 | public static float getDensity(Context context) { 78 | if (displayDensity == 0.0) 79 | displayDensity = getDisplayMetrics(context).density; 80 | return displayDensity; 81 | } 82 | 83 | public static DisplayMetrics getDisplayMetrics(Context context) { 84 | DisplayMetrics displaymetrics = new DisplayMetrics(); 85 | ((WindowManager) context.getSystemService( 86 | Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics( 87 | displaymetrics); 88 | return displaymetrics; 89 | } 90 | 91 | /** 92 | * 屏幕高度 93 | * 94 | * @param context 95 | * @return 96 | */ 97 | public static int getScreenHeight(Context context) { 98 | return getDisplayMetrics(context).heightPixels; 99 | } 100 | 101 | /** 102 | * 屏幕宽度 103 | * 104 | * @param context 105 | * @return 106 | */ 107 | public static int getScreenWidth(Context context) { 108 | return getDisplayMetrics(context).widthPixels; 109 | } 110 | 111 | /** 112 | * 获取activity尺寸 113 | * 114 | * @param activity 115 | * @return 116 | */ 117 | public static int[] getRealScreenSize(Activity activity) { 118 | int[] size = new int[2]; 119 | int screenWidth = 0, screenHeight = 0; 120 | WindowManager w = activity.getWindowManager(); 121 | Display d = w.getDefaultDisplay(); 122 | DisplayMetrics metrics = new DisplayMetrics(); 123 | d.getMetrics(metrics); 124 | // since SDK_INT = 1; 125 | screenWidth = metrics.widthPixels; 126 | screenHeight = metrics.heightPixels; 127 | // includes window decorations (statusbar bar/menu bar) 128 | if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) 129 | try { 130 | screenWidth = (Integer) Display.class.getMethod("getRawWidth") 131 | .invoke(d); 132 | screenHeight = (Integer) Display.class 133 | .getMethod("getRawHeight").invoke(d); 134 | } catch (Exception ignored) { 135 | } 136 | // includes window decorations (statusbar bar/menu bar) 137 | if (Build.VERSION.SDK_INT >= 17) 138 | try { 139 | Point realSize = new Point(); 140 | Display.class.getMethod("getRealSize", Point.class).invoke(d, 141 | realSize); 142 | screenWidth = realSize.x; 143 | screenHeight = realSize.y; 144 | } catch (Exception ignored) { 145 | } 146 | size[0] = screenWidth; 147 | size[1] = screenHeight; 148 | return size; 149 | } 150 | 151 | /** 152 | * 获取状态栏高度 153 | * 154 | * @param context 155 | * @return 156 | */ 157 | public static int getStatusBarHeight(Context context) { 158 | Class c = null; 159 | Object obj = null; 160 | Field field = null; 161 | int x = 0; 162 | try { 163 | c = Class.forName("com.android.internal.R$dimen"); 164 | obj = c.newInstance(); 165 | field = c.getField("status_bar_height"); 166 | x = Integer.parseInt(field.get(obj).toString()); 167 | return context.getResources() 168 | .getDimensionPixelSize(x); 169 | } catch (Exception e) { 170 | e.printStackTrace(); 171 | } 172 | return 0; 173 | } 174 | 175 | 176 | public static boolean hasBigScreen(Context context) { 177 | boolean flag = true; 178 | if (_hasBigScreen == null) { 179 | boolean flag1; 180 | if ((0xf & context.getResources() 181 | .getConfiguration().screenLayout) >= 3) 182 | flag1 = flag; 183 | else 184 | flag1 = false; 185 | Boolean boolean1 = Boolean.valueOf(flag1); 186 | _hasBigScreen = boolean1; 187 | if (!boolean1.booleanValue()) { 188 | if (getDensity(context) <= 1.5F) 189 | flag = false; 190 | _hasBigScreen = Boolean.valueOf(flag); 191 | } 192 | } 193 | return _hasBigScreen.booleanValue(); 194 | } 195 | 196 | } 197 | 198 | 199 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.reflect.TypeToken; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by licheng on 5/1/17. 10 | */ 11 | public class JsonUtils { 12 | private static Gson gson = new Gson(); 13 | 14 | /** 15 | * 对象转json 16 | * 17 | * @param obj 18 | * 需要转换json的对象 19 | * @param cls 20 | * 对象类型 21 | * @return 把对象转换成json的string 22 | */ 23 | public static String objectToString(Object obj, Class cls) { 24 | String json = gson.toJson(obj, cls); 25 | return json; 26 | } 27 | 28 | /** 29 | * json转对象 30 | * 31 | * @param json 32 | * 需要转换的json 33 | * @return json解析之后的对象 34 | */ 35 | public static Object StringToObject(String json, Class cls) { 36 | Object obj = gson.fromJson(json, cls); 37 | return obj; 38 | } 39 | 40 | /** 41 | * 集合转json 42 | * 43 | * @param 44 | * 对象类型 45 | * @param list 46 | * 需要转换json的对象集合 47 | * @return 转换成json之后的string 48 | */ 49 | public static String objectArrayToString(List list) { 50 | String json = gson.toJson(list, new TypeToken>() { 51 | }.getType()); 52 | return json; 53 | } 54 | 55 | 56 | /** 57 | * json转集合 58 | * 59 | * @param 60 | * 61 | * @param json 62 | * 需要转换成对象集合的json 63 | * 对象类型 64 | * @return 解析json之后的对象集合 65 | */ 66 | public static List StringToObjectArray(String json, Class cls) { 67 | List list = gson.fromJson(json, new TypeToken>() { 68 | }.getType()); 69 | return list; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.utils; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | import java.util.Locale; 7 | 8 | /** 9 | * 时间相关工具类 10 | */ 11 | public class TimeUtils { 12 | 13 | private TimeUtils() { 14 | throw new UnsupportedOperationException("u can't instantiate me..."); 15 | } 16 | 17 | 18 | public static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss"; 19 | 20 | /** 21 | * 将时间戳转为时间字符串 22 | *

格式为yyyy-MM-dd HH:mm:ss

23 | * 24 | * @param millis 毫秒时间戳 25 | * @return 时间字符串 26 | */ 27 | public static String millis2String(long millis) { 28 | return new SimpleDateFormat(DEFAULT_PATTERN, Locale.getDefault()).format(new Date(millis)); 29 | } 30 | 31 | /** 32 | * 将时间戳转为时间字符串 33 | *

格式为pattern

34 | * 35 | * @param millis 毫秒时间戳 36 | * @param pattern 时间格式 37 | * @return 时间字符串 38 | */ 39 | public static String millis2String(long millis, String pattern) { 40 | return new SimpleDateFormat(pattern, Locale.getDefault()).format(new Date(millis)); 41 | } 42 | 43 | /** 44 | * 将时间字符串转为时间戳 45 | *

time格式为yyyy-MM-dd HH:mm:ss

46 | * 47 | * @param time 时间字符串 48 | * @return 毫秒时间戳 49 | */ 50 | public static long string2Millis(String time) { 51 | return string2Millis(time, DEFAULT_PATTERN); 52 | } 53 | 54 | /** 55 | * 将时间字符串转为时间戳 56 | *

time格式为pattern

57 | * 58 | * @param time 时间字符串 59 | * @param pattern 时间格式 60 | * @return 毫秒时间戳 61 | */ 62 | public static long string2Millis(String time, String pattern) { 63 | try { 64 | return new SimpleDateFormat(pattern, Locale.getDefault()).parse(time).getTime(); 65 | } catch (ParseException e) { 66 | e.printStackTrace(); 67 | } 68 | return -1; 69 | } 70 | 71 | /** 72 | * 将时间字符串转为Date类型 73 | *

time格式为yyyy-MM-dd HH:mm:ss

74 | * 75 | * @param time 时间字符串 76 | * @return Date类型 77 | */ 78 | public static Date string2Date(String time) { 79 | return string2Date(time, DEFAULT_PATTERN); 80 | } 81 | 82 | /** 83 | * 将时间字符串转为Date类型 84 | *

time格式为pattern

85 | * 86 | * @param time 时间字符串 87 | * @param pattern 时间格式 88 | * @return Date类型 89 | */ 90 | public static Date string2Date(String time, String pattern) { 91 | return new Date(string2Millis(time, pattern)); 92 | } 93 | 94 | /** 95 | * 将Date类型转为时间字符串 96 | *

格式为yyyy-MM-dd HH:mm:ss

97 | * 98 | * @param date Date类型时间 99 | * @return 时间字符串 100 | */ 101 | public static String date2String(Date date) { 102 | return date2String(date, DEFAULT_PATTERN); 103 | } 104 | 105 | /** 106 | * 将Date类型转为时间字符串 107 | *

格式为pattern

108 | * 109 | * @param date Date类型时间 110 | * @param pattern 时间格式 111 | * @return 时间字符串 112 | */ 113 | public static String date2String(Date date, String pattern) { 114 | return new SimpleDateFormat(pattern, Locale.getDefault()).format(date); 115 | } 116 | 117 | /** 118 | * 将Date类型转为时间戳 119 | * 120 | * @param date Date类型时间 121 | * @return 毫秒时间戳 122 | */ 123 | public static long date2Millis(Date date) { 124 | return date.getTime(); 125 | } 126 | 127 | /** 128 | * 将时间戳转为Date类型 129 | * 130 | * @param millis 毫秒时间戳 131 | * @return Date类型时间 132 | */ 133 | public static Date millis2Date(long millis) { 134 | return new Date(millis); 135 | } 136 | 137 | 138 | 139 | /** 140 | * 获取当前毫秒时间戳 141 | * 142 | * @return 毫秒时间戳 143 | */ 144 | public static long getNowTimeMills() { 145 | return System.currentTimeMillis(); 146 | } 147 | 148 | /** 149 | * 获取当前时间字符串 150 | *

格式为yyyy-MM-dd HH:mm:ss

151 | * 152 | * @return 时间字符串 153 | */ 154 | public static String getNowTimeString() { 155 | return millis2String(System.currentTimeMillis(), DEFAULT_PATTERN); 156 | } 157 | 158 | /** 159 | * 获取当前时间字符串 160 | *

格式为pattern

161 | * 162 | * @param pattern 时间格式 163 | * @return 时间字符串 164 | */ 165 | public static String getNowTimeString(String pattern) { 166 | return millis2String(System.currentTimeMillis(), pattern); 167 | } 168 | 169 | /** 170 | * 获取当前Date 171 | * 172 | * @return Date类型时间 173 | */ 174 | public static Date getNowTimeDate() { 175 | return new Date(); 176 | } 177 | 178 | 179 | } -------------------------------------------------------------------------------- /app/src/main/java/com/licheng/android/expressview/utils/ToastUtil.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview.utils; import android.content.Context; import android.view.Gravity; import android.widget.Toast; import java.lang.reflect.Method; public class ToastUtil { public static Method showMethod; public static Method hideMethod; public static Object obj; private static Toast toast = null; /** * 屏幕上方弹窗 * * @param context * @param msg */ public static void ToastCenter(Context context, String msg) { if (null == toast) { toast = Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_SHORT); } toast.setGravity(Gravity.CENTER, 0, 0); toast.setText(msg); toast.show(); } /** * 屏幕底端 * * @param context * @param msg */ public static void ToastBottow(Context context, String msg) { if (null == toast) { toast = Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_SHORT); } toast.setGravity(Gravity.BOTTOM, 0, 0); toast.setText(msg); toast.show(); } /** * 默认位置 * * @param context * @param msg */ public static void ToastDefult(Context context, String msg) { if (null == toast) { toast = Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_SHORT); } toast.setText(msg); toast.show(); } } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomanzijia/ExpressView/f32e3e50921bbbc6a45a67fc563ede75290b77db/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomanzijia/ExpressView/f32e3e50921bbbc6a45a67fc563ede75290b77db/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomanzijia/ExpressView/f32e3e50921bbbc6a45a67fc563ede75290b77db/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomanzijia/ExpressView/f32e3e50921bbbc6a45a67fc563ede75290b77db/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomanzijia/ExpressView/f32e3e50921bbbc6a45a67fc563ede75290b77db/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 5 | 16 6 | 6 7 | 8 8 | 12 9 | 8 10 | 5 11 | 18 12 | 14 13 | false 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ExpressView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/licheng/android/expressview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.licheng.android.expressview; 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.2.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /screen/express.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomanzijia/ExpressView/f32e3e50921bbbc6a45a67fc563ede75290b77db/screen/express.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------