summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2020-02-02 17:09:25 +0100
committerByteHamster <info@bytehamster.com>2020-02-02 17:09:25 +0100
commit998a17a852323f96f0fdaa6feaa3136a694d93c6 (patch)
tree1572f36cb44859b14f461bbdfc496c07c42e0ea0 /app/src/main/java
parent63290ae762518c94563b8c128aef3eccc35d6fd9 (diff)
downloadAntennaPod-998a17a852323f96f0fdaa6feaa3136a694d93c6.zip
Update speed when changing feed defaults
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java26
1 files changed, 11 insertions, 15 deletions
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 bd5381df6..63160bb2c 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
@@ -2,22 +2,21 @@ package de.danoeh.antennapod.fragment;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.os.Bundle;
-import androidx.preference.SwitchPreference;
+import android.util.Log;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
-import android.util.Log;
+import androidx.preference.SwitchPreference;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
+import de.danoeh.antennapod.core.event.settings.SpeedPresetChangedEvent;
import de.danoeh.antennapod.core.event.settings.VolumeAdaptionChangedEvent;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedFilter;
import de.danoeh.antennapod.core.feed.FeedPreferences;
import de.danoeh.antennapod.core.feed.VolumeAdaptionSetting;
import de.danoeh.antennapod.core.preferences.UserPreferences;
-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.dialog.AuthenticationDialog;
@@ -38,7 +37,8 @@ import static de.danoeh.antennapod.core.feed.FeedPreferences.SPEED_USE_GLOBAL;
public class FeedSettingsFragment extends PreferenceFragmentCompat {
private static final CharSequence PREF_EPISODE_FILTER = "episodeFilter";
private static final String PREF_FEED_PLAYBACK_SPEED = "feedPlaybackSpeed";
- private static final DecimalFormat decimalFormat = new DecimalFormat("0.00", DecimalFormatSymbols.getInstance(Locale.US));
+ private static final DecimalFormat SPEED_FORMAT =
+ new DecimalFormat("0.00", DecimalFormatSymbols.getInstance(Locale.US));
private static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
private static final String TAG = "FeedSettingsFragment";
@@ -120,7 +120,7 @@ public class FeedSettingsFragment extends PreferenceFragmentCompat {
String[] speeds = UserPreferences.getPlaybackSpeedArray();
String[] values = new String[speeds.length + 1];
- values[0] = decimalFormat.format(SPEED_USE_GLOBAL);
+ values[0] = SPEED_FORMAT.format(SPEED_USE_GLOBAL);
String[] entries = new String[speeds.length + 1];
entries[0] = getString(R.string.feed_auto_download_global);
@@ -130,11 +130,12 @@ public class FeedSettingsFragment extends PreferenceFragmentCompat {
feedPlaybackSpeedPreference.setEntryValues(values);
feedPlaybackSpeedPreference.setEntries(entries);
-
feedPlaybackSpeedPreference.setOnPreferenceChangeListener((preference, newValue) -> {
feedPreferences.setFeedPlaybackSpeed(Float.parseFloat((String) newValue));
feed.savePreferences();
updatePlaybackSpeedPreference();
+ EventBus.getDefault().post(
+ new SpeedPresetChangedEvent(feedPreferences.getFeedPlaybackSpeed(), feed.getId()));
return false;
});
}
@@ -192,7 +193,7 @@ public class FeedSettingsFragment extends PreferenceFragmentCompat {
ListPreference feedPlaybackSpeedPreference = findPreference(PREF_FEED_PLAYBACK_SPEED);
float speedValue = feedPreferences.getFeedPlaybackSpeed();
- feedPlaybackSpeedPreference.setValue(decimalFormat.format(speedValue));
+ feedPlaybackSpeedPreference.setValue(SPEED_FORMAT.format(speedValue));
}
private void updateAutoDeleteSummary() {
@@ -230,17 +231,12 @@ public class FeedSettingsFragment extends PreferenceFragmentCompat {
}
feed.savePreferences();
updateVolumeReductionValue();
- sendVolumeAdaptionChangedIntent();
-
+ EventBus.getDefault().post(
+ new VolumeAdaptionChangedEvent(feedPreferences.getVolumeAdaptionSetting(), feed.getId()));
return false;
});
}
- private void sendVolumeAdaptionChangedIntent() {
- EventBus.getDefault().post(
- new VolumeAdaptionChangedEvent(feedPreferences.getVolumeAdaptionSetting(), feed.getId()));
- }
-
private void updateVolumeReductionValue() {
ListPreference volumeReductionPreference = (ListPreference) findPreference("volumeReduction");