Skip to content

Commit

Permalink
Only bold the number of shown entries if it's found in the translated…
Browse files Browse the repository at this point in the history
… string

This should fix the following crash:

```
Exception java.lang.IndexOutOfBoundsException: setSpan (-1 ... 0) starts before 0
  at android.text.SpannableStringInternal.checkRange (SpannableStringInternal.java:499)
  at android.text.SpannableStringInternal.setSpan (SpannableStringInternal.java:199)
  at android.text.SpannableStringInternal.setSpan (SpannableStringInternal.java:186)
  at android.text.SpannableString.setSpan (SpannableString.java:60)
  at com.beemdevelopment.aegis.ui.views.EntryAdapter$FooterView.refresh (EntryAdapter.java:596)
```
  • Loading branch information
alexbakker committed Mar 10, 2024
1 parent f7bac43 commit 5161a97
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.beemdevelopment.aegis.CopyBehavior;
import com.beemdevelopment.aegis.AccountNamePosition;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.CopyBehavior;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory;
import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.helpers.ItemTouchHelperAdapter;
Expand Down Expand Up @@ -777,8 +777,10 @@ public void refresh() {

String entriesShownString = String.format("%d", entriesShown);
int spanStart = entriesShownSpannable.toString().indexOf(entriesShownString);
int spanEnd = spanStart + entriesShownString.length();
entriesShownSpannable.setSpan(new StyleSpan(Typeface.BOLD), spanStart, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if (spanStart >= 0) {
int spanEnd = spanStart + entriesShownString.length();
entriesShownSpannable.setSpan(new StyleSpan(Typeface.BOLD), spanStart, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}

TextView textView = _footerView.findViewById(R.id.entries_shown_count);
textView.setText(entriesShownSpannable);
Expand Down

0 comments on commit 5161a97

Please sign in to comment.