From 208351bd267fcb425ee20ba224654ddf915ad3e2 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 10 Jul 2016 14:55:05 +0300 Subject: [PATCH] - likes system fixed and modified on map --- .../animated_vector_drawable_23_4_0.xml | 4 +-- .idea/libraries/appcompat_v7_23_4_0.xml | 4 +-- .idea/libraries/design_23_4_0.xml | 4 +-- .../firebase_analytics_impl_9_2_0.xml | 2 +- .idea/libraries/firebase_auth_9_2_0.xml | 2 +- .../libraries/firebase_auth_common_9_2_0.xml | 2 +- .../libraries/firebase_auth_module_9_2_0.xml | 2 +- .idea/libraries/firebase_config_9_2_0.xml | 2 +- .idea/libraries/firebase_crash_9_2_0.xml | 2 +- .idea/libraries/firebase_database_9_2_0.xml | 2 +- .idea/libraries/firebase_messaging_9_2_0.xml | 2 +- .idea/libraries/firebase_storage_9_2_0.xml | 2 +- .../firebase_storage_common_9_2_0.xml | 2 +- .idea/libraries/mediarouter_v7_23_0_0.xml | 4 +-- .idea/libraries/play_services_9_2_0.xml | 2 +- .../play_services_appindexing_9_2_0.xml | 2 +- .../play_services_auth_base_9_2_0.xml | 2 +- .../play_services_basement_9_2_0.xml | 2 +- .idea/libraries/play_services_cast_9_2_0.xml | 2 +- .../play_services_contextmanager_9_2_0.xml | 2 +- .../play_services_location_9_2_0.xml | 2 +- .idea/libraries/play_services_plus_9_2_0.xml | 2 +- .../play_services_tagmanager_api_9_2_0.xml | 2 +- .idea/libraries/play_services_tasks_9_2_0.xml | 2 +- .../libraries/play_services_vision_9_2_0.xml | 2 +- .idea/libraries/recyclerview_v7_23_4_0.xml | 4 +-- .../libraries/support_annotations_23_4_0.xml | 4 +-- .idea/libraries/support_v4_23_4_0.xml | 4 +-- .../support_vector_drawable_23_4_0.xml | 2 +- .idea/libraries/volley_1_0_0.xml | 2 +- .../sagi/thesocialnotework/GmapFragment.java | 35 +++++++++++++------ 31 files changed, 61 insertions(+), 48 deletions(-) diff --git a/.idea/libraries/animated_vector_drawable_23_4_0.xml b/.idea/libraries/animated_vector_drawable_23_4_0.xml index 581ec94..4688c4a 100644 --- a/.idea/libraries/animated_vector_drawable_23_4_0.xml +++ b/.idea/libraries/animated_vector_drawable_23_4_0.xml @@ -1,13 +1,13 @@ - + - + diff --git a/.idea/libraries/appcompat_v7_23_4_0.xml b/.idea/libraries/appcompat_v7_23_4_0.xml index 7fc3be6..215af43 100644 --- a/.idea/libraries/appcompat_v7_23_4_0.xml +++ b/.idea/libraries/appcompat_v7_23_4_0.xml @@ -4,13 +4,13 @@ - + - + diff --git a/.idea/libraries/design_23_4_0.xml b/.idea/libraries/design_23_4_0.xml index e917021..da6f2ae 100644 --- a/.idea/libraries/design_23_4_0.xml +++ b/.idea/libraries/design_23_4_0.xml @@ -4,13 +4,13 @@ - + - + diff --git a/.idea/libraries/firebase_analytics_impl_9_2_0.xml b/.idea/libraries/firebase_analytics_impl_9_2_0.xml index 6e0d7e2..4993bce 100644 --- a/.idea/libraries/firebase_analytics_impl_9_2_0.xml +++ b/.idea/libraries/firebase_analytics_impl_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_auth_9_2_0.xml b/.idea/libraries/firebase_auth_9_2_0.xml index 7185ab6..f4f9543 100644 --- a/.idea/libraries/firebase_auth_9_2_0.xml +++ b/.idea/libraries/firebase_auth_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_auth_common_9_2_0.xml b/.idea/libraries/firebase_auth_common_9_2_0.xml index 86f4201..7a29d3c 100644 --- a/.idea/libraries/firebase_auth_common_9_2_0.xml +++ b/.idea/libraries/firebase_auth_common_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_auth_module_9_2_0.xml b/.idea/libraries/firebase_auth_module_9_2_0.xml index a45803b..06c2d67 100644 --- a/.idea/libraries/firebase_auth_module_9_2_0.xml +++ b/.idea/libraries/firebase_auth_module_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_config_9_2_0.xml b/.idea/libraries/firebase_config_9_2_0.xml index d4a396e..fc1bc23 100644 --- a/.idea/libraries/firebase_config_9_2_0.xml +++ b/.idea/libraries/firebase_config_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_crash_9_2_0.xml b/.idea/libraries/firebase_crash_9_2_0.xml index 7b7a413..5f6e0d0 100644 --- a/.idea/libraries/firebase_crash_9_2_0.xml +++ b/.idea/libraries/firebase_crash_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_database_9_2_0.xml b/.idea/libraries/firebase_database_9_2_0.xml index 4cf8d04..2ce92c1 100644 --- a/.idea/libraries/firebase_database_9_2_0.xml +++ b/.idea/libraries/firebase_database_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_messaging_9_2_0.xml b/.idea/libraries/firebase_messaging_9_2_0.xml index f28a963..036d0ad 100644 --- a/.idea/libraries/firebase_messaging_9_2_0.xml +++ b/.idea/libraries/firebase_messaging_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_storage_9_2_0.xml b/.idea/libraries/firebase_storage_9_2_0.xml index 111cccc..d84dec2 100644 --- a/.idea/libraries/firebase_storage_9_2_0.xml +++ b/.idea/libraries/firebase_storage_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/firebase_storage_common_9_2_0.xml b/.idea/libraries/firebase_storage_common_9_2_0.xml index 206dd0b..380abaf 100644 --- a/.idea/libraries/firebase_storage_common_9_2_0.xml +++ b/.idea/libraries/firebase_storage_common_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/mediarouter_v7_23_0_0.xml b/.idea/libraries/mediarouter_v7_23_0_0.xml index d53bf7d..9e4c862 100644 --- a/.idea/libraries/mediarouter_v7_23_0_0.xml +++ b/.idea/libraries/mediarouter_v7_23_0_0.xml @@ -5,13 +5,13 @@ - + - + diff --git a/.idea/libraries/play_services_9_2_0.xml b/.idea/libraries/play_services_9_2_0.xml index 7460e35..c48c16f 100644 --- a/.idea/libraries/play_services_9_2_0.xml +++ b/.idea/libraries/play_services_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_appindexing_9_2_0.xml b/.idea/libraries/play_services_appindexing_9_2_0.xml index 1f748dc..972539a 100644 --- a/.idea/libraries/play_services_appindexing_9_2_0.xml +++ b/.idea/libraries/play_services_appindexing_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_auth_base_9_2_0.xml b/.idea/libraries/play_services_auth_base_9_2_0.xml index a6522a6..992cc4d 100644 --- a/.idea/libraries/play_services_auth_base_9_2_0.xml +++ b/.idea/libraries/play_services_auth_base_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_basement_9_2_0.xml b/.idea/libraries/play_services_basement_9_2_0.xml index 0aec068..d4ac257 100644 --- a/.idea/libraries/play_services_basement_9_2_0.xml +++ b/.idea/libraries/play_services_basement_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_cast_9_2_0.xml b/.idea/libraries/play_services_cast_9_2_0.xml index 984c4b1..db48fce 100644 --- a/.idea/libraries/play_services_cast_9_2_0.xml +++ b/.idea/libraries/play_services_cast_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_contextmanager_9_2_0.xml b/.idea/libraries/play_services_contextmanager_9_2_0.xml index f1795a0..0c01383 100644 --- a/.idea/libraries/play_services_contextmanager_9_2_0.xml +++ b/.idea/libraries/play_services_contextmanager_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_location_9_2_0.xml b/.idea/libraries/play_services_location_9_2_0.xml index 37fb730..53c7ebe 100644 --- a/.idea/libraries/play_services_location_9_2_0.xml +++ b/.idea/libraries/play_services_location_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_plus_9_2_0.xml b/.idea/libraries/play_services_plus_9_2_0.xml index 13b2aef..a1e9d21 100644 --- a/.idea/libraries/play_services_plus_9_2_0.xml +++ b/.idea/libraries/play_services_plus_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_tagmanager_api_9_2_0.xml b/.idea/libraries/play_services_tagmanager_api_9_2_0.xml index 785dae0..0ccf9df 100644 --- a/.idea/libraries/play_services_tagmanager_api_9_2_0.xml +++ b/.idea/libraries/play_services_tagmanager_api_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_tasks_9_2_0.xml b/.idea/libraries/play_services_tasks_9_2_0.xml index 255cf7b..e7d0a1b 100644 --- a/.idea/libraries/play_services_tasks_9_2_0.xml +++ b/.idea/libraries/play_services_tasks_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/play_services_vision_9_2_0.xml b/.idea/libraries/play_services_vision_9_2_0.xml index d05e55f..02a9a1e 100644 --- a/.idea/libraries/play_services_vision_9_2_0.xml +++ b/.idea/libraries/play_services_vision_9_2_0.xml @@ -1,8 +1,8 @@ - + diff --git a/.idea/libraries/recyclerview_v7_23_4_0.xml b/.idea/libraries/recyclerview_v7_23_4_0.xml index af5c00a..0651040 100644 --- a/.idea/libraries/recyclerview_v7_23_4_0.xml +++ b/.idea/libraries/recyclerview_v7_23_4_0.xml @@ -4,13 +4,13 @@ - + - + diff --git a/.idea/libraries/support_annotations_23_4_0.xml b/.idea/libraries/support_annotations_23_4_0.xml index 92ae113..4619479 100644 --- a/.idea/libraries/support_annotations_23_4_0.xml +++ b/.idea/libraries/support_annotations_23_4_0.xml @@ -1,12 +1,12 @@ - + - + diff --git a/.idea/libraries/support_v4_23_4_0.xml b/.idea/libraries/support_v4_23_4_0.xml index 550c072..b9606c9 100644 --- a/.idea/libraries/support_v4_23_4_0.xml +++ b/.idea/libraries/support_v4_23_4_0.xml @@ -5,13 +5,13 @@ - + - + diff --git a/.idea/libraries/support_vector_drawable_23_4_0.xml b/.idea/libraries/support_vector_drawable_23_4_0.xml index 2f49a78..c4f8c3a 100644 --- a/.idea/libraries/support_vector_drawable_23_4_0.xml +++ b/.idea/libraries/support_vector_drawable_23_4_0.xml @@ -6,8 +6,8 @@ - + diff --git a/.idea/libraries/volley_1_0_0.xml b/.idea/libraries/volley_1_0_0.xml index 81a83dd..8e317b7 100644 --- a/.idea/libraries/volley_1_0_0.xml +++ b/.idea/libraries/volley_1_0_0.xml @@ -1,8 +1,8 @@ - + 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 81a2a81..8b49bac 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 @@ -8,6 +8,9 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.location.Location; import android.net.Uri; import android.os.AsyncTask; @@ -167,7 +170,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { // set text button in the right filter string map_small_filter.setText(day); map_medium_filter.setText(week); - map_medium_filter.setText(week); map_large_filter.setText(month); } setButtonsColor(); @@ -290,10 +292,6 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { noteViewDialog.setContentView(R.layout.note_display_full); boolean isOwner = note.getOwnerId().equals(mainActivity.getUserId()); -// if (isOwner) -// noteViewDialog.setTitle("You wrote..."); -// else -// noteViewDialog.setTitle("Someone wrote..."); noteViewDialog.show(); @@ -325,10 +323,15 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } else { permissionImg.setVisibility(View.INVISIBLE); permission.setText(""); - deleteBtn.setBackgroundResource(R.drawable.like_icon); + deleteBtn.setBackgroundResource(R.drawable.unlike_icon); + int filterColor; + if (mainActivity.getUser().getLiked_notes().contains(note.getId())) { + deleteBtn.setBackgroundResource(R.drawable.like_icon); + } else { + deleteBtn.setBackgroundResource(R.drawable.unlike_icon); + } } - if (isOwner) { deleteBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { @@ -377,9 +380,8 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { //like Btn deleteBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - //add like only if user is didnt like already + //add like only if user didnt like already if (!mainActivity.getUser().getLiked_notes().contains(note.getId())) { - JSONObject jsonObj = new JSONObject(); try { jsonObj.put("uid", mainActivity.getUserId()); @@ -388,10 +390,12 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } catch (JSONException e) { e.printStackTrace(); } - VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, getNotesSuccessListener, Utils.genericErrorListener); + VolleyUtilSingleton.getInstance(getActivity()).post(Utils.BASE_URL + "/note/like", jsonObj, likeNotesSuccessListener, Utils.genericErrorListener); mainActivity.getUser().getLiked_notes().add(note.getId()); mainActivity.getUser().updateUser(mainActivity); - likes.setText("Likes: " + (note.getLikes() + 1)); + note.setLikes(note.getLikes()+1); + likes.setText("" + note.getLikes()); + deleteBtn.setBackgroundResource(R.drawable.like_icon); } } }); @@ -432,6 +436,15 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback { } }; + //response listener for getting all user notes + Response.Listener likeNotesSuccessListener = new Response.Listener() { + @Override + public void onResponse(JSONObject response) { + Log.d(TAG, "likeNotesSuccessListener: " + response.toString()); + } + }; + + private class getMarkersFromNotes extends AsyncTask, MarkerNoteStruct, Void> { GoogleMap mMap;