From 131bd0736a20cb06ac439a11c5b1b4522a88afdb Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sat, 13 Oct 2018 16:30:04 +0300 Subject: [PATCH] Some refactoring --- .../bookmarks/BoardBookmarksFragment.java | 2 +- .../bookmarks/TopicBookmarksFragment.java | 2 +- .../mthmmy/services/NotificationService.java | 9 ++-- ...ard_row.xml => fragment_bookmarks_row.xml} | 0 .../layout/fragment_bookmarks_topic_row.xml | 50 ------------------- 5 files changed, 7 insertions(+), 56 deletions(-) rename app/src/main/res/layout/{fragment_bookmarks_board_row.xml => fragment_bookmarks_row.xml} (100%) delete mode 100644 app/src/main/res/layout/fragment_bookmarks_topic_row.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java index 1912b1de..6c7db47f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java @@ -90,7 +90,7 @@ public class BoardBookmarksFragment extends Fragment { for (final Bookmark bookmarkedBoard : boardBookmarks) { if (bookmarkedBoard != null && bookmarkedBoard.getTitle() != null) { final LinearLayout row = (LinearLayout) layoutInflater.inflate( - R.layout.fragment_bookmarks_board_row, bookmarksLinearView, false); + R.layout.fragment_bookmarks_row, bookmarksLinearView, false); row.setOnClickListener(view -> { Activity activity = getActivity(); if (activity instanceof BookmarkActivity){ diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java index 7b8b5305..c7a14b84 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java @@ -85,7 +85,7 @@ public class TopicBookmarksFragment extends Fragment { for (final Bookmark bookmarkedTopic : topicBookmarks) { if (bookmarkedTopic != null && bookmarkedTopic.getTitle() != null) { final LinearLayout row = (LinearLayout) layoutInflater.inflate( - R.layout.fragment_bookmarks_topic_row, bookmarksLinearView, false); + R.layout.fragment_bookmarks_row, bookmarksLinearView, false); row.setOnClickListener(view -> { Activity activity = getActivity(); if (activity instanceof BookmarkActivity) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java index 02319378..00dee3f3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java @@ -50,19 +50,20 @@ public class NotificationService extends FirebaseMessagingService { int userId = BaseApplication.getInstance().getSessionManager().getUserId(); //Don't notify me if the sender is me! if (Integer.parseInt(json.getString("posterId")) != userId) { - int topicId = Integer.parseInt(json.getString("topicId")); - int postId = Integer.parseInt(json.getString("postId")); - String topicTitle = json.getString("topicTitle"); - String poster = json.getString("poster"); int boardId = -1; String boardTitle = null; if(remoteMessage.getFrom().contains("b")){ Timber.i("FCM BOARD type message detected."); + //TODO: return early and don't create notification if the user is also subscribed to this topicId boardId = Integer.parseInt(json.getString("boardId")); boardTitle = json.getString("boardTitle"); } else Timber.i("FCM TOPIC type message detected."); + int topicId = Integer.parseInt(json.getString("topicId")); + int postId = Integer.parseInt(json.getString("postId")); + String topicTitle = json.getString("topicTitle"); + String poster = json.getString("poster"); sendNotification(new PostNotification(postId, topicId, topicTitle, poster, boardId, boardTitle)); } else diff --git a/app/src/main/res/layout/fragment_bookmarks_board_row.xml b/app/src/main/res/layout/fragment_bookmarks_row.xml similarity index 100% rename from app/src/main/res/layout/fragment_bookmarks_board_row.xml rename to app/src/main/res/layout/fragment_bookmarks_row.xml diff --git a/app/src/main/res/layout/fragment_bookmarks_topic_row.xml b/app/src/main/res/layout/fragment_bookmarks_topic_row.xml deleted file mode 100644 index b3e17ebe..00000000 --- a/app/src/main/res/layout/fragment_bookmarks_topic_row.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - \ No newline at end of file