mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-15 20:09:19 +00:00
Improve: Use single Installer instance in whole app
This commit is contained in:
@ -12,17 +12,15 @@ abstract class AppInstaller {
|
||||
fun getInstance(context: Context?): AppInstaller? {
|
||||
if (INSTANCE == null) {
|
||||
synchronized(AppInstaller::class.java) {
|
||||
if (INSTANCE == null) {
|
||||
context?.let {
|
||||
INSTANCE = object : AppInstaller() {
|
||||
override val defaultInstaller: BaseInstaller
|
||||
get() {
|
||||
return when (rootInstallerEnabled) {
|
||||
false -> DefaultInstaller(it)
|
||||
true -> RootInstaller(it)
|
||||
}
|
||||
context?.let {
|
||||
INSTANCE = object : AppInstaller() {
|
||||
override val defaultInstaller: BaseInstaller
|
||||
get() {
|
||||
return when (rootInstallerEnabled) {
|
||||
false -> DefaultInstaller(it)
|
||||
true -> RootInstaller(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,10 @@ import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
class DefaultInstaller(context: Context) : BaseInstaller(context) {
|
||||
override suspend fun install(cacheFileName: String) {
|
||||
val cacheFile = Cache.getReleaseFile(context, cacheFileName)
|
||||
mDefaultInstaller(cacheFile)
|
||||
}
|
||||
|
||||
override suspend fun install(packageName: String, cacheFileName: String) {
|
||||
val cacheFile = Cache.getReleaseFile(context, cacheFileName)
|
||||
|
@ -3,6 +3,8 @@ package com.looker.droidify.installer
|
||||
import java.io.File
|
||||
|
||||
interface InstallationEvents {
|
||||
suspend fun install(cacheFileName: String)
|
||||
|
||||
suspend fun install(packageName: String, cacheFileName: String)
|
||||
|
||||
suspend fun install(packageName: String, cacheFile: File)
|
||||
|
@ -11,6 +11,10 @@ import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
class RootInstaller(context: Context) : BaseInstaller(context) {
|
||||
override suspend fun install(cacheFileName: String) {
|
||||
val cacheFile = Cache.getReleaseFile(context, cacheFileName)
|
||||
mRootInstaller(cacheFile)
|
||||
}
|
||||
|
||||
override suspend fun install(packageName: String, cacheFileName: String) {
|
||||
val cacheFile = Cache.getReleaseFile(context, cacheFileName)
|
||||
|
Reference in New Issue
Block a user