From 2f9263f3c94edb3b93ec4db29694ec99b4262444 Mon Sep 17 00:00:00 2001 From: eggmanQQQ <3671373519@qq.com> Date: Fri, 27 Dec 2024 14:31:03 +0800 Subject: [PATCH] =?UTF-8?q?feat=20;=20=E9=A2=84=E5=8A=A0=E8=BD=BD=20?= =?UTF-8?q?=E9=BA=A6=E4=BD=8D=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chwl/app/utils/ResourceManager.kt | 51 +++++++++++++++++++ mode.json | 14 ++--- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/chwl/app/utils/ResourceManager.kt b/app/src/main/java/com/chwl/app/utils/ResourceManager.kt index 343de79ed..66180c1e8 100644 --- a/app/src/main/java/com/chwl/app/utils/ResourceManager.kt +++ b/app/src/main/java/com/chwl/app/utils/ResourceManager.kt @@ -1,11 +1,21 @@ package com.chwl.app.utils +import com.bumptech.glide.load.DataSource +import com.bumptech.glide.load.engine.GlideException +import com.bumptech.glide.request.RequestListener +import com.bumptech.glide.request.target.Target import com.chwl.core.gift.bean.RoomMicDress import com.chwl.core.home.bean.ClientResource import com.chwl.core.initial.InitialModel import com.chwl.core.manager.AvRoomDataManager +import com.chwl.library.common.glide.GlideUtils import com.chwl.library.common.util.doLog import com.chwl.library.common.util.isVerify +import com.example.lib_utils.AppUtils +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import java.io.File object ResourceManager { @@ -15,6 +25,7 @@ object ResourceManager { InitialModel.get().clientResource().doOnSuccess { "data = $it".doLog() mClientResource = it + preLoad(it) }.subscribe() } @@ -47,4 +58,44 @@ object ResourceManager { } return data } + + private fun preLoad(clientResource: ClientResource) { + GlobalScope.launch { + clientResource?.roomMicDressList?.forEach { + delay(500) + doLoad(it.normalMicLockUrl) + doLoad(it.normalMicLockUrl) + doLoad(it.bossMicUrl) + doLoad(it.bossMicLockUrl) + } + } + } + + private fun doLoad(url: String) { + if (url.isVerify()) { + "预加载 -> ResourceManager doLoad url = $url".doLog() + GlideUtils.instance().downloadFromUrl2(AppUtils.getApp(),url,object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + "预加载 -> ResourceManager onLoadFailed error = ${e?.message} url = $url".doLog() + return true + } + + override fun onResourceReady( + resource: File?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + "预加载 -> ResourceManager onResourceReady Success url = $url".doLog() + return true + } + }) + } + } } \ No newline at end of file diff --git a/mode.json b/mode.json index 84b5c1391..3b1640d73 100644 --- a/mode.json +++ b/mode.json @@ -2,13 +2,7 @@ "code": 200, "message": "success", "data": { - "roomVal": 60936.5, - "currentLevelIcon": "https://image.pekolive.com/3room_lv.png", - "currentLevel": 3, - "currentLevelExp": 52500, - "nextLevel": 4, - "nextLevelExp": 78750, - "micEffects": [ + "roomMicDressList": [ { "id": 4, "dressType": 2, @@ -35,9 +29,7 @@ "normalMicLockUrl": "", "bossMicUrl": "", "bossMicLockUrl": "" - } - ], - "micSkins": [ + }, { "id": 1, "dressType": 1, @@ -67,5 +59,5 @@ } ] }, - "timestamp": 1735200527891 + "timestamp": 1735280964981 }