Ejemplo n.º 1
0
  public String searchCover(String track, String artist) {
    String urlResult = null;
    String key = "49175f0086374abc087b4774bc075343";

    Caller.getInstance().setCache(null);

    int limit = 30;
    // track="Spirit Indestructible";
    // artist="Nelly Furtado";

    Collection<Track> chart1 = Track.search(artist, track, limit, key);

    if (chart1.isEmpty()) {
      Collection<Artist> artists = Artist.search(artist, key);
      for (Artist artist2 : artists) {
        urlResult = artist2.getImageURL(ImageSize.EXTRALARGE);
        if (urlResult != null) {
          break;
        }
      }
    } else {
      for (Track track2 : chart1) {
        urlResult = track2.getImageURL(ImageSize.EXTRALARGE);
        if (urlResult != null) {
          break;
        }
      }
    }

    if (urlResult == null) {
      urlResult = "http://www.drs3.ch/static/global/logo.gif";
    }

    return urlResult;
  }
 private void showMenu() {
   String input = "";
   do {
     Iterator<Artist> iter = currentArtists.iterator();
     // display all current results with an associated index number
     for (int j = 1; j <= currentArtists.size(); j++) {
       Artist a = iter.next();
       System.out.println("[" + j + "] " + a.getName());
     }
     System.out.println("-");
     System.out.println("[L] List traveled artists");
     System.out.println("[q] Quit program");
     // prompt
     System.out.println(separator);
     System.out.println("Which artist do you want to check out?");
     System.out.print("Enter his/her index number or enter 'q' to exit: ");
     System.out.flush();
     ArtistNode anode = null;
     try {
       input = in.readLine();
       int neuerIndex = Integer.parseInt(input);
       // if the index exceeds the array's bounds, prompt again
       if (neuerIndex > currentArtists.size() || neuerIndex < 1)
         System.out.println("There is no such index! Please re-try your request, would you?");
       else {
         // fetch the selected artist - it will become the new center
         Artist a = (Artist) ((ArrayList<Artist>) currentArtists).get(neuerIndex - 1);
         anode = ui.retrieveArtistInformation(a.getName());
         displayArtistInformation(anode);
         currentArtists = ui.findArtistsByName(a.getName());
         System.out.println(separator);
       }
     } catch (UnknownHostException e) {
       System.out.println(
           "You don't seem to have established a working internet "
               + "connection going on right now. Please fix that and try again.");
       System.exit(1);
     } catch (IOException e) {
       e.printStackTrace();
     } catch (NumberFormatException e) {
       if (input.equals("L")) {
         listTraveledArtists();
         System.out.println(separator);
       } else if (input.equals("q")) break;
       else
         System.out.println(
             "I believe you screwed up the index input (your input: "
                 + input
                 + ")"
                 + "\n Would you mind doing it again, please?");
     } catch (NoSuchEntryException e) {
       System.out.println("There was an entry retrieval error! The code is " + e.getMessage());
     }
   } while (!input.equals("q"));
 }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_artist_events);

    Artist artist = ActiveData.artist;

    if (MainActivity.wifi.isWifiEnabled()) new GetEventsTask().execute(artist.getName());
    else Toast.makeText(getApplicationContext(), R.string.wifi_off, Toast.LENGTH_LONG).show();
  }
Ejemplo n.º 4
0
 @DebugLog
 public Metadata lookupArtistInfo(final String artistName) {
   Call<Artist> call = mLastFM.getArtist(artistName);
   Response<Artist> response;
   try {
     response = call.execute();
   } catch (IOException e) {
     return null;
   }
   Artist artist = response.body();
   if (artist == null) {
     Timber.w("Failed to retrieve artist %s", artistName);
     return null;
   }
   Metadata.Builder bob = Metadata.builder();
   bob.putString(KEY_ARTIST_NAME, artist.getName());
   bob.putString(KEY_ARTIST_SUMMARY, artist.getWikiSummary());
   bob.putString(KEY_ARTIST_BIO, artist.getWikiText());
   Date lastChanged = artist.getWikiLastChanged();
   if (lastChanged != null) {
     bob.putLong(KEY_LAST_MODIFIED, lastChanged.getTime());
   }
   bob.putUri(KEY_ARTIST_URL_URI, Uri.parse(artist.getUrl()));
   bob.putString(KEY_ARTIST_MBID, artist.getMbid());
   return bob.build();
 }
Ejemplo n.º 5
0
 protected Collection<Event> doInBackground(String... artist) {
   try {
     Caller.getInstance().setCache(null);
     Caller.getInstance().setUserAgent("tst");
     Collection<Event> events_result =
         Artist.getEvents(artist[0], MainActivity.API_KEY).getPageResults();
     return events_result;
   } catch (Exception e) {
     return null;
   }
 }
Ejemplo n.º 6
0
 @Override
 public void onResume() {
   super.onResume();
   Artist artist = ActiveData.artist;
   new GetEventsTask().execute(artist.getName());
 }