[fragment 内存泄漏]
This commit is contained in:
yangyakun
2024-04-26 19:21:23 +08:00
parent fd5ec5750a
commit e9f4da7389
24 changed files with 193 additions and 72 deletions

View File

@@ -26,17 +26,10 @@ import com.mogo.och.shuttle.passenger.ui.widget.M2StatusBarView
class ShuttlePassengerProvider : CommonServiceImpl() {
private val tag = ShuttlePassengerProvider::class.java.simpleName
private lateinit var mPM2Fragment: Fragment
private var mPM2Fragment: Fragment?=null
override fun init(context: Context) {
TicketModel.load()
mPM2Fragment = if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) {
PM2BaseFragment()
}else if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) {
BusPassengerRouteFragment()
}else{
BusPassengerRouteFragment()
}
}
override fun getStatusBarView(context: Context): View {
@@ -56,7 +49,21 @@ class ShuttlePassengerProvider : CommonServiceImpl() {
if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) {
MultiDisplayUtils.startActWithSecond(ActivityUtils.getTopActivity(), MediaPlayerActivity::class.java)
}
return mPM2Fragment
if(mPM2Fragment==null){
mPM2Fragment = if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) {
PM2BaseFragment()
}else if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) {
BusPassengerRouteFragment()
}else{
BusPassengerRouteFragment()
}
}
return mPM2Fragment!!
}
override fun resetFragment() {
super.resetFragment()
mPM2Fragment = null
}
}

View File

@@ -86,20 +86,26 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
@Override
public void onAutopilotEnable() {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE));
if(mView != null) {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE));
}
}
@Override
public void onAutopilotDisable() {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE));
if(mView != null) {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE));
}
}
@Override
public void onAutopilotRunning() {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING));
if(mView != null) {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING));
}
}
@Override
@@ -109,14 +115,16 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
@Override
public void onCarLocationChanged(MogoLocation location) {
if (location != null){
if (location != null && mView != null){
runOnUIThread(() -> mView.onCarLocationChanged(location));
}
}
@Override
public void changeOperationStatus(boolean changeStatus) {
runOnUIThread(() -> mView.changeOperationStatus(changeStatus));
if(mView != null) {
runOnUIThread(() -> mView.changeOperationStatus(changeStatus));
}
}
@Override
@@ -126,27 +134,37 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
@Override
public void updateLineInfo(String lineName) {
runOnUIThread(() -> mView.updateLineInfo(lineName));
if(mView != null) {
runOnUIThread(() -> mView.updateLineInfo(lineName));
}
}
@Override
public void updateStationsInfo(List<BusStationBean> stations, int currentStationIndex, boolean isArrived) {
runOnUIThread(() -> mView.updateStationsInfo(stations,currentStationIndex, isArrived));
if(mView != null) {
runOnUIThread(() -> mView.updateStationsInfo(stations, currentStationIndex, isArrived));
}
}
@Override
public void showNoTaskView() {
runOnUIThread(() -> mView.showNoTaskView());
if(mView != null) {
runOnUIThread(() -> mView.showNoTaskView());
}
}
@Override
public void hideNoTaskView() {
runOnUIThread(() -> mView.hideNoTaskView());
if(mView != null) {
runOnUIThread(() -> mView.hideNoTaskView());
}
}
@Override
public void routePlanningToNextStationChanged(long meters, long timeInSecond) {
runOnUIThread(() -> mView.updateRoutePlanningToNextStation(meters, timeInSecond));
if(mView != null) {
runOnUIThread(() -> mView.updateRoutePlanningToNextStation(meters, timeInSecond));
}
}
@Override

View File

@@ -58,6 +58,7 @@ class BusPTurnLightView @JvmOverloads constructor(
super.onDetachedFromWindow()
CallerChassisLamplightListenerManager.removeListener(TAG)
CallerTurnLightListenerManager.removeListener(TAG)
TurnLightManager.removeTurnLightStatusChangeListener(TAG)
}
override fun hideTurnLightView() {

View File

@@ -124,11 +124,9 @@ class PM2DrivingInfoFragment :
}
}
override fun onDestroy() {
super.onDestroy()
overMapView?.let{
it.onDestroy()
}
override fun onDestroyView() {
overMapView?.onDestroy()
super.onDestroyView()
}
fun updateSpeed(speed: Int){

View File

@@ -58,6 +58,7 @@ class M2TurnLightView @JvmOverloads constructor(
super.onDetachedFromWindow()
CallerChassisLamplightListenerManager.removeListener(TAG)
CallerTurnLightListenerManager.removeListener(TAG)
TurnLightManager.removeTurnLightStatusChangeListener(TAG)
}
override fun hideTurnLightView() {