From 78aadd55a10c50097e16c5b150786f23897e87d9 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 1 Aug 2018 07:19:44 +0200 Subject: [PATCH] Created method visibility_level_to_api --- .../client/data/helpers/PostsHelper.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java index 5b402a7..1f1bb55 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java @@ -212,23 +212,7 @@ public class PostsHelper { } //Determine the visibility level of the post - switch (post.getVisibilityLevel()){ - - case PUBLIC: - req.addString("visibility", "public"); - break; - - case FRIENDS: - req.addString("visibility", "friends"); - break; - - case PRIVATE: - req.addString("visibility", "private"); - break; - - default: - throw new RuntimeException("Unsupported kind of Visibility level!"); - } + req.addString("visibility", visibility_level_to_api(post.getVisibilityLevel())); //Set the kind of target page switch (post.getPage_type()){ @@ -407,4 +391,27 @@ public class PostsHelper { return post; } + + /** + * Turn a POST visibility level into a string ready for the API + * + * @param level The level to convert + * @return Generated API string + */ + private String visibility_level_to_api(PostVisibilityLevels level){ + switch (level){ + + case PUBLIC: + return "public"; + + case FRIENDS: + return "friends"; + + case PRIVATE: + return "private"; + + default: + throw new RuntimeException("Unsupported kind of Visibility level!"); + } + } }