Exemplo n.º 1
0
  /**
   * Registers an artist if that artist is a user.
   *
   * @param v the v
   */
  public void registerArtistAction(View v) {
    String artistName = registerArtistNameInput.getText().toString();
    String artistGenre = registerArtistGenreInput.getText().toString();

    try {
      RestResult<ArtistEntity> restResult =
          registerArtistTaskProvider
              .get()
              .execute(this.vistingUser.getUserId(), artistName, artistGenre)
              .get();
      if (restResult.isFailure()) {
        InsiemeExceptionEntity insiemeExceptionEntity = restResult.getError();
        Toast.makeText(this, insiemeExceptionEntity.getException(), Toast.LENGTH_LONG).show();
      } else {
        ArtistEntity newArtist = restResult.getRestResult();
        Toast.makeText(this, "Welcome: " + newArtist.getName(), Toast.LENGTH_LONG).show();
        // you are now an artist and cant register.
        registerArtistLayout.setVisibility(View.INVISIBLE);
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (ExecutionException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  /**
   * Search artist action when search button is pressed.
   *
   * @param v the view
   */
  public void searchArtistAction(View v) {
    String artistName = searchArtistNameInput.getText().toString();

    try {
      RestResult<ArtistListEntity> result = findArtistsTaskProvider.get().execute(artistName).get();
      if (result.isFailure()) {
        InsiemeExceptionEntity insiemeExceptionEntity = result.getError();
        Toast.makeText(this, insiemeExceptionEntity.getException(), Toast.LENGTH_LONG).show();
      } else {
        populateArtistList(result.getRestResult().getArtists());
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (ExecutionException e) {
      e.printStackTrace();
    }
  }