Code example for SparseArray

Methods: appendputvalueAt

0
		this.serverUrl = settings.getString(Parameters.SERVER_URL.name(), null)
				+ "/" + RemoteAction.WISSL_ENTRY_POINT; 
	} 
 
	public Bitmap getArtwork(int albumId) {
		return this.artworkCache.valueAt(albumId);
	} 
 
	public void showArtwork(int albumId, ImageView view) {
		Bitmap artwork = this.getArtwork(albumId);
 
		if (artwork == null) {
			artwork = this.loadArtworkFromFileCache(albumId);
		} 
 
		if (artwork == null) {
			artwork = this.loadArtworkFormStream(albumId);
		} 
 
		if (artwork != null) {
			this.artworkCache.append(albumId, artwork);
			view.setImageBitmap(artwork);
		} 
 
	} 
 
	private Bitmap loadArtworkFormStream(int albumId) {
		Bitmap artwork = null;
		try { 
			// TODO do it asynchronously 
			String urlString = this.serverUrl + "/"
					+ RemoteAction.ARTWORK.getRequestURI() + "/" + albumId;
			Log.d(LOGGER_ID, urlString);
			InputStream is = this.fetch(urlString);
			artwork = BitmapFactory.decodeStream(is);
 
			this.artworkCache.put(albumId, artwork);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} 
Stop searching for code, let great code find you!  Add Codota to your java IDE