diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java index a7c7425..481af4d 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java @@ -16,6 +16,7 @@ public class Post { private int userID; private int post_time; private String content; + private PostTypes type; //Set and get the ID of the post @@ -56,5 +57,15 @@ public class Post { public String getContent() { return content; } + + //Set and get the type of the post + + public void setType(PostTypes type) { + this.type = type; + } + + public PostTypes getType() { + return type; + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostTypes.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostTypes.java new file mode 100644 index 0000000..92fec64 --- /dev/null +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostTypes.java @@ -0,0 +1,27 @@ +package org.communiquons.android.comunic.client.data.posts; + +/** + * Posts types enum + * + * @author Pierre HUBERT + * Created by pierre on 1/28/18. + */ + +public enum PostTypes { + + /** + * Text post + */ + TEXT, + + /** + * Image post + */ + IMAGE, + + /** + * Unknown type + */ + UNKNOWN + +} diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java index f1fc5c4..e53f408 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java @@ -2,6 +2,7 @@ package org.communiquons.android.comunic.client.data.posts; import android.content.Context; import android.support.annotation.Nullable; +import android.view.View; import org.communiquons.android.comunic.client.api.APIRequest; import org.communiquons.android.comunic.client.api.APIRequestParameters; @@ -86,6 +87,22 @@ public class PostsHelper { post.setPost_time(json.getInt("post_time")); post.setContent(json.getString("content")); + //Determine the type of the post + switch (json.getString("kind")){ + + case "text": + post.setType(PostTypes.TEXT); + break; + + case "image": + post.setType(PostTypes.IMAGE); + break; + + default: + post.setType(PostTypes.UNKNOWN); + + } + return post; } }