diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-07-05 18:52:51 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-07-05 18:52:51 +0200 |
| commit | 85f5277e6e4780960b8e028f8a8b717d121ac3be (patch) | |
| tree | 36f047dc47dc05aa86edd505a2c486db2ec0007d /main/src/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java | |
| parent | f4a05a82e889609a743cdb9198b9edf6734fbfe9 (diff) | |
| download | cgeo-85f5277e6e4780960b8e028f8a8b717d121ac3be.zip cgeo-85f5277e6e4780960b8e028f8a8b717d121ac3be.tar.gz cgeo-85f5277e6e4780960b8e028f8a8b717d121ac3be.tar.bz2 | |
fix #2057
* can be reproduced in my emulator with GCH8T5
Diffstat (limited to 'main/src/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java b/main/src/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java new file mode 100644 index 0000000..a0c8b52 --- /dev/null +++ b/main/src/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java @@ -0,0 +1,55 @@ +package cgeo.geocaching.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.TextView; + +/** + * Jelly beans can crash when calculating the layout of a textview. + * + * https://code.google.com/p/android/issues/detail?id=35466 + * + */ +public class IndexOutOfBoundsAvoidingTextView extends TextView { + + public IndexOutOfBoundsAvoidingTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public IndexOutOfBoundsAvoidingTextView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public IndexOutOfBoundsAvoidingTextView(Context context) { + super(context); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + try{ + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } catch (IndexOutOfBoundsException e) { + setText(getText().toString()); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + } + + @Override + public void setGravity(int gravity){ + try{ + super.setGravity(gravity); + } catch (IndexOutOfBoundsException e) { + setText(getText().toString()); + super.setGravity(gravity); + } + } + + @Override + public void setText(CharSequence text, BufferType type) { + try{ + super.setText(text, type); + } catch (IndexOutOfBoundsException e) { + setText(text.toString()); + } + } +}
\ No newline at end of file |
