From 5ce499f68851a18faff6f2d198b674483e936626 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 8 Dec 2018 20:50:13 +0100 Subject: [PATCH] Created a method to check if a user is at least a member of a group. --- .../android/comunic/client/data/models/GroupInfo.java | 11 +++++++++++ .../fragments/groups/GroupAccessDeniedFragment.java | 4 +--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/models/GroupInfo.java b/app/src/main/java/org/communiquons/android/comunic/client/data/models/GroupInfo.java index bec6775..bce03a8 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/models/GroupInfo.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/models/GroupInfo.java @@ -124,4 +124,15 @@ public class GroupInfo { public void setFollowing(boolean following) { this.following = following; } + + /** + * Check if the current user is at least a member of the group + * + * @return TRUE if the user is at least a member of the group / FALSE else + */ + public boolean isAtLeastMember(){ + return getMembershipLevel() == GroupsMembershipLevels.ADMINISTRATOR + || getMembershipLevel() == GroupsMembershipLevels.MODERATOR + || getMembershipLevel() == GroupsMembershipLevels.MEMBER; + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/groups/GroupAccessDeniedFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/groups/GroupAccessDeniedFragment.java index 15cf280..ae368ad 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/groups/GroupAccessDeniedFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/groups/GroupAccessDeniedFragment.java @@ -118,9 +118,7 @@ public class GroupAccessDeniedFragment extends AbstractGroupFragment { } //Check if the user is now at least a member of the group - if(info.getMembershipLevel() == GroupsMembershipLevels.MEMBER - || info.getMembershipLevel() == GroupsMembershipLevels.MODERATOR - || info.getMembershipLevel() == GroupsMembershipLevels.ADMINISTRATOR){ + if(info.isAtLeastMember()){ //Go back to the group Objects.requireNonNull(getActivity())