diff --git a/FramedRendering/AppScope/app.json5 b/FramedRendering/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a04d89d5563b81f4538cdaaef3639bd05f627c93 --- /dev/null +++ b/FramedRendering/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.framedrendering", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/FramedRendering/AppScope/resources/base/element/string.json b/FramedRendering/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8dee2c80170b6d9b38a5c1db639a4e640b09eb04 --- /dev/null +++ b/FramedRendering/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FramedRendering" + } + ] +} diff --git a/FramedRendering/AppScope/resources/base/media/app_icon.png b/FramedRendering/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/FramedRendering/AppScope/resources/base/media/app_icon.png differ diff --git a/FramedRendering/LICENSE b/FramedRendering/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/FramedRendering/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/FramedRendering/README.md b/FramedRendering/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7756fcfca07be17476f44e8a31aae788f6a43b47 --- /dev/null +++ b/FramedRendering/README.md @@ -0,0 +1,62 @@ +# 基于分帧渲染实现应用界面优化 + +### 介绍 + +在应用开发中,页面内列表结构复杂,每个列表项包含的组件较多,就会导致嵌套层级较深,从而引起组件负载加重,绘制耗时增长。 +本示例介绍在高负载的转场场景和滑动场景下使用分帧渲染提升性能,本工程配套官网[高负载场景下分帧渲染](https://developer.huawei.com/consumer/cn/doc/best-practices-V5/bpta-dispose-highly-loaded-component-render-V5)。 +涉及的ArkUI接口:[@ohos.graphics.displaySync (可变帧率)](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V13/js-apis-graphics-displaysync-V13#displaysynccreate)。 + +### 预览效果 + +| 转场场景 | 滑动场景 | +|--------------------------------------------------|-----------------------------------------------| +| ![image](screenshots/device/TransitionScene.gif) | ![image](screenshots/device/SlidingScene.gif) | + +#### 使用说明 + +1. 点击“转场场景”按钮,转场动画完成后进入页面,页面加载完成。 +2. 点击“滑动场景”按钮,进入日历页面,页面可以上下流畅滑动。 + +## 工程目录 + +``` +├──entry/src/main/ets +│ ├──common +│ │ ├──Constants.ets // 公共常量 +│ │ └──GlobalBuilderContext.ets // 缓存全局@Builder +│ ├──entryability +│ │ └──EntryAbility.ets // 程序入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 自定义应用数据转换和迁移模板类 +│ ├──model +│ │ ├──BasicDataSource.ets // 数据适配器基类 +│ │ ├──MidListDataSource.ets // 转场场景中间横向List数据适配器 +│ │ ├──MonthDataSource.ets // 日历数据适配器 +│ │ ├──ProductDetailSource.ets // 转场场景底部瀑布流数据适配器 +│ │ └──SwiperDataSource.ets // 转场场景swiper数据适配器 +│ ├──pages +│ │ └──Index.ets // 首页 +│ ├──util +│ │ └──CalculationDateUtil.ets // 日历工具类 +│ └──view +│ ├──DateItemView.ets // 每个月的日历数据 +│ ├──SlidingScene.ets // 日历页面 UI +│ └──TransitionScene.ets // 转场场景 UI +└──entry/src/main/resources // 应用资源目录 +``` + +### 具体实现 + +1. [转场场景](https://developer.huawei.com/consumer/cn/doc/best-practices-V5/bpta-dispose-highly-loaded-component-render-V5#section5987133112411) +2. [滑动场景](https://developer.huawei.com/consumer/cn/doc/best-practices-V5/bpta-dispose-highly-loaded-component-render-V5#section15195122915243) + +### 相关权限 + +不涉及 + +## 约束与限制 + +* 本示例仅支持标准系统上运行,支持设备:华为手机。 +* HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 +* DevEco Studio版本:DevEco Studio 5.0.0 Release及以上。 +* HarmonyOS SDK版本:HarmonyOS 5.0.0 Release SDK及以上。 \ No newline at end of file diff --git a/FramedRendering/build-profile.json5 b/FramedRendering/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6d93d9cd5af96ec9ec78db4738722a66c9464d7e --- /dev/null +++ b/FramedRendering/build-profile.json5 @@ -0,0 +1,40 @@ +{ + "app": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/FramedRendering/entry/build-profile.json5 b/FramedRendering/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/FramedRendering/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/FramedRendering/entry/hvigorfile.ts b/FramedRendering/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/FramedRendering/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/FramedRendering/entry/obfuscation-rules.txt b/FramedRendering/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/FramedRendering/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/FramedRendering/entry/oh-package.json5 b/FramedRendering/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/FramedRendering/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/FramedRendering/entry/src/main/ets/common/CommonConstants.ets b/FramedRendering/entry/src/main/ets/common/CommonConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c2f18cc0bbe803abda9a1fa01ffe7119be52d69 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/common/CommonConstants.ets @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +export class CommonConstants { + /** + * WaterFlow component vertical spacing. + */ + public static readonly COLUMNS_GAP: number = 7; + + /** + * Horizontal spacing between WaterFlow components. + */ + public static readonly ROWS_GAP: number = 12; + + /** + * NavDestination item0. + */ + public static readonly NAV_DESTINATION_ITEM_0: string = 'NavDestination_item_0'; + + /** + * NavDestination item1. + */ + public static readonly NAV_DESTINATION_ITEM_1: string = 'NavDestination_item_1'; + + /** + * 100 percent. + */ + public static readonly FULL_PERCENT: string = '100%'; +} diff --git a/FramedRendering/entry/src/main/ets/common/GlobalBuilderContext.ets b/FramedRendering/entry/src/main/ets/common/GlobalBuilderContext.ets new file mode 100644 index 0000000000000000000000000000000000000000..13569101278cd662f39e7c78668777e7dffb3589 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/common/GlobalBuilderContext.ets @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { wrappedBuilderSlidingScene } from '../view/SlidingScene'; +import { wrappedBuilderTransitionScene } from '../view/TransitionScene'; +import { CommonConstants } from './CommonConstants'; + +export class GlobalBuilderContext { + private static instance: GlobalBuilderContext; + private objects = new Map(); + + public static getContext(): GlobalBuilderContext { + if (!GlobalBuilderContext.instance) { + GlobalBuilderContext.instance = new GlobalBuilderContext(); + GlobalBuilderContext.instance.setObject(CommonConstants.NAV_DESTINATION_ITEM_0, wrappedBuilderTransitionScene); + GlobalBuilderContext.instance.setObject(CommonConstants.NAV_DESTINATION_ITEM_1, wrappedBuilderSlidingScene); + } + return GlobalBuilderContext.instance; + } + + getObject(key: string): Object | undefined { + return this.objects.get(key); + } + + setObject(key: string, objectClass: Object): void { + this.objects.set(key, objectClass); + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/entryability/EntryAbility.ets b/FramedRendering/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..658b37ad825e994dbaae500a620986562981d06a --- /dev/null +++ b/FramedRendering/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { UIAbility } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class EntryAbility extends UIAbility { + private windowClass: window.Window | undefined = undefined; + + onCreate(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + this.windowClass = windowStage.getMainWindowSync(); + this.windowClass.setWindowLayoutFullScreen(true).then(() => { + hilog.info(0x0000, 'testTag', 'Success in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.info(0x0000, 'testTag', + 'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + }); + this.immersive(); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + private immersive(): void { + let type: window.AvoidAreaType = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; + let avoidArea: window.AvoidArea = this.windowClass?.getWindowAvoidArea(type) as window.AvoidArea; + let bottomRectHeight: number = avoidArea.bottomRect.height; + AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); + type = window.AvoidAreaType.TYPE_SYSTEM; + avoidArea = this.windowClass?.getWindowAvoidArea(type) as window.AvoidArea; + let topRectHeight: number = avoidArea.topRect.height; + AppStorage.setOrCreate('topRectHeight', topRectHeight); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/FramedRendering/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/FramedRendering/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..1086e7e62c43cb995cd63f2edc6ce3fbc206084e --- /dev/null +++ b/FramedRendering/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/model/BasicDataSource.ets b/FramedRendering/entry/src/main/ets/model/BasicDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..360f30bf442212cedf8ec6ab0af4ff0af1562b95 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/model/BasicDataSource.ets @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +export abstract class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public abstract totalCount(): number; + + public abstract getData(index: number): T | void; + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos > 0) { + this.listeners.splice(pos, 1); + } + } + + notifyDataAdd(index: number): void { + this.listeners.forEach((listener: DataChangeListener) => { + listener.onDataAdd(index); + }) + } +} + +/** + * product introduction data model + */ +export class ProductIntroductionModel { + id: string; + icon: Resource; + title: ResourceStr; + + constructor(id: string, icon: Resource, title: ResourceStr) { + this.id = id; + this.icon = icon; + this.title = title; + } +} + +/** + * product detail data model + */ +export class ProductDetailModel { + id: string; + title: ResourceStr; + icon: Resource; + des: ResourceStr; + price: ResourceStr; + + constructor(id: string, title: ResourceStr, icon: Resource, des: ResourceStr, price: ResourceStr) { + this.id = id; + this.title = title; + this.icon = icon; + this.des = des; + this.price = price; + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/model/MidListDataSource.ets b/FramedRendering/entry/src/main/ets/model/MidListDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..662ceaf53450e2db8054413a9402723f87f5476e --- /dev/null +++ b/FramedRendering/entry/src/main/ets/model/MidListDataSource.ets @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { BasicDataSource, ProductIntroductionModel } from './BasicDataSource'; + +export class MidListDataSource extends BasicDataSource { + private dataList: Array = []; + + public totalCount(): number { + return this.dataList.length; + } + + public getData(index: number): ProductIntroductionModel { + return this.dataList[index]; + } + + public pushData(data: ProductIntroductionModel[]): void { + this.dataList.push(...data); + this.notifyDataAdd(this.dataList.length - 1); + } + + public getProductData(): void { + const productIntroductions: Array = + [ + new ProductIntroductionModel('0', $r('sys.symbol.car_fill'), $r('app.string.car')), + new ProductIntroductionModel('1', $r('sys.symbol.creditcard'), $r('app.string.wallet')), + new ProductIntroductionModel('2', $r('sys.symbol.rectangle_4_group_1'), $r('app.string.jigsaw')), + new ProductIntroductionModel('3', $r('sys.symbol.star_bookmark'), $r('app.string.favorite')), + new ProductIntroductionModel('0', $r('sys.symbol.car_fill'), $r('app.string.car')), + new ProductIntroductionModel('1', $r('sys.symbol.creditcard'), $r('app.string.wallet')), + new ProductIntroductionModel('2', $r('sys.symbol.rectangle_4_group_1'), $r('app.string.jigsaw')), + new ProductIntroductionModel('3', $r('sys.symbol.star_bookmark'), $r('app.string.favorite')) + ]; + this.pushData(productIntroductions); + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/model/MonthDataSource.ets b/FramedRendering/entry/src/main/ets/model/MonthDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..300f5823cc6a80c31f01e50f87cab3cece0e3d87 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/model/MonthDataSource.ets @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { CalculationDateUtil } from '../util/CalculationDateUtil'; +import { BasicDataSource } from './BasicDataSource'; + +export class MonthDataSource extends BasicDataSource { + private currentYear: number = new Date().getFullYear(); + private dataArray: Month[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): Month { + return this.dataArray[index]; + } + + public pushData(data: Month): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } + + public clearData() { + for (let i = 0; i < this.dataArray.length; i++) { + this.dataArray.pop(); + this.notifyDataAdd(this.dataArray.length - 1); + } + } + + public getDateData() { + for (let i = 1; i <= 12; i++) { + let monthDays: number[] = CalculationDateUtil.getMonthDate(i, this.currentYear); + let lunarDays: string[] = []; + for (let j = 0; j < monthDays.length; j++) { + if (monthDays[j] === 0) { + lunarDays.push(''); + } else { + lunarDays.push(CalculationDateUtil.dateToLunar(this.currentYear, i, monthDays[j])); + } + } + const month: Month = { + month: CalculationDateUtil.numberToCharacter(i) as string, + num: i, + days: monthDays, + lunarDays: lunarDays, + year: this.currentYear + } + this.pushData(month); + } + } +} + +export interface Month { + month: string; + num: number; + days: number[]; + lunarDays: string[]; + year: number; +} diff --git a/FramedRendering/entry/src/main/ets/model/ProductDetailSource.ets b/FramedRendering/entry/src/main/ets/model/ProductDetailSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..355d7e0f4c8059eaa450de3a831876db577e3f9e --- /dev/null +++ b/FramedRendering/entry/src/main/ets/model/ProductDetailSource.ets @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { BasicDataSource, ProductDetailModel } from './BasicDataSource'; + +export class ProductDetailSource extends BasicDataSource { + private dataList: Array = []; + private itemId: number = 0; + + public totalCount(): number { + return this.dataList.length; + } + + public getData(index: number): ProductDetailModel { + return this.dataList[index]; + } + + private pushData(data: ProductDetailModel[]): void { + let startIndex: number = this.dataList.length === 0 ? 0 : this.dataList.length - 1; + let endIndex: number = startIndex + data.length; + this.dataList.push(...data); + for (let i = startIndex; i < endIndex; i++) { + this.notifyDataAdd(i); + } + } + + public getProductData(startIndex?: number, endIndex?: number): void { + const productIntroductions: Array = + [ + new ProductDetailModel(`${this.itemId}`, $r('app.string.product_title01'), $r('app.media.product01'), + $r('app.string.product_des01'), $r('app.string.product_price01')), + new ProductDetailModel(`${this.itemId + 1}`, $r('app.string.product_title02'), $r('app.media.product02'), + $r('app.string.product_des02'), $r('app.string.product_price02')), + new ProductDetailModel(`${this.itemId + 2}`, $r('app.string.product_title03'), $r('app.media.product03'), + $r('app.string.product_des03'), $r('app.string.product_price03')), + new ProductDetailModel(`${this.itemId + 3}`, $r('app.string.product_title04'), $r('app.media.product04'), + $r('app.string.product_des04'), $r('app.string.product_price04')), + new ProductDetailModel(`${this.itemId + 4}`, $r('app.string.product_title01'), $r('app.media.product01'), + $r('app.string.product_des01'), $r('app.string.product_price01')), + new ProductDetailModel(`${this.itemId + 5}`, $r('app.string.product_title02'), $r('app.media.product02'), + $r('app.string.product_des02'), $r('app.string.product_price02')), + new ProductDetailModel(`${this.itemId + 6}`, $r('app.string.product_title03'), $r('app.media.product03'), + $r('app.string.product_des03'), $r('app.string.product_price03')), + new ProductDetailModel(`${this.itemId + 7}`, $r('app.string.product_title04'), $r('app.media.product04'), + $r('app.string.product_des04'), $r('app.string.product_price04')), + new ProductDetailModel(`${this.itemId + 8}`, $r('app.string.product_title01'), $r('app.media.product01'), + $r('app.string.product_des01'), $r('app.string.product_price01')), + new ProductDetailModel(`${this.itemId + 9}`, $r('app.string.product_title02'), $r('app.media.product02'), + $r('app.string.product_des02'), $r('app.string.product_price02')) + ]; + this.itemId += 10; + this.pushData(productIntroductions.slice(startIndex, endIndex)); + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/model/SwiperDataSource.ets b/FramedRendering/entry/src/main/ets/model/SwiperDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c447f79b8da2cf13205414ce111742a0ff10725 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/model/SwiperDataSource.ets @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { BasicDataSource, ProductIntroductionModel } from './BasicDataSource'; + +export class SwiperDataSource extends BasicDataSource { + private dataList: Array = []; + + public totalCount(): number { + return this.dataList.length; + } + + public getData(index: number): ProductIntroductionModel { + return this.dataList[index]; + } + + private pushData(data: ProductIntroductionModel[]): void { + this.dataList.push(...data); + this.notifyDataAdd(this.dataList.length - 1); + } + + public getProductData(): void { + if (this.dataList.length > 0) { + return; + } + const productIntroductions: Array = + [ + new ProductIntroductionModel('0', $r('sys.symbol.matebook_fill'), $r('app.string.computer')), + new ProductIntroductionModel('1', $r('sys.symbol.smartscreen_fill'), $r('app.string.vision')), + new ProductIntroductionModel('2', $r('sys.symbol.soundx_fill'), $r('app.string.sound_box')), + new ProductIntroductionModel('3', $r('sys.symbol.phone_fill_1'), $r('app.string.mobile_phone')), + new ProductIntroductionModel('4', $r('sys.symbol.earphone_case_16896'), $r('app.string.watches')), + new ProductIntroductionModel('5', $r('sys.symbol.matebook_fill'), $r('app.string.computer')), + new ProductIntroductionModel('6', $r('sys.symbol.smartscreen_fill'), $r('app.string.vision')), + new ProductIntroductionModel('7', $r('sys.symbol.soundx_fill'), $r('app.string.sound_box')), + new ProductIntroductionModel('8', $r('sys.symbol.phone_fill_1'), $r('app.string.mobile_phone')), + new ProductIntroductionModel('9', $r('sys.symbol.earphone_case_16896'), $r('app.string.watches')) + ]; + this.pushData(productIntroductions); + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/pages/Index.ets b/FramedRendering/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d43b2b28947ac1a341b3cce1ff0a498598b0ddc --- /dev/null +++ b/FramedRendering/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { CommonConstants } from '../common/CommonConstants'; +import { GlobalBuilderContext } from '../common/GlobalBuilderContext'; + +@Entry +@Component +struct Index { + @StorageProp('topRectHeight') topRectHeight: number = 0; + @StorageProp('bottomRectHeight') bottomHeight: number = 0; + private pageStack: NavPathStack = new NavPathStack(); + private readonly COLUMN_SPACE: number = 12; + + build() { + Navigation(this.pageStack) { + Column({ space: this.COLUMN_SPACE }) { + Button($r('app.string.transition')) + .width(CommonConstants.FULL_PERCENT) + .onClick(() => { + this.pageStack.pushPathByName(CommonConstants.NAV_DESTINATION_ITEM_0, ''); + }) + Button($r('app.string.sliding')) + .width(CommonConstants.FULL_PERCENT) + .onClick(() => { + this.pageStack.pushPathByName(CommonConstants.NAV_DESTINATION_ITEM_1, ''); + }) + } + .padding({ left: 16, right: 16, bottom: (16 + px2vp(this.bottomHeight)) }) + .justifyContent(FlexAlign.End) + .alignItems(HorizontalAlign.Center) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + } + .title({ + builder: this.navTitle(), + height: 112 + }) + .navDestination(this.PagesMap) + .padding({ top: px2vp(this.topRectHeight) }) + .backgroundColor('#F1F3F5') + } + + @Builder + navTitle() { + Column() { + Text($r('app.string.EntryAbility_label')) + .fontSize(30) + .fontWeight(700) + .lineHeight(40) + } + .justifyContent(FlexAlign.End) + .alignItems(HorizontalAlign.Start) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .padding({ + left: 16, + right: 16, + bottom: 8 + }) + } + + @Builder + PagesMap(id: string) { + if (GlobalBuilderContext.getContext().getObject(id)) { + (GlobalBuilderContext.getContext().getObject(id) as WrappedBuilder<[string]>).builder(id); + } + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/util/CalculationDateUtil.ets b/FramedRendering/entry/src/main/ets/util/CalculationDateUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..58703696fd5fc6343af8a4b72f7a042f5efe5ac0 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/util/CalculationDateUtil.ets @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { LunarDate, solar2lunar } from 'lunar_lite'; +import hilog from '@ohos.hilog'; + +const TAG = 'CalculationDateUtil'; +const SATURDAY: number = 6; + +export class CalculationDateUtil { + private static dateMap: Map = new Map( + [ + [1, $r('app.string.january')], [2, $r('app.string.february')], [3, $r('app.string.march')], + [4, $r('app.string.april')], [5, $r('app.string.may')], [6, $r('app.string.june')], [7, $r('app.string.july')], + [8, $r('app.string.august')], [9, $r('app.string.september')], [10, $r('app.string.october')], + [11, $r('app.string.november')], [12, $r('app.string.december')], + ] + ); + + public static getMonthDate(specifiedMonth: number, specifiedYear: number): number[] { + let currentFirstWeekDay: number = 0; + let currentLastWeekDay: number = 0; + const currentAllDay: number[] = []; + const totalDays: number = new Date(specifiedYear, specifiedMonth, 0).getDate(); + currentFirstWeekDay = new Date(specifiedYear, specifiedMonth - 1, 1).getDay(); + currentLastWeekDay = new Date(specifiedYear, specifiedMonth - 1, totalDays).getDay(); + + for (let item = 0; item < currentFirstWeekDay; item++) { + currentAllDay[item] = 0; + } + + for (let item = 1; item <= totalDays; item++) { + currentAllDay.push(item); + } + + for (let item = 0; item < SATURDAY - currentLastWeekDay; item++) { + currentAllDay.push(0); + } + return currentAllDay; + } + + public static dateToLunar(year: number, month: number, day: number): string { + let lunarDate: LunarDate = solar2lunar(`${year}-${month}-${day}`); + const dayStr: Resource[] = + [ + $r('app.string.monday'), $r('app.string.tuesday'), $r('app.string.wednesday'), $r('app.string.thursday'), + $r('app.string.Friday'), $r('app.string.saturday'), $r('app.string.seven'), $r('app.string.eight'), + $r('app.string.nine'), $r('app.string.ten') + ]; + let lunarDay: string = ''; + const numberDay: number = lunarDate.lunarDay; + if (numberDay <= 10 && numberDay > 0) { + lunarDay = CalculationDateUtil.getString($r('app.string.grade').id) + CalculationDateUtil.getString(dayStr[numberDay - 1].id); + } else { + const first: Resource = + numberDay.toString().charAt(0) === '1' ? $r('app.string.ten') : (numberDay.toString().charAt(0) === '2' ? + $r('app.string.chinese_twenty'): $r('app.string.wednesday')); + const second: Resource = + numberDay.toString().charAt(1) === '0' ? $r('app.string.ten') : + dayStr[Number.parseInt(numberDay.toString().charAt(1)) - 1]; + lunarDay = CalculationDateUtil.getString(first.id) + CalculationDateUtil.getString(second.id); + } + return lunarDay; + } + + public static numberToCharacter(num: number): ResourceStr | undefined { + return CalculationDateUtil.dateMap.get(num); + } + + public static getString(resourceId: number): string { + try { + return getContext().resourceManager.getStringSync(resourceId); + } catch (error) { + hilog.error(0x0000, TAG, `getString failed, errorCode: ${error.code}`); + return ''; + } + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/view/DateItemView.ets b/FramedRendering/entry/src/main/ets/view/DateItemView.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec05ebff4856c3aa6ce394c312b29f4ef46b5b46 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/view/DateItemView.ets @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { displaySync } from '@kit.ArkGraphics2D'; +import { Month } from '../model/MonthDataSource'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; +import { CommonConstants } from '../common/CommonConstants'; + +const WEEK: Resource[] = + [ + $r('app.string.sunday'), $r('app.string.january'), $r('app.string.february'), $r('app.string.march'), + $r('app.string.april'), $r('app.string.may'), $r('app.string.june') + ]; // Set calendar week, starting on Sunday +const allDisplaySyncArray: displaySync.DisplaySync[] = []; + +@Reusable +@Component +export struct DateItemView { + monthItem: Month = { + month: '', + num: 0, + days: [], + lunarDays: [], + year: 0 + }; + @State month: string = ''; + @State monthNumber: number = 0; + @State days: number[] = []; + @State lunarDays: string[] = []; + private currentMonth: number = new Date().getMonth() + 1; + private currentDay: number = new Date().getDate(); + private displaySync: displaySync.DisplaySync | undefined = undefined; + private temp: Month[] = []; + private step: number = 0; + private maxStep: number = 2; + private readonly MAX_EVERY_FRAME: number = 5; // Only five-day data is updated for one frame + + aboutToReuse(params: Record): void { + hiTraceMeter.startTrace('reuse_' + (params.monthItem as Month).month, 1); + this.temp.push(params.monthItem as Month); + hiTraceMeter.finishTrace('reuse_' + (params.monthItem as Month).month, 1); + } + + aboutToRecycle(): void { + hiTraceMeter.startTrace('recycle_', 1); + this.temp = []; + this.step = 0; + this.maxStep = 2; + hiTraceMeter.finishTrace('recycle_', 1); + } + + aboutToAppear(): void { + hiTraceMeter.startTrace('appear_', 1); + this.displaySync = displaySync.create(); + const range: ExpectedFrameRateRange = { + expected: 120, + min: 60, + max: 120 + }; + this.displaySync.setExpectedFrameRateRange(range); + this.displaySync.on('frame', () => { + if (this.temp.length > 0) { + if (this.step === 0) { + // Step 1: Add the monthly data and calculate the maximum number of frames required to complete the data operation. + hiTraceMeter.startTrace('reuse_' + this.step, 1); + this.month = this.temp[0].month; + this.monthNumber = this.temp[0].num; + this.maxStep = this.maxStep + Math.ceil(this.temp[0].days.length / this.MAX_EVERY_FRAME); + hiTraceMeter.finishTrace('reuse_' + this.step, 1); + this.step += 1; + } else if (this.step === this.maxStep - 1) { + // Final step: Initialize partial count data. + this.temp = []; + this.step = 0; + this.maxStep = 2; + } else { + hiTraceMeter.startTrace('reuse_' + this.step, 1); + const start: number = this.MAX_EVERY_FRAME * (this.step - 1); + const end: number = (this.MAX_EVERY_FRAME * this.step) > this.temp[0].days.length ? + this.temp[0].days.length : this.MAX_EVERY_FRAME * this.step; + for (let i = start; i < end; i++) { + this.days[i] = this.temp[0].days[i]; + this.lunarDays[i] = this.temp[0].lunarDays[i]; + } + hiTraceMeter.finishTrace('reuse_' + this.step, 1); + this.step += 1; + } + } + }); + this.displaySync.start(); + allDisplaySyncArray.push(this.displaySync); + this.temp.push(this.monthItem); + hiTraceMeter.finishTrace('appear_', 1); + } + + aboutToDisappear(): void { + if (allDisplaySyncArray.length > 0) { + allDisplaySyncArray.forEach((displaySync: displaySync.DisplaySync) => { + displaySync.stop(); + }); + } + } + + build() { + Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceAround }) { + Text(this.month) + .fontSize(16) + .fontColor(Color.Black) + .width(CommonConstants.FULL_PERCENT) + .textAlign(TextAlign.Center) + .lineHeight(21) + + Row() { + ForEach(WEEK, (weekday: Resource, index: number) => { + Text(weekday) + .fontSize(12) + .fontWeight(400) + .height(16) + .lineHeight(16) + .fontColor(index === 0 || index === 6 ? '#66000000' : Color.Black) + .textAlign(TextAlign.Center) + .layoutWeight(1) + }, (index: number): string => index.toString()) + } + .justifyContent(FlexAlign.SpaceBetween) + .width(CommonConstants.FULL_PERCENT) + .margin({ top: 16 }) + + ForEach(this.days, (day: number, index: number) => { + Text() { + Span(day.toString() + '\n') + .fontSize(18) + .fontWeight(700) + .lineHeight(24) + Span(this.lunarDays[index] === '' ? '' : this.lunarDays[index]) + .fontSize(10) + .fontWeight(400) + .lineHeight(13) + } + .width(50) + .height(50) + .fontColor(day === this.currentDay && this.monthNumber === this.currentMonth ? Color.White : + index % 7 === 0 || (index - 6) % 7 === 0 ? '#66000000' : Color.Black) + .textAlign(TextAlign.Center) + .borderRadius(25) + .opacity(day === 0 ? 0 : + 1) // Set the value 0 in the date array to not display, that is, the content of the last month and the next month is not displayed. + .backgroundColor(day === this.currentDay && this.monthNumber === this.currentMonth ? + '#0a59f7' : Color.Transparent) + .layoutWeight(1) + }, (index: number): string => index.toString()) + } + .alignSelf(ItemAlign.Center) + .margin({ top: 5 }) + .width(CommonConstants.FULL_PERCENT) + } +} diff --git a/FramedRendering/entry/src/main/ets/view/SlidingScene.ets b/FramedRendering/entry/src/main/ets/view/SlidingScene.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe3e25ad4f015c051d8e2f31467d8c4524743f65 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/view/SlidingScene.ets @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { Month, MonthDataSource } from '../model/MonthDataSource' +import { SegmentButton, SegmentButtonItemTuple, SegmentButtonOptions } from '@kit.ArkUI'; +import { CommonConstants } from '../common/CommonConstants'; +import { DateItemView } from './DateItemView'; + +@Entry +@Component +struct SlidingScene { + @State contentData: MonthDataSource = new MonthDataSource(); + @State currentYear: number = new Date().getFullYear(); + @State singleSelectCapsuleOptions: SegmentButtonOptions = SegmentButtonOptions.capsule({ + buttons: [ + { text: $r('app.string.year') }, { text: $r('app.string.month') }, { text: $r('app.string.week') }, + { text: $r('app.string.sunday') }] as SegmentButtonItemTuple, + multiply: false, + fontSize: 14, + fontWeight: 500, + backgroundBlurStyle: BlurStyle.BACKGROUND_THICK, + selectedFontColor: Color.Black, + selectedFontWeight: FontWeight.Bold, + backgroundColor: '#0000000d', + selectedBackgroundColor: Color.White + }); + @State singleSelectCapsuleSelectedIndexes: number[] = [1]; + private readonly LIST_SPACE: number = 24; + private readonly LIST_CACHE: number = 2; + + aboutToAppear(): void { + this.contentData.getDateData(); + } + + aboutToDisappear(): void { + this.contentData.clearData(); + } + + build() { + Column() { + SegmentButton({ + options: this.singleSelectCapsuleOptions, + selectedIndexes: $singleSelectCapsuleSelectedIndexes + }) + .margin({ + left: 16, + right: 16, + top: 8 + }) + List({ space: this.LIST_SPACE }) { + LazyForEach(this.contentData, (monthItem: Month) => { + ListItem() { + DateItemView({ + monthItem: monthItem + }) + .reuseId('reuse_id_' + monthItem.days.length.toString()) + } + }) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .layoutWeight(1) + .margin({ top: 24 }) + .cachedCount(this.LIST_CACHE) + .edgeEffect(EdgeEffect.None) + .scrollBar(BarState.Off) + .onScrollIndex((first: number) => { + if (first < 12) { + this.currentYear = new Date().getFullYear(); + } else { + this.currentYear = new Date().getFullYear() + 1; + } + }) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .alignItems(HorizontalAlign.Center) + } +} + +@Builder +function slidingSceneBuilder(name: string): void { + if (name === CommonConstants.NAV_DESTINATION_ITEM_1) { + NavDestination() { + SlidingScene(); + } + .title('2024') + .backgroundColor('#F1F3F5') + } +} + +export const wrappedBuilderSlidingScene: WrappedBuilder<[string]> = + wrapBuilder(slidingSceneBuilder); \ No newline at end of file diff --git a/FramedRendering/entry/src/main/ets/view/TransitionScene.ets b/FramedRendering/entry/src/main/ets/view/TransitionScene.ets new file mode 100644 index 0000000000000000000000000000000000000000..0db72fa72285e0c90ce9d184facce174e0c0ca49 --- /dev/null +++ b/FramedRendering/entry/src/main/ets/view/TransitionScene.ets @@ -0,0 +1,334 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { MidListDataSource } from '../model/MidListDataSource'; +import { ProductDetailSource } from '../model/ProductDetailSource'; +import { SwiperDataSource } from '../model/SwiperDataSource'; +import displaySync from '@ohos.graphics.displaySync'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; +import { CommonConstants } from '../common/CommonConstants'; +import { ProductDetailModel, ProductIntroductionModel } from '../model/BasicDataSource'; + +@Entry +@Component +struct TransitionScene { + @State currentIndex: number = 0; + private readonly LIST_SPACE: number = 10; + private readonly FRAME_60: number = 60; + private readonly FRAME_120: number = 120; + private readonly SWIPER_CACHE: number = 2; + private readonly HORIZONTAL_LIST_CACHE: number = 2; + private swiperDataSource: SwiperDataSource = new SwiperDataSource(); + private midListDataSource: MidListDataSource = new MidListDataSource(); + private productDetailSource: ProductDetailSource = new ProductDetailSource(); + private displaySync: displaySync.DisplaySync | undefined = undefined; + private frame: number = 1; + + aboutToAppear(): void { + this.swiperDataSource.getProductData(); + this.midListDataSource.getProductData(); + + // Creating a DisplaySync Object + this.displaySync = displaySync.create(); + + // Set the expected frame rate + let range: ExpectedFrameRateRange = { + expected: this.FRAME_120, + min: this.FRAME_60, + max: this.FRAME_120 + }; + this.displaySync.setExpectedFrameRateRange(range); + + // Add Frame Callback + this.displaySync.on('frame', () => { + if (this.frame === 1) { + hiTraceMeter.startTrace('firstFrame', 1); + this.productDetailSource.getProductData(0, 2); + this.frame += 1; + hiTraceMeter.finishTrace('firstFrame', 1); + } else if (this.frame === 2) { + hiTraceMeter.startTrace('secondFrame', 2); + this.productDetailSource.getProductData(2, 10); + hiTraceMeter.finishTrace('secondFrame', 2); + this.frame += 1; + this.displaySync?.stop(); + } + }); + + // Enable frame callback listening + this.displaySync.start(); + } + + aboutToDisappear(): void { + this.displaySync?.stop(); + } + + build() { + Column() { + Search({ placeholder: $r('app.string.search_title') }) + this.typeSwiper(); + this.typeList(); + this.typeWaterFlow(); + } + .padding({ + left: 16, + right: 16 + }) + } + + @Builder + typeSwiper() { + Row() { + Swiper() { + LazyForEach(this.swiperDataSource, (item: ProductIntroductionModel) => { + SwiperItem({ + icon: item.icon, + title: item.title + }) + }, (item: ProductIntroductionModel) => item.id) + } + .itemSpace(3) + .displayCount(5) + .cachedCount(this.SWIPER_CACHE) + .autoPlay(true) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + } + .margin({ top: 16 }) + .width(CommonConstants.FULL_PERCENT) + .height(106) + .borderRadius(16) + .linearGradient({ + direction: GradientDirection.Bottom, + colors: [['#190A59F7', 0.0], ['#00FFFFFF', 0.3], [Color.White, 0.7]] + }) + } + + @Builder + typeList() { + Row() { + List({ space: this.LIST_SPACE }) { + LazyForEach(this.midListDataSource, (item: ProductIntroductionModel, index: number) => { + ListItem() { + this.midListItem(item, index); + } + }, (item: ProductIntroductionModel) => item.id) + } + .listDirection(Axis.Horizontal) + .cachedCount(this.HORIZONTAL_LIST_CACHE) + .scrollBar(BarState.Off) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + } + .width(CommonConstants.FULL_PERCENT) + .height(56) + .margin({ top: 12 }) + } + + @Builder + midListItem(item: ProductIntroductionModel, index: number) { + Row() { + SymbolGlyph(item.icon) + .fontSize(16) + .fontColor(this.currentIndex === index ? [Color.White] : [Color.Black]) + .margin({ left: 16 }) + Text(item.title) + .fontSize(14) + .fontWeight(500) + .lineHeight(19) + .margin({ left: 8 }) + .fontColor(this.currentIndex === index ? Color.White : Color.Black) + } + .width(84) + .height(36) + .borderRadius(21) + .backgroundColor(this.currentIndex === index ? $r('sys.color.comp_background_emphasize') : + $r('sys.color.comp_background_tertiary')) + .onClick(() => { + this.currentIndex = index; + }) + } + + @Builder + typeWaterFlow() { + WaterFlow() { + LazyForEach(this.productDetailSource, (item: ProductDetailModel, index: number) => { + FlowItem() { + BotFlowItem({ item: item }) + } + .onAppear(() => { + if (index + 4 === this.productDetailSource.totalCount()) { + this.productDetailSource.getProductData(); + } + }) + }, (item: ProductDetailModel) => item.id) + } + .columnsTemplate('1fr 1fr') + .columnsGap(CommonConstants.COLUMNS_GAP) + .rowsGap(CommonConstants.ROWS_GAP) + .cachedCount(2) + .margin({ top: 8 }) + .layoutWeight(1) + } +} + +@Builder +function transitionSceneBuilder(name: string): void { + if (name === CommonConstants.NAV_DESTINATION_ITEM_0) { + NavDestination() { + TransitionScene(); + } + .title(title()) + .backgroundColor('#F1F3F5') + } +} + +@Builder +function title() { + Row() { + Text($r('app.string.transition')) + .fontSize(20) + .fontWeight(700) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .lineHeight(27) + .width(152) + + Row() { + Stack() { + Circle() + .fill($r('sys.color.comp_background_tertiary')) + .width(40) + .aspectRatio(1) + SymbolGlyph($r('sys.symbol.line_viewfinder')) + .fontSize(20) + } + .margin({ right: 8 }) + + Stack() { + Circle() + .fill($r('sys.color.comp_background_tertiary')) + .width(40) + .aspectRatio(1) + SymbolGlyph($r('sys.symbol.person_fill')) + .fontSize(20) + } + } + .margin({ right: 8 }) + .width(136) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.End) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .padding({ left: 8 }) +} + +@Reusable +@Component +export struct BotFlowItem { + @State item: ProductDetailModel = new ProductDetailModel('', '', $r('app.media.product01'), '', ''); + + aboutToReuse(params: Record): void { + this.item = params.item as ProductDetailModel; + } + + build() { + Column() { + Column() { + Text($r('app.string.new_product')) + .fontSize(10) + .fontWeight(500) + .lineHeight(13) + .fontColor(Color.White) + } + .width(28) + .height(16) + .borderRadius(4) + .justifyContent(FlexAlign.Center) + .backgroundColor('#CF0A2C') + + Text(this.item.title) + .fontSize(12) + .fontWeight(500) + .lineHeight(18) + .margin({ top: 2 }) + + Text(this.item.des) + .fontSize(10) + .fontWeight(400) + .lineHeight(18) + .margin({ top: 2 }) + + Text(this.item.price) + .fontSize(12) + .fontWeight(700) + .lineHeight(18) + .margin({ top: 6 }) + + Image(this.item.icon) + .width(117) + .height(117) + .alignSelf(ItemAlign.Center) + } + .alignItems(HorizontalAlign.Start) + .padding({ + left: 12, + top: 10 + }) + .width(CommonConstants.FULL_PERCENT) + .height(236) + .backgroundColor(Color.White) + .borderRadius(16) + } +} + +@Reusable +@Component +export struct SwiperItem { + @State icon: Resource = $r('app.media.product01'); + @State title: ResourceStr = ''; + + aboutToReuse(params: Record): void { + this.icon = params.icon as Resource; + this.title = params.title as ResourceStr; + } + + build() { + Column() { + Stack() { + Circle() + .fill('#0A59F7') + .width(37) + .height(37) + SymbolGlyph(this.icon) + .fontSize(24) + .fontColor([Color.White]) + } + + Text(this.title) + .fontSize(12) + .fontWeight(40) + .lineHeight(16) + .margin({ top: 5.33 }) + } + .padding({ top: 14 }) + .width(66) + .height(66) + } +} + +export const wrappedBuilderTransitionScene: WrappedBuilder<[string]> = + wrapBuilder(transitionSceneBuilder); \ No newline at end of file diff --git a/FramedRendering/entry/src/main/module.json5 b/FramedRendering/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/FramedRendering/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/resources/base/element/color.json b/FramedRendering/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/FramedRendering/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/resources/base/element/string.json b/FramedRendering/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5cebd70d4e06ca409f88ea5f9b6b9d0b2d1ca7b3 --- /dev/null +++ b/FramedRendering/entry/src/main/resources/base/element/string.json @@ -0,0 +1,228 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Frame-based rendering in heavy-load scenarios" + }, + { + "name": "car", + "value": "car" + }, + { + "name": "wallet", + "value": "wallet" + }, + { + "name": "jigsaw", + "value": "jigsaw" + }, + { + "name": "favorite", + "value": "favorite" + }, + { + "name": "product_title01", + "value": "Laptops" + }, + { + "name": "product_title02", + "value": "Mobile phone" + }, + { + "name": "product_title03", + "value": "Minimal trend backpack" + }, + { + "name": "product_title04", + "value": "Folding screen" + }, + { + "name": "product_price01", + "value": "¥6975.8" + }, + { + "name": "product_price02", + "value": "¥4279.6" + }, + { + "name": "product_price03", + "value": "105.3" + }, + { + "name": "product_price04", + "value": "1252.9" + }, + { + "name": "product_des01", + "value": "Satellite call | Full focus ultra clear image" + }, + { + "name": "product_des02", + "value": "Ultra lightweight and versatile folding | Ultra clear mirror" + }, + { + "name": "product_des03", + "value": "Dual satellite communication | Xuanwu tempered Kunlun" + }, + { + "name": "product_des04", + "value": "Ultra reliable Kunlun Glass | Beidou Satellite" + }, + { + "name": "new_product", + "value": "New product" + }, + { + "name": "computer", + "value": "computer" + }, + { + "name": "vision", + "value": "vision" + }, + { + "name": "sound_box", + "value": "soundBox" + }, + { + "name": "mobile_phone", + "value": "mobilePhone" + }, + { + "name": "watches", + "value": "watch" + }, + { + "name": "transition", + "value": "transition scene" + }, + { + "name": "sliding", + "value": "sliding scene" + }, + { + "name": "search_title", + "value": "Good things selection" + }, + { + "name": "year", + "value": "year" + }, + { + "name": "month", + "value": "month" + }, + { + "name": "week", + "value": "week" + }, + { + "name": "sunday", + "value": "sunday" + }, + { + "name": "monday", + "value": "monday" + }, + { + "name": "tuesday", + "value": "tuesday" + }, + { + "name": "wednesday", + "value": "wednesday" + }, + { + "name": "thursday", + "value": "thursday" + }, + { + "name": "Friday", + "value": "Friday" + }, + { + "name": "saturday", + "value": "saturday" + }, + { + "name": "seven", + "value": "seven" + }, + { + "name": "eight", + "value": "eight" + }, + { + "name": "nine", + "value": "nine" + }, + { + "name": "ten", + "value": "ten" + }, + { + "name": "january", + "value": "january" + }, + { + "name": "february", + "value": "february" + }, + { + "name": "march", + "value": "march" + }, + { + "name": "april", + "value": "april" + }, + { + "name": "may", + "value": "may" + }, + { + "name": "june", + "value": "june" + }, + { + "name": "july", + "value": "july" + }, + { + "name": "august", + "value": "august" + }, + { + "name": "september", + "value": "september" + }, + { + "name": "october", + "value": "october" + }, + { + "name": "november", + "value": "november" + }, + { + "name": "december", + "value": "december" + }, + { + "name": "grade", + "value": "grade" + }, + { + "name": "chinese_twenty", + "value": "twenty" + } + ] +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/resources/base/media/background.png b/FramedRendering/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/background.png differ diff --git a/FramedRendering/entry/src/main/resources/base/media/foreground.png b/FramedRendering/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/foreground.png differ diff --git a/FramedRendering/entry/src/main/resources/base/media/layered_image.json b/FramedRendering/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/FramedRendering/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/resources/base/media/product01.png b/FramedRendering/entry/src/main/resources/base/media/product01.png new file mode 100644 index 0000000000000000000000000000000000000000..fc998c51ae7fbf2e9d92850d7828082aa68b872f Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/product01.png differ diff --git a/FramedRendering/entry/src/main/resources/base/media/product02.png b/FramedRendering/entry/src/main/resources/base/media/product02.png new file mode 100644 index 0000000000000000000000000000000000000000..f5896010b24d0f8571e3a7795506a087e7401fba Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/product02.png differ diff --git a/FramedRendering/entry/src/main/resources/base/media/product03.png b/FramedRendering/entry/src/main/resources/base/media/product03.png new file mode 100644 index 0000000000000000000000000000000000000000..a0a50da0ef61692f020e4c29bfe972edfc5c4216 Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/product03.png differ diff --git a/FramedRendering/entry/src/main/resources/base/media/product04.png b/FramedRendering/entry/src/main/resources/base/media/product04.png new file mode 100644 index 0000000000000000000000000000000000000000..b2c84a35e62cc920dd359ad2ee6b404f4957f376 Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/product04.png differ diff --git a/FramedRendering/entry/src/main/resources/base/media/startIcon.png b/FramedRendering/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/FramedRendering/entry/src/main/resources/base/media/startIcon.png differ diff --git a/FramedRendering/entry/src/main/resources/base/profile/backup_config.json b/FramedRendering/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/FramedRendering/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/resources/base/profile/main_pages.json b/FramedRendering/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/FramedRendering/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/FramedRendering/entry/src/main/resources/en_US/element/string.json b/FramedRendering/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5cebd70d4e06ca409f88ea5f9b6b9d0b2d1ca7b3 --- /dev/null +++ b/FramedRendering/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,228 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Frame-based rendering in heavy-load scenarios" + }, + { + "name": "car", + "value": "car" + }, + { + "name": "wallet", + "value": "wallet" + }, + { + "name": "jigsaw", + "value": "jigsaw" + }, + { + "name": "favorite", + "value": "favorite" + }, + { + "name": "product_title01", + "value": "Laptops" + }, + { + "name": "product_title02", + "value": "Mobile phone" + }, + { + "name": "product_title03", + "value": "Minimal trend backpack" + }, + { + "name": "product_title04", + "value": "Folding screen" + }, + { + "name": "product_price01", + "value": "¥6975.8" + }, + { + "name": "product_price02", + "value": "¥4279.6" + }, + { + "name": "product_price03", + "value": "105.3" + }, + { + "name": "product_price04", + "value": "1252.9" + }, + { + "name": "product_des01", + "value": "Satellite call | Full focus ultra clear image" + }, + { + "name": "product_des02", + "value": "Ultra lightweight and versatile folding | Ultra clear mirror" + }, + { + "name": "product_des03", + "value": "Dual satellite communication | Xuanwu tempered Kunlun" + }, + { + "name": "product_des04", + "value": "Ultra reliable Kunlun Glass | Beidou Satellite" + }, + { + "name": "new_product", + "value": "New product" + }, + { + "name": "computer", + "value": "computer" + }, + { + "name": "vision", + "value": "vision" + }, + { + "name": "sound_box", + "value": "soundBox" + }, + { + "name": "mobile_phone", + "value": "mobilePhone" + }, + { + "name": "watches", + "value": "watch" + }, + { + "name": "transition", + "value": "transition scene" + }, + { + "name": "sliding", + "value": "sliding scene" + }, + { + "name": "search_title", + "value": "Good things selection" + }, + { + "name": "year", + "value": "year" + }, + { + "name": "month", + "value": "month" + }, + { + "name": "week", + "value": "week" + }, + { + "name": "sunday", + "value": "sunday" + }, + { + "name": "monday", + "value": "monday" + }, + { + "name": "tuesday", + "value": "tuesday" + }, + { + "name": "wednesday", + "value": "wednesday" + }, + { + "name": "thursday", + "value": "thursday" + }, + { + "name": "Friday", + "value": "Friday" + }, + { + "name": "saturday", + "value": "saturday" + }, + { + "name": "seven", + "value": "seven" + }, + { + "name": "eight", + "value": "eight" + }, + { + "name": "nine", + "value": "nine" + }, + { + "name": "ten", + "value": "ten" + }, + { + "name": "january", + "value": "january" + }, + { + "name": "february", + "value": "february" + }, + { + "name": "march", + "value": "march" + }, + { + "name": "april", + "value": "april" + }, + { + "name": "may", + "value": "may" + }, + { + "name": "june", + "value": "june" + }, + { + "name": "july", + "value": "july" + }, + { + "name": "august", + "value": "august" + }, + { + "name": "september", + "value": "september" + }, + { + "name": "october", + "value": "october" + }, + { + "name": "november", + "value": "november" + }, + { + "name": "december", + "value": "december" + }, + { + "name": "grade", + "value": "grade" + }, + { + "name": "chinese_twenty", + "value": "twenty" + } + ] +} \ No newline at end of file diff --git a/FramedRendering/entry/src/main/resources/zh_CN/element/string.json b/FramedRendering/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..10c26e6754a49bbf89493b5aa4f62c9a4c226f76 --- /dev/null +++ b/FramedRendering/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,228 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "高负载分帧渲染" + }, + { + "name": "car", + "value": "汽车" + }, + { + "name": "wallet", + "value": "钱包" + }, + { + "name": "jigsaw", + "value": "拼图" + }, + { + "name": "favorite", + "value": "收藏" + }, + { + "name": "product_title01", + "value": "笔记本电脑" + }, + { + "name": "product_title02", + "value": "移动手机" + }, + { + "name": "product_title03", + "value": "极简潮流背包" + }, + { + "name": "product_title04", + "value": "折叠屏" + }, + { + "name": "product_price01", + "value": "¥6975.8" + }, + { + "name": "product_price02", + "value": "¥4279.6" + }, + { + "name": "product_price03", + "value": "105.3" + }, + { + "name": "product_price04", + "value": "1252.9" + }, + { + "name": "product_des01", + "value": "卫星通话 | 全焦段超清影像" + }, + { + "name": "product_des02", + "value": "超轻薄全能折叠 | 超清临镜" + }, + { + "name": "product_des03", + "value": "双卫星通信 | 玄武钢化昆仑" + }, + { + "name": "product_des04", + "value": "超可靠昆仑玻璃 | 北斗卫星" + }, + { + "name": "new_product", + "value": "新品" + }, + { + "name": "computer", + "value": "笔记本" + }, + { + "name": "vision", + "value": "智慧屏" + }, + { + "name": "sound_box", + "value": "音箱" + }, + { + "name": "mobile_phone", + "value": "手机" + }, + { + "name": "watches", + "value": "手表" + }, + { + "name": "transition", + "value": "转场场景" + }, + { + "name": "sliding", + "value": "滑动场景" + }, + { + "name": "search_title", + "value": "好物精选" + }, + { + "name": "year", + "value": "年" + }, + { + "name": "month", + "value": "月" + }, + { + "name": "week", + "value": "周" + }, + { + "name": "sunday", + "value": "日" + }, + { + "name": "monday", + "value": "一" + }, + { + "name": "tuesday", + "value": "二" + }, + { + "name": "wednesday", + "value": "三" + }, + { + "name": "thursday", + "value": "四" + }, + { + "name": "Friday", + "value": "五" + }, + { + "name": "saturday", + "value": "六" + }, + { + "name": "seven", + "value": "七" + }, + { + "name": "eight", + "value": "八" + }, + { + "name": "nine", + "value": "九" + }, + { + "name": "ten", + "value": "十" + }, + { + "name": "january", + "value": "一月" + }, + { + "name": "february", + "value": "二月" + }, + { + "name": "march", + "value": "三月" + }, + { + "name": "april", + "value": "四月" + }, + { + "name": "may", + "value": "五月" + }, + { + "name": "june", + "value": "六月" + }, + { + "name": "july", + "value": "七月" + }, + { + "name": "august", + "value": "八月" + }, + { + "name": "september", + "value": "九月" + }, + { + "name": "october", + "value": "十月" + }, + { + "name": "november", + "value": "十一月" + }, + { + "name": "december", + "value": "十二月" + }, + { + "name": "grade", + "value": "初" + }, + { + "name": "chinese_twenty", + "value": "廿" + } + ] +} \ No newline at end of file diff --git a/FramedRendering/hvigor/hvigor-config.json5 b/FramedRendering/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/FramedRendering/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/FramedRendering/hvigorfile.ts b/FramedRendering/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/FramedRendering/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/FramedRendering/oh-package.json5 b/FramedRendering/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b0fd4f4fd63477187853ae0c2d3e4ebac203c20c --- /dev/null +++ b/FramedRendering/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + "lunar_lite": "^1.0.0" + }, + "devDependencies": { + } +} diff --git a/FramedRendering/screenshots/device/SlidingScene.gif b/FramedRendering/screenshots/device/SlidingScene.gif new file mode 100644 index 0000000000000000000000000000000000000000..03001d29a7645b37213c0fe4baf451e7047ecd54 Binary files /dev/null and b/FramedRendering/screenshots/device/SlidingScene.gif differ diff --git a/FramedRendering/screenshots/device/TransitionScene.gif b/FramedRendering/screenshots/device/TransitionScene.gif new file mode 100644 index 0000000000000000000000000000000000000000..348fcf3ec15c92ab98ed66d559c1a5c2a03139bc Binary files /dev/null and b/FramedRendering/screenshots/device/TransitionScene.gif differ diff --git a/README.md b/README.md index 43343617d8cf86604d37940481b934b749367e52..1154bc2e5d267831009ec6b32b95f5a020cdc9b3 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ * [AvoidTimeComsume:主线程耗时操作优化指导](AvoidTimeComsume) * [ComponentReuse:组件复用开发实践](ComponentReuse) * [CustomDialogPractice:应用自定义弹窗开发实践](CustomDialogPractice) +* [FramedRendering:高负载分帧渲染开发实践](FramedRendering) * [FuzzySceneOptimization:图像模糊动效优化](FuzzySceneOptimization) * [NdkQoS:基于QoS设置线程优先级](NdkQoS) * [NetworkManagement:网络管理与状态监听](NetworkManagement)