Fix a rounding issue that caused text to overflow on 4.3 & 4.4

Also reduce the size of the cache by 4, I believe there were memory problems
multisite
Floens 10 years ago
parent ea19554f50
commit 442241afa5
  1. 4
      Clover/app/src/main/java/org/floens/chan/ui/text/FastTextView.java

@ -42,7 +42,7 @@ import static org.floens.chan.utils.AndroidUtils.sp;
*/ */
public class FastTextView extends View { public class FastTextView extends View {
private static final String TAG = "FastTextView"; private static final String TAG = "FastTextView";
private static LruCache<Long, StaticLayout> textCache = new LruCache<>(1000); private static LruCache<Long, StaticLayout> textCache = new LruCache<>(250);
private TextPaint paint; private TextPaint paint;
private boolean singleLine; private boolean singleLine;
@ -164,7 +164,7 @@ public class FastTextView extends View {
if (widthMode == MeasureSpec.EXACTLY) { if (widthMode == MeasureSpec.EXACTLY) {
width = widthSize; width = widthSize;
} else if ((widthMode == MeasureSpec.AT_MOST || widthMode == MeasureSpec.UNSPECIFIED) && !TextUtils.isEmpty(text)) { } else if ((widthMode == MeasureSpec.AT_MOST || widthMode == MeasureSpec.UNSPECIFIED) && !TextUtils.isEmpty(text)) {
width = (int) Layout.getDesiredWidth(text, paint) + getPaddingLeft() + getPaddingRight(); width = Math.round(Layout.getDesiredWidth(text, paint) + getPaddingLeft() + getPaddingRight());
if (widthMode == MeasureSpec.AT_MOST) { if (widthMode == MeasureSpec.AT_MOST) {
width = Math.min(width, widthSize); width = Math.min(width, widthSize);
} }

Loading…
Cancel
Save