完成1+16左侧面板功能

This commit is contained in:
tongchenfei
2020-07-07 18:52:33 +08:00
parent 4c37a05baf
commit 58c4599263
7 changed files with 40 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import kotlinx.android.synthetic.main.module_left_panel_simple_speed.*
*
* @author tongchenfei
*/
private const val SPEED_THRESHOLD = 90
class SimpleSpeedFragment: MvpFragment<SimpleSpeedFragment, SimpleSpeedPresenter>() {
override fun getLayoutId(): Int {
return R.layout.module_left_panel_simple_speed
@@ -24,5 +25,11 @@ class SimpleSpeedFragment: MvpFragment<SimpleSpeedFragment, SimpleSpeedPresenter
fun refreshSpeed(speed: Int) {
tvModuleLeftPanelSpeed.text = speed.toString()
if (speed >= SPEED_THRESHOLD) {
// 速度超过90需要改变背景颜色
tvModuleLeftPanelSpeed.setBackgroundResource(R.drawable.module_left_panel_warn_speed_bg)
}else{
tvModuleLeftPanelSpeed.setBackgroundResource(R.drawable.module_left_panel_normal_speed_bg)
}
}
}

View File

@@ -11,6 +11,7 @@ import com.zhidao.mogo.module.left.panel.LeftPanelConst.MODULE_NAME
import com.zhidao.mogo.module.left.panel.fragment.SimpleSpeedFragment
import java.lang.Thread.sleep
import kotlin.concurrent.thread
import kotlin.random.Random
/**
* 临时左侧车速逻辑的presenter

View File

@@ -1,16 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/ivContainerBg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_left_panel_speed_container_bg"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvModuleLeftPanelSpeed"
android:text="50"
android:text="0"
android:gravity="center"
android:textSize="40sp"
android:textStyle="bold"
android:textSize="@dimen/module_left_panel_simple_speed_text_size"
app:layout_constraintLeft_toLeftOf="@id/ivContainerBg"
app:layout_constraintRight_toRightOf="@id/ivContainerBg"
app:layout_constraintTop_toTopOf="@id/ivContainerBg"
android:layout_marginTop="@dimen/module_left_panel_simple_speed_text_margin_top"
android:textColor="#fff"
android:background="#000" />
android:background="@drawable/module_left_panel_normal_speed_bg" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_left_panel_simple_speed_text_size">80px</dimen>
<dimen name="module_left_panel_simple_speed_text_margin_top">69.6px</dimen>
</resources>

View File

@@ -36,7 +36,7 @@
<!-- 左侧浮层,布局位置目前只考虑了1+16独立app情况 -->
<FrameLayout
android:layout_width="@dimen/module_main_id_entrance_fragment_container_marginLeft"
android:layout_width="@dimen/module_main_id_left_panel_fragment_container_width"
android:layout_height="match_parent"
android:id="@+id/module_main_id_left_panel_fragment_container" />

View File

@@ -22,4 +22,6 @@
<dimen name="module_main_id_entrance_fragment_container_marginLeft">800px</dimen>
<dimen name="module_main_entrance_fragment_container_padding">30px</dimen>
<dimen name="module_main_id_left_panel_fragment_container_width">340px</dimen>
</resources>

View File

@@ -21,6 +21,7 @@
<dimen name="module_main_header_fragment_container_marginTop">15px</dimen>
<dimen name="module_main_header_fragment_container_marginLeft">460px</dimen>
<dimen name="module_main_id_entrance_fragment_container_marginLeft">444px</dimen>
<dimen name="module_main_id_left_panel_fragment_container_width">350px</dimen>
<dimen name="module_main_entrance_fragment_container_padding">16px</dimen>
</resources>