Overview
ThePosts_Model class represents a post in the Threadly application. It contains information about the post content, engagement metrics, and the user who created it.
Fields
Content type indicator:
0: Regular content post1: Suggested post
Unique identifier for the post
ID of the user who created the post
Username of the post creator
URL to the user’s display picture/profile photo
URL to the post media content
Caption text for the post
Timestamp when the post was created
Username of a user who liked the post (used for displaying “Liked by…”)
Total number of likes on the post
Total number of comments on the post
Total number of shares for the post
Whether the current user has liked this post
Whether the post content is a video (
true) or image (false)Whether the current user follows the post creator
Methods
The model provides standard getter and setter methods for all fields:getCONTENT_TYPE()/setCONTENT_TYPE(int)getPostId()/setPostId(int)getUserId()/setUserId(String)getUsername()/setUsername(String)getUserDpUrl()/setUserDpUrl(String)getPostUrl()/setPostUrl(String)getCaption()/setCaption(String)getCreatedAt()/setCreatedAt(String)getLikedBy()/setLikedBy(String)getLikeCount()/setLikeCount(int)getCommentCount()/setCommentCount(int)getShareCount()/setShareCount(int)getIsliked()/setIsliked(Boolean)isVideo()/setVideo(boolean)isFollowed()/setFollowed(boolean)
Example
Usage Notes
- The
CONTENT_TYPEfield distinguishes between regular content (0) and suggested/recommended posts (1) - The
islikedfield is derived from an integer value during construction (>0 = true) - Both image and video posts use the same model, differentiated by the
isVideoflag - Engagement metrics (
likeCount,commentCount,shareCount) are updated as users interact with the post