RepoDB does not need to run on main thread

This commit is contained in:
topjohnwu 2019-08-02 01:20:16 -07:00
parent 1f75e63c37
commit 1ababc8c7f
2 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -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() {
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
} }