/* * Adds the albums in the json response TreeItem. */ private void addAlbums(JSONValue jsonValue) { JSONArray jsonArray = (JSONArray) jsonValue; Set<Integer> allAlbums = new HashSet<Integer>(m_IDtoAlbum.keySet()); for (int i = 0; i < jsonArray.size(); ++i) { JSONObject jso = (JSONObject) jsonArray.get(i); int id = Utils.extractId(jso.get("id")); if (m_IDtoAlbum.containsKey(id)) { m_IDtoAlbum.get(id).updateValues(jso); } else { Album album = new Album(jso, m_Container); m_IDtoAlbum.put(id, album); addItem(album); } allAlbums.remove(id); } for (Integer id : allAlbums) { Album a = m_IDtoAlbum.remove(id); a.cleanup(); removeItem(a); } }