Skip to content

LogAdapter copies full list and scrolls on every update #96

Closed

Description

@rossigee

Problem

LogAdapter.updateLogs always does this.logs = new ArrayList<>(newLogs).

In MainActivity, the observer does:

logAdapter.updateLogs(logs);
if (!logs.isEmpty()) {
    logRecyclerView.scrollToPosition(0);
}

When newSize <= prevSize it falls back to notifyDataSetChanged().

Impact

  • Unnecessary full list copies on every log emission
  • Scroll jumps to top on every new log line
  • notifyDataSetChanged is inefficient for RecyclerView
  • Bad for long-running devices with hundreds of log entries

Suggested

  • Use DiffUtil (or AsyncListDiffer)
  • Only scroll when user is already at top or on explicit "new messages"
  • Consider limiting visible log size (virtual scrolling + in-memory ring buffer)

See also: MainActivity:166, LogAdapter:46

Activity

  1. rossigee commented on Oct 6, 2026

    @rossigee
    OwnerAuthor

    Fixed in #99 (merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions