From 9c0b4ebacea9ea8bbcc73064e88e4c35d673dd10 Mon Sep 17 00:00:00 2001 From: madixin Date: Fri, 25 Oct 2024 17:17:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E5=B9=B6=E5=8F=91=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E8=AF=B7=E6=B1=82=EF=BC=8C=E5=8F=AA=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AAonLoadStart=E7=9A=84bug=202.?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E8=A6=81=E6=8E=92=E9=98=9F?= =?UTF-8?q?=E7=9A=84=E6=9D=A1=E4=BB=B6=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=A4=A7=E4=BA=8E=E7=AD=89=E4=BA=8EmaxRequests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: madixin --- CHANGELOG.md | 2 ++ library/src/main/ets/ImageKnifeDispatcher.ets | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cae97f0..fcaf96b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ - The sub-thread network request is changed to asynchronous, thereby increasing the number of concurrent sub-thread network requests - Set the concurrency through the setMaxRequests interface under the ImageKnife class - aboutToRecycle life cycle clear image content +- Fixed bug for receive only the first onLoadStart for concurrent identical requests +- Modify the condition for determining whether to queue to be greater than or equal to maxRequests ## 3.0.3 - Released version 3.0.3 diff --git a/library/src/main/ets/ImageKnifeDispatcher.ets b/library/src/main/ets/ImageKnifeDispatcher.ets index a6a2af6..0272046 100644 --- a/library/src/main/ets/ImageKnifeDispatcher.ets +++ b/library/src/main/ets/ImageKnifeDispatcher.ets @@ -104,7 +104,7 @@ export class ImageKnifeDispatcher { } } //3.判断是否要排队 - if (this.executingJobMap.length > this.maxRequests) { + if (this.executingJobMap.length >= this.maxRequests) { this.jobQueue.add(request) return } @@ -128,6 +128,11 @@ export class ImageKnifeDispatcher { */ getAndShowImage(currentRequest: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): void { LogUtil.log("ImageKnife_DataTime_getAndShowImage.start:" + currentRequest.imageKnifeOption.loadSrc) + if (requestSource === ImageKnifeRequestSource.SRC && currentRequest.imageKnifeOption.onLoadListener?.onLoadStart !== undefined) { + currentRequest.imageKnifeOption.onLoadListener?.onLoadStart() + LogUtil.log("ImageKnife_DataTime_getAndShowImage_onLoadStart:" + currentRequest.imageKnifeOption.loadSrc) + } + let memoryKey: string = this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator) let requestList: List | undefined = this.executingJobMap.get(memoryKey) if (requestList == undefined) { @@ -140,6 +145,9 @@ export class ImageKnifeDispatcher { } let isWatchProgress : boolean = false + if (currentRequest.imageKnifeOption.progressListener !== undefined && requestSource === ImageKnifeRequestSource.SRC) { + isWatchProgress = true + } // 回调请求开始 requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => {