diff --git a/OCH/mogo-och-bus-passenger/build.gradle b/OCH/mogo-och-bus-passenger/build.gradle index af805de9a1..8749b55ad1 100644 --- a/OCH/mogo-och-bus-passenger/build.gradle +++ b/OCH/mogo-och-bus-passenger/build.gradle @@ -53,20 +53,10 @@ dependencies { implementation rootProject.ext.dependencies.amapnavi3dmap implementation project(":OCH:mogo-och-common-module") if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { - implementation rootProject.ext.dependencies.mogoutils - implementation rootProject.ext.dependencies.mogocommons - implementation rootProject.ext.dependencies.mogo_core_data - implementation rootProject.ext.dependencies.mogo_core_function_call implementation rootProject.ext.dependencies.mogo_core_function_v2x - implementation rootProject.ext.dependencies.mogo_core_function_hmi }else { implementation project(':foudations:mogo-aicloud-services-sdk') - implementation project(":foudations:mogo-commons") - implementation project(':core:mogo-core-data') - implementation project(":core:mogo-core-utils") - implementation project(':core:mogo-core-function-call') implementation project(':core:function-impl:mogo-core-function-v2x') - implementation project(':core:function-impl:mogo-core-function-hmi') } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java index 10ba73cf1a..29103f4c3a 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java @@ -44,8 +44,7 @@ public class BusPassengerRouteFragment extends private final String TAG = "BusPassengerRouteFragment"; - private BusPassengerTrafficLightView mTrafficLightView; - private List mStationsList = new ArrayList<>(); + private final List mStationsList = new ArrayList<>(); private TextView mSpeedTv; private ConstraintLayout mNoLineInfoView; @@ -75,8 +74,6 @@ public class BusPassengerRouteFragment extends @Override protected void initViews() { super.initViews(); - mTrafficLightView = findViewById(R.id.bus_p_traffic_light_view); - CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView); mSpeedTv = findViewById(R.id.bus_p_speed_tv); diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java deleted file mode 100644 index e021a8675b..0000000000 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.mogo.och.bus.passenger.ui; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.bus.passenger.R; - -import org.jetbrains.annotations.Nullable; - -/** - * bus乘客端:红绿灯view - * - * Created on 2022/3/14 - */ -public class BusPassengerTrafficLightView extends IViewTrafficLight { - - private ImageView mLightIconIV; - private TextView mLightTimeTV; - private int mCurrentLightId; - private ImageView mLightIconBG; - - public BusPassengerTrafficLightView(@Nullable Context context) { - this(context, null, 0); - } - - public BusPassengerTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public BusPassengerTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context); - } - - private void init(Context context) { - LayoutInflater.from(context).inflate(R.layout.bus_p_traffic_light_view, this, true); - mLightIconIV = findViewById(R.id.bus_p_traffic_light_iv); - mLightTimeTV = findViewById(R.id.bus_p_traffic_light_time_tv); - mLightIconBG = findViewById(R.id.bus_p_traffic_light_bg); - } - - /** - * 展示红绿灯预警 - * - * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 - * @param lightSource 1:云端下发;2:自车感知 - */ - @Override - public void showWarningTrafficLight(int checkLightId,int lightSource) { - super.showWarningTrafficLight(checkLightId,lightSource); - mCurrentLightId = checkLightId; - updateTrafficLightIcon(checkLightId); - } - - /** - * 关闭红绿灯预警展示,并重制灯态 - */ - @Override - public void disableWarningTrafficLight() { - super.disableWarningTrafficLight(); - UiThreadHandler.post(() -> { - mCurrentLightId = 0; - BusPassengerTrafficLightView.this.setVisibility(GONE); - }); - } - - /** - * @param redNum 红灯倒计时 - * @param yellowNum 黄灯倒计时 - * @param greenNum 绿灯倒计时 - */ - @Override - public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) { - super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum); - resetView(); - switch (mCurrentLightId) { - case 1: - changeCountdownRed(redNum); - break; - case 2: - changeCountdownYellow(yellowNum); - break; - case 3: - changeCountdownGreen(greenNum); - break; - default: - UiThreadHandler.post(() -> { - mLightTimeTV.setText(""); - }); - break; - } - } - - @Override - public void changeCountdownRed(int redNum) { - super.changeCountdownRed(redNum); - UiThreadHandler.post(() -> { - if (redNum > 0) { - resetView(); - mLightTimeTV.setText(String.valueOf(redNum)); - } else { - disableCountdown(); - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownGreen(int greenNum) { - super.changeCountdownGreen(greenNum); - UiThreadHandler.post(() -> { - if (greenNum > 0) { - resetView(); - mLightTimeTV.setText(String.valueOf(greenNum)); - } else { - disableCountdown(); - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownYellow(int yellowNum) { - super.changeCountdownYellow(yellowNum); - UiThreadHandler.post(() -> { - if (yellowNum > 0) { - resetView(); - mLightTimeTV.setText(String.valueOf(yellowNum)); - } else { - disableCountdown(); - mLightTimeTV.setText(""); - } - }); - } - - /** - * 更新红绿灯icon - * - * @param lightId 0-都是默认,1-红,2-黄,3-绿 - */ - private void updateTrafficLightIcon(int lightId) { - UiThreadHandler.post(() -> { - switch (lightId) { - case 1: - mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_red_nor); - BusPassengerTrafficLightView.this.setVisibility(VISIBLE); - break; - case 2: - mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_yellow_nor); - BusPassengerTrafficLightView.this.setVisibility(VISIBLE); - break; - case 3: - mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_green_nor); - BusPassengerTrafficLightView.this.setVisibility(VISIBLE); - break; - default: - BusPassengerTrafficLightView.this.setVisibility(GONE); - break; - } - }); - } - - @Override - public void disableCountdown() { - super.disableCountdown(); - UiThreadHandler.post(() ->{ - ViewGroup.LayoutParams layoutParams = getLayoutParams(); - if (layoutParams instanceof MarginLayoutParams){ - MarginLayoutParams lp = (MarginLayoutParams) layoutParams; - lp.width = (int) getResources().getDimension(R.dimen.bus_p_traffic_light_icon_size); - setLayoutParams(lp); - mLightTimeTV.setVisibility(GONE); - mLightIconBG.getLayoutParams().width = (int)getResources().getDimension(R.dimen.dp_90); - } - }); - } - - private void resetView(){ - ViewGroup.LayoutParams layoutParams = getLayoutParams(); - if (layoutParams instanceof MarginLayoutParams) { - MarginLayoutParams lp = (MarginLayoutParams) layoutParams; - lp.width = (int) getResources().getDimension(R.dimen.bus_p_route_traffic_light_view_width); - setLayoutParams(lp); - mLightTimeTV.setVisibility(VISIBLE); - mLightIconBG.getLayoutParams().width = (int) getResources().getDimension(R.dimen.bus_p_traffic_light_bg_width); - } - } -} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.kt new file mode 100644 index 0000000000..9ac253d812 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.kt @@ -0,0 +1,179 @@ +package com.mogo.och.bus.passenger.ui + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.data.enums.TrafficLightEnum +import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener +import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.main.bus_p_traffic_light_view.view.* + +/** + * bus乘客端:红绿灯view + * + * Created on 2022/3/14 + */ +class BusPassengerTrafficLightView @JvmOverloads constructor( + context: Context?, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener { + + companion object { + private const val TAG = "BusPassengerTrafficLightView" + } + + private var mCurrentLightId = TrafficLightEnum.BLACK + + init { + init(context) + } + + private fun init(context: Context?) { + LayoutInflater.from(context).inflate(R.layout.bus_p_traffic_light_view, this, true) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerTrafficLightListenerManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTrafficLightListenerManager.removeListener(TAG) + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + * @param lightSource 1:云端下发;2:自车感知 + */ + override fun showTrafficLight(checkLightId: TrafficLightEnum, lightSource: DataSourceType) { + super.showTrafficLight(checkLightId, lightSource) + mCurrentLightId = checkLightId + updateTrafficLightIcon(checkLightId) + } + + /** + * 关闭红绿灯预警展示,并重制灯态 + */ + override fun disableTrafficLight() { + super.disableTrafficLight() + UiThreadHandler.post { + mCurrentLightId = TrafficLightEnum.BLACK + this@BusPassengerTrafficLightView.visibility = GONE + } + } + + /** + * @param redNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) { + super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum) + resetView() + when (mCurrentLightId) { + TrafficLightEnum.RED -> changeCountdownRed(redNum) + TrafficLightEnum.YELLOW -> changeCountdownYellow(yellowNum) + TrafficLightEnum.GREEN -> changeCountdownGreen(greenNum) + else -> UiThreadHandler.post { bus_p_traffic_light_time_tv.text = "" } + } + } + + override fun changeCountdownRed(redNum: Int) { + super.changeCountdownRed(redNum) + UiThreadHandler.post { + if (redNum > 0) { + resetView() + bus_p_traffic_light_time_tv.text = redNum.toString() + } else { + disableTrafficLightCountDown() + bus_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownGreen(greenNum: Int) { + super.changeCountdownGreen(greenNum) + UiThreadHandler.post { + if (greenNum > 0) { + resetView() + bus_p_traffic_light_time_tv.text = greenNum.toString() + } else { + disableTrafficLightCountDown() + bus_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownYellow(yellowNum: Int) { + super.changeCountdownYellow(yellowNum) + UiThreadHandler.post { + if (yellowNum > 0) { + resetView() + bus_p_traffic_light_time_tv.text = yellowNum.toString() + } else { + disableTrafficLightCountDown() + bus_p_traffic_light_time_tv.text = "" + } + } + } + + /** + * 更新红绿灯icon + * + * @param lightId 0-都是默认,1-红,2-黄,3-绿 + */ + private fun updateTrafficLightIcon(lightId: TrafficLightEnum) { + UiThreadHandler.post { + when (lightId) { + TrafficLightEnum.RED -> { + bus_p_traffic_light_iv.setBackgroundResource(R.drawable.bus_p_light_red_nor) + this@BusPassengerTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.YELLOW -> { + bus_p_traffic_light_iv.setBackgroundResource(R.drawable.bus_p_light_yellow_nor) + this@BusPassengerTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.GREEN -> { + bus_p_traffic_light_iv.setBackgroundResource(R.drawable.bus_p_light_green_nor) + this@BusPassengerTrafficLightView.visibility = VISIBLE + } + else -> this@BusPassengerTrafficLightView.visibility = GONE + } + } + } + + override fun disableTrafficLightCountDown() { + super.disableTrafficLightCountDown() + UiThreadHandler.post { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.bus_p_traffic_light_icon_size).toInt() + setLayoutParams(lp) + bus_p_traffic_light_time_tv.visibility = GONE + bus_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.dp_90).toInt() + } + } + } + + private fun resetView() { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.bus_p_route_traffic_light_view_width).toInt() + setLayoutParams(lp) + bus_p_traffic_light_time_tv.visibility = VISIBLE + bus_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.bus_p_traffic_light_bg_width).toInt() + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml index 59714c2b32..95eaa395d2 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml @@ -26,15 +26,14 @@ app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent"/> - - + + Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file +//package com.mogo.och.bus.passenger; +// +//import org.junit.Test; +// +//import static org.junit.Assert.*; +// +///** +// * Example local unit test, which will execute on the development machine (host). +// * +// * @see Testing documentation +// */ +//public class ExampleUnitTest { +// @Test +// public void addition_isCorrect() { +// assertEquals(4, 2 + 2); +// } +//} \ No newline at end of file diff --git a/OCH/mogo-och-bus/build.gradle b/OCH/mogo-och-bus/build.gradle index 7d6e998bbc..3e3369f724 100644 --- a/OCH/mogo-och-bus/build.gradle +++ b/OCH/mogo-och-bus/build.gradle @@ -56,19 +56,6 @@ dependencies { implementation project(":OCH:mogo-och-common-module") implementation rootProject.ext.dependencies.androidxrecyclerview - if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { - implementation rootProject.ext.dependencies.mogoutils - implementation rootProject.ext.dependencies.mogocommons - implementation rootProject.ext.dependencies.mogo_core_data - implementation rootProject.ext.dependencies.mogo_core_function_call - implementation rootProject.ext.dependencies.mogo_core_function_hmi - }else { - implementation project(":core:mogo-core-utils") - implementation project(":foudations:mogo-commons") - implementation project(':core:mogo-core-data') - implementation project(':core:mogo-core-function-call') - implementation project(':core:function-impl:mogo-core-function-hmi') - } } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java index 5233b3699e..fa5adf8e1a 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java @@ -22,7 +22,6 @@ import androidx.constraintlayout.widget.Group; import com.mogo.commons.mvp.IView; import com.mogo.commons.mvp.MvpFragment; import com.mogo.commons.mvp.Presenter; -import com.mogo.eagle.core.data.config.HmiBuildConfig; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; @@ -30,7 +29,9 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListener import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; -import com.mogo.eagle.core.function.hmi.ui.setting.SOPSettingView; +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxBubbleView; +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView; +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxListView; import com.mogo.eagle.core.function.hmi.ui.widget.TrafficDataView; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener; @@ -79,6 +80,11 @@ public abstract class BaseBusTabFragment private ImageView mSwitchMapModeImage; private LinearLayout mSwitchMapModeLayout; + //消息盒子 + private DriverMsgBoxButtonView viewDriverMsgBoxButton; + private DriverMsgBoxListView viewDriverMsgBoxList; + private DriverMsgBoxBubbleView viewDriverMsgBoxBubble; + private ObjectAnimator autopilotLoadingAnimator; public boolean isAnimateRunning = false; @@ -189,15 +195,29 @@ public abstract class BaseBusTabFragment if (mBadcaseBtn != null) { CallerDevaToolsManager.INSTANCE.initBadCase(mBadcaseBtn); - if (!HmiBuildConfig.isShowBadCaseView) { - CallerAutopilotRecordListenerManager.INSTANCE.addListener(TAG, this); - } + CallerAutopilotRecordListenerManager.INSTANCE.addListener(TAG, this); } mAICollectBtn = findViewById(R.id.module_mogo_och_ai_collet_rl); if (mAICollectBtn != null) { CallerDevaToolsManager.INSTANCE.initAiCollect(mAICollectBtn); } + //消息盒子 + viewDriverMsgBoxButton = findViewById(R.id.viewDriverMsgBoxButton); + viewDriverMsgBoxList = findViewById(R.id.viewDriverMsgBoxList); + viewDriverMsgBoxBubble = findViewById(R.id.viewDriverMsgBoxBubble); + viewDriverMsgBoxButton.setClickListener(show -> { + if(show){ + viewDriverMsgBoxList.setVisibility(View.VISIBLE); + viewDriverMsgBoxList.notifyData(); + viewDriverMsgBoxBubble.setVisibility(View.GONE); + viewDriverMsgBoxBubble.isShowData(false); + }else{ + viewDriverMsgBoxList.setVisibility(View.GONE); + viewDriverMsgBoxBubble.setVisibility(View.VISIBLE); + viewDriverMsgBoxBubble.isShowData(true); + } + }); } @Nullable @@ -230,9 +250,7 @@ public abstract class BaseBusTabFragment @Override public void onDestroyView() { super.onDestroyView(); - if (!HmiBuildConfig.isShowBadCaseView) { - CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG); - } + CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG); EventBus.getDefault().unregister(this); } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/ui/BusTrafficLightView.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/ui/BusTrafficLightView.java deleted file mode 100644 index 4b25021821..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/ui/BusTrafficLightView.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.mogo.och.bus.ui; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.widget.ImageView; - -import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.bus.R; -import com.mogo.och.common.module.wigets.OCHGradientTextView; - -import org.jetbrains.annotations.Nullable; - -/** - * Bus司机端:红绿灯view - * - * Created on 2022/3/29 - */ -public class BusTrafficLightView extends IViewTrafficLight { - - private ImageView mLightIconIV; - private OCHGradientTextView mLightTimeTV; - private int mCurrentLightId; - - public BusTrafficLightView(@Nullable Context context) { - this(context, null, 0); - } - - public BusTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public BusTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context); - } - - private void init(Context context) { - LayoutInflater.from(context).inflate(R.layout.bus_traffic_light_view, this, true); - mLightIconIV = findViewById(R.id.bus_traffic_light_iv); - mLightTimeTV = findViewById(R.id.bus_traffic_light_time_tv); - } - - /** - * 展示红绿灯预警 - * - * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 - * @param lightSource 1:云端下发;2:自车感知 - */ - @Override - public void showWarningTrafficLight(int checkLightId,int lightSource) { - super.showWarningTrafficLight(checkLightId,lightSource); - mCurrentLightId = checkLightId; - updateTrafficLightIcon(checkLightId); - } - - /** - * 关闭红绿灯预警展示,并重制灯态 - */ - @Override - public void disableWarningTrafficLight() { - super.disableWarningTrafficLight(); - UiThreadHandler.post(() -> { - mCurrentLightId = 0; - BusTrafficLightView.this.setVisibility(GONE); - }); - } - - /** - * @param redNum 红灯倒计时 - * @param yellowNum 黄灯倒计时 - * @param greenNum 绿灯倒计时 - */ - @Override - public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) { - super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum); - switch (mCurrentLightId) { - case 1: - changeCountdownRed(redNum); - break; - case 2: - changeCountdownYellow(yellowNum); - break; - case 3: - changeCountdownGreen(greenNum); - break; - default: - UiThreadHandler.post(() -> { - mLightTimeTV.setText(""); - }); - break; - } - } - - @Override - public void changeCountdownRed(int redNum) { - super.changeCountdownRed(redNum); - UiThreadHandler.post(() -> { - if (redNum > 0) { - mLightTimeTV.setVertrial(true); - mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_red_color_up), - getResources().getColor(R.color.bus_traffic_light_red_color_down)}); - mLightTimeTV.setText(String.valueOf(redNum)); - } else { - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownGreen(int greenNum) { - super.changeCountdownGreen(greenNum); - UiThreadHandler.post(() -> { - if (greenNum > 0) { - mLightTimeTV.setVertrial(true); - mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_green_color_up), - getResources().getColor(R.color.bus_traffic_light_green_color_down)}); - mLightTimeTV.setText(String.valueOf(greenNum)); - } else { - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownYellow(int yellowNum) { - super.changeCountdownYellow(yellowNum); - UiThreadHandler.post(() -> { - if (yellowNum > 0) { - mLightTimeTV.setVertrial(true); - mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_yellow_color_up), - getResources().getColor(R.color.bus_traffic_light_yellow_color_down)}); - mLightTimeTV.setText(String.valueOf(yellowNum)); - } else { - mLightTimeTV.setText(""); - } - }); - } - - /** - * 更新红绿灯icon - * - * @param lightId 0-都是默认,1-红,2-黄,3-绿 - */ - private void updateTrafficLightIcon(int lightId) { - UiThreadHandler.post(() -> { - switch (lightId) { - case 1: - mLightIconIV.setBackgroundResource(R.drawable.bus_light_red_nor); - BusTrafficLightView.this.setVisibility(VISIBLE); - break; - case 2: - mLightIconIV.setBackgroundResource(R.drawable.bus_lightyellow_nor); - BusTrafficLightView.this.setVisibility(VISIBLE); - break; - case 3: - mLightIconIV.setBackgroundResource(R.drawable.bus_light_green_nor); - BusTrafficLightView.this.setVisibility(VISIBLE); - break; - default: - BusTrafficLightView.this.setVisibility(GONE); - break; - } - }); - } -} diff --git a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml index 5536384f8a..4a79c2c3a4 100644 --- a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml +++ b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml @@ -29,8 +29,115 @@ android:visibility="gone" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" - app:marginStart="@dimen/dp_640" - app:marginTop="@dimen/dp_80" /> + android:layout_marginStart="@dimen/dp_640" + android:layout_marginTop="@dimen/dp_80"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +