mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 15:59:29 +00:00
Display post images
This commit is contained in:
parent
89172a7c88
commit
9b4ed6da7e
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<Post>{
|
||||
((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;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,13 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Post image (if any) -->
|
||||
<ImageView
|
||||
android:id="@+id/post_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitCenter"/>
|
||||
|
||||
<!-- Post content -->
|
||||
<TextView
|
||||
android:id="@+id/post_content"
|
||||
|
Loading…
Reference in New Issue
Block a user