@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { long albumId = albumCursorAdapter.getItemId(position); // We need to pass the album information over to the next activity Bundle extras = new Bundle(); extras.putLong(AlbumImageViewingActivity.ALBUM_ID, albumId); Intent imageBrowser = new Intent(this, AlbumImageViewingActivity.class); imageBrowser.putExtras(extras); startActivity(imageBrowser); }
/** * Hardcoded example showing how we use everything that has been put together. This will pull down * the RSS feed from a specific stream, parse it, then pull down all the images required and store * them in the database. */ public void populateDataWithDefaults() { try { SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); PicasaHandler picasaHandler = new PicasaHandler(); URL picasaFeed = new URL( "http://picasaweb.google.com/data/feed/base/user/c.saunders322/albumid/5513471319225508497?alt=rss&kind=photo&hl=en_US"); parser.parse(picasaFeed.openStream(), picasaHandler); PicasaAlbum album = picasaHandler.getParsedAlbum(); Log.d( "Parser Results:", "There are " + album.getAlbumImages().size() + " images in the " + album.getTitle() + " album created by " + album.getAuthor()); ImageAlbumDatabaseHelper databaseHelper = new ImageAlbumDatabaseHelper(getApplicationContext()); PicasaAlbumManager albumManager = databaseHelper.getAlbumManager(); if (!albumManager.albumExists(album.getTitle())) { long albumId = albumManager.addAlbum(album); if (albumId > 0) { Log.d(getClass().toString(), "Successfully added album to the database"); } else { Log.e( getClass().toString(), "Something went wrong when trying to add new information to disk"); } } // Since our data has changed, we need to inform the cursor to update itself albumCursorAdapter.getCursor().requery(); } catch (SAXException saxException) { saxException.printStackTrace(); } catch (MalformedURLException murlException) { murlException.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } }