Example #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();
    }
  }
Example #2
0
 /**
  * Checks to see whether a user is an artist given an artist id.
  *
  * <p>TODO: this method is duplicated across two activities. Find a way to refactor to a common
  * place.
  *
  * @param userId the user id
  * @return the boolean
  */
 private Boolean isArtist(String userId) {
   Boolean isArtistResult = Boolean.FALSE;
   if (userId == null) {
     return isArtistResult;
   } else {
     try {
       RestResult<ArtistEntity> result = getArtistTaskProvider.get().execute(userId).get();
       isArtistResult = result.isSuccessfull();
     } catch (InterruptedException e) {
       e.printStackTrace();
     } catch (ExecutionException e) {
       e.printStackTrace();
     }
   }
   return isArtistResult;
 }
Example #3
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();
    }
  }