Kaynağa Gözat

hicar的监听导致pc和pad端白屏的bug。播放页进度条调整优化

onecold 1 yıl önce
ebeveyn
işleme
f67a45e1a6

+ 37 - 28
entry/src/main/ets/entryability/EntryAbility.ets

@@ -38,7 +38,8 @@ import { display } from '@kit.ArkUI';
 export default class EntryAbility extends UIAbility {
     // UI上下文对象,用于获取窗口信息
     private uiContext?: UIContext;
-    private awareness: smartMobilityCommon.SmartMobilityAwareness = smartMobilityCommon.getSmartMobilityAwareness();
+    // private awareness: smartMobilityCommon.SmartMobilityAwareness = smartMobilityCommon.getSmartMobilityAwareness();
+    private awareness: smartMobilityCommon.SmartMobilityAwareness|undefined = canIUse("SystemCapability.SmartOptimizer.SmartMobility")?smartMobilityCommon.getSmartMobilityAwareness():undefined;
 
     /**
      * 窗口尺寸变化回调函数
@@ -163,14 +164,17 @@ export default class EntryAbility extends UIAbility {
 
     onDestroy() {
         hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
-        let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.CAR_HOP];
-        // 出行连接状态回调函数
-        const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
-            hilog.info(0x0000, 'Received smart mobility info: ', JSON.stringify(info));
-        };
-        // 解注册智慧出行连接状态的监听 示例2
-        this.awareness.off('smartMobilityStatus', types, callBack);
-    }
+        if(this.awareness){
+            let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.CAR_HOP];
+            // 出行连接状态回调函数
+            const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
+                hilog.info(0x0000, 'Received smart mobility info: ', JSON.stringify(info));
+            };
+            // 解注册智慧出行连接状态的监听 示例2
+            this.awareness.off('smartMobilityStatus', types, callBack);
+        }
+        }
+
 
     onWindowStageCreate(windowStage: window.WindowStage) {
         // Main window is created, set main page for this ability
@@ -274,32 +278,37 @@ export default class EntryAbility extends UIAbility {
 
 
     getHiCarStatus(){
-        this.awareness = smartMobilityCommon.getSmartMobilityAwareness();
+        if(this.awareness){
+            // this.awareness = smartMobilityCommon.getSmartMobilityAwareness();
 
-        // 业务类型
-        let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.HICAR];
-        // 获取出行业务连接状态
-        let info = this.awareness.getSmartMobilityStatus(types[0]);
-
-        hilog.info(0x0000, 'getHiCarStatus  info: ', JSON.stringify(info));
-        if(info&&info.status==1){
-            AppStorage.setOrCreate('isHiCarStatus', true);
-        }else{
-            AppStorage.setOrCreate('isHiCarStatus', false);
-        }
+            // 业务类型
+            let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.HICAR];
+            // 获取出行业务连接状态
+            let info = this.awareness.getSmartMobilityStatus(types[0]);
 
-        // 出行连接状态回调函数
-        const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
-            hilog.info(0x0000, 'getHiCarStatus Received smart mobility info: ', JSON.stringify(info));
+            hilog.info(0x0000, 'getHiCarStatus  info: ', JSON.stringify(info));
             if(info&&info.status==1){
                 AppStorage.setOrCreate('isHiCarStatus', true);
             }else{
                 AppStorage.setOrCreate('isHiCarStatus', false);
             }
-            this.sendChangeEvent()
-        };
-        // 注册智慧出行连接状态的监听
-        this.awareness.on('smartMobilityStatus', types, callBack);
+
+            // 出行连接状态回调函数
+            const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
+                hilog.info(0x0000, 'getHiCarStatus Received smart mobility info: ', JSON.stringify(info));
+                if(info&&info.status==1){
+                    AppStorage.setOrCreate('isHiCarStatus', true);
+                }else{
+                    AppStorage.setOrCreate('isHiCarStatus', false);
+                }
+                this.sendChangeEvent()
+            };
+            // 注册智慧出行连接状态的监听
+            this.awareness.on('smartMobilityStatus', types, callBack);
+        }else{
+            AppStorage.setOrCreate('isHiCarStatus', false);
+        }
+
 
 
     }

+ 2 - 2
entry/src/main/ets/view/LocalMusic.ets

@@ -7248,7 +7248,7 @@ export struct LocalMusic {
 
     }
     //x5的竖屏模式需要99%
-    .width('95%')
+    .width(this.isLandscape?'80%':'93%')
     .justifyContent(FlexAlign.Center)
     .margin({bottom:5})
     .animation({
@@ -7366,7 +7366,7 @@ export struct LocalMusic {
       })
 
     }
-    .width('95%')
+    .width(this.isLandscape?'88%':'95%')
     .justifyContent(FlexAlign.SpaceAround)
     .height(30)
     .margin({top:3})