Added groups notification support

This commit is contained in:
Pierre HUBERT 2018-12-26 10:32:31 +01:00
parent cf4a2da0ae
commit 4e79e299bf

View File

@ -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.data.models.Notif;
import org.communiquons.android.comunic.client.ui.activities.MainActivity; 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.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.onOpenUsersPageListener;
import org.communiquons.android.comunic.client.ui.listeners.onPostOpenListener; import org.communiquons.android.comunic.client.ui.listeners.onPostOpenListener;
import java.util.Objects;
/** /**
* Notifications fragment * Notifications fragment
* *
@ -91,6 +94,11 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
*/ */
private onOpenUsersPageListener mUserPageOpener; private onOpenUsersPageListener mUserPageOpener;
/**
* Groups opener
*/
private OnOpenGroupListener mOnOpenGroupListener;
/** /**
* Post open listener * Post open listener
*/ */
@ -101,7 +109,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
//Initialize helpers //Initialize helpers
mNotificationsHelper = new NotificationsHelper(getActivity()); mNotificationsHelper = new NotificationsHelper(Objects.requireNonNull(getActivity()));
mUsersInfoHelper = new GetUsersHelper(getActivity()); mUsersInfoHelper = new GetUsersHelper(getActivity());
mGroupsHelper = new GroupsHelper(getActivity()); mGroupsHelper = new GroupsHelper(getActivity());
} }
@ -141,14 +149,13 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
super.onResume(); super.onResume();
//Update the title of the application //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); MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_notifications);
//Get user page opener //Get openers
mUserPageOpener = (onOpenUsersPageListener) getActivity(); mUserPageOpener = (onOpenUsersPageListener) getActivity();
//Get post opener
mOpenPostListener = (onPostOpenListener) getActivity(); mOpenPostListener = (onPostOpenListener) getActivity();
mOnOpenGroupListener = (OnOpenGroupListener) getActivity();
//Check if it is required to fetch the list of notifications //Check if it is required to fetch the list of notifications
if(mNotificationsList == null){ if(mNotificationsList == null){
@ -308,7 +315,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
return; return;
//Inflate the menu //Inflate the menu
MenuInflater inflater = getActivity().getMenuInflater(); MenuInflater inflater = Objects.requireNonNull(getActivity()).getMenuInflater();
inflater.inflate(R.menu.menu_notification_actions, menu); 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()); mOpenPostListener.onOpenPost(notif.getOn_elem_id());
} }
if(notif.getOn_elem_type() == NotifElemType.GROUPS_MEMBERSHIP){
//Open target group
mOnOpenGroupListener.onOpenGroup(notif.getOn_elem_id());
}
} }
/** /**