Jamendo开源在线音乐播放器源码分析(四)
四、网络操作,调用music API
HomeActivity上面那个gallery加载的是这周最流行的专辑,是用NewsTask异步加载的,下面来大体走一下请求网络api那一块的流程,在NewsTask的doInBackground()中:
public void put(String url, String data){history.add(url);// too much in the cache, we need to clear somethingif(history.size() > CACHE_LIMIT){String old_url = (String) history.poll();cache.remove(old_url);}cache.put(url, data);}public String get(String url){return cache.get(url);}