From 36846acbe5ce2d09c054205f06ae03a268c058c5 Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 19 Oct 2023 00:38:06 +0200 Subject: [PATCH] fix null pointer when content language is null --- .../android/ui/displayitems/TextStatusDisplayItem.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index 122b20fddb..5881c66674 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -210,9 +210,10 @@ public void updateTranslation(boolean updateText){ Translation existingTrans=item.status.getContentStatus().translation; String existingTransLang=existingTrans!=null ? existingTrans.detectedSourceLanguage : null; String lang=existingTransLang!=null ? existingTransLang : item.status.getContentStatus().language; - String displayLang=Locale.forLanguageTag(lang != null ? lang - : AccountSessionManager.get(item.parentFragment.getAccountID()).preferences.postingDefaultLanguage).getDisplayLanguage(); - translationButton.setText(item.parentFragment.getString(R.string.translate_post, !displayLang.isBlank() ? displayLang : lang)); + Locale locale=lang!=null ? Locale.forLanguageTag(lang) : null; + translationButton.setText(locale!=null + ? item.parentFragment.getString(R.string.translate_post, locale.getDisplayLanguage()) + : item.parentFragment.getString(R.string.sk_translate_post)); translationButton.setClickable(true); translationButton.animate().alpha(1).setDuration(100).start(); translationInfo.setVisibility(View.GONE);