Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. MYSPOTFRAGMENT: ///////////////////////////////////////////////////////////////////////////
  2.  
  3. View.OnClickListener leaveClickListener = view -> {
  4. user = SpotsManager.INSTANCE.getCurrentUser();
  5.  
  6. try {
  7. DialogUtil.createOkNoThanksDialog(view.getContext(), getString(R.string.rate_spot),
  8. new DialogUtil.InputDialogSubmitListenerForRating() {
  9.  
  10. @Override
  11. public void onSubmit(int spotRating) {
  12. user.addRating(parkingSpot.getId(), spotRating);
  13.  
  14. SpotsManager.INSTANCE.updateCurrentUser(user, new FirebaseEventResultListener() {
  15. @Override
  16. public void onSuccessful() {
  17. actionListener.onLeaveSpotButtonClicked();
  18. }
  19.  
  20. @Override
  21. public void onFailure(Exception e) {
  22. showMessage(Integer.parseInt(e.getMessage()));
  23. }
  24. });
  25. }
  26.  
  27. @Override
  28. public void onCancel() {
  29. actionListener.onLeaveSpotButtonClicked();
  30. }
  31. }).show();
  32. } catch (NullPointerException e) {
  33. showMessage(R.string.default_errormessage);
  34. LogUtil.LogD(view.getContext(), R.string.default_errormessage);
  35. }
  36. };
  37.  
  38.  
  39. USER: ///////////////////////////////////////////////////////////////////////////////
  40.  
  41. private HashMap<String, Integer> ratings;
  42.  
  43. public User() {
  44. this.ratings = new HashMap<>();
  45. }
  46.  
  47. public User(String name, String email, String password, Boolean disabled) {
  48. this.name = name;
  49. this.email = email;
  50. this.password = password;
  51. this.disabled = disabled;
  52. this.ratings = new HashMap<>();
  53. }
  54.  
  55. public HashMap<String, Integer> getRatings() {
  56. return ratings;
  57. }
  58.  
  59. public User setRatings(HashMap<String, Integer> ratings) {
  60. this.ratings = ratings;
  61. return this;
  62. }
  63.  
  64. public void addRating(String spotId, Integer ratingValue) {
  65. ratings.put(spotId, ratingValue);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement