(MediaEntry e)
| 119 | } |
| 120 | |
| 121 | public void add(MediaEntry e) { |
| 122 | e.isLocal = this.equals(LOCAL_LIBRARY); |
| 123 | // Randomize ID if it is not already set |
| 124 | // This is a combination of the string hash as well as a 8-bit sequence number |
| 125 | if (e.id == 0 || e.id == -1) { |
| 126 | e.id = e.name.hashCode(); |
| 127 | e.id <<= 8; |
| 128 | while (mediaLookup.containsKey(e.id)) { |
| 129 | e.id++; |
| 130 | } |
| 131 | } |
| 132 | mediaLookup.put(e.id, e); |
| 133 | cacheEntry(nameLookup, e.name, e.id); |
| 134 | cacheEntry(categoryLookup, e.category, e.id); |
| 135 | if (e.favorite) { |
| 136 | favorites.add(e.id); |
| 137 | } |
| 138 | for (String s : e.keywords) { |
| 139 | cacheEntry(keywordLookup, s, e.id); |
| 140 | } |
| 141 | markDirty(); |
| 142 | } |
| 143 | |
| 144 | public void remove(MediaEntry e) { |
| 145 | mediaLookup.remove(e.id); |
no test coverage detected