@Override protected String doInBackground(String... upgradeString) { /*Upgrade or copy*/ // Upgrade existing if (db.needsUpgrade) { Logging.Log(LOG_TAG, "Upgrading DB"); success = db.upgradeDB(); // Copy new one if failure upgrading if (!success) { try { db.copyDB(); } catch (IOException e) { throw new Error("Error copying database"); } } // Finally open DB try { db.openDataBase(); } catch (SQLException e) { Logging.Log(LOG_TAG, "Unable to open database"); Logging.Log(LOG_TAG, e.getStackTrace().toString()); } // DB is now ready to use db.updatePref("splashShown", "true"); publishProgress(25); } // Fix bad shows ArrayList<ArchiveShowObj> shows = db.getBadShows(); Logging.Log(LOG_TAG, "Looking for shows to fix, found " + shows.size()); if (shows.size() > 0) { Logging.Log(LOG_TAG, "Starting to fix shows"); for (ArchiveShowObj s : shows) { Searching.getSongs(s, null, db, false); } publishProgress(50); } // Update Artists if necessary if (needsArtistFetching()) { Searching.updateArtists(db); publishProgress(75); } Downloading.syncFilesDirectory(parentScreen, db); return "Completed"; }
/** * Parse the show details page. * * <p>I didn't want to use an external .JAR to parse the HTML, but it is better practice than * "rolling my own" parser using regex's or something. We use HtmlCleaner instead of TagSoup * because it is smaller, even though HtmlCleaner doesn't support 100% of XPath features. We use * another AsyncTask to not block the UI thread. I don't know if this is really necessary, but I * think that it is good idea in case we want to use this Activity in different ways in the * future. */ public static void getSongs( ArchiveShowObj show, ArrayList<ArchiveSongObj> songs, StaticDataStore db) { Searching.getSongs(show, songs, db, true); }