New cache system
Refactoring Separation into libraries
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -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<*>)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user