diff --git a/app/src/main/java/com/dp/logcatapp/fragments/logcatlive/MyRecyclerViewAdapter.kt b/app/src/main/java/com/dp/logcatapp/fragments/logcatlive/MyRecyclerViewAdapter.kt index 0648db0..a48ba38 100644 --- a/app/src/main/java/com/dp/logcatapp/fragments/logcatlive/MyRecyclerViewAdapter.kt +++ b/app/src/main/java/com/dp/logcatapp/fragments/logcatlive/MyRecyclerViewAdapter.kt @@ -14,6 +14,7 @@ import com.dp.logcat.Logcat import com.dp.logcatapp.R import com.dp.logcatapp.util.PreferenceKeys import com.logcat.collections.FixedCircularArray +import kotlin.math.max internal class MyRecyclerViewAdapter(context: Context, initialCapacity: Int) : RecyclerView.Adapter(), @@ -83,7 +84,11 @@ internal class MyRecyclerViewAdapter(context: Context, initialCapacity: Int) : internal fun addItems(items: List) { val startPosition = list.size list.add(items) - notifyItemRangeInserted(startPosition, items.size) + if (list.size < list.capacity) { + notifyItemRangeInserted(startPosition, items.size) + } else { + notifyItemRangeChanged(0, list.size) + } } internal fun setItems(items: List) { diff --git a/logcat/src/main/java/com/dp/logcat/Logcat.kt b/logcat/src/main/java/com/dp/logcat/Logcat.kt index 0138e33..5fdc9c1 100644 --- a/logcat/src/main/java/com/dp/logcat/Logcat.kt +++ b/logcat/src/main/java/com/dp/logcat/Logcat.kt @@ -420,7 +420,7 @@ class Logcat(initialCapacity: Int = INITIAL_LOG_CAPACITY) : Closeable { val DEFAULT_BUFFERS: Set val AVAILABLE_BUFFERS: Array const val INITIAL_LOG_CAPACITY = 250_000 - const val INITIAL_LOG_SIZE = 25_000 + const val INITIAL_LOG_SIZE = 1_000 private const val LOG_FILE_HEADER_FMT = "<<< log_count = %d >>>" init {