/** * 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(); } }
/** * Helper method to populate the artists tab with the artists returned from a query. * * @param artists the artists */ private void populateArtistList(Collection<ArtistEntity> artists) { ArtistButton artistButton; artistListLayout.removeAllViews(); if (artists.isEmpty()) { return; } else { for (ArtistEntity artist : artists) { artistButton = new ArtistButton(this, artist); artistButton.setText(artist.getName()); artistListLayout.addView(artistButton); } } }
/** * Set the artist values in the artist info layout when an artist is clicked in scroll view. * * @param artist the new artist info */ private void setArtistInfo(ArtistEntity artist) { artistInfoGenreValue.setText(artist.getGenre()); artistInfoNameValue.setText(artist.getName()); this.focusedArtist = artist; }