private boolean needsArtistFetching() {
   String dateString = db.getPref("artistUpdate");
   SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
   try {
     Logging.Log(LOG_TAG, "Trying date parse: " + dateString);
     Date dbDate = format.parse(dateString);
     GregorianCalendar cal1 = new GregorianCalendar();
     cal1.add(Calendar.MONTH, -2);
     Date upgradeDate = cal1.getTime();
     GregorianCalendar cal2 = new GregorianCalendar();
     cal2.add(Calendar.YEAR, 1);
     Date yearLater = cal2.getTime();
     Logging.Log(LOG_TAG, "Comparing " + upgradeDate.toString() + " .after(" + dbDate.toString());
     if (upgradeDate.after(dbDate) || yearLater.before(dbDate)) {
       return true;
     } else {
       return false;
     }
   } catch (java.text.ParseException e) {
     Logging.Log(LOG_TAG, "Error Getting Artists");
     e.printStackTrace();
     return false;
   }
 }
  public static Boolean updateArtists(StaticDataStore db) {

    ArrayList<ArrayList<String>> artists = new ArrayList<ArrayList<String>>();
    int numArtists;

    HtmlCleaner pageParser = new HtmlCleaner();
    CleanerProperties props = pageParser.getProperties();
    props.setAllowHtmlInsideAttributes(true);
    props.setAllowMultiWordAttributes(true);
    props.setRecognizeUnicodeChars(true);
    props.setOmitComments(true);

    try {
      String url =
          "http://www.archive.org/browse.php?field=/metadata/bandWithMP3s&collection=etree";

      HttpParams params = new BasicHttpParams();
      int timeout = (int) (15 * DateUtils.SECOND_IN_MILLIS);
      HttpConnectionParams.setConnectionTimeout(params, timeout);
      HttpConnectionParams.setSoTimeout(params, timeout);
      HttpClient client = new DefaultHttpClient(params);

      HttpGet request = new HttpGet(url);
      HttpResponse response = client.execute(request);
      StatusLine status = response.getStatusLine();
      if (status.getStatusCode() == HttpStatus.SC_OK) {
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        TagNode node = pageParser.clean(responseHandler.handleResponse(response));
        client.getConnectionManager().shutdown();
        // XPATH to get the nodes that we Want.
        Object[] artistsNodes = node.evaluateXPath("//tr[@valign='top']//li");

        numArtists = artistsNodes.length;

        for (int i = 0; i < numArtists; i++) {

          // Cast the artistNode as a TagNode.
          TagNode artist = ((TagNode) artistsNodes[i]);
          // Grab the first child node, which is the link to the artist's page.
          // The inner HTML of this node will be the title.
          TagNode artistTitleSubNode = artist.getChildTags()[0];
          // Remove the child node, so that the inner HTML of the artistNode
          // only contains the number of shows that the artist has.
          artist.removeChild(artistTitleSubNode);
          String artistTitle = pageParser.getInnerHtml(artistTitleSubNode);

          if (artistTitle != null) {
            ArrayList<String> artistPair = new ArrayList<String>();
            artistPair.add(
                artistTitle
                    .replace("&apos;", "'")
                    .replace("&gt;", ">")
                    .replace("&lt;", "<")
                    .replace("&quot;", "\"")
                    .replace("&amp;", "&"));
            artistPair.add(pageParser.getInnerHtml(artist).trim());
            /*
             * VibeVault.db.addArtist(artistTitle, pageParser
             * .getInnerHtml(artist).trim());
             */
            artists.add(artistPair);
          }
        }
        if (artists.size() > 0) {
          db.insertArtistBulk(artists);
          String s = DateFormat.format("yyyy-MM-dd", new GregorianCalendar().getTime()).toString();
          db.updatePref("artistUpdate", s);

        } else {

        }
      } else {
        client.getConnectionManager().shutdown();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return true;
  }
  public static void getSongs(
      ArchiveShowObj show,
      ArrayList<ArchiveSongObj> songs,
      StaticDataStore db,
      boolean processSongs) {

    HtmlCleaner pageParser = new HtmlCleaner();
    CleanerProperties props = pageParser.getProperties();
    props.setAllowHtmlInsideAttributes(true);
    props.setAllowMultiWordAttributes(true);
    props.setRecognizeUnicodeChars(true);
    props.setOmitComments(true);

    ArrayList<String> songLinks = new ArrayList<String>();
    ArrayList<String> songTitles = new ArrayList<String>();
    String showTitle = show.getArtistAndTitle();
    String showIdent = show.getIdentifier();

    // XPATH says "Select out of all 'table' elements with attribute 'class'
    // equal to 'fileFormats' which contain element 'tr'..."
    // String songXPath = "//table[@class='fileFormats']//tr";

    // XPATH says "Select out of all 'script' elements with attribute 'type'
    // equal to 'text/javascript'..."
    String m3uXPath = "//script";
    String titlePath = "//head//title";

    if (db.getShowExists(show) && processSongs) {

      songs.addAll(db.getSongsFromShow(show.getIdentifier()));
      show.setFullTitle(db.getShow(show.getIdentifier()).getArtistAndTitle());
      return;
    }

    try {
      HttpParams params = new BasicHttpParams();
      int timeout = (int) (15 * DateUtils.SECOND_IN_MILLIS);
      HttpConnectionParams.setConnectionTimeout(params, timeout);
      HttpConnectionParams.setSoTimeout(params, timeout);
      HttpClient client = new DefaultHttpClient(params);

      HttpGet page = new HttpGet(show.getShowURL().toString());
      HttpResponse pageResponse = client.execute(page);
      StatusLine pageStatus = pageResponse.getStatusLine();
      if (pageStatus.getStatusCode() == HttpStatus.SC_OK) {
        ResponseHandler<String> pageResponseHandler = new BasicResponseHandler();
        TagNode node = pageParser.clean(pageResponseHandler.handleResponse(pageResponse));

        String queryString = show.getLinkPrefix();

        if (db.getPref("downloadFormat").equalsIgnoreCase("LBR")) {
          if (show.hasLBR()) {
            queryString += "_64kb.m3u";
          } else if (show.hasVBR()) {
            queryString += "_vbr.m3u";
          }
        } else {
          if (show.hasVBR()) {
            queryString += "_vbr.m3u";
          } else if (show.hasLBR()) {
            queryString += "_64kb.m3u";
          }
        }

        HttpGet M3Urequest = new HttpGet(queryString);

        HttpResponse M3Uresponse = client.execute(M3Urequest);
        StatusLine M3Ustatus = M3Uresponse.getStatusLine();
        if (M3Ustatus.getStatusCode() == HttpStatus.SC_OK) {
          ResponseHandler<String> M3UresponseHandler = new BasicResponseHandler();
          String m3uString = M3UresponseHandler.handleResponse(M3Uresponse);

          client.getConnectionManager().shutdown();

          // Now split the .M3U file based on newlines. This will give
          // us the download links, which we store..

          String m3uLinks[] = m3uString.split("\n");
          for (String link : m3uLinks) {
            songLinks.add(link);
          }

          // Now use an XPATH evaluation to find all of the javascript scripts on the page.
          // If one of them can be split by "IAD.mrss = ", it should have the track names
          // in it. The second half of the split is valid javascript and can be interpreted,
          // therefore, as JSON. Pull the song titles out of that, and together with the
          // download links make ArchiveSongObjs and add them to the list of songs.
          Object[] titleNodes = node.evaluateXPath(m3uXPath);
          for (Object titleNode : titleNodes) {
            //
            List x = ((TagNode) titleNode).getChildren();
            String songTitle = "";
            for (Object y : x) {
              if (y instanceof ContentNode) {
                songTitle = ((ContentNode) y).toString();
                songTitle = songTitle.trim();
                if (songTitle.startsWith("Play(")) {
                  String[] titles = songTitle.split("\\{\"title\"");
                  for (int i = 1; i < titles.length; i++) {
                    try {
                      String title =
                          titles[i].substring(
                              nthIndexOf(titles[i], '"', 1), nthIndexOf(titles[i], '"', 2));
                      songTitles.add(title.substring(title.indexOf('.') + 2));
                    } catch (StringIndexOutOfBoundsException e) {
                    }
                  }
                }
              }
            }
          }
          if (show.getShowTitle().length() < 2) {

            String s =
                ((TagNode) node.evaluateXPath(titlePath)[0])
                    .getChildren()
                    .toString()
                    .replaceFirst(Pattern.quote("["), "");
            show.setFullTitle(s.substring(0, s.lastIndexOf(": Free") - 1));
            showTitle = show.getArtistAndTitle();
            db.updateShow(show);
          }

          if (processSongs) {
            if (songLinks.size() == 0) {

            } else {
              // Do things for successful show parse
              db.insertShow(show);
            }
            // If we have the same amount of song titles as song links,
            // we should be all set.
            if (songTitles.size() == songLinks.size()) {
              for (int i = 0; i < songTitles.size(); i++) {
                String songLink = songLinks.get(i);
                String songTitle = songTitles.get(i);
                // If the show has a "selectedSong"
                // meaning that it was opened by
                // the user clicking on a song link, do
                // a comparison to see
                // if the song being added is the
                // selected song. If it is, set
                // selectedPos to the right index so
                // that the song can be played
                // once the ListView is filled.  This is
                // inefficient, though it probably doesn't make a difference,
                // but we might consider making this a bit more efficient/elegant in the future.
                // FIXME.
                //						if (show.hasSelectedSong()) {
                //							if (songLink.equals(show.getSelectedSong())) {
                //								selectedPos = i;
                //							}
                //						} else {
                //							selectedPos = -1;
                //						}
                ArchiveSongObj song = new ArchiveSongObj(songTitle, songLink, showTitle, showIdent);
                song.setID(db.insertSong(song));
                songs.add(song);
              }
              db.setShowExists(show);
              db.insertRecentShow(show);
            } else {

            }
          }

        } else {
          client.getConnectionManager().shutdown();
        }
      } else {
        client.getConnectionManager().shutdown();
      }

    } catch (XPatherException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    // TODO Auto-generated method stub

  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_screen);

    Object retained = getLastNonConfigurationInstance();

    if (retained instanceof UpgradeTask) {
      Logging.Log(LOG_TAG, "UpgradeTask retained");
      upgradeTask = (UpgradeTask) retained;
      upgradeTask.setActivity(this);
    } else {
      // upgradeTask = new UpgradeTask(this);
    }

    int[] gradientColors = {0, 0xFF127DD4, 0};
    int curOrientation = this.getResources().getConfiguration().orientation;
    // FIXME
    separator1 = (ImageView) findViewById(R.id.separator1);
    separator1.setBackgroundDrawable(
        new GradientDrawable(
            curOrientation == Configuration.ORIENTATION_PORTRAIT
                ? Orientation.RIGHT_LEFT
                : Orientation.RIGHT_LEFT,
            gradientColors));
    // separator1.setBackground(new GradientDrawable(Orientation.RIGHT_LEFT, gradientColors));
    separator2 = (ImageView) findViewById(R.id.separator2);
    separator2.setBackgroundDrawable(
        new GradientDrawable(
            curOrientation == Configuration.ORIENTATION_PORTRAIT
                ? Orientation.RIGHT_LEFT
                : Orientation.TOP_BOTTOM,
            gradientColors));
    // separator2.setBackground(new GradientDrawable(Orientation.RIGHT_LEFT, gradientColors));
    separator3 = (ImageView) findViewById(R.id.separator3);
    separator3.setBackgroundDrawable(
        new GradientDrawable(
            curOrientation == Configuration.ORIENTATION_PORTRAIT
                ? Orientation.TOP_BOTTOM
                : Orientation.TOP_BOTTOM,
            gradientColors));
    // separator3.setBackground(new GradientDrawable(Orientation.TOP_BOTTOM, gradientColors));

    searchButton = (ImageButton) findViewById(R.id.HomeSearch);
    recentButton = (ImageButton) findViewById(R.id.HomeRecent);
    downloadButton = (ImageButton) findViewById(R.id.HomeDownload);
    playingButton = (ImageButton) findViewById(R.id.HomePlaying);
    featuredShowsButton = (ImageButton) findViewById(R.id.HomeFeatured);
    browseArtistsButton = (ImageButton) findViewById(R.id.HomeBrowse);

    db = StaticDataStore.getInstance(this);
    //		setImageButtonToToast();
    //		upgradeTask = new UpgradeTask(this);
    //		upgradeTask.execute();
    if (db.needsUpgrade && upgradeTask == null) { // DB needs updating
      setImageButtonToToast();
      upgradeTask = new UpgradeTask(this);
      upgradeTask.execute();
    } else { // DB Up to date, check artist date
      setImageButtonToFragments();
      if (needsArtistFetching() && upgradeTask == null) {
        upgradeTask = new UpgradeTask(this);
        upgradeTask.execute();
      }
    }

    if (db.dbCopied && !Boolean.parseBoolean(db.getPref("splashShown"))) {
      this.showDialog(
          this.getResources().getString(R.string.splash_screen), "Welcome to Vibe Vault 4");
      db.updatePref("splashShown", "true");
    } else if (db.needsUpgrade) {
      this.showDialog(
          this.getResources().getString(R.string.splash_screen), "Welcome to Vibe Vault 4");
    }
  }