优化提前显示面板
This commit is contained in:
@@ -8,6 +8,10 @@ import android.widget.EditText
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import com.navinfo.omqs.R
|
||||
|
||||
/**
|
||||
* 滚动嵌套时,处理滚动的edittext
|
||||
*/
|
||||
|
||||
class MyEditeText @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.navinfo.omqs.ui.widget
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import androidx.annotation.StringDef
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
import java.lang.annotation.Retention
|
||||
import java.lang.annotation.RetentionPolicy
|
||||
|
||||
/**
|
||||
* 用来设置recyclerView 要素间的间隔
|
||||
*/
|
||||
class RecyclerViewSpacesItemDecoration : ItemDecoration {
|
||||
@StringDef(TOP_DECORATION, BOTTOM_DECORATION, LEFT_DECORATION, RIGHT_DECORATION)
|
||||
@Retention(
|
||||
RetentionPolicy.SOURCE
|
||||
)
|
||||
private annotation class Decoration
|
||||
|
||||
private var rightSpace = 0 //右边间距
|
||||
private var topSpace = 0 //上边边间距
|
||||
private var leftSpace = 0 //左边间距
|
||||
private var bottomSpace = 0 //下边间距
|
||||
|
||||
/**
|
||||
* @param bottomSpace 下间距
|
||||
*/
|
||||
constructor(bottomSpace: Int) {
|
||||
this.bottomSpace = bottomSpace
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定某一个属性
|
||||
*
|
||||
* @param decoration decoration
|
||||
* @param space 间距
|
||||
*/
|
||||
constructor(@Decoration decoration: String?, space: Int) {
|
||||
when (decoration) {
|
||||
RIGHT_DECORATION -> rightSpace = space
|
||||
TOP_DECORATION -> topSpace = space
|
||||
LEFT_DECORATION -> leftSpace = space
|
||||
BOTTOM_DECORATION -> bottomSpace = space
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rightSpace 右间距
|
||||
* @param topSpace 上间距
|
||||
* @param leftSpace 左间距
|
||||
* @param bottomSpace 下间距
|
||||
*/
|
||||
constructor(rightSpace: Int, topSpace: Int, leftSpace: Int, bottomSpace: Int) {
|
||||
this.rightSpace = rightSpace
|
||||
this.topSpace = topSpace
|
||||
this.leftSpace = leftSpace
|
||||
this.bottomSpace = bottomSpace
|
||||
}
|
||||
|
||||
/**
|
||||
* @param outRect Item的矩边界
|
||||
* @param view ItemView
|
||||
* @param parent RecyclerView
|
||||
* @param state RecyclerView的状态
|
||||
*/
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
outRect.top = topSpace
|
||||
outRect.left = leftSpace
|
||||
outRect.right = rightSpace
|
||||
outRect.bottom = bottomSpace
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TOP_DECORATION = "top_decoration"
|
||||
const val BOTTOM_DECORATION = "bottom_decoration"
|
||||
const val LEFT_DECORATION = "left_decoration"
|
||||
const val RIGHT_DECORATION = "right_decoration"
|
||||
}
|
||||
}
|
||||
153
app/src/main/java/com/navinfo/omqs/ui/widget/SignUtil.kt
Normal file
153
app/src/main/java/com/navinfo/omqs/ui/widget/SignUtil.kt
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.navinfo.omqs.ui.widget
|
||||
|
||||
import android.util.Log
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.omqs.R
|
||||
|
||||
class SignUtil {
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* 获取面板上的文字
|
||||
*/
|
||||
fun getSignText(data: RenderEntity): String {
|
||||
return when (data.code) {
|
||||
//常规点限速
|
||||
4002 -> getSpeedLimitText(data)
|
||||
// //道路种别
|
||||
// 2008 -> getKindCodeIcon(data)
|
||||
// //道路方向
|
||||
// 2010 -> getRoadDirection(data)
|
||||
// //车道数
|
||||
// 2041 -> getLaneNumIcon(data)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取限速值文字
|
||||
*/
|
||||
private fun getSpeedLimitText(data: RenderEntity): String {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val maxSpeed = data.properties["max_speed"]
|
||||
val minSpeed = data.properties["min_speed"]
|
||||
return if (maxSpeed != "0")
|
||||
maxSpeed.toString()
|
||||
else
|
||||
minSpeed.toString()
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取限速面板ICON出错1 $e")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 限速图标
|
||||
*/
|
||||
fun getSpeedLimitIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val speedFlag = data.properties["speed_flag"]
|
||||
return when (speedFlag) {
|
||||
"1" -> return R.drawable.icon_speed_limit_off
|
||||
else -> return R.drawable.icon_speed_limit
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取限速面板ICON出错2 $e")
|
||||
}
|
||||
return R.drawable.icon_speed_limit
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取看板图标
|
||||
*/
|
||||
|
||||
fun getSignIcon(data: RenderEntity): Int {
|
||||
return when (data.code) {
|
||||
//道路种别
|
||||
2008 -> getKindCodeIcon(data)
|
||||
//道路方向
|
||||
2010 -> getRoadDirection(data)
|
||||
//车道数
|
||||
2041 -> getLaneNumIcon(data)
|
||||
//限速
|
||||
4002 -> getSpeedLimitIcon(data)
|
||||
else -> R.drawable.icon_speed_limit
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取种别图标
|
||||
*/
|
||||
fun getKindCodeIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
val kind = data.properties["kind"]
|
||||
return when (kind!!.toInt()) {
|
||||
1 -> R.mipmap.icon_kind_code_k1
|
||||
2 -> R.mipmap.icon_kind_code_k2
|
||||
3 -> R.mipmap.icon_kind_code_k3
|
||||
4 -> R.mipmap.icon_kind_code_k4
|
||||
6 -> R.mipmap.icon_kind_code_k6
|
||||
7 -> R.mipmap.icon_kind_code_k7
|
||||
8 -> R.mipmap.icon_kind_code_k8
|
||||
9 -> R.mipmap.icon_kind_code_k9
|
||||
10 -> R.mipmap.icon_kind_code_k10
|
||||
11 -> R.mipmap.icon_kind_code_k11
|
||||
13 -> R.mipmap.icon_kind_code_k13
|
||||
15 -> R.mipmap.icon_kind_code_k15
|
||||
else -> R.mipmap.icon_kind_code
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取种别面板ICON出错 $e")
|
||||
}
|
||||
return R.mipmap.icon_kind_code
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取到路线
|
||||
*/
|
||||
fun getLaneNumIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
val lineNum = data.properties["laneNum"]
|
||||
return when (lineNum!!.toInt()) {
|
||||
1 -> R.mipmap.icon_lane_num1
|
||||
2 -> R.mipmap.icon_lane_num2
|
||||
3 -> R.mipmap.icon_lane_num3
|
||||
4 -> R.mipmap.icon_lane_num4
|
||||
5 -> R.mipmap.icon_lane_num5
|
||||
6 -> R.mipmap.icon_lane_num6
|
||||
7 -> R.mipmap.icon_lane_num7
|
||||
8 -> R.mipmap.icon_lane_num8
|
||||
9 -> R.mipmap.icon_lane_num9
|
||||
10 -> R.mipmap.icon_lane_num10
|
||||
11 -> R.mipmap.icon_lane_num11
|
||||
12 -> R.mipmap.icon_lane_num12
|
||||
else -> R.mipmap.icon_lane_num1
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取车道数面板ICON出错 $e")
|
||||
}
|
||||
return R.mipmap.icon_road_direction
|
||||
}
|
||||
|
||||
fun getRoadDirection(data: RenderEntity): Int {
|
||||
try {
|
||||
val direct = data.properties["direct"]
|
||||
return when (direct!!.toInt()) {
|
||||
0 -> R.mipmap.icon_road_direction
|
||||
1 -> R.mipmap.icon_road_direction
|
||||
2 -> R.mipmap.icon_road_direction
|
||||
3 -> R.mipmap.icon_road_direction
|
||||
-99 -> R.mipmap.icon_road_direction
|
||||
else -> R.mipmap.icon_road_direction
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取道路方向面板ICON出错 $e")
|
||||
}
|
||||
return R.mipmap.icon_road_direction
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user