mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 21:27:47 +02:00
refactor: actions
This commit is contained in:
@ -166,6 +166,7 @@ class SnapEnhance {
|
||||
features.onActivityCreate()
|
||||
inAppOverlay.onActivityCreate(mainActivity!!)
|
||||
scriptRuntime.eachModule { callFunction("module.onSnapMainActivityCreate", mainActivity!!) }
|
||||
actionManager.onActivityCreate()
|
||||
}
|
||||
}.also { time ->
|
||||
appContext.log.verbose("onActivityCreate took $time")
|
||||
|
@ -11,6 +11,8 @@ abstract class AbstractAction{
|
||||
*/
|
||||
open fun run() {}
|
||||
|
||||
open fun onActivityCreate() {}
|
||||
|
||||
protected open fun deleteRecursively(parent: File?) {
|
||||
if (parent == null) return
|
||||
if (parent.isDirectory) for (child in parent.listFiles()!!) deleteRecursively(
|
||||
|
@ -31,6 +31,10 @@ class ActionManager(
|
||||
execute(EnumAction.entries.find { it.key == action } ?: return)
|
||||
}
|
||||
|
||||
fun onActivityCreate() {
|
||||
actions.values.forEach { it.onActivityCreate() }
|
||||
}
|
||||
|
||||
fun execute(enumAction: EnumAction) {
|
||||
val action = actions[enumAction] ?: return
|
||||
action.run()
|
||||
|
Reference in New Issue
Block a user