summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util/ConjunctionListenerMux.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/util/ConjunctionListenerMux.java')
-rw-r--r--src/com/android/camera/util/ConjunctionListenerMux.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/com/android/camera/util/ConjunctionListenerMux.java b/src/com/android/camera/util/ConjunctionListenerMux.java
index 866b2f5fb..a32072400 100644
--- a/src/com/android/camera/util/ConjunctionListenerMux.java
+++ b/src/com/android/camera/util/ConjunctionListenerMux.java
@@ -95,9 +95,7 @@ public class ConjunctionListenerMux<Input extends Enum<Input>> {
// If the output has changed, notify the listeners.
if (oldOutput != mOutput) {
- for (OutputChangeListener listener : mListeners) {
- listener.onOutputChange(mOutput);
- }
+ notifyListeners();
}
return mOutput;
@@ -105,6 +103,11 @@ public class ConjunctionListenerMux<Input extends Enum<Input>> {
}
}
+ public ConjunctionListenerMux(Class<Input> clazz, OutputChangeListener listener) {
+ this(clazz);
+ addListener(listener);
+ }
+
public ConjunctionListenerMux(Class<Input> clazz) {
mInputs = new EnumMap<Input, Boolean>(clazz);
@@ -114,4 +117,16 @@ public class ConjunctionListenerMux<Input extends Enum<Input>> {
mOutput = false;
}
+
+ /**
+ * Notifies all listeners of the current state, regardless of whether or not
+ * it has actually changed.
+ */
+ public void notifyListeners() {
+ synchronized (mLock) {
+ for (OutputChangeListener listener : mListeners) {
+ listener.onOutputChange(mOutput);
+ }
+ }
+ }
}