Ejemplo n.º 1
0
  private void fetchRecentStations() {
    LastFmServer server = AndroidLastFmServerFactory.getServer();

    Session session = LastFMApplication.getInstance().session;
    // Is it worth it?
    if (session != null) {
      try {
        // Let me work it
        Station stations[] = server.getUserRecentStations(session.getName(), session.getKey());
        if (stations != null && stations.length > 0) {
          // I put my thing down, flip it, and reverse it
          List<Station> list = Arrays.asList(stations);
          Collections.reverse(list);
          stations = (Station[]) list.toArray();
          RecentStationsDao.getInstance().clearTable();
          for (Station station : stations) {
            RecentStationsDao.getInstance()
                .appendRecentStation(station.getUrl(), station.getName());
          }
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Ejemplo n.º 2
0
  private void SetupRecentStations() {
    if (!isAuthenticatedUser) return;
    SharedPreferences settings = getSharedPreferences(LastFm.PREFS, 0);
    mMyRecentAdapter.resetList();
    List<Station> stations = RecentStationsDao.getInstance().getRecentStations();
    if (stations != null) {
      for (Station station : stations) {
        String name = station.getName();
        String url = station.getUrl();

        if (url.startsWith("lastfm://playlist/") && settings.getBoolean("remove_playlists", false))
          continue;
        if (url.startsWith("lastfm://usertags/") && settings.getBoolean("remove_tags", false))
          continue;
        if (url.endsWith("/loved") && settings.getBoolean("remove_loved", false)) continue;
        mMyRecentAdapter.putStation(name, url);
      }
    }
    mMyRecentAdapter.updateModel();
  }