Bläddra i källkod

修复从手机切换到车机时导致的显示bug

chendeben 1 år sedan
förälder
incheckning
467e680372
1 ändrade filer med 10 tillägg och 0 borttagningar
  1. 10 0
      entry/src/main/ets/entryability/EntryAbility.ets

+ 10 - 0
entry/src/main/ets/entryability/EntryAbility.ets

@@ -84,6 +84,15 @@ export default class EntryAbility extends UIAbility {
         }
 
     }
+    onDisplayIdChange=(displayId: number)=> {
+        let curDisplay = display.getDisplayByIdSync(displayId);
+        console.info('twocold curDisplay 2 = '+curDisplay.name);
+        if(curDisplay.name =='HiCar'||curDisplay.name =='SuperLauncher'){
+            AppStorage.setOrCreate('curDisplayIsHiCar', true);
+        }else{
+            AppStorage.setOrCreate('curDisplayIsHiCar', false);
+        }
+    }
 
     async onCreate(want:Want, launchParam:AbilityConstant.LaunchParam) {
         AppStorage.setOrCreate('context', this.context);
@@ -218,6 +227,7 @@ export default class EntryAbility extends UIAbility {
 
             LogUtil.info('onecold  topRectHeight = '+topRectHeight);
             windowClass.on('avoidAreaChange', this.onAvoidAreaChange)
+            windowClass.on('displayIdChange', this.onDisplayIdChange)
         })