New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement activity of SNS Feed(Post) #13
Conversation
Existing ServerAPI with MoshiConverterFactory was not suitable for SNS Post, so added ServerPostAPI containing Scalars, Gson ConverterFactory
class SnsFeedInformation(postInfo: PostFeedItem, baseurl : String) { | ||
val postId: Int = postInfo.postID | ||
val writerName: String = postInfo.writer.username | ||
val writerImage: String = baseurl + postInfo.writer.picture | ||
val postcontent: String = postInfo.contents | ||
val postTime: String = postInfo.postTime.split(".")[0].replace("T", " ") | ||
val postLat: Double = postInfo.location.lat | ||
val postLong: Double = postInfo.location.lng | ||
val liker = postInfo.like | ||
var likerCount: Int = 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class SnsFeedInformation(postInfo: PostFeedItem, baseurl : String) { | |
val postId: Int = postInfo.postID | |
val writerName: String = postInfo.writer.username | |
val writerImage: String = baseurl + postInfo.writer.picture | |
val postcontent: String = postInfo.contents | |
val postTime: String = postInfo.postTime.split(".")[0].replace("T", " ") | |
val postLat: Double = postInfo.location.lat | |
val postLong: Double = postInfo.location.lng | |
val liker = postInfo.like | |
var likerCount: Int = 0 | |
} | |
/** class of informations of sns feed */ | |
data class SnsFeedInformation( | |
val postId: Int, | |
val writerName: String, | |
val writerImage: String, | |
val postcontent: String, | |
val postTime: String, | |
val postLat: Double, | |
val postLong: Double, | |
val liker: List<Like>, | |
var likerCount: Int, | |
) { | |
constructor(postInfo: PostFeedItem, baseurl : String) : this( | |
postInfo.postID, | |
postInfo.writer.username, | |
baseurl + postInfo.writer.picture, | |
postInfo.contents, | |
postInfo.postTime.split(".")[0].replace("T", " "), | |
postInfo.location.lat, | |
postInfo.location.lng, | |
postInfo.like, | |
0, | |
) | |
} |
This kind of class have an advantage when declare it as a data class, as it kvm automatically add equals,
hashCode, etc.. Although it may seems little bit more verbose, I think this is a more kotlinic way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion, I'll commit this right away!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Applying above my suggestion is up to you .You do not have to change it in this PR
5f06a37
to
388473c
Compare
This revision includes
Changes
1. Add new activity&layout to display SNS feed from server (SnsFeedActivity)
2. Add interfaces, data classses for SNS related communication (API/ServerClient, Model/PostFeedItem)
3. Add new retrofit2 instance object (API/ServerPostAPI)
4. Add ViewPager, Recycler layout&adapter to show comments, images of post (image_viewpager.xml, commnet_recycler.xml, ImageSliderAdapter, CommentRecyclerAdapter)
5. Add dependencies for processing request and images
Documents