summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2020-02-12 21:58:15 +0100
committerJavier <dev.git@javispedro.com>2020-02-12 21:58:15 +0100
commitdc93a3e70dee8e715fdd4b1897dfb24855705d91 (patch)
tree43a32a0c38f49bfe6157385a889c12204f37818d
parentac329e140435c3488ea5dfef89d237e2325da9e4 (diff)
downloadwallmotion-dc93a3e70dee8e715fdd4b1897dfb24855705d91.tar.gz
wallmotion-dc93a3e70dee8e715fdd4b1897dfb24855705d91.zip
reset saved position on video file change
-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
}
}
}