فهرست منبع

条数太大的时候 播放列表滚动非常卡 导致闪退,先改为不滚

onecold 11 ماه پیش
والد
کامیت
5bbeb18326
1فایلهای تغییر یافته به همراه25 افزوده شده و 9 حذف شده
  1. 25 9
      entry/src/main/ets/view/LocalMusic.ets

+ 25 - 9
entry/src/main/ets/view/LocalMusic.ets

@@ -4640,9 +4640,8 @@ export struct LocalMusic {
                 this.isShowSheet = !this.isShowSheet;
                 this.isShowSheet = !this.isShowSheet;
                 this.isFrontWhite = false
                 this.isFrontWhite = false
                 LogUtil.info('onecold scrollToIndex = ' + this.curIndex)
                 LogUtil.info('onecold scrollToIndex = ' + this.curIndex)
-                setTimeout(() => {
-                  this.playListScroller.scrollToIndex(this.curIndex, true, ScrollAlign.CENTER)
-                }, 123)
+
+                this.scrollIndex()
 
 
               } else {
               } else {
                 ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
                 ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
@@ -4678,6 +4677,27 @@ export struct LocalMusic {
 
 
   @State isFrontWhite: boolean = false
   @State isFrontWhite: boolean = false
 
 
+  scrollIndex(){
+    if(this.curIndex>500)//条数太大的时候 滚动非常卡 导致闪退,先改为不滚
+     return
+    try {
+      // const C_ITEM_HEIGHT = this.twoFingerType == 3 ? ITEM_HEIGHT_BIG : this.twoFingerType == 2 ? ITEM_HEIGHT : ITEM_HEIGHT_SMALL
+      // const offset = this.curIndex * C_ITEM_HEIGHT;
+
+
+      setTimeout(() => {
+        //this.playListScroller.scrollTo({ xOffset: 0, yOffset: offset, animation: { duration: 1000, curve: Curve.EaseInOut } });
+
+        this.getUIContext()?.animateTo({ duration: 555 }, () => {
+          this.playListScroller.scrollToIndex(this.curIndex,true, ScrollAlign.CENTER)
+        })
+      }, 123)
+    }catch (error) {
+      console.error(`onecold scrollIndex出错: ${error}`);
+    }
+
+  }
+
   //播放列表布局
   //播放列表布局
   @Builder
   @Builder
   PlayListSheet() {
   PlayListSheet() {
@@ -7723,9 +7743,7 @@ export struct LocalMusic {
         }else{
         }else{
           this.isFrontWhite = false
           this.isFrontWhite = false
         }
         }
-        setTimeout(() => {
-          this.playListScroller.scrollToIndex(this.curIndex,true, ScrollAlign.CENTER)
-        }, 123)
+          this.scrollIndex()
       })
       })
 
 
     }
     }
@@ -7854,9 +7872,7 @@ export struct LocalMusic {
         } else {
         } else {
           this.isFrontWhite = false
           this.isFrontWhite = false
         }
         }
-        setTimeout(() => {
-          this.playListScroller.scrollToIndex(this.curIndex, true, ScrollAlign.CENTER)
-        }, 123)
+        this.scrollIndex()
       })
       })
 
 
     }
     }