soneProperties.put("time", currentTimeMillis());
soneProperties.put("requestUri", sone.getRequestUri());
soneProperties.put("profile", sone.getProfile());
- soneProperties.put("posts", Ordering.from(Post.TIME_COMPARATOR).sortedCopy(sone.getPosts()));
+ soneProperties.put("posts", Ordering.from(Post.NEWEST_FIRST).sortedCopy(sone.getPosts()));
soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies()));
soneProperties.put("likedPostIds", new HashSet<String>(sone.getLikedPostIds()));
soneProperties.put("likedReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
public interface Post extends Identified {
/** Comparator for posts, sorts descending by time. */
- public static final Comparator<Post> TIME_COMPARATOR = new Comparator<Post>() {
+ public static final Comparator<Post> NEWEST_FIRST = new Comparator<Post>() {
@Override
public int compare(Post leftPost, Post rightPost) {
synchronized (this) {
sortedPosts = new ArrayList<Post>(posts);
}
- Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+ Collections.sort(sortedPosts, Post.NEWEST_FIRST);
return sortedPosts;
}
allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
- Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+ Collections.sort(sortedPosts, Post.NEWEST_FIRST);
if (sortedPosts.size() < startPost) {
return new Response("PostFeed", encodePosts(Collections.<Post> emptyList(), "Posts.", false));
}
});
List<Post> sortedPosts = new ArrayList<Post>(loadedPosts);
- Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+ Collections.sort(sortedPosts, Post.NEWEST_FIRST);
Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0));
templateContext.set("pagination", pagination);
templateContext.set("posts", pagination.getItems());
}
allPosts = Collections2.filter(allPosts, postVisibilityFilter.isVisible(currentSone));
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
- Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+ Collections.sort(sortedPosts, Post.NEWEST_FIRST);
Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0));
templateContext.set("pagination", pagination);
templateContext.set("posts", pagination.getItems());
/* filter and sort them. */
List<Post> sortedPosts = new ArrayList(posts);
- Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+ Collections.sort(sortedPosts, Post.NEWEST_FIRST);
/* paginate them. */
Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0));
}
List<Post> sonePosts = sone.get().getPosts();
sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
- Collections.sort(sonePosts, Post.TIME_COMPARATOR);
+ Collections.sort(sonePosts, Post.NEWEST_FIRST);
Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("postPage"), 0));
templateContext.set("postPagination", postPagination);
templateContext.set("posts", postPagination.getItems());