main: populate menu header in onLogbookLoaded and onLogbookSaved

This targets the dynamic menu setting when only very
few events are available. Before the header stayed empty
when the first events very added, now the header is updated
immediately.
This commit is contained in:
2026-10-12 22:20:15 +02:00
committed by penguin86
parent 5109e15a09
commit 9ad9aa7754
@@ -86,8 +86,6 @@ class MainActivity : AppCompatActivity() {
recyclerView = findViewById(R.id.list_events) recyclerView = findViewById(R.id.list_events)
recyclerView.setLayoutManager(LinearLayoutManager(applicationContext)) recyclerView.setLayoutManager(LinearLayoutManager(applicationContext))
populateHeaderMenu()
// Set listeners // Set listeners
findViewById<View>(R.id.logbooks_add_button).setOnClickListener { findViewById<View>(R.id.logbooks_add_button).setOnClickListener {
showAddLogbookDialog(true) showAddLogbookDialog(true)
@@ -138,8 +136,6 @@ class MainActivity : AppCompatActivity() {
allEvents = logbook?.logs ?: arrayListOf() allEvents = logbook?.logs ?: arrayListOf()
setListAdapter(allEvents) setListAdapter(allEvents)
populateHeaderMenu()
} }
private fun populateHeaderMenu() { private fun populateHeaderMenu() {
@@ -1127,6 +1123,8 @@ class MainActivity : AppCompatActivity() {
logbook = lb logbook = lb
showLogbook() showLogbook()
populateHeaderMenu()
if (DEBUG_CHECK_LOGBOOK_CONSISTENCY) { if (DEBUG_CHECK_LOGBOOK_CONSISTENCY) {
for (e in logbook?.logs ?: listOf()) { for (e in logbook?.logs ?: listOf()) {
val em = e.getHeaderEmoji(this@MainActivity) val em = e.getHeaderEmoji(this@MainActivity)
@@ -1245,6 +1243,8 @@ class MainActivity : AppCompatActivity() {
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
savingEvent(false) savingEvent(false)
populateHeaderMenu()
}) })
} }