Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MYSPOTFRAGMENT: ///////////////////////////////////////////////////////////////////////////
- View.OnClickListener leaveClickListener = view -> {
- user = SpotsManager.INSTANCE.getCurrentUser();
- try {
- DialogUtil.createOkNoThanksDialog(view.getContext(), getString(R.string.rate_spot),
- new DialogUtil.InputDialogSubmitListenerForRating() {
- @Override
- public void onSubmit(int spotRating) {
- user.addRating(parkingSpot.getId(), spotRating);
- SpotsManager.INSTANCE.updateCurrentUser(user, new FirebaseEventResultListener() {
- @Override
- public void onSuccessful() {
- actionListener.onLeaveSpotButtonClicked();
- }
- @Override
- public void onFailure(Exception e) {
- showMessage(Integer.parseInt(e.getMessage()));
- }
- });
- }
- @Override
- public void onCancel() {
- actionListener.onLeaveSpotButtonClicked();
- }
- }).show();
- } catch (NullPointerException e) {
- showMessage(R.string.default_errormessage);
- LogUtil.LogD(view.getContext(), R.string.default_errormessage);
- }
- };
- USER: ///////////////////////////////////////////////////////////////////////////////
- private HashMap<String, Integer> ratings;
- public User() {
- this.ratings = new HashMap<>();
- }
- public User(String name, String email, String password, Boolean disabled) {
- this.name = name;
- this.email = email;
- this.password = password;
- this.disabled = disabled;
- this.ratings = new HashMap<>();
- }
- public HashMap<String, Integer> getRatings() {
- return ratings;
- }
- public User setRatings(HashMap<String, Integer> ratings) {
- this.ratings = ratings;
- return this;
- }
- public void addRating(String spotId, Integer ratingValue) {
- ratings.put(spotId, ratingValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement