Skip to content

Commit

Permalink
Merge pull request #509 from zhengxiaopeng/bugfix_#508
Browse files Browse the repository at this point in the history
Fix #508 ConcurrentModificationException in iterator
  • Loading branch information
galenlin authored Oct 16, 2017
2 parents cdacc1c + 73f7c3c commit cb519fd
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,12 @@ public static void mergeResources(Application app, Object activityThread, String
references = map.values();
}

for (WeakReference<Resources> wr : references) {
Resources resources = wr.get();
//to array
WeakReference[] referenceArrays = new WeakReference[references.size()];
references.toArray(referenceArrays);

for (int i = 0; i < referenceArrays.length; i++) {
Resources resources = (Resources) referenceArrays[i].get();
if (resources == null) continue;

try {
Expand Down Expand Up @@ -550,8 +554,8 @@ public static void mergeResources(Application app, Object activityThread, String
}

if (Build.VERSION.SDK_INT >= 21) {
for (WeakReference<Resources> wr : references) {
Resources resources = wr.get();
for (int i = 0; i < referenceArrays.length; i++) {
Resources resources = (Resources) referenceArrays[i].get();
if (resources == null) continue;

// android.util.Pools$SynchronizedPool<TypedArray>
Expand Down

0 comments on commit cb519fd

Please sign in to comment.