diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index 09cc733f0..acd60d17a 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -50,10 +50,7 @@ public class ContributionListing { List listeners; final List advertisedContributions; - private Map> librariesByCategory; Map librariesByImportHeader; - // TODO: Every contribution is getting added twice - // and nothing is replaced ever. [akarshit 151031] Set allContributions; boolean listDownloaded; boolean listDownloadFailed; @@ -63,7 +60,6 @@ public class ContributionListing { private ContributionListing() { listeners = new ArrayList<>(); advertisedContributions = new ArrayList<>(); - librariesByCategory = new HashMap<>(); librariesByImportHeader = new HashMap<>(); allContributions = new LinkedHashSet<>(); downloadingListingLock = new ReentrantLock(); @@ -119,18 +115,6 @@ public class ContributionListing { protected void replaceContribution(Contribution oldLib, Contribution newLib) { if (oldLib != null && newLib != null) { - for (String category : oldLib.getCategories()) { - if (librariesByCategory.containsKey(category)) { - List list = librariesByCategory.get(category); - - for (int i = 0; i < list.size(); i++) { - if (list.get(i) == oldLib) { - list.set(i, newLib); - } - } - } - } - if (oldLib.getImports() != null) { for (String importName : oldLib.getImports()) { if (getLibrariesByImportHeader().containsKey(importName)) { @@ -138,10 +122,8 @@ public class ContributionListing { } } } - allContributions.remove(oldLib); allContributions.add(newLib); - notifyChange(oldLib, newLib); } } @@ -153,29 +135,12 @@ public class ContributionListing { getLibrariesByImportHeader().put(importName, contribution); } } - for (String category : contribution.getCategories()) { - if (librariesByCategory.containsKey(category)) { - List list = librariesByCategory.get(category); - list.add(contribution); - list.sort(COMPARATOR); - - } else { - ArrayList list = new ArrayList<>(); - list.add(contribution); - librariesByCategory.put(category, list); - } - allContributions.add(contribution); - notifyAdd(contribution); - } + allContributions.add(contribution); + notifyAdd(contribution); } protected void removeContribution(Contribution contribution) { - for (String category : contribution.getCategories()) { - if (librariesByCategory.containsKey(category)) { - librariesByCategory.get(category).remove(contribution); - } - } if (contribution.getImports() != null) { for (String importName : contribution.getImports()) { getLibrariesByImportHeader().remove(importName); @@ -220,8 +185,8 @@ public class ContributionListing { } - static private boolean matchField(String field, String typed) { - return (field != null) && field.toLowerCase().matches(typed); + static private boolean matchField(String field, String regex) { + return (field != null) && field.toLowerCase().matches(regex); } diff --git a/todo.txt b/todo.txt index cb3b7fdb5..b30507424 100755 --- a/todo.txt +++ b/todo.txt @@ -44,6 +44,9 @@ X search by contrib type (is:) wasn't even working properly X removing accents was trashing some input too X redo category tallying for contribs (Libraries only anyway?) X gets rid of maze of code that's storing libraries by their category +X remove unnecessary code that tracks contribs by category +X this was hiding the issue that was causing contribs to be added several times, +X because the add() was inside the category loop of that code _ allow update of the current Mode