Commit f0a734fd authored by Viktor De Pasquale's avatar Viktor De Pasquale

Fixed clearing cache crashing due to operations on main thread

parent aaabd836
...@@ -12,6 +12,7 @@ import com.topjohnwu.magisk.utils.Utils ...@@ -12,6 +12,7 @@ import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.magisk.utils.toSingle import com.topjohnwu.magisk.utils.toSingle
import com.topjohnwu.magisk.utils.writeToFile import com.topjohnwu.magisk.utils.writeToFile
import com.topjohnwu.magisk.utils.writeToString import com.topjohnwu.magisk.utils.writeToString
import io.reactivex.Completable
import io.reactivex.Single import io.reactivex.Single
class ModuleRepository( class ModuleRepository(
...@@ -59,7 +60,7 @@ class ModuleRepository( ...@@ -59,7 +60,7 @@ class ModuleRepository(
.fetchModuleInstaller() .fetchModuleInstaller()
.map { it.writeToFile(context, FILE_MODULE_INSTALLER_SH) } .map { it.writeToFile(context, FILE_MODULE_INSTALLER_SH) }
fun deleteAllCached() = repoDao.deleteAll() fun deleteAllCached() = Completable.fromCallable { repoDao.deleteAll() }
private fun fetchProperties(module: String, lastChanged: Long) = apiRaw private fun fetchProperties(module: String, lastChanged: Long) = apiRaw
......
...@@ -110,7 +110,9 @@ public final class SettingsFragment extends BasePreferenceFragment { ...@@ -110,7 +110,9 @@ public final class SettingsFragment extends BasePreferenceFragment {
Preference clear = findPreference("clear"); Preference clear = findPreference("clear");
clear.setOnPreferenceClickListener(pref -> { clear.setOnPreferenceClickListener(pref -> {
getPrefs().edit().remove(Config.Key.ETAG_KEY).apply(); getPrefs().edit().remove(Config.Key.ETAG_KEY).apply();
getModuleRepo().deleteAllCached(); getModuleRepo().deleteAllCached().subscribeOn(Schedulers.io()).subscribe(() -> {
}, throwable -> {
});
Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT); Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
return true; return 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