Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ private android.os.Handler getHandler() {
* Get the position for a specific comment in the adapter
*
* @param comment The comment to find
* @return The position or 0 if not found
* @return The position or -1 if not found
*/
public int getPositionForComment(RenderableComment comment) {
if (comment == null || commentsTree.visibleNodes.isEmpty()) {
return 0;
return -1;
}

return commentsTree.visibleNodes.indexOf(comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,13 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
}
}

// Notify adapter to update UI immediately for better UX
adapter.notifyDataSetChanged();
// Notify adapter to update UI immediately for better UX - use targeted update for performance
int position = adapter.getPositionForComment(commentToVote);
if (position != -1) {
adapter.notifyItemChanged(position);
} else {
Log.w("FastCommentsView", "Could not find comment position for vote update, UI may not refresh");
}

// Store toast message for display after successful API call
final String finalToastMessage = toastMessage;
Expand Down Expand Up @@ -360,8 +365,13 @@ public boolean onSuccess(APIError error) {
android.widget.Toast.LENGTH_SHORT
).show();

// Update the UI
adapter.notifyDataSetChanged();
// Update the UI - use targeted update for performance
int position = adapter.getPositionForComment(commentToVote);
if (position != -1) {
adapter.notifyItemChanged(position);
} else {
Log.w("FastCommentsView", "Could not find comment position for vote rollback, UI may not refresh");
}
});

return CONSUME;
Expand Down Expand Up @@ -468,8 +478,13 @@ public void onCancel() {
toastMessage = getContext().getString(R.string.you_downvoted, commenterName);
}

// Notify adapter to update UI immediately for better UX
adapter.notifyDataSetChanged();
// Notify adapter to update UI immediately for better UX - use targeted update for performance
int position = adapter.getPositionForComment(commentToVote);
if (position != -1) {
adapter.notifyItemChanged(position);
} else {
Log.w("FastCommentsView", "Could not find comment position for vote update, UI may not refresh");
}

// Store toast message for display after successful API call
final String finalToastMessage = toastMessage;
Expand Down