Open Kuki93 opened 1 year ago
interface ITaskInitExecute<Result> : ITask {
suspend fun executeInit(application: Application, processName: String): Result
}
fun interface ITaskCompleteListener {
fun onCompleted()
}
fun interface ITaskStateChangeListener {
fun onChanged(task: TaskInfo)
}
class AutoInitTask constructor(val taskInfo: TaskInfo, val task: ITask?) : Comparable<AutoInitTask> {
override fun compareTo(other: AutoInitTask): Int {
return taskInfo.compareTo(other.taskInfo)
}
}
internal object UnResult : Any()
enum class TaskState {
NONE,
READY,
RUNNING,
DONE
}
data class TaskInfo(
val name: String,
val priority: Int,
val isMainThread: Boolean,
val process: Array<String>?,
val depends: Array<String>?,
val taskIdentity: String
) : Comparable<TaskInfo> {
var childTask: Array<String>? = null
var result: Any? = UnResult
var state: TaskState = TaskState.NONE
fun isDone() = result !== UnResult
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as TaskInfo
if (name != other.name) return false
return true
}
override fun hashCode(): Int {
return name.hashCode()
}
override fun compareTo(other: TaskInfo): Int {
return priority.compareTo(other.priority)
}
override fun toString(): String {
return "TaskInfo(name='$name', priority=$priority, isMainThread=$isMainThread, process=${process?.contentToString()}, depends=${depends?.contentToString()}, taskIdentity='$taskIdentity', childTask=${childTask?.contentToString()}, result=$result)"
}
fun toStateString(): String {
return "TaskInfo(name='$name', state=$state, result=$result)"
}
}