summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-03-10 04:23:30 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-03-10 04:23:30 -0800
commit7b0b29812811ec993883fffa2cd3c63215214a88 (patch)
treef3430cea00e99118edfce18194c4603152277a5b
parent6cebec4c307413f5d0dadabe033ab78f103e842b (diff)
parent3d27906176c2d4381bc038245313ddac2440fdee (diff)
downloadandroid_packages_apps_Gallery2-7b0b29812811ec993883fffa2cd3c63215214a88.tar.gz
android_packages_apps_Gallery2-7b0b29812811ec993883fffa2cd3c63215214a88.tar.bz2
android_packages_apps_Gallery2-7b0b29812811ec993883fffa2cd3c63215214a88.zip
Merge "Gallery2: fix ConcurrentModificationException in MediaSet.java." into android_ui.lnx.1.2-dev
-rw-r--r--src/com/android/gallery3d/data/MediaSet.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/data/MediaSet.java b/src/com/android/gallery3d/data/MediaSet.java
index b43874070..d0f0ec3c4 100644
--- a/src/com/android/gallery3d/data/MediaSet.java
+++ b/src/com/android/gallery3d/data/MediaSet.java
@@ -43,6 +43,8 @@ public abstract class MediaSet extends MediaObject {
public static final int SYNC_RESULT_CANCELLED = 1;
public static final int SYNC_RESULT_ERROR = 2;
+ private final Object mLock = new Object();
+
/** Listener to be used with requestSync(SyncListener). */
public static interface SyncListener {
/**
@@ -180,17 +182,23 @@ public abstract class MediaSet extends MediaObject {
// listener is automatically removed when there is no other reference to
// the listener.
public void addContentListener(ContentListener listener) {
- mListeners.put(listener, null);
+ synchronized (mLock) {
+ mListeners.put(listener, null);
+ }
}
public void removeContentListener(ContentListener listener) {
- mListeners.remove(listener);
+ synchronized (mLock) {
+ mListeners.remove(listener);
+ }
}
// This should be called by subclasses when the content is changed.
public void notifyContentChanged() {
- for (ContentListener listener : mListeners.keySet()) {
- listener.onContentDirty();
+ synchronized (mLock) {
+ for (ContentListener listener : mListeners.keySet()) {
+ listener.onContentDirty();
+ }
}
}