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 481af4d..bcdb837 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 @@ -18,6 +18,9 @@ public class Post { private String content; private PostTypes type; + //Files specific + private String file_path_url; + //Set and get the ID of the post public void setId(int id) { @@ -59,7 +62,6 @@ public class Post { } //Set and get the type of the post - public void setType(PostTypes type) { this.type = type; } @@ -67,5 +69,14 @@ public class Post { public PostTypes getType() { return type; } + + //Set and get file path url + public void setFile_path_url(String file_path_url) { + this.file_path_url = file_path_url; + } + + public String getFile_path_url() { + return file_path_url; + } } 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 e53f408..f3a8aa8 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,7 +2,6 @@ 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; @@ -103,6 +102,11 @@ public class PostsHelper { } + //Get file path url (if any) + if(json.getString("file_path_url") != null){ + post.setFile_path_url(json.getString("file_path_url")); + } + return post; } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java index 02e1235..20f8505 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java @@ -15,6 +15,7 @@ import org.communiquons.android.comunic.client.R; import org.communiquons.android.comunic.client.data.ImageLoad.ImageLoadManager; import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo; import org.communiquons.android.comunic.client.data.posts.Post; +import org.communiquons.android.comunic.client.data.posts.PostTypes; import org.communiquons.android.comunic.client.data.posts.PostsList; import org.communiquons.android.comunic.client.data.utils.UiUtils; import org.communiquons.android.comunic.client.data.utils.Utilities; @@ -91,9 +92,23 @@ public class PostsAdapter extends ArrayAdapter{ ((TextView) convertView.findViewById(R.id.post_creation_time)).setText(utils. timeToString(Utilities.time() - post.getPost_time())); - //Set post conent + //Set post content ((TextView) convertView.findViewById(R.id.post_content)).setText(Utilities.prepareStringTextView(post.getContent())); + //Set post image (if any) + ImageView postImage = convertView.findViewById(R.id.post_image); + postImage.setVisibility(View.GONE); + postImage.setImageDrawable(null); + ImageLoadManager.remove(postImage); + if(post.getType() == PostTypes.IMAGE){ + + //Make image visible + postImage.setVisibility(View.VISIBLE); + + //Load image + ImageLoadManager.load(getContext(), post.getFile_path_url(), postImage); + } + return convertView; } } diff --git a/app/src/main/res/layout/post_item.xml b/app/src/main/res/layout/post_item.xml index d1552d0..8711d8f 100644 --- a/app/src/main/res/layout/post_item.xml +++ b/app/src/main/res/layout/post_item.xml @@ -47,6 +47,13 @@ + + +