Use Collection.removeIf() instead of using Iterator.remove() to remove elements conditionally.
This commit is contained in:
parent
abcacf8c74
commit
b0b0a75c87
3 changed files with 9 additions and 23 deletions
|
|
@ -13,7 +13,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import us.shandian.giga.get.DownloadMission;
|
||||
import us.shandian.giga.get.FinishedMission;
|
||||
|
|
@ -564,14 +564,10 @@ public class DownloadManager {
|
|||
synchronized (DownloadManager.this) {
|
||||
ArrayList<Mission> pending = new ArrayList<>(mMissionsPending);
|
||||
ArrayList<Mission> finished = new ArrayList<>(mMissionsFinished);
|
||||
ArrayList<Mission> remove = new ArrayList<>(hidden);
|
||||
List<Mission> remove = new ArrayList<>(hidden);
|
||||
|
||||
// hide missions (if required)
|
||||
Iterator<Mission> iterator = remove.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Mission mission = iterator.next();
|
||||
if (pending.remove(mission) || finished.remove(mission)) iterator.remove();
|
||||
}
|
||||
remove.removeIf(mission -> pending.remove(mission) || finished.remove(mission));
|
||||
|
||||
int fakeTotal = pending.size();
|
||||
if (fakeTotal > 0) fakeTotal++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue