From 4e79e299bf873330930e5e9a1f73aec15ed05e2e Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 26 Dec 2018 10:32:31 +0100 Subject: [PATCH] Added groups notification support --- .../ui/fragments/NotificationsFragment.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java index 5a09d71..4032688 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java @@ -28,9 +28,12 @@ import org.communiquons.android.comunic.client.data.arrays.NotifsList; import org.communiquons.android.comunic.client.data.models.Notif; import org.communiquons.android.comunic.client.ui.activities.MainActivity; import org.communiquons.android.comunic.client.ui.adapters.NotificationsAdapter; +import org.communiquons.android.comunic.client.ui.listeners.OnOpenGroupListener; import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener; import org.communiquons.android.comunic.client.ui.listeners.onPostOpenListener; +import java.util.Objects; + /** * Notifications fragment * @@ -91,6 +94,11 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont */ private onOpenUsersPageListener mUserPageOpener; + /** + * Groups opener + */ + private OnOpenGroupListener mOnOpenGroupListener; + /** * Post open listener */ @@ -101,7 +109,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont super.onCreate(savedInstanceState); //Initialize helpers - mNotificationsHelper = new NotificationsHelper(getActivity()); + mNotificationsHelper = new NotificationsHelper(Objects.requireNonNull(getActivity())); mUsersInfoHelper = new GetUsersHelper(getActivity()); mGroupsHelper = new GroupsHelper(getActivity()); } @@ -141,14 +149,13 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont super.onResume(); //Update the title of the application - getActivity().setTitle(R.string.fragment_notifications_title); + Objects.requireNonNull(getActivity()).setTitle(R.string.fragment_notifications_title); MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_notifications); - //Get user page opener + //Get openers mUserPageOpener = (onOpenUsersPageListener) getActivity(); - - //Get post opener mOpenPostListener = (onPostOpenListener) getActivity(); + mOnOpenGroupListener = (OnOpenGroupListener) getActivity(); //Check if it is required to fetch the list of notifications if(mNotificationsList == null){ @@ -308,7 +315,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont return; //Inflate the menu - MenuInflater inflater = getActivity().getMenuInflater(); + MenuInflater inflater = Objects.requireNonNull(getActivity()).getMenuInflater(); inflater.inflate(R.menu.menu_notification_actions, menu); } @@ -390,6 +397,13 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont mOpenPostListener.onOpenPost(notif.getOn_elem_id()); } + + if(notif.getOn_elem_type() == NotifElemType.GROUPS_MEMBERSHIP){ + + //Open target group + mOnOpenGroupListener.onOpenGroup(notif.getOn_elem_id()); + + } } /**