Skip to content

Commit

Permalink
fix(translations): fix crash when status language is null
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGGamerM authored and sk22 committed Oct 6, 2023
1 parent 1988849 commit bc4619e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.BaseStatusListFragment;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.model.Translation;
Expand Down Expand Up @@ -207,7 +208,7 @@ public void updateTranslation(boolean updateText){
translationProgress.setVisibility(View.GONE);
Translation existingTrans=item.status.getContentStatus().translation;
String lang=existingTrans!=null ? existingTrans.detectedSourceLanguage : null;
String displayLang=Locale.forLanguageTag(lang!=null ? lang : item.status.getContentStatus().language).getDisplayLanguage();
String displayLang=Locale.forLanguageTag(lang!=null ? lang : (item.status.getContentStatus().language != null ? item.status.getContentStatus().language : AccountSessionManager.get(item.parentFragment.getAccountID()).preferences.postingDefaultLanguage)).getDisplayLanguage();
translationButton.setText(item.parentFragment.getString(R.string.translate_post, !displayLang.isBlank() ? displayLang : lang));
translationButton.setEnabled(true);
translationButton.setAlpha(1);
Expand Down

0 comments on commit bc4619e

Please sign in to comment.