update fork #128

Manually merged
tristan merged 181 commits from mirror/monocles_chat_clean:master into master 2026-01-23 14:02:38 +01:00
Showing only changes of commit 176f4c3af0 - Show all commits

Sort comments by date

Arne 2026-01-11 21:12:49 +01:00

View file

@ -27,6 +27,7 @@ import com.bumptech.glide.request.transition.Transition;
import java.io.File;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -252,7 +253,6 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.share_post_with)));
});
if (post.getAuthor() != null && mActivity.xmppConnectionService != null) {
Account account = AccountUtils.getFirstEnabled(mActivity.xmppConnectionService.getAccounts());
if (account != null && post.getAuthor().asBareJid().equals(account.getJid().asBareJid())) {
@ -352,8 +352,6 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
}
}
private void loadComments(final Post post, final RecyclerView recyclerView) {
if (mActivity.xmppConnectionService == null) {
return;
@ -380,10 +378,25 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
}
mActivity.runOnUiThread(() -> {
if (!comments.isEmpty()) {
java.util.Collections.sort(comments, (c1, c2) -> {
Date d1 = c1.getPublished();
Date d2 = c2.getPublished();
if (d1 == null && d2 == null) {
return 0;
} else if (d1 == null) {
return -1;
} else if (d2 == null) {
return 1;
} else {
return d1.compareTo(d2);
}
});
CommentsAdapter commentsAdapter = new CommentsAdapter(mActivity, comments);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
recyclerView.setAdapter(commentsAdapter);
recyclerView.setVisibility(View.VISIBLE);
} else {
recyclerView.setVisibility(View.GONE);
}
});
} catch (Exception e) {
@ -402,4 +415,5 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
}
}
}
}