New cache system

Refactoring
Separation into libraries
This commit is contained in:
2021-03-17 19:47:53 +03:00
parent 2004cb7c5e
commit 84d812a6d6
198 changed files with 4892 additions and 3477 deletions
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.meloda.concurrent">
</manifest>
@@ -0,0 +1,3 @@
package com.meloda.concurrent
class EventInfo<T> constructor(var key: String, var data: T? = null)
@@ -0,0 +1,12 @@
package com.meloda.concurrent
import android.os.Process
class LowThread(runnable: Runnable?) : Thread(runnable) {
override fun run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND)
super.run()
}
}
@@ -0,0 +1,30 @@
package com.meloda.concurrent
object TaskManager {
private const val TAG = "TaskManager"
private val listeners = arrayListOf<OnEventListener>()
fun addOnEventListener(listener: OnEventListener) {
listeners.add(listener)
}
fun removeOnEventListener(listener: OnEventListener?) {
listeners.remove(listener)
}
fun execute(runnable: Runnable?) {
LowThread(runnable).start()
}
fun sendEvent(eventInfo: EventInfo<*>) {
for (listener in listeners) {
listener.onNewEvent(eventInfo)
}
}
interface OnEventListener {
fun onNewEvent(info: EventInfo<*>)
}
}