Commit 1ababc8c authored by topjohnwu's avatar topjohnwu

RepoDB does not need to run on main thread

parent 1f75e63c
...@@ -20,5 +20,4 @@ val databaseModule = module { ...@@ -20,5 +20,4 @@ val databaseModule = module {
fun createRepoDatabase(context: Context) = fun createRepoDatabase(context: Context) =
Room.databaseBuilder(context, RepoDatabase::class.java, "repo.db") Room.databaseBuilder(context, RepoDatabase::class.java, "repo.db")
.fallbackToDestructiveMigration() .fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build() .build()
...@@ -33,6 +33,7 @@ import com.topjohnwu.magisk.utils.Utils ...@@ -33,6 +33,7 @@ import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog
import com.topjohnwu.net.Networking import com.topjohnwu.net.Networking
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import io.reactivex.Completable
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
import java.io.File import java.io.File
...@@ -83,13 +84,15 @@ class SettingsFragment : BasePreferenceFragment() { ...@@ -83,13 +84,15 @@ class SettingsFragment : BasePreferenceFragment() {
true true
} }
findPreference("clear").setOnPreferenceClickListener { findPreference("clear").setOnPreferenceClickListener {
repoDB.clear() Completable.fromAction { repoDB.clear() }.subscribeK {
Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT) Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT)
}
true true
} }
findPreference("hosts").setOnPreferenceClickListener { findPreference("hosts").setOnPreferenceClickListener {
Shell.su("add_hosts_module").exec() Shell.su("add_hosts_module").submit {
Utils.toast(R.string.settings_hosts_toast, Toast.LENGTH_SHORT) Utils.toast(R.string.settings_hosts_toast, Toast.LENGTH_SHORT)
}
true true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment