nolanlawson / KeepScore

Score keeping app for Android (unmaintained)
http://nolanlawson.com/apps/#keepscore
69 stars 56 forks source link

Crash on too many rounds #85

Open Pluckerpluck opened 9 years ago

Pluckerpluck commented 9 years ago

I still get a crash when I have enough rounds such that the numbers would drop off the bottom of the list (probably require scrolling).

I have reported the error, it gives a ClassCastException in widget.AutofitTextView.onMeasure;

It states that SpannableString cannot be cast to SpannedString.

My guess is this occurs on line 65:

ForegroundColorSpan[] foregroundColorSpans = ((SpannedString) getText()).getSpans(startOfLastLine + 1, cutoffIndex, ForegroundColorSpan.class);

as this is the only place a cast of this type occurs.

This could be fixed by instead casting to the interface (Spanned). This interface is also the interface for SpannedString anyway, so it should make no difference if this is NOT the problem. This is, however, the preferred way of dealing with casting variables in Java. Whenever possible, one should cast to the interface rather than the implementation (unless you need it). This is why you regularly see things like the following:

List myList = new ArrayList();

rather than

ArrayList myList = new ArrayList();

The Android Javadocs also state that getText() can be cast to either Spannable or Editiable (not SpannedString) depending on how it was set.


All in all, even if this isn't a bug I believe it should be changed. Though I do believe it is the bug I am experiencing.

BuonOmo commented 7 years ago

I have the same issue now. Sadly, this makes the application unusable...