VancedManager/app/src/main/java/com/vanced/manager/model/RootDataModel.kt

36 lines
1011 B
Kotlin
Raw Normal View History

package com.vanced.manager.model
import android.content.Context
2021-02-26 15:34:22 +00:00
import androidx.annotation.DrawableRes
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import com.beust.klaxon.JsonObject
import com.vanced.manager.utils.PackageHelper
2021-01-17 10:54:48 +00:00
class RootDataModel(
jsonObject: LiveData<JsonObject?>,
2021-01-17 12:52:50 +00:00
context: Context,
appPkg: String,
appName: String,
2021-02-26 15:34:22 +00:00
appDescription: String,
@DrawableRes appIcon: Int,
2021-01-17 12:52:50 +00:00
//BUG THIS!
//kotlin thinks that this value is null if we use
//private val scriptName: String
//Although it's impossible for it to be null.
//Ironic, isn't it?
private val scriptName: String?
2021-04-19 15:57:14 +00:00
) : DataModel(
jsonObject, context, appPkg, appName, appDescription, appIcon
) {
2021-01-17 12:52:50 +00:00
override fun isAppInstalled(pkg: String): Boolean {
//Adapt to nullable shit
return if (scriptName?.let { PackageHelper.scriptExists(it) } == true) {
super.isAppInstalled(appPkg)
} else {
2021-01-17 12:52:50 +00:00
false
}
}
}