From 336a8194bdda0073c0e9c3a0a2ddaa917752da4a Mon Sep 17 00:00:00 2001 From: sk Date: Sun, 4 Jun 2023 01:36:05 +0200 Subject: [PATCH] fix settings button binding not reset visibility and events --- .../android/fragments/SettingsFragment.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index fcd26b27d..a7b4f727a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -1084,14 +1084,17 @@ public class SettingsFragment extends MastodonToolbarFragment implements Provide button=findViewById(R.id.button); } + @SuppressLint("ClickableViewAccessibility") @Override public void onBind(ButtonItem item){ text.setText(item.text); - if (item.icon == 0) { - icon.setVisibility(View.GONE); - } else { - icon.setImageResource(item.icon); - } + icon.setVisibility(item.icon == 0 ? View.GONE : View.VISIBLE); + icon.setImageResource(item.icon == 0 ? 0 : item.icon); + // reset listeners before letting the button consumer consume the button + // (and potentially set some listeners, but not others) + button.setOnTouchListener(null); + button.setOnClickListener(null); + button.setOnLongClickListener(null); item.buttonConsumer.accept(button); } }