fix #163, remove invalid Favorites items on app startup

This commit is contained in:
tibbi 2018-09-10 21:24:34 +02:00
parent f69228be71
commit e776be0b5a
1 changed files with 13 additions and 3 deletions

View File

@ -52,10 +52,10 @@ class MainActivity : SimpleActivity() {
if (savedInstanceState == null) { if (savedInstanceState == null) {
tryInitFileManager() tryInitFileManager()
checkWhatsNewDialog()
checkIfRootAvailable()
checkInvalidFavorites()
} }
checkWhatsNewDialog()
checkIfRootAvailable()
} }
override fun onStop() { override fun onStop() {
@ -285,6 +285,16 @@ class MainActivity : SimpleActivity() {
}.start() }.start()
} }
private fun checkInvalidFavorites() {
Thread {
config.favorites.forEach {
if (!it.startsWith(OTG_PATH) && !isPathOnSD(it) && !getDoesFilePathExist(it)) {
config.removeFavorite(it)
}
}
}.start()
}
fun pickedPath(path: String) { fun pickedPath(path: String) {
val resultIntent = Intent() val resultIntent = Intent()
val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID) val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID)