From 6330f5952cd2cd763796f922d704692b150a5743 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 6 Apr 2020 23:20:44 +0200 Subject: [PATCH] show the thread Delete button only if there are actual messages present --- .../smsmessenger/activities/ThreadActivity.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index bd95592e..8a9c5ca0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -35,6 +35,7 @@ class ThreadActivity : SimpleActivity() { private var targetNumber = "" private var threadId = 0 + private var threadItems = ArrayList() private var bus: EventBus? = null private var selectedContacts = ArrayList() @@ -85,6 +86,7 @@ class ThreadActivity : SimpleActivity() { menuInflater.inflate(R.menu.menu_thread, menu) menu.apply { findItem(R.id.manage_people).isVisible = false + findItem(R.id.delete).isVisible = threadItems.isNotEmpty() } return true @@ -101,10 +103,11 @@ class ThreadActivity : SimpleActivity() { private fun setupAdapter() { val threadId = intent.getIntExtra(THREAD_ID, 0) - val items = getThreadItems(threadId) + threadItems = getThreadItems(threadId) + invalidateOptionsMenu() runOnUiThread { - val adapter = ThreadAdapter(this, items, thread_messages_list, thread_messages_fastscroller) {} + val adapter = ThreadAdapter(this, threadItems, thread_messages_list, thread_messages_fastscroller) {} thread_messages_list.adapter = adapter }