Skip to content

Commit

Permalink
Fix a bug where new logs weren't being shown
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanparajuli committed Jul 13, 2020
1 parent 61a7af5 commit eb7aca0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyRecyclerViewAdapter.MyViewHolder>(),
Expand Down Expand Up @@ -83,7 +84,11 @@ internal class MyRecyclerViewAdapter(context: Context, initialCapacity: Int) :
internal fun addItems(items: List<Log>) {
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<Log>) {
Expand Down
2 changes: 1 addition & 1 deletion logcat/src/main/java/com/dp/logcat/Logcat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class Logcat(initialCapacity: Int = INITIAL_LOG_CAPACITY) : Closeable {
val DEFAULT_BUFFERS: Set<String>
val AVAILABLE_BUFFERS: Array<String>
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 {
Expand Down

0 comments on commit eb7aca0

Please sign in to comment.