Skip to content
Open
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 @@ -157,9 +157,9 @@ class MainActivity : AppCompatActivity() {
historyAdapter.updateHistoryList()
binding.historyRecylcleView.adapter = historyAdapter

// Scroll to the bottom of the recycle view
// Scroll to the top of the recycle view
if (historyAdapter.itemCount > 0) {
binding.historyRecylcleView.scrollToPosition(historyAdapter.itemCount - 1)
binding.historyRecylcleView.scrollToPosition(0)
}

setSwipeTouchHelperForRecyclerView()
Expand Down Expand Up @@ -712,8 +712,8 @@ class MainActivity : AppCompatActivity() {
}
checkEmptyHistoryForNoHistoryLabel()

// Scroll to the bottom of the recycle view
binding.historyRecylcleView.scrollToPosition(historyAdapter.itemCount - 1)
// Scroll to the top of the recycle view
binding.historyRecylcleView.scrollToPosition(0)
}
}
}
Expand Down Expand Up @@ -1097,8 +1097,8 @@ class MainActivity : AppCompatActivity() {
historyAdapter.removeFirstHistoryElement()
}
checkEmptyHistoryForNoHistoryLabel()
// Scroll to the bottom of the recycle view
binding.historyRecylcleView.scrollToPosition(historyAdapter.itemCount - 1)
// Scroll to the top of the recycle view
binding.historyRecylcleView.scrollToPosition(0)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ class HistoryAdapter(
)
}

fun appendOneHistoryElement(history: History) {
this.history.add(history)
// Update the last 2 elements to avoid to have the same date and bar separator
if (this.history.size > 1) {
notifyItemInserted(this.history.size - 1)
notifyItemRangeChanged(this.history.size - 2, 2)
} else {
notifyItemInserted(this.history.size - 1)
}
fun appendOneHistoryElement(history: History) {
this.history.add(0, history)
notifyItemInserted(0)
// Update the first 2 elements to avoid to have the same date and bar separator
if (this.history.size > 1) {
notifyItemRangeChanged(0, 2)
}
}

fun removeHistoryElement(position: Int){
// No idea why, but time.isNotEmpty() is not working, only time.isNullOrEmpty() works
Expand Down