diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index d3ee54d2beea61d38866762868bd056d3e39e3c9..628ee717d06a6f2942674ed198048fd14e8bfbf8 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -14,46 +14,52 @@ */ import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import Logger from '../utils/Logger'; -const DOMAIN = 0x0000; +const TAG = 'EntryAbility'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + let error = err as BusinessError; + Logger.error(TAG, `Ability onCreate, err.code is ${error.code}, err.message is ${error.message}`); + } + Logger.info(TAG, 'Ability onCreate'); } onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + Logger.info(TAG, 'Ability onDestroy'); } onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + Logger.info(TAG, 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err) => { if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); return; } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + Logger.info(TAG, 'Succeeded in loading the content.'); }); } onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + Logger.info(TAG, 'Ability onWindowStageDestroy'); } onForeground(): void { // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + Logger.info(TAG, 'Ability onForeground'); } onBackground(): void { // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + Logger.info(TAG, 'Ability onBackground'); } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/ImageGenerate.ets b/entry/src/main/ets/pages/ImageGenerate.ets index 1e92470d0faa4248feada5a2344128956163defa..10c697fd9dbf1be679915f244d9e06d8f584b3b6 100644 --- a/entry/src/main/ets/pages/ImageGenerate.ets +++ b/entry/src/main/ets/pages/ImageGenerate.ets @@ -251,7 +251,7 @@ export struct ImageGenerate { // Synthesize the next image let img = this.currentPreviewImageIndex >= 3 ? ListDataConstants.IMG_LIST[this.currentPreviewImageIndex] : this.previewImageList[this.currentPreviewImageIndex].src as Resource; - resMgr.getMediaContent(img).then(async (img) => { + resMgr.getMediaContent(img.id).then(async (img) => { let imageSourceBg: image.ImageSource = image.createImageSource(img.buffer.slice(0)); // Create pixelMap let pixelMapBg: image.PixelMap = imageSourceBg.createPixelMapSync();