1.修复并发相同请求,只收到第一个onLoadStart的bug

2.判断是否要排队的条件,修改为大于等于maxRequests

Signed-off-by: madixin <madixin@huawei.com>
This commit is contained in:
madixin 2024-10-25 17:17:44 +08:00
parent 8d4442157c
commit 9c0b4ebace
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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<ImageKnifeRequestWithSource> | 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) => {