1.适配SDK4.0.10.9严格类型检查IDE编译错误的问题

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2023-09-27 14:59:40 +08:00
parent 283b805f28
commit da1d9c22df
23 changed files with 128 additions and 164 deletions

View File

@ -7,6 +7,6 @@
"version": "2.0.5-rc.0",
"dependencies": {
"@ohos/imageknife": "file:../imageknife",
"@ohos/disklrucache": "^2.0.0"
"@ohos/disklrucache": "^2.0.1"
}
}

View File

@ -18,17 +18,15 @@ import window from '@ohos.window';
import { ImageKnifeGlobal,ImageKnife,ImageKnifeDrawFactory,LogUtil } from '@ohos/imageknife'
import { CustomEngineKeyImpl } from './CustomEngineKeyImpl'
import abilityAccessCtrl,{Permissions} from '@ohos.abilityAccessCtrl';
import { BusinessError } from '@ohos.base'
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
let list : Array<Permissions> = ['ohos.permission.MEDIA_LOCATION','ohos.permission.READ_MEDIA'];
let permissionRequestResult;
let permissionRequestResult:Object;
let atManager = abilityAccessCtrl.createAtManager();
atManager.requestPermissionsFromUser(this.context, list, (err,result)=>{
atManager.requestPermissionsFromUser(this.context, list, (err:BusinessError,result:Object)=>{
if(err){
console.log("dodo requestPermissionsFromUserError:"+JSON.stringify(err));
}else{
@ -37,19 +35,19 @@ export default class EntryAbility extends UIAbility {
}
})
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
windowStage.loadContent('pages/index', (err:BusinessError, data:void) => {
});
ImageKnife.with(this.context);
// 全局配置网络加载进度条
ImageKnifeGlobal.getInstance().getImageKnife().setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
// 全局配置缓存key
ImageKnifeGlobal.getInstance().getImageKnife().setEngineKeyImpl(new CustomEngineKeyImpl())
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
if(imageKnife != undefined) {
// 全局配置网络加载进度条
imageKnife
.setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
// 全局配置缓存key
imageKnife.setEngineKeyImpl(new CustomEngineKeyImpl())
}
//开启ImageKnife所有级别日志开关
LogUtil.mLogLevel = LogUtil.ALL
}

View File

@ -64,7 +64,7 @@ struct CompressPage {
.onClick(() => {
this.cropressRecource();
});
Image(this.mRPixelMap )
Image(this.mRPixelMap == undefined?'': this.mRPixelMap!)
.width(200)
.height(200)
.margin({ top: 10 })
@ -82,7 +82,7 @@ struct CompressPage {
.margin({ top: 10 })
.onClick(() => {
});
Image(this.mFPixelMap )
Image(this.mFPixelMap == undefined ?'':this.mFPixelMap!)
.width(200)
.height(200)
.margin({ top: 10 });
@ -139,7 +139,7 @@ struct CompressPage {
console.info("asasd start compress")
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
if(imageKnife != undefined) {
(ImageKnifeGlobal.getInstance().getImageKnife())
imageKnife
.compressBuilder()
.load(data)
.ignoreBy(100)

View File

@ -39,11 +39,10 @@ struct DataShareUriLoadPage {
const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
// 创建文件获取选项此处参数为获取image类型的文件资源
let imagesFetchOp:mediaLibrary.MediaFetchOptions = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
};
// 获取文件资源使用callback方式返回异步结果

View File

@ -106,7 +106,7 @@ struct gifTestCasePage {
Text("下面为展示图片区域").margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Image(this.pixels)
Image(this.pixels == undefined?'':this.pixels!)
.width(400)
.height(400)
.backgroundColor(Color.Pink)

View File

@ -51,7 +51,7 @@ struct svgTestCasePage {
Text("下面为展示图片区域").margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Image(this.svgSamplePixelMap)
Image(this.svgSamplePixelMap == undefined ? '':this.svgSamplePixelMap!)
.width(400)
.height(400)
.backgroundColor(Color.Pink)
@ -81,7 +81,7 @@ struct svgTestCasePage {
Text("下面为展示图片区域").margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Image(this.svgIconPixelMap)
Image(this.svgIconPixelMap == undefined ? '':this.svgIconPixelMap!)
.width(400)
.height(400)
.backgroundColor(Color.Pink)

View File

@ -88,7 +88,7 @@ struct TestAllCacheInfoPage {
Scroll() {
Text(this.cacheinfo1).fontSize(15)
}.width(300).height(200)
Image(this.nativePixelMap )
Image(this.nativePixelMap == undefined ? '':this.nativePixelMap!)
.width(300)
.height(300)
.objectFit(ImageFit.Contain)
@ -101,7 +101,7 @@ struct TestAllCacheInfoPage {
Scroll() {
Text(this.cacheinfo2).fontSize(15)
}.width(300).height(200)
Image(this.networkPixelMap )
Image(this.networkPixelMap==undefined?'':this.networkPixelMap! )
.width(300)
.height(300)
.objectFit(ImageFit.Contain)

View File

@ -100,10 +100,11 @@ struct TestGifLoadWithWorkerPage {
Button('加载gif')
.margin({ top: 16 })
.onClick(() => {
(ImageKnifeGlobal.getInstance().getImageKnife()).setGifWorker(undefined)
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife();
if(imageKnife != undefined) {
imageKnife.setGifWorker(undefined)
}
//主线程加载gif,阻塞toast的消失
this.options = {
loadSrc: $r("app.media.test"),

View File

@ -54,19 +54,7 @@ struct TestImageKnifeOptionChangedPage3 {
thumbSizeMultiplier:0.1,
transformation:rotateTrans,
};
animateTo({
duration: 500,
curve: Curve.EaseInOut,
delay: 100,
iterations: 1,
playMode:PlayMode.Normal,
onFinish:()=>{
console.log('play end!')
}
},()=>{
this.compHeight = 350
this.compWidht = 350
})
}).margin({left:5}).backgroundColor(Color.Blue)
Button("本地png")
.onClick(()=>{
@ -80,19 +68,7 @@ struct TestImageKnifeOptionChangedPage3 {
thumbSizeMultiplier:0.1,
transformation:rotateTrans,
};
animateTo({
duration: 500,
curve: Curve.EaseInOut,
delay: 100,
iterations: 1,
playMode:PlayMode.Normal,
onFinish:()=>{
console.log('play end!')
}
},()=>{
this.compHeight = 400
this.compWidht = 300
})
}).margin({left:5}).backgroundColor(Color.Blue)
}.margin({top:15})
Flex({direction:FlexDirection.Row}){
@ -106,19 +82,7 @@ struct TestImageKnifeOptionChangedPage3 {
thumbSizeMultiplier:0.1,
transformations:[new GrayscaleTransformation()],
};
animateTo({
duration: 500,
curve: Curve.EaseInOut,
delay: 100,
iterations: 1,
playMode:PlayMode.Normal,
onFinish:()=>{
console.log('play end!')
}
},()=>{
this.compHeight = 250
this.compWidht = 350
})
}).margin({left:5}).backgroundColor(Color.Blue)
Button("本地webp")
.onClick(()=>{
@ -130,19 +94,7 @@ struct TestImageKnifeOptionChangedPage3 {
thumbSizeMultiplier:0.1,
transformations:[new SketchFilterTransformation()],
};
animateTo({
duration: 500,
curve: Curve.EaseInOut,
delay: 100,
iterations: 1,
playMode:PlayMode.Normal,
onFinish:()=>{
console.log('play end!')
}
},()=>{
this.compHeight = 400
this.compWidht = 400
})
}).margin({left:5}).backgroundColor(Color.Blue)
}.margin({top:15})
Flex({direction:FlexDirection.Row}){

View File

@ -101,7 +101,7 @@ struct TransformPixelMapPage {
});
}.margin({ top: 10 })
Image(this.mCropPixelMap)
Image(this.mCropPixelMap == undefined ? '':this.mCropPixelMap!)
.objectFit(ImageFit.None)
.width(100)
.height(100)
@ -154,7 +154,7 @@ struct TransformPixelMapPage {
});
}.margin({ top: 10 })
Image(this.mRoundPixelMap)
Image(this.mRoundPixelMap == undefined ? '': this.mRoundPixelMap!)
.objectFit(ImageFit.Fill)
.width(100)
.height(100)
@ -173,7 +173,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.circleTransformation();
});
Image(this.mCirclePixelMap)
Image(this.mCirclePixelMap == undefined ? '':this.mCirclePixelMap!)
.width(200)
.height(200)
.margin({ top: 10 })
@ -191,7 +191,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.circleBorderTransformation(5);
});
Image(this.mCircleBorderPixelMap)
Image(this.mCircleBorderPixelMap == undefined ? '':this.mCircleBorderPixelMap!)
.width(200)
.height(200)
.margin({ top: 10 })
@ -213,7 +213,7 @@ struct TransformPixelMapPage {
}
this.transformRotate(mRotate);
});
Image(this.mRotatePixelMap)
Image(this.mRotatePixelMap == undefined ? '':this.mRotatePixelMap!)
.width(200)
.height(200)
.margin({ top: 10 })
@ -231,7 +231,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.transformSquare();
});
Image(this.mSquarePixelMap)
Image(this.mSquarePixelMap == undefined ? '' : this.mSquarePixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -269,17 +269,17 @@ struct TransformPixelMapPage {
}.margin({ top: 10 })
Row({ space: 1 }) {
Image(this.mClipTopPixelMap)
Image(this.mClipTopPixelMap == undefined ? '':this.mClipTopPixelMap!)
.objectFit(ImageFit.Fill)
.width(100)
.height(100)
.margin({ top: 10 })
Image(this.mClipCenterPixelMap)
Image(this.mClipCenterPixelMap == undefined ? '':this.mClipCenterPixelMap!)
.objectFit(ImageFit.Fill)
.width(100)
.height(100)
.margin({ top: 10 })
Image(this.mClipBottomPixelMap)
Image(this.mClipBottomPixelMap == undefined ? '':this.mClipBottomPixelMap!)
.objectFit(ImageFit.Fill)
.width(100)
.height(100)
@ -298,7 +298,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.grayscalePixelMap();
});
Image(this.mGrayscalePixelMap)
Image(this.mGrayscalePixelMap == undefined ? '': this.mGrayscalePixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -316,7 +316,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.brightnessPixelMap(0.8);
});
Image(this.mBrightnessPixelMap)
Image(this.mBrightnessPixelMap == undefined?'':this.mBrightnessPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -334,7 +334,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.contrastPixelMap(4);
});
Image(this.mContrastPixelMap)
Image(this.mContrastPixelMap == undefined?'':this.mContrastPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -352,7 +352,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.invertPixelMap();
});
Image(this.mInvertPixelMap)
Image(this.mInvertPixelMap == undefined ? '':this.mInvertPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -371,7 +371,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.sepiaPixelMap();
});
Image(this.mSepiaPixelMap)
Image(this.mSepiaPixelMap == undefined ? '':this.mSepiaPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -389,7 +389,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.sketchPixelMap();
});
Image(this.mSketchPixelMap)
Image(this.mSketchPixelMap == undefined ? '':this.mSketchPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -408,7 +408,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.blurHandlePixelMap(20);
});
Image(this.mBlurPixelMap)
Image(this.mBlurPixelMap==undefined?'':this.mBlurPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -428,7 +428,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.pixelHandlePixelMap(20);
});
Image(this.mPixelPixelMap)
Image(this.mPixelPixelMap == undefined ? '':this.mPixelPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -447,7 +447,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.swirlHandlePixelMap();
});
Image(this.mSwirlPixelMap)
Image(this.mSwirlPixelMap == undefined ? '':this.mSwirlPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -466,7 +466,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.maskHandlePixelMap($r('app.media.mask_starfish'));
});
Image(this.mMaskPixelMap)
Image(this.mMaskPixelMap == undefined ? '':this.mMaskPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -485,7 +485,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.kuwaharaHandlePixelMap();
});
Image(this.mKuwaharaPixelMap)
Image(this.mKuwaharaPixelMap == undefined? '':this.mKuwaharaPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -504,7 +504,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.toonHandlePixelMap();
});
Image(this.mToonPixelMap)
Image(this.mToonPixelMap == undefined?'':this.mToonPixelMap!)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)
@ -523,7 +523,7 @@ struct TransformPixelMapPage {
.onClick(() => {
this.vignetteHandlePixelMap();
});
Image(this.mVignettePixelMap)
Image(this.mVignettePixelMap == undefined ? '':this.mVignettePixelMap)
.objectFit(ImageFit.Fill)
.width(200)
.height(200)

View File

@ -22,7 +22,7 @@
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"srcEntrance": "./ets/entryability/EntryAbility.ets",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",

View File

@ -17,7 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function abilityTest() {
describe('ActsAbilityTest', function () {
describe('ActsAbilityTest', ()=> {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll( ()=> {
// Presets an action, which is performed only once before all test cases of the test suite start.

View File

@ -17,7 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import {ImageKnife,ImageKnifeDrawFactory,ImageKnifeGlobal} from '@ohos/imageknife'
export default function ImageKnifeTest() {
describe('ImageKnifeTest', function () {
describe('ImageKnifeTest', ()=> {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll( ()=> {
// Presets an action, which is performed only once before all test cases of the test suite start.
@ -40,16 +40,22 @@ export default function ImageKnifeTest() {
it('TestGlobalImageKnife',0, ()=> {
let global:ImageKnifeGlobal = ImageKnife.with(ImageKnifeGlobal.getInstance().getHapContext())
expect(global.getImageKnife()).not().assertUndefined()
let context:Object|undefined = ImageKnifeGlobal.getInstance().getHapContext();
if(context != undefined) {
let global: ImageKnifeGlobal = ImageKnife.with(context)
expect(global.getImageKnife()).not().assertUndefined()
}
})
it('TestGlobalDefaultLifeCycle',1, ()=> {
ImageKnife.with(ImageKnifeGlobal.getInstance().getHapContext())
(ImageKnifeGlobal.getInstance().getImageKnife()).setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
let globalLifeCycle = (ImageKnifeGlobal.getInstance().getImageKnife()).getDefaultLifeCycle();
expect(globalLifeCycle).not().assertUndefined()
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
if(imageKnife != undefined){
imageKnife.setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
let globalLifeCycle = imageKnife.getDefaultLifeCycle();
expect(globalLifeCycle).not().assertUndefined()
}
})

View File

@ -15,7 +15,7 @@
*/
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {RequestOption} from '@ohos/imageknife'
import {RequestOption,Size} from '@ohos/imageknife'
export default function RequestOptionTest() {
describe('RequestOptionTest', ()=> {
@ -40,7 +40,9 @@ export default function RequestOptionTest() {
})
it('TestRequestOption',0, ()=> {
let option = new RequestOption();
expect(option.requestListeners.length == 0).assertTrue()
if(option.requestListeners != undefined) {
expect(option.requestListeners.length == 0).assertTrue()
}
})
it('TestConfigLoadSrc',1, ()=> {
let option = new RequestOption();
@ -50,9 +52,10 @@ export default function RequestOptionTest() {
})
it('TestConfigViewSize',2, ()=> {
let option = new RequestOption();
option.loadSrc = $r('app.media.icon')
option.setImageViewSize({width:100,height:100})
expect(JSON.stringify(option.size)).assertEqual(JSON.stringify({width:100,height:100}))
option.loadSrc = ''
let size:Size = {width:100,height:100}
option.setImageViewSize(size)
expect(JSON.stringify(option.size)).assertEqual(JSON.stringify(size))
})
it('TestNormalConfigInfo',3, ()=>{
let option = new RequestOption();

View File

@ -19,34 +19,30 @@ import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
import {ImageKnife,ImageKnifeDrawFactory,ImageKnifeGlobal} from '@ohos/imageknife'
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base'
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
onCreate(want: Want, param: AbilityConstant.LaunchParam) {
let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
// 初始化xts的ImageKnife
ImageKnife.with(this.context.createModuleContext("entry_test"));
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
windowStage.loadContent('testability/pages/Index', (err:BusinessError, data:void) => {
});
}

View File

@ -16,8 +16,8 @@
"type": "module",
"version": "2.1.0",
"dependencies": {
"@ohos/disklrucache": "^2.0.0",
"@ohos/svg": "^2.0.0",
"@ohos/disklrucache": "^2.0.1",
"@ohos/svg": "^2.1.0",
"@ohos/gpu_transform": "^1.0.0"
},
"tags": [

View File

@ -41,31 +41,31 @@ import common from '@ohos.app.ability.common'
export class ImageKnife {
static readonly SEPARATOR: string = '/'
private memoryCache: LruCache<string, ImageKnifeData>;
private diskMemoryCache: DiskLruCache;
private dataFetch: IDataFetch;
private resourceFetch: IResourceFetch<ArrayBuffer>;
private filesPath: string = ""; // data/data/包名/files目录
memoryCache: LruCache<string, ImageKnifeData>;
diskMemoryCache: DiskLruCache;
dataFetch: IDataFetch;
resourceFetch: IResourceFetch<ArrayBuffer>;
filesPath: string = ""; // data/data/包名/files目录
private placeholderCache: string = "placeholderCache"
private runningRequest: Array<RequestOption>;
private pendingRequest: Array<RequestOption>;
private fileTypeUtil: FileTypeUtil; // 通用文件格式辨别
private diskCacheFolder: string = "ImageKnifeDiskCache"
placeholderCache: string = "placeholderCache"
runningRequest: Array<RequestOption>;
pendingRequest: Array<RequestOption>;
fileTypeUtil: FileTypeUtil; // 通用文件格式辨别
diskCacheFolder: string = "ImageKnifeDiskCache"
private defaultListener: AsyncCallback<ImageKnifeData> = {
defaultListener: AsyncCallback<ImageKnifeData> = {
callback:(err: string, data: ImageKnifeData)=>{return false}
}; // 全局监听器
// gifWorker
private gifWorker: worker.ThreadWorker|undefined = undefined;
gifWorker: worker.ThreadWorker|undefined = undefined;
private defaultLifeCycle: IDrawLifeCycle|undefined = undefined;
defaultLifeCycle: IDrawLifeCycle|undefined = undefined;
// 开发者可配置全局缓存
private engineKeyImpl: EngineKeyInterface;
engineKeyImpl: EngineKeyInterface;
private constructor() {

View File

@ -651,7 +651,7 @@ export struct ImageKnifeComponent {
renderFrames_compWidth: number = 0;
renderFrames_compHeight: number = 0
renderFrames = ()=> {
renderFrames:()=>void = ()=> {
LogUtil.log('ImageKnifeComponent renderFrames frames length =' + this.renderFrames_frames?.length)
let start = new Date().getTime();
if (this.renderFrames_index === 0) {

View File

@ -53,7 +53,7 @@ export class ImageKnifeGlobal {
}
}
setImageKnife(imageKnife:ImageKnife):void{
setImageKnife(imageKnife:Object):void{
this._objects.set(GlobalEnum.IMAGE_KNIFE_KEY, imageKnife);
}

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {ImageKnife} from './ImageKnife'
import { DiskStrategy } from "../cache/diskstrategy/DiskStrategy"
import { AsyncCallback } from "../imageknife/interface/AsyncCallback"
import { AsyncSuccess } from "../imageknife/interface/AsyncSuccess"
@ -89,8 +89,8 @@ export class RequestOption {
generateCacheKey: string = "";
generateResourceKey: string = "";
generateDataKey: string = "";
private filesPath: string = ""; // data/data/包名/files目录
private cachesPath: string = ""; // 网络下载默认存储在data/data/包名/cache/ImageKnifeNetworkFolder/目标md5.img下面
filesPath: string = ""; // data/data/包名/files目录
cachesPath: string = ""; // 网络下载默认存储在data/data/包名/cache/ImageKnifeNetworkFolder/目标md5.img下面
// 下载原始文件地址
downloadFilePath: string = "";
@ -478,14 +478,16 @@ export class RequestOption {
// 等落盘结束后主动调用#removeCurrentAndSearchNext方法
}else{
// 非落盘情况,直接进行寻找下一个加载
if(ImageKnifeGlobal.getInstance().getImageKnife() != undefined) {
(ImageKnifeGlobal.getInstance().getImageKnife())?.removeRunning(this);
let imageKnife:ImageKnife | undefined = ImageKnifeGlobal.getInstance().getImageKnife();
if(imageKnife != undefined) {
imageKnife.removeRunning(this);
}
}
// 加载成功之后
if(ImageKnifeGlobal.getInstance().getImageKnife() != undefined) {
(ImageKnifeGlobal.getInstance().getImageKnife())?.removeRunning(this);
let imageKnife:ImageKnife | undefined = ImageKnifeGlobal.getInstance().getImageKnife();
if(imageKnife != undefined) {
imageKnife.removeRunning(this);
}
}

View File

@ -25,7 +25,7 @@ import { BusinessError } from '@ohos.base'
// 数据加载器
export class NetworkDownloadClient implements IDataFetch {
loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void) {
let filename = SparkMD5.hashBinary(request.generateDataKey);
let filename:string = SparkMD5.hashBinary(request.generateDataKey);
let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder;
let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img";
if (!FileUtils.getInstance().existFolder(downloadFolder)) {

View File

@ -114,14 +114,14 @@ export class RequestManager {
// 变换后缓存
allCacheInfo.resourceCacheInfo = {
key: SparkMD5.hashBinary(this.options.generateResourceKey),
path: (this.mDiskCacheProxy.getCachePath() + SparkMD5.hashBinary(this.options.generateResourceKey))
key: SparkMD5.hashBinary(this.options.generateResourceKey) as string,
path: (this.mDiskCacheProxy.getCachePath() + SparkMD5.hashBinary(this.options.generateResourceKey)) as string
};
// 原图缓存
allCacheInfo.dataCacheInfo = {
key: SparkMD5.hashBinary(this.options.generateDataKey),
path: this.mDiskCacheProxy.getCachePath() + SparkMD5.hashBinary(this.options.generateDataKey)
key: SparkMD5.hashBinary(this.options.generateDataKey) as string,
path: (this.mDiskCacheProxy.getCachePath() + SparkMD5.hashBinary(this.options.generateDataKey)) as string
}
this.options.allCacheInfoCallback.callback(allCacheInfo)
}

View File

@ -19,6 +19,13 @@ import {Size} from '../../RequestOption'
export class SVGParseImpl implements IParseSvg{
parseSvg(imageinfo: ArrayBuffer,size?:Size): Promise<PixelMap>{
let model = new SVGImageView.SVGImageViewModel();
return model.getSVGPixelMap(new Uint8Array(imageinfo),size);
let svgSize:SVGImageView.Size = new SVGImageView.Size();
svgSize.width = 0;
svgSize.height = 0;
if(size != undefined){
svgSize.width = size.width;
svgSize.height = size.height;
}
return model.getSVGPixelMap(new Uint8Array(imageinfo),svgSize);
}
}