Update lists after changing 'prefer streaming' preference
This commit is contained in:
parent
29a8a5e5aa
commit
29a7c5583e
|
@ -2,29 +2,28 @@ package de.danoeh.antennapod.fragment.preferences;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.collection.ArrayMap;
|
import androidx.collection.ArrayMap;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.MediaplayerActivity;
|
import de.danoeh.antennapod.activity.MediaplayerActivity;
|
||||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||||
|
import de.danoeh.antennapod.core.event.UnreadItemsUpdateEvent;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
||||||
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
||||||
import de.danoeh.antennapod.preferences.PreferenceControllerFlavorHelper;
|
import de.danoeh.antennapod.preferences.PreferenceControllerFlavorHelper;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
public class PlaybackPreferencesFragment extends PreferenceFragmentCompat {
|
public class PlaybackPreferencesFragment extends PreferenceFragmentCompat {
|
||||||
private static final String PREF_PLAYBACK_SPEED_LAUNCHER = "prefPlaybackSpeedLauncher";
|
private static final String PREF_PLAYBACK_SPEED_LAUNCHER = "prefPlaybackSpeedLauncher";
|
||||||
private static final String PREF_PLAYBACK_REWIND_DELTA_LAUNCHER = "prefPlaybackRewindDeltaLauncher";
|
private static final String PREF_PLAYBACK_REWIND_DELTA_LAUNCHER = "prefPlaybackRewindDeltaLauncher";
|
||||||
private static final String PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER = "prefPlaybackFastForwardDeltaLauncher";
|
private static final String PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER = "prefPlaybackFastForwardDeltaLauncher";
|
||||||
|
private static final String PREF_PLAYBACK_PREFER_STREAMING = "prefStreamOverDownload";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
@ -44,26 +43,28 @@ public class PlaybackPreferencesFragment extends PreferenceFragmentCompat {
|
||||||
private void setupPlaybackScreen() {
|
private void setupPlaybackScreen() {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
|
|
||||||
findPreference(PREF_PLAYBACK_SPEED_LAUNCHER)
|
findPreference(PREF_PLAYBACK_SPEED_LAUNCHER).setOnPreferenceClickListener(preference -> {
|
||||||
.setOnPreferenceClickListener(preference -> {
|
VariableSpeedDialog.showDialog(activity);
|
||||||
VariableSpeedDialog.showDialog(activity);
|
return true;
|
||||||
return true;
|
});
|
||||||
});
|
findPreference(PREF_PLAYBACK_REWIND_DELTA_LAUNCHER).setOnPreferenceClickListener(preference -> {
|
||||||
findPreference(PREF_PLAYBACK_REWIND_DELTA_LAUNCHER)
|
MediaplayerActivity.showSkipPreference(activity, MediaplayerActivity.SkipDirection.SKIP_REWIND);
|
||||||
.setOnPreferenceClickListener(preference -> {
|
return true;
|
||||||
MediaplayerActivity.showSkipPreference(activity, MediaplayerActivity.SkipDirection.SKIP_REWIND);
|
});
|
||||||
return true;
|
findPreference(PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER).setOnPreferenceClickListener(preference -> {
|
||||||
});
|
MediaplayerActivity.showSkipPreference(activity, MediaplayerActivity.SkipDirection.SKIP_FORWARD);
|
||||||
findPreference(PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER)
|
return true;
|
||||||
.setOnPreferenceClickListener(preference -> {
|
});
|
||||||
MediaplayerActivity.showSkipPreference(activity, MediaplayerActivity.SkipDirection.SKIP_FORWARD);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
if (!PictureInPictureUtil.supportsPictureInPicture(activity)) {
|
if (!PictureInPictureUtil.supportsPictureInPicture(activity)) {
|
||||||
ListPreference behaviour = (ListPreference) findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR);
|
ListPreference behaviour = findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR);
|
||||||
behaviour.setEntries(R.array.video_background_behavior_options_without_pip);
|
behaviour.setEntries(R.array.video_background_behavior_options_without_pip);
|
||||||
behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip);
|
behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip);
|
||||||
}
|
}
|
||||||
|
findPreference(PREF_PLAYBACK_PREFER_STREAMING).setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
// Update all visible lists to reflect new streaming action button
|
||||||
|
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
buildEnqueueLocationPreference();
|
buildEnqueueLocationPreference();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue