From d0a97331eb06d4dd2668ebe48aed0973c39469e5 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 22 Aug 2023 17:50:01 +0200 Subject: [PATCH] Added fail-safe --- .../email/FragmentDialogSelectAccount.java | 19 ++++++++++------- .../email/FragmentDialogSelectIdentity.java | 21 ++++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogSelectAccount.java b/app/src/main/java/eu/faircode/email/FragmentDialogSelectAccount.java index 931657a3a0..f2273a1c08 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogSelectAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogSelectAccount.java @@ -52,16 +52,21 @@ public class FragmentDialogSelectAccount extends FragmentDialogBase { @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { View view = super.getView(position, convertView, parent); - EntityAccount account = (EntityAccount) getItem(position); - View vwColor = view.findViewById(R.id.vwColor); - TextView tv = view.findViewById(android.R.id.text1); + try { + EntityAccount account = getItem(position); - int vpad = (getCount() > 10 ? dp6 : dp12); - tv.setPadding(0, vpad, 0, vpad); + View vwColor = view.findViewById(R.id.vwColor); + TextView tv = view.findViewById(android.R.id.text1); - vwColor.setBackgroundColor(account.color == null ? Color.TRANSPARENT : account.color); - tv.setText(account.name); + int vpad = (getCount() > 10 ? dp6 : dp12); + tv.setPadding(0, vpad, 0, vpad); + + vwColor.setBackgroundColor(account.color == null ? Color.TRANSPARENT : account.color); + tv.setText(account.name); + } catch (Throwable ex) { + Log.e(ex); + } return view; } diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogSelectIdentity.java b/app/src/main/java/eu/faircode/email/FragmentDialogSelectIdentity.java index 06dfabbb75..4a2c8fa865 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogSelectIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogSelectIdentity.java @@ -51,17 +51,22 @@ public class FragmentDialogSelectIdentity extends FragmentDialogBase { @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { View view = super.getView(position, convertView, parent); - TupleIdentityEx identity = getItem(position); - View vwColor = view.findViewById(R.id.vwColor); - TextView tv = view.findViewById(android.R.id.text1); + try { + TupleIdentityEx identity = getItem(position); - int vpad = (getCount() > 10 ? dp6 : dp12); - tv.setPadding(0, vpad, 0, vpad); + View vwColor = view.findViewById(R.id.vwColor); + TextView tv = view.findViewById(android.R.id.text1); - Integer color = (identity.color == null ? identity.accountColor : identity.color); - vwColor.setBackgroundColor(color == null ? Color.TRANSPARENT : color); - tv.setText(identity.getDisplayName()); + int vpad = (getCount() > 10 ? dp6 : dp12); + tv.setPadding(0, vpad, 0, vpad); + + Integer color = (identity.color == null ? identity.accountColor : identity.color); + vwColor.setBackgroundColor(color == null ? Color.TRANSPARENT : color); + tv.setText(identity.getDisplayName()); + } catch (Throwable ex) { + Log.e(ex); + } return view; }