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

Add some exception handling to OffscreenEditText.java.

parent e105b8c5
...@@ -397,34 +397,48 @@ class OffscreenEditText extends OffscreenView ...@@ -397,34 +397,48 @@ 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()
{ {
int contentHeight; try {
if (single_line_) int contentHeight;
{ if (single_line_)
contentHeight = getHeight(); {
} contentHeight = getHeight();
else }
{ else
int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY); {
int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMinimalTextHeight(), MeasureSpec.UNSPECIFIED); int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
measure(widthMeasureSpec, heightMeasureSpec); int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMinimalTextHeight(), MeasureSpec.UNSPECIFIED);
measure(widthMeasureSpec, heightMeasureSpec);
contentHeight = getMeasuredHeight(); contentHeight = getMeasuredHeight();
} }
if (content_height_ != contentHeight)
if (content_height_ != contentHeight) {
{ content_height_ = contentHeight;
content_height_ = contentHeight; runViewAction(new Runnable() {
runViewAction(new Runnable() { @Override
@Override public void run() {
public void run() { nativeOnContentHeightChanged(getNativePtr(), content_height_);
nativeOnContentHeightChanged(getNativePtr(), content_height_); }
} });
}); }
} 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