From dc93a3e70dee8e715fdd4b1897dfb24855705d91 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 12 Feb 2020 21:58:15 +0100 Subject: reset saved position on video file change --- app/src/main/java/com/javispedro/wallmotion/Renderer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/javispedro/wallmotion/Renderer.java b/app/src/main/java/com/javispedro/wallmotion/Renderer.java index 6730afe..efcd7c5 100644 --- a/app/src/main/java/com/javispedro/wallmotion/Renderer.java +++ b/app/src/main/java/com/javispedro/wallmotion/Renderer.java @@ -18,6 +18,7 @@ public class Renderer extends ContextWrapper { private static final String TAG = "Renderer"; private SharedPreferences prefs; + private SharedPreferences.OnSharedPreferenceChangeListener prefsListener; private MediaPlayer player; private int savedPosition; @@ -26,7 +27,8 @@ public class Renderer extends ContextWrapper { super(context); prefs = PreferenceManager.getDefaultSharedPreferences(context); - prefs.registerOnSharedPreferenceChangeListener(new PrefsListener()); + prefsListener = new PrefsListener(); // must keep a reference according to SharedPreferences docs + prefs.registerOnSharedPreferenceChangeListener(prefsListener); } public boolean isActive() { @@ -55,9 +57,7 @@ public class Renderer extends ContextWrapper { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(getString(R.string.settings_video_file_key))) { Log.d(TAG, "video file key changed"); - reset(); - } else if (key.equals(getString(R.string.settings_display_restart_key))) { - savedPosition = 0; + reset(); // to ensure we reset the savedPosition } } } -- cgit v1.2.3