Commit 9451e94f authored by Sergey Galin's avatar Sergey Galin

Add some exception handling to OffscreenEditText.java.

parent e105b8c5
...@@ -397,11 +397,24 @@ class OffscreenEditText extends OffscreenView ...@@ -397,11 +397,24 @@ class OffscreenEditText extends OffscreenView
private int getMinimalTextHeight() private int getMinimalTextHeight()
{ {
return (new StaticLayout(getText(), getPaint(), getWidth() - getTotalPaddingRight() - getTotalPaddingLeft(), Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true)).getHeight(); try {
return (new StaticLayout(
getText(),
getPaint(),
getWidth() - getTotalPaddingRight() - getTotalPaddingLeft(),
Alignment.ALIGN_NORMAL,
1.0f,
0.0f,
true)).getHeight();
} catch (final Throwable e) {
Log.e(TAG, "getMinimalTextHeight exception: " + e);
return 0;
}
} }
private void updateContentHeight() private void updateContentHeight()
{ {
try {
int contentHeight; int contentHeight;
if (single_line_) if (single_line_)
{ {
...@@ -412,10 +425,8 @@ class OffscreenEditText extends OffscreenView ...@@ -412,10 +425,8 @@ class OffscreenEditText extends OffscreenView
int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY); int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMinimalTextHeight(), MeasureSpec.UNSPECIFIED); int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMinimalTextHeight(), MeasureSpec.UNSPECIFIED);
measure(widthMeasureSpec, heightMeasureSpec); measure(widthMeasureSpec, heightMeasureSpec);
contentHeight = getMeasuredHeight(); contentHeight = getMeasuredHeight();
} }
if (content_height_ != contentHeight) if (content_height_ != contentHeight)
{ {
content_height_ = contentHeight; content_height_ = contentHeight;
...@@ -426,6 +437,9 @@ class OffscreenEditText extends OffscreenView ...@@ -426,6 +437,9 @@ class OffscreenEditText extends OffscreenView
} }
}); });
} }
} catch (final Throwable e) {
Log.e(TAG, "updateContentHeight exception: " + e);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment