Skip to content

Commit ec126a9

Browse files
committed
ui: do not notify entire dataset when adding log items
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 2da80e8 commit ec126a9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,18 @@ class LogViewerActivity : AppCompatActivity() {
198198
recyclerView?.let {
199199
val shouldScroll = haveScrolled && !it.canScrollVertically(1)
200200
logLines.add(logLine)
201-
if (haveScrolled) logAdapter.notifyDataSetChanged()
201+
if (haveScrolled) logAdapter.notifyItemInserted(logLines.size - 1)
202202
if (shouldScroll)
203203
it.scrollToPosition(logLines.size - 1)
204204
}
205205
} else {
206206
logLines.lastOrNull()?.msg += "\n$line"
207-
if (haveScrolled) logAdapter.notifyDataSetChanged()
207+
if (haveScrolled) logAdapter.notifyItemChanged(logLines.size - 1)
208208
}
209209
if (!haveScrolled) {
210210
val end = System.nanoTime()
211211
val scroll = (end - start) > 1000000000L * 2.5 || !stdout.ready()
212212
if (logLines.isNotEmpty() && (scroll || (end - startPeriod) > 1000000000L / 4)) {
213-
logAdapter.notifyDataSetChanged()
214213
recyclerView?.scrollToPosition(logLines.size - 1)
215214
startPeriod = end
216215
}

0 commit comments

Comments
 (0)