修改topview在vr模式下的位置

This commit is contained in:
tongchenfei
2020-10-23 18:49:43 +08:00
parent c944d8245f
commit e05e9aa542
10 changed files with 144 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayoutMediator
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.mvp.MvpFragment
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.v2x.R
import com.mogo.module.v2x.V2XConst.MODULE_NAME
import com.mogo.module.v2x.V2XServiceManager
@@ -22,6 +23,8 @@ import com.mogo.module.v2x.view.V2XEventPanelHistoryCountView
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener
import com.mogo.module.v2x.voice.V2XVoiceConstants
import com.mogo.module.v2x.voice.V2XVoiceManager
import com.mogo.service.statusmanager.IMogoStatusChangedListener
import com.mogo.service.statusmanager.StatusDescriptor
import com.mogo.utils.logger.Logger
@@ -30,7 +33,7 @@ import com.mogo.utils.logger.Logger
*
* @author tongchenfei
*/
class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPresenter>() {
class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPresenter>(),IMogoStatusChangedListener {
private val TAG = "EventPanelFragment"
@@ -178,6 +181,7 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
}
}
}
val x = resources.getDimensionPixelSize(if (DebugConfig.isLauncher()) {
R.dimen.module_v2x_event_panel_in_launcher_btn_x
} else {
@@ -186,13 +190,23 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
val y = resources.getDimensionPixelSize(R.dimen.module_v2x_event_panel_btn_y)
V2XServiceManager.getMogoEntranceButtonController()
.addBottomLayerView(mV2XEventPanelHistoryCountView, x, y)
mV2XEventPanelHistoryCountView?.visibility = if (MogoApisHandler.getInstance().apis.statusManagerApi.isVrMode) {
View.GONE
}else{
View.VISIBLE
}
changeEventCount()
MogoApisHandler.getInstance().apis.statusManagerApi.registerStatusChangedListener(MODULE_NAME, StatusDescriptor.VR_MODE, this)
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun onDestroyView() {
MogoApisHandler.getInstance().apis.statusManagerApi.unregisterStatusChangedListener(MODULE_NAME, StatusDescriptor.VR_MODE, this)
mediator?.detach()
// 避免内存泄漏
fragment = null
@@ -246,4 +260,13 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
// mV2XEventPanelHistoryCountView?.changeMsgCount(0)
// }
}
override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) {
if (isTrue) {
// 在vr模式
mV2XEventPanelHistoryCountView?.visibility = View.GONE
}else{
mV2XEventPanelHistoryCountView?.visibility = View.VISIBLE
}
}
}

View File

@@ -22,10 +22,12 @@ import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.alarm.V2XAlarmServer;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.module.v2x.utils.ObuConfig;
import com.mogo.module.v2x.utils.TrackUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
@@ -165,6 +167,10 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
v2XMessageEntity.setShowState(true);
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
}
if (!ObuConfig.useObuLocation) {
// 绿波车速引导刷新划线
V2XObuEventScenario.getInstance().updateLocation(location);
}
}
public MogoLocation getLastCarLocation() {