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())