コード例 #1
0
  public static void migrateAllowedSources() {
    SharedPreferences prefs = DDGApplication.getSharedPreferences();
    if (PreferencesManager.shouldMigrateSources()) {
      Set<String> oldAllowed = DDGUtils.loadSet(prefs, "sourceset");
      DDGUtils.deleteSet(prefs, "sourceset");
      saveUserAllowedSources(oldAllowed);

      Set<String> cachedSources = DDGUtils.getCachedSources();
      // XXX cachedSources is not expected to be null during a migration
      // since before APP VERSION_CODE 43, source response is always cached
      if (cachedSources != null) {
        Set<String> oldDisallowed = new HashSet<String>(cachedSources);
        oldDisallowed.removeAll(oldAllowed);
        saveUserDisallowedSources(oldDisallowed);
      }
      sourcesWereMigratedRightNow = true;
    }
  }