From f72c82c3e9d4f62be1c0faeab913441e3f5f8961 Mon Sep 17 00:00:00 2001 From: Aran Zaiger Date: Fri, 8 Jul 2016 16:32:29 +0300 Subject: [PATCH] added like option in map --- .../sagi/thesocialnotework/GmapFragment.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java index 91ea629..149e5f3 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/GmapFragment.java @@ -213,7 +213,8 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } - if (isOwner) { + if (isOwner) + { deleteBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Put up the Yes/No message box @@ -258,11 +259,35 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } + else{ + //like Btn + deleteBtn.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + //add like only if user is didnt like already + if (!mainActivity.getUser().getLiked_notes().contains(note.getId())) { + + JSONObject jsonObj = new JSONObject(); + try { + jsonObj.put("uid", mainActivity.getUserId()); + jsonObj.put("nid", note.getId()); + + } catch (JSONException e) { + e.printStackTrace(); + } + VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, getNotesSuccessListener, Utils.genericErrorListener); + mainActivity.getUser().getLiked_notes().add(note.getId()); + likes.setText("Likes: "+(note.getLikes()+1)); + } + } + }); + } } + }); return null; } + };