mirror of
https://github.com/YTVanced/VancedManager
synced 2024-12-01 07:23:02 +00:00
clean up viewmodel
This commit is contained in:
parent
7141df8af8
commit
770221290a
2 changed files with 13 additions and 13 deletions
|
@ -59,6 +59,7 @@ class MainActivity : ComponentActivity() {
|
|||
)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mainViewModel.fetch()
|
||||
setContent {
|
||||
ManagerTheme {
|
||||
val surfaceColor = managerSurfaceColor()
|
||||
|
|
|
@ -35,18 +35,12 @@ class MainViewModel(
|
|||
data class Error(val error: String) : AppState()
|
||||
}
|
||||
|
||||
var appState by mutableStateOf<AppState>(AppState.Fetching(3))
|
||||
var appState by mutableStateOf<AppState>(AppState.Fetching(appCount))
|
||||
private set
|
||||
|
||||
fun fetch() {
|
||||
viewModelScope.launch {
|
||||
var appsCount = 0
|
||||
|
||||
if (vancedEnabled) appsCount++
|
||||
if (musicEnabled) appsCount++
|
||||
if (isNonroot) appsCount++
|
||||
|
||||
appState = AppState.Fetching(appsCount)
|
||||
appState = AppState.Fetching(appCount)
|
||||
|
||||
try {
|
||||
with(repository.fetch()) {
|
||||
|
@ -104,14 +98,19 @@ class MainViewModel(
|
|||
uninstallPackage(appPackage, app)
|
||||
}
|
||||
|
||||
init {
|
||||
fetch()
|
||||
}
|
||||
private val appCount: Int
|
||||
get() {
|
||||
var appsCount = 0
|
||||
|
||||
if (vancedEnabled) appsCount++
|
||||
if (musicEnabled) appsCount++
|
||||
if (isNonroot) appsCount++
|
||||
|
||||
return appsCount
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val TAG = "MainViewModel"
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue