From cc3e0c38d2796aa213cf62d07bafe7e413b28388 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 26 Feb 2021 11:10:00 +0100 Subject: [PATCH] Removed DbWriter dependency from model --- .../activity/OnlineFeedViewActivity.java | 3 ++- .../fragment/FeedSettingsFragment.java | 18 +++++++++--------- .../de/danoeh/antennapod/core/feed/Feed.java | 5 ----- .../antennapod/core/feed/FeedPreferences.java | 6 ------ 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index f53c629b9..bd2c7f9a6 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -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.playback.PlaybackService; 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.DownloadRequester; import de.danoeh.antennapod.core.syndication.handler.FeedHandler; @@ -525,7 +526,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { Feed feed1 = DBReader.getFeed(getFeedId(feed)); FeedPreferences feedPreferences = feed1.getPreferences(); feedPreferences.setAutoDownload(autoDownload); - feed1.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); SharedPreferences preferences = getSharedPreferences(PREFS, MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java index fb9ac4a59..e24c89478 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java @@ -193,7 +193,7 @@ public class FeedSettingsFragment extends Fragment { protected void onConfirmed(int skipIntro, int skipEnding) { feedPreferences.setFeedSkipIntro(skipIntro); feedPreferences.setFeedSkipEnding(skipEnding); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); EventBus.getDefault().post( new SkipIntroEndingChangedEvent(feedPreferences.getFeedSkipIntro(), feedPreferences.getFeedSkipEnding(), @@ -221,7 +221,7 @@ public class FeedSettingsFragment extends Fragment { feedPlaybackSpeedPreference.setEntries(entries); feedPlaybackSpeedPreference.setOnPreferenceChangeListener((preference, newValue) -> { feedPreferences.setFeedPlaybackSpeed(Float.parseFloat((String) newValue)); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); updatePlaybackSpeedPreference(); EventBus.getDefault().post( new SpeedPresetChangedEvent(feedPreferences.getFeedPlaybackSpeed(), feed.getId())); @@ -235,7 +235,7 @@ public class FeedSettingsFragment extends Fragment { @Override protected void onConfirmed(FeedFilter filter) { feedPreferences.setFilter(filter); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); } }.show(); return false; @@ -251,7 +251,7 @@ public class FeedSettingsFragment extends Fragment { protected void onConfirmed(String username, String password) { feedPreferences.setUsername(username); feedPreferences.setPassword(password); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); } }.show(); return false; @@ -271,7 +271,7 @@ public class FeedSettingsFragment extends Fragment { feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NO); break; } - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); updateAutoDeleteSummary(); return false; }); @@ -317,7 +317,7 @@ public class FeedSettingsFragment extends Fragment { feedPreferences.setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION); break; } - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); updateVolumeReductionValue(); EventBus.getDefault().post( new VolumeAdaptionChangedEvent(feedPreferences.getVolumeAdaptionSetting(), feed.getId())); @@ -348,7 +348,7 @@ public class FeedSettingsFragment extends Fragment { pref.setOnPreferenceChangeListener((preference, newValue) -> { boolean checked = newValue == Boolean.TRUE; feedPreferences.setKeepUpdated(checked); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); pref.setChecked(checked); return false; }); @@ -379,7 +379,7 @@ public class FeedSettingsFragment extends Fragment { boolean checked = newValue == Boolean.TRUE; feedPreferences.setAutoDownload(checked); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); updateAutoDownloadEnabled(); ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(getActivity(), checked); dialog.createNewDialog().show(); @@ -402,7 +402,7 @@ public class FeedSettingsFragment extends Fragment { pref.setOnPreferenceChangeListener((preference, newValue) -> { boolean checked = newValue == Boolean.TRUE; feedPreferences.setShowEpisodeNotification(checked); - feed.savePreferences(); + DBWriter.setFeedPreferences(feedPreferences); pref.setChecked(checked); return false; }); diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java index 51138e407..da946cf0b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.util.SortOrder; @@ -478,10 +477,6 @@ public class Feed extends FeedFile { return preferences; } - public void savePreferences() { - DBWriter.setFeedPreferences(preferences); - } - @Override public void setId(long id) { super.setId(id); diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java index 21474db89..93efed7e1 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedPreferences.java @@ -1,12 +1,10 @@ package de.danoeh.antennapod.core.feed; -import android.content.Context; import android.database.Cursor; import androidx.annotation.NonNull; import android.text.TextUtils; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.storage.DBWriter; 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() { return username; }