Removed DbWriter dependency from model

This commit is contained in:
ByteHamster 2021-02-26 11:10:00 +01:00
parent 39f9796656
commit cc3e0c38d2
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.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();

View File

@ -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;
});

View File

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

View File

@ -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;
}