Skip to content

Commit 1b50fda

Browse files
Use set in findAllArtworksToBeUploadedFromCells() to prevent duplicates
1 parent ef086d7 commit 1b50fda

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public void onComplete(boolean success) {
198198
}
199199

200200
private void uploadMenuArtworks(final CompletionListener listener) {
201-
List<SdlArtwork> artworksToBeUploaded = findAllArtworksToBeUploadedFromCells(updatedMenu, fileManager.get(), windowCapability);
201+
List<SdlArtwork> artworksToBeUploaded = new ArrayList<>(findAllArtworksToBeUploadedFromCells(updatedMenu, fileManager.get(), windowCapability));
202202
if (artworksToBeUploaded.isEmpty()) {
203203
listener.onComplete(true);
204204
return;

base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilities.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@
5555

5656
import java.util.ArrayList;
5757
import java.util.HashMap;
58+
import java.util.HashSet;
5859
import java.util.List;
5960
import java.util.Map;
61+
import java.util.Set;
6062

6163
/**
6264
* Created by Bilal Alsharifi on 1/25/21.
@@ -115,13 +117,13 @@ static void transferCellListenersFromCells(List<MenuCell> fromCells, List<MenuCe
115117
}
116118
}
117119

118-
static List<SdlArtwork> findAllArtworksToBeUploadedFromCells(List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability) {
120+
static Set<SdlArtwork> findAllArtworksToBeUploadedFromCells(List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability) {
119121
// Make sure we can use images in the menus
120122
if (!hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon)) {
121-
return new ArrayList<>();
123+
return new HashSet<>();
122124
}
123125

124-
List<SdlArtwork> artworks = new ArrayList<>();
126+
Set<SdlArtwork> artworks = new HashSet<>();
125127
for (MenuCell cell : cells) {
126128
if (fileManager != null) {
127129
if (fileManager.fileNeedsUpload(cell.getIcon())) {

0 commit comments

Comments
 (0)