finish the multi thread down load func and wait to test

This commit is contained in:
zhongchao
2022-03-22 21:57:26 +08:00
parent b28c3ab3cd
commit 22adb762c3
16 changed files with 396 additions and 175 deletions

View File

@@ -0,0 +1,87 @@
package com.mogo.eagle.core.function.call.devatools
import androidx.annotation.Nullable
import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener
import java.util.concurrent.ConcurrentHashMap
object CallerDevaToolsUpgradeListenerManager {
private val M_DEVA_TOOLS_UPGRADE_LISTENER: ConcurrentHashMap<String, IMogoDevaToolsUpgradeListener> =
ConcurrentHashMap()
/**
* 添加监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun registerDevaToolsUpgradeListener(
@Nullable tag: String,
@Nullable listener: IMogoDevaToolsUpgradeListener
) {
if (M_DEVA_TOOLS_UPGRADE_LISTENER.containsKey(tag)) {
return
}
M_DEVA_TOOLS_UPGRADE_LISTENER[tag] = listener
}
/**
* 删除监听
* @param tag 标记,用来注销监听使用
*/
fun unRegisterDevaToolsUpgradeListener(@Nullable tag: String) {
if (!M_DEVA_TOOLS_UPGRADE_LISTENER.containsKey(tag)) {
return
}
M_DEVA_TOOLS_UPGRADE_LISTENER.remove(tag)
}
/**
* 删除监听
* @param listener 要删除的监听对象
*/
fun unRegisterDevaToolsUpgradeListener(@Nullable listener: IMogoDevaToolsUpgradeListener) {
if (!M_DEVA_TOOLS_UPGRADE_LISTENER.containsValue(listener)) {
return
}
M_DEVA_TOOLS_UPGRADE_LISTENER.forEach {
if (it.value == listener) {
M_DEVA_TOOLS_UPGRADE_LISTENER.remove(it.key)
}
}
}
fun invokeUpgradeStart(url: String) {
M_DEVA_TOOLS_UPGRADE_LISTENER.forEach {
val listener = it.value
listener.onStart(url)
}
}
fun invokeUpgradeProgress(url: String, progress: Int) {
M_DEVA_TOOLS_UPGRADE_LISTENER.forEach {
val listener = it.value
listener.onProgress(url, progress)
}
}
fun invokeUpgradePause(url: String) {
M_DEVA_TOOLS_UPGRADE_LISTENER.forEach {
val listener = it.value
listener.onPause(url)
}
}
fun invokeUpgradeFinish(url: String) {
M_DEVA_TOOLS_UPGRADE_LISTENER.forEach {
val listener = it.value
listener.onFinished(url)
}
}
fun invokeUpgradeError(url: String, errorMsg: String) {
M_DEVA_TOOLS_UPGRADE_LISTENER.forEach {
val listener = it.value
listener.onError(url, errorMsg)
}
}
}