mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 01:39:19 +01:00
Add automatic refreshing games list
This commit is contained in:
parent
d00fcee79d
commit
0eed72664d
@ -351,5 +351,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
setAppListDecoration()
|
setAppListDecoration()
|
||||||
adapter.notifyItemRangeChanged(0, adapter.currentItems.size)
|
adapter.notifyItemRangeChanged(0, adapter.currentItems.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.checkRomHash(Uri.parse(appSettings.searchLocation), EmulationSettings.global.systemLanguage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ import emu.skyline.loader.AppEntry
|
|||||||
import emu.skyline.loader.RomFormat
|
import emu.skyline.loader.RomFormat
|
||||||
import emu.skyline.utils.fromFile
|
import emu.skyline.utils.fromFile
|
||||||
import emu.skyline.utils.toFile
|
import emu.skyline.utils.toFile
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.collections.HashMap
|
|
||||||
|
|
||||||
sealed class MainState {
|
sealed class MainState {
|
||||||
object Loading : MainState()
|
object Loading : MainState()
|
||||||
@ -73,4 +73,19 @@ class MainViewModel @Inject constructor(@ApplicationContext context : Context, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checks if the roms have changed since the last time they were loaded and if so it reloads them
|
||||||
|
*/
|
||||||
|
fun checkRomHash(searchLocation : Uri, systemLanguage : Int) {
|
||||||
|
if(state !is MainState.Loaded) return
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val currentHash = (state as MainState.Loaded).items.hashCode()
|
||||||
|
val romElements = romProvider.loadRoms(searchLocation, systemLanguage)
|
||||||
|
val newHash = romElements.hashCode()
|
||||||
|
if (newHash != currentHash) {
|
||||||
|
state = MainState.Loaded(romElements)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user