summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/com/javispedro/wallmotion/Renderer.java8
1 files 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
}
}
}