Merge pull request #4966 from ByteHamster/remove-feedpreferences-save-from-model

Removed DbWriter dependency from model
This commit is contained in:
ByteHamster 2021-02-26 11:29:36 +01:00 committed by GitHub
commit 642d852aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 21 deletions

View File

@ -42,6 +42,7 @@ import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.service.download.HttpDownloader; import de.danoeh.antennapod.core.service.download.HttpDownloader;
import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.syndication.handler.FeedHandler; import de.danoeh.antennapod.core.syndication.handler.FeedHandler;
@ -525,7 +526,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
Feed feed1 = DBReader.getFeed(getFeedId(feed)); Feed feed1 = DBReader.getFeed(getFeedId(feed));
FeedPreferences feedPreferences = feed1.getPreferences(); FeedPreferences feedPreferences = feed1.getPreferences();
feedPreferences.setAutoDownload(autoDownload); feedPreferences.setAutoDownload(autoDownload);
feed1.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
SharedPreferences preferences = getSharedPreferences(PREFS, MODE_PRIVATE); SharedPreferences preferences = getSharedPreferences(PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();

View File

@ -193,7 +193,7 @@ public class FeedSettingsFragment extends Fragment {
protected void onConfirmed(int skipIntro, int skipEnding) { protected void onConfirmed(int skipIntro, int skipEnding) {
feedPreferences.setFeedSkipIntro(skipIntro); feedPreferences.setFeedSkipIntro(skipIntro);
feedPreferences.setFeedSkipEnding(skipEnding); feedPreferences.setFeedSkipEnding(skipEnding);
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
EventBus.getDefault().post( EventBus.getDefault().post(
new SkipIntroEndingChangedEvent(feedPreferences.getFeedSkipIntro(), new SkipIntroEndingChangedEvent(feedPreferences.getFeedSkipIntro(),
feedPreferences.getFeedSkipEnding(), feedPreferences.getFeedSkipEnding(),
@ -221,7 +221,7 @@ public class FeedSettingsFragment extends Fragment {
feedPlaybackSpeedPreference.setEntries(entries); feedPlaybackSpeedPreference.setEntries(entries);
feedPlaybackSpeedPreference.setOnPreferenceChangeListener((preference, newValue) -> { feedPlaybackSpeedPreference.setOnPreferenceChangeListener((preference, newValue) -> {
feedPreferences.setFeedPlaybackSpeed(Float.parseFloat((String) newValue)); feedPreferences.setFeedPlaybackSpeed(Float.parseFloat((String) newValue));
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
updatePlaybackSpeedPreference(); updatePlaybackSpeedPreference();
EventBus.getDefault().post( EventBus.getDefault().post(
new SpeedPresetChangedEvent(feedPreferences.getFeedPlaybackSpeed(), feed.getId())); new SpeedPresetChangedEvent(feedPreferences.getFeedPlaybackSpeed(), feed.getId()));
@ -235,7 +235,7 @@ public class FeedSettingsFragment extends Fragment {
@Override @Override
protected void onConfirmed(FeedFilter filter) { protected void onConfirmed(FeedFilter filter) {
feedPreferences.setFilter(filter); feedPreferences.setFilter(filter);
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
} }
}.show(); }.show();
return false; return false;
@ -251,7 +251,7 @@ public class FeedSettingsFragment extends Fragment {
protected void onConfirmed(String username, String password) { protected void onConfirmed(String username, String password) {
feedPreferences.setUsername(username); feedPreferences.setUsername(username);
feedPreferences.setPassword(password); feedPreferences.setPassword(password);
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
} }
}.show(); }.show();
return false; return false;
@ -271,7 +271,7 @@ public class FeedSettingsFragment extends Fragment {
feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NO); feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NO);
break; break;
} }
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
updateAutoDeleteSummary(); updateAutoDeleteSummary();
return false; return false;
}); });
@ -317,7 +317,7 @@ public class FeedSettingsFragment extends Fragment {
feedPreferences.setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION); feedPreferences.setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION);
break; break;
} }
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
updateVolumeReductionValue(); updateVolumeReductionValue();
EventBus.getDefault().post( EventBus.getDefault().post(
new VolumeAdaptionChangedEvent(feedPreferences.getVolumeAdaptionSetting(), feed.getId())); new VolumeAdaptionChangedEvent(feedPreferences.getVolumeAdaptionSetting(), feed.getId()));
@ -348,7 +348,7 @@ public class FeedSettingsFragment extends Fragment {
pref.setOnPreferenceChangeListener((preference, newValue) -> { pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean checked = newValue == Boolean.TRUE; boolean checked = newValue == Boolean.TRUE;
feedPreferences.setKeepUpdated(checked); feedPreferences.setKeepUpdated(checked);
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked); pref.setChecked(checked);
return false; return false;
}); });
@ -379,7 +379,7 @@ public class FeedSettingsFragment extends Fragment {
boolean checked = newValue == Boolean.TRUE; boolean checked = newValue == Boolean.TRUE;
feedPreferences.setAutoDownload(checked); feedPreferences.setAutoDownload(checked);
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
updateAutoDownloadEnabled(); updateAutoDownloadEnabled();
ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(getActivity(), checked); ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(getActivity(), checked);
dialog.createNewDialog().show(); dialog.createNewDialog().show();
@ -402,7 +402,7 @@ public class FeedSettingsFragment extends Fragment {
pref.setOnPreferenceChangeListener((preference, newValue) -> { pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean checked = newValue == Boolean.TRUE; boolean checked = newValue == Boolean.TRUE;
feedPreferences.setShowEpisodeNotification(checked); feedPreferences.setShowEpisodeNotification(checked);
feed.savePreferences(); DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked); pref.setChecked(checked);
return false; return false;
}); });

View File

@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.SortOrder; import de.danoeh.antennapod.core.util.SortOrder;
@ -478,10 +477,6 @@ public class Feed extends FeedFile {
return preferences; return preferences;
} }
public void savePreferences() {
DBWriter.setFeedPreferences(preferences);
}
@Override @Override
public void setId(long id) { public void setId(long id) {
super.setId(id); super.setId(id);

View File

@ -1,12 +1,10 @@
package de.danoeh.antennapod.core.feed; package de.danoeh.antennapod.core.feed;
import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.storage.PodDBAdapter;
/** /**
@ -202,10 +200,6 @@ public class FeedPreferences {
} }
} }
public void save(Context context) {
DBWriter.setFeedPreferences(this);
}
public String getUsername() { public String getUsername() {
return username; return username;
} }