refactor code

This commit is contained in:
sk 2023-10-06 15:01:17 +02:00 committed by sk22
parent bc4619e6b1
commit ebb49c44fe
1 changed files with 4 additions and 2 deletions

View File

@ -207,8 +207,10 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
translationFooter.setVisibility(translateEnabled ? View.VISIBLE : View.GONE); translationFooter.setVisibility(translateEnabled ? View.VISIBLE : View.GONE);
translationProgress.setVisibility(View.GONE); translationProgress.setVisibility(View.GONE);
Translation existingTrans=item.status.getContentStatus().translation; Translation existingTrans=item.status.getContentStatus().translation;
String lang=existingTrans!=null ? existingTrans.detectedSourceLanguage : null; String existingTransLang=existingTrans!=null ? existingTrans.detectedSourceLanguage : null;
String displayLang=Locale.forLanguageTag(lang!=null ? lang : (item.status.getContentStatus().language != null ? item.status.getContentStatus().language : AccountSessionManager.get(item.parentFragment.getAccountID()).preferences.postingDefaultLanguage)).getDisplayLanguage(); 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)); translationButton.setText(item.parentFragment.getString(R.string.translate_post, !displayLang.isBlank() ? displayLang : lang));
translationButton.setEnabled(true); translationButton.setEnabled(true);
translationButton.setAlpha(1); translationButton.setAlpha(1);