Skip to content
This repository was archived by the owner on Jun 8, 2024. It is now read-only.

Commit 2f9ec76

Browse files
committed
Update libraries version & Show chiba icon when it is slow express
Signed-off-by: Fung <fython@163.com>
1 parent 9c03253 commit 2f9ec76

6 files changed

Lines changed: 35 additions & 6 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
ext.kotlin_version = '1.1.4-2'
3-
ext.android_support_lib_version = '26.0.0'
3+
ext.android_support_lib_version = '26.1.0'
44
ext.kotlinyan_version = '0.2.2.1'
55
repositories {
66
jcenter()

mobile/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ dependencies {
5858
compile project(':libraries:StatusBarCompat')
5959
compile 'de.hdodenhof:circleimageview:2.1.0'
6060
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
61-
compile 'moe.feng:MaterialStepperView:0.2.1'
61+
compile 'moe.feng:MaterialStepperView:0.2.2'
6262
compile 'com.getkeepsafe.taptargetview:taptargetview:1.9.1'
6363
compile 'me.dm7.barcodescanner:zxing:1.9'
6464

mobile/src/main/java/info/papdt/express/helper/ui/items/DetailsStatusItemBinder.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package info.papdt.express.helper.ui.items;
22

33
import android.content.Intent;
4+
import android.graphics.Color;
45
import android.net.Uri;
56
import android.support.annotation.NonNull;
67
import android.support.v7.widget.AppCompatTextView;
@@ -12,6 +13,7 @@
1213
import android.view.ViewGroup;
1314
import android.view.animation.OvershootInterpolator;
1415
import info.papdt.express.helper.R;
16+
import info.papdt.express.helper.drawable.TextDrawable;
1517
import info.papdt.express.helper.model.Package;
1618
import info.papdt.express.helper.view.VerticalStepIconView;
1719
import info.papdt.express.helper.view.VerticalStepLineView;
@@ -21,6 +23,7 @@ public class DetailsStatusItemBinder extends ItemViewBinder<Package.Status, Deta
2123

2224
private Package mPackage;
2325
private boolean isShowed[] = new boolean[1000];
26+
public boolean showChiba = false; // 是否为慢递
2427

2528
public void setData(Package src) {
2629
mPackage = src;
@@ -127,6 +130,13 @@ void setData(Package.Status newData) {
127130
}
128131
stepIcon.setPointColorResource(pointColorResId);
129132
stepIcon.setCenterIcon(pointIconResId);
133+
if (showChiba) {
134+
stepIcon.setCenterIcon(TextDrawable.Companion.builder()
135+
.beginConfig()
136+
.fullSizeFont()
137+
.endConfig()
138+
.buildRound("\uD83D\uDC22", Color.TRANSPARENT));
139+
}
130140
} else {
131141
stepIcon.setIsMini(true);
132142
stepIcon.setPointColorResource(R.color.blue_grey_500);

mobile/src/main/kotlin/info/papdt/express/helper/drawable/TextDrawable.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ class TextDrawable private constructor(builder: Builder) : ShapeDrawable(builder
2222
private val fontSize: Int
2323
private val radius: Float
2424
private val borderThickness: Int
25+
private val fullSizeFont: Boolean
2526

2627
init {
2728
// shape properties
2829
shape = builder.shape
2930
height = builder.height
3031
width = builder.width
3132
radius = builder.radius
33+
fullSizeFont = builder.fullSizeFont
3234

3335
// text and color
3436
text = if (builder.toUpperCase) builder.text!!.toUpperCase() else builder.text
@@ -80,7 +82,11 @@ class TextDrawable private constructor(builder: Builder) : ShapeDrawable(builder
8082
// draw text
8183
val width = if (this.width < 0) r.width() else this.width
8284
val height = if (this.height < 0) r.height() else this.height
83-
val fontSize = if (this.fontSize < 0) Math.min(width, height) / 2 else this.fontSize
85+
val fontSize = if (fullSizeFont) {
86+
if (this.fontSize < 0) Math.min(width, height) else this.fontSize
87+
} else {
88+
if (this.fontSize < 0) Math.min(width, height) / 2 else this.fontSize
89+
}
8490
textPaint.textSize = fontSize.toFloat()
8591
canvas.drawText(text, (width / 2).toFloat(), height / 2 - (textPaint.descent() + textPaint.ascent()) / 2, textPaint)
8692

@@ -119,7 +125,7 @@ class TextDrawable private constructor(builder: Builder) : ShapeDrawable(builder
119125
return height
120126
}
121127

122-
class Builder () : IConfigBuilder, IShapeBuilder, IBuilder {
128+
class Builder : IConfigBuilder, IShapeBuilder, IBuilder {
123129

124130
var text: String? = null
125131
var color: Int = 0
@@ -133,6 +139,7 @@ class TextDrawable private constructor(builder: Builder) : ShapeDrawable(builder
133139
var isBold: Boolean = false
134140
var toUpperCase: Boolean = false
135141
var radius: Float = 0.toFloat()
142+
var fullSizeFont: Boolean = false
136143

137144
init {
138145
text = ""
@@ -233,6 +240,11 @@ class TextDrawable private constructor(builder: Builder) : ShapeDrawable(builder
233240
this.text = text
234241
return TextDrawable(this)
235242
}
243+
244+
override fun fullSizeFont(): IConfigBuilder {
245+
this.fullSizeFont = true
246+
return this
247+
}
236248
}
237249

238250
interface IConfigBuilder {
@@ -244,6 +256,7 @@ class TextDrawable private constructor(builder: Builder) : ShapeDrawable(builder
244256
fun fontSize(size: Int): IConfigBuilder
245257
fun bold(): IConfigBuilder
246258
fun toUpperCase(): IConfigBuilder
259+
fun fullSizeFont(): IConfigBuilder
247260
fun endConfig(): IShapeBuilder
248261
}
249262

mobile/src/main/kotlin/info/papdt/express/helper/ui/DetailsActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class DetailsActivity : AbsActivity() {
312312
override fun onPostExecute(items: Items) {
313313
mStatusBinder.setData(data)
314314
mAdapter.items = items
315+
mStatusBinder.showChiba = data?.data?.find { it.context.contains("佛山") || it.context.contains("广州") } != null
315316
mAdapter.notifyDataSetChanged()
316317

317318
val color: Int = when (state) {

mobile/src/main/kotlin/info/papdt/express/helper/view/VerticalStepIconView.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import android.util.AttributeSet
1212
import android.view.View
1313
import info.papdt.express.helper.R
1414
import info.papdt.express.helper.support.ScreenUtils
15+
import moe.feng.kotlinyan.common.AndroidExtensions
1516

1617
class VerticalStepIconView @JvmOverloads
17-
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr) {
18+
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr), AndroidExtensions {
1819

1920
private var mPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
2021
private var mCirclePaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
@@ -111,7 +112,11 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
111112
val bitmap: Bitmap = if (d is ColorDrawable) {
112113
Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
113114
} else {
114-
Bitmap.createBitmap(d.intrinsicWidth, d.intrinsicHeight, Bitmap.Config.ARGB_8888)
115+
Bitmap.createBitmap(
116+
Math.max(24f.dpToPx(context).toInt(), d.intrinsicWidth),
117+
Math.max(24f.dpToPx(context).toInt(), d.intrinsicHeight),
118+
Bitmap.Config.ARGB_8888
119+
)
115120
}
116121

117122
val canvas = Canvas(bitmap)

0 commit comments

Comments
 (0)