diff --git a/features/longList/src/main/ets/longlistability/LongListAbility.ets b/features/longList/src/main/ets/longlistability/LongListAbility.ets index c4156dcb2e706be6057f4df48851939a72e3cf25..e41fd29df760077701f6e0a5e05fb5fed50fb1f1 100644 --- a/features/longList/src/main/ets/longlistability/LongListAbility.ets +++ b/features/longList/src/main/ets/longlistability/LongListAbility.ets @@ -36,14 +36,14 @@ export default class LongListAbility extends UIAbility { return; } - // 2.1 调用create()接口创建并得到一个分布式数据对象实例 + // 2.1 Invoke the create () interface to create and obtain a distributed data object instance let continueData: ContinueData = new ContinueData(undefined,undefined); let dataObject = distributedDataObject.create(this.context, continueData); - // 2.2 注册恢复状态监听。收到状态为'restored'的回调通知时,表示接收端分布式数据对象已恢复发起端保存过来的数据(有资产数据时,对应的文件也迁移过来了) + // 2.2 Register the recovery state listening. When a callback notification with the status of'restored' is received, the distributed data object at the receiving end has restored the data saved by the originating end. (When asset data is available, the corresponding files are also migrated.) dataObject.on('status', (sessionId: string, networkId: string, status: string) => { if (status === 'restored') { - // 收到'restored'的状态通知表示已恢复发起端保存的数据 + // The status notification of "restored" is received, indicating that the data stored on the initiator has been restored AppStorage.setOrCreate('continueIndex', dataObject['continueIndex']); AppStorage.setOrCreate('currentOffset', dataObject['currentOffset']); AppStorage.setOrCreate('continueEntry', true); @@ -51,7 +51,7 @@ export default class LongListAbility extends UIAbility { } }); - // 2.3 从want.parameters中获取发起端放入的sessionId,调用setSessionId接口设置同步的sessionId + // 2.3 Obtain the sessionId placed by the initiator from want.parameters and call the setSessionId interface to set the synchronized sessionId let sessionId = want.parameters.distributedSessionId as string; dataObject.setSessionId(sessionId); this.context.restoreWindowStage(new LocalStorage()); @@ -60,20 +60,20 @@ export default class LongListAbility extends UIAbility { // [Start on_continue] async onContinue(wantParam: Record): Promise { - // 1.1 调用create()接口创建并得到一个分布式数据对象实例 - // continueData是一个object,可以用来存储需要接续的数据 + // 1.1 Invoke the create () interface to create and obtain a distributed data object instance + // continueData is an object that can be used to store the data that needs to be connected let continueIndex = AppStorage.get('continueIndex') as number; let currentOffset = AppStorage.get('currentOffset') as number; let continueData: ContinueData = new ContinueData(continueIndex, currentOffset); let dataObject = distributedDataObject.create(this.context, continueData); - // 1.2 调用genSessionId()接口创建一个sessionId,调用setSessionId()接口设置同步的sessionId,并将这个sessionId放入wantParam + // 1.2 Call the genSessionId () interface to create a sessionId, call the setSessionId () interface to set the synchronized sessionId, and put the sessionId into the wantParam let sessionId = distributedDataObject.genSessionId(); console.log(`gen sessionId: ${sessionId}`); dataObject.setSessionId(sessionId); wantParam.distributedSessionId = sessionId; - // 1.3 从wantParam获取接收端设备networkId,使用这个networkId调用save接口保存数据到接收端 + // 1.3 Obtain the networkId of the receiver device from wantParam. Use the networkId to invoke the save interface to save the data to the receiver let deviceId = wantParam.targetDevice as string; console.log(`get deviceId: ${deviceId}`); dataObject.save(deviceId); diff --git a/features/longList/src/main/ets/view/WaterFlowView.ets b/features/longList/src/main/ets/view/WaterFlowView.ets index 4dd302eb776fb1a53048e47a67b82f4a42762aa6..3741327efdcc2cb4b98477188f5e94869e20b88d 100644 --- a/features/longList/src/main/ets/view/WaterFlowView.ets +++ b/features/longList/src/main/ets/view/WaterFlowView.ets @@ -125,7 +125,9 @@ export struct WaterFlowView { build() { Column({ space: CommonConstants.SPACE_EIGHT }) { Column() { + // [Start water_flow] WaterFlow({ footer: this.footStyle, scroller: this.waterFlowScroller }) { + // [StartExclude water_flow] LazyForEach(this.waterFlowListData.getData(), (item: WaterFlowData, index: number) => { FlowItem() { if (item.waterFlowHead.type === CommonConstants.WATER_FLOW_IMAGE_TYPE) { @@ -197,7 +199,10 @@ export struct WaterFlowView { }, (item: WaterFlowData) => { return item.waterFlowDescription.index.toString(); }); + // [EndExclude water_flow] } + .restoreId(1) + // [End water_flow] .onDisAppear(()=>{ this.continueIndex = this.waterFlowScroller.currentOffset().yOffset; })