From 21e5d77e85ced10db6fe9c1bf2e0461195e1560c Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 20 Oct 2014 14:18:34 +0300 Subject: Android: Fix more exceptions in ExtractStyle.java on Android L Task-number: QTBUG-40120 Change-Id: I949f19ced4eefcf7a40e64ad63e316765c6f2f48 Reviewed-by: J-P Nurmi --- .../org/qtproject/qt5/android/ExtractStyle.java | 55 +++++++++++++++++----- 1 file changed, 44 insertions(+), 11 deletions(-) (limited to 'src/android') diff --git a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java index 0eda08c9d9..b75dbac4b8 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java +++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java @@ -647,7 +647,8 @@ public class ExtractStyle { GradientDrawable.Orientation orientation=(Orientation) gradientStateClass.getField("mOrientation").get(obj); json.put("orientation",orientation.name()); int [] intArray=(int[]) gradientStateClass.getField("mColors").get(obj); - json.put("colors",getJsonArray(intArray, 0, intArray.length)); + if (intArray != null) + json.put("colors",getJsonArray(intArray, 0, intArray.length)); json.put("positions",getJsonArray((float[]) gradientStateClass.getField("mPositions").get(obj))); json.put("strokeWidth",gradientStateClass.getField("mStrokeWidth").getInt(obj)); json.put("strokeDashWidth",gradientStateClass.getField("mStrokeDashWidth").getFloat(obj)); @@ -1210,9 +1211,17 @@ public class ExtractStyle { json.put("TextView_drawableEnd", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableEnd", null)); else if (attr == TextView_drawablePadding) json.put("TextView_drawablePadding", a.getDimensionPixelSize(attr, 0)); - else if (attr == TextView_textCursorDrawable) - json.put("TextView_textCursorDrawable", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textCursorDrawable", null)); - else if (attr == TextView_maxLines) + else if (attr == TextView_textCursorDrawable) { + try { + json.put("TextView_textCursorDrawable", getDrawable(a.getDrawable(attr), styleName + "_TextView_textCursorDrawable", null)); + } catch (Exception e_) { + try { + json.put("TextView_textCursorDrawable", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textCursorDrawable", null)); + } catch (Exception e) { + e.printStackTrace(); + } + } + }else if (attr == TextView_maxLines) json.put("TextView_maxLines", a.getInt(attr, -1)); else if (attr == TextView_maxHeight) json.put("TextView_maxHeight", a.getDimensionPixelSize(attr, -1)); @@ -1300,13 +1309,37 @@ public class ExtractStyle { json.put("TextView_imeActionId", a.getInt(attr,0)); else if (attr == TextView_privateImeOptions) json.put("TextView_privateImeOptions", a.getString(attr)); - else if (attr == TextView_textSelectHandleLeft && styleName.equals("textViewStyle")) - json.put("TextView_textSelectHandleLeft", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandleLeft", null)); - else if (attr == TextView_textSelectHandleRight && styleName.equals("textViewStyle")) - json.put("TextView_textSelectHandleRight", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandleRight", null)); - else if (attr == TextView_textSelectHandle && styleName.equals("textViewStyle")) - json.put("TextView_textSelectHandle", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandle", null)); - else if (attr == TextView_textIsSelectable) + else if (attr == TextView_textSelectHandleLeft && styleName.equals("textViewStyle")) { + try { + json.put("TextView_textSelectHandleLeft", getDrawable(a.getDrawable(attr), styleName + "_TextView_textSelectHandleLeft", null)); + } catch (Exception _e) { + try { + json.put("TextView_textSelectHandleLeft", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandleLeft", null)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else if (attr == TextView_textSelectHandleRight && styleName.equals("textViewStyle")) { + try { + json.put("TextView_textSelectHandleRight", getDrawable(a.getDrawable(attr), styleName + "_TextView_textSelectHandleRight", null)); + } catch (Exception _e) { + try { + json.put("TextView_textSelectHandleRight", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandleRight", null)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else if (attr == TextView_textSelectHandle && styleName.equals("textViewStyle")) { + try { + json.put("TextView_textSelectHandle", getDrawable(a.getDrawable(attr), styleName + "_TextView_textSelectHandle", null)); + } catch (Exception _e) { + try { + json.put("TextView_textSelectHandle", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandle", null)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else if (attr == TextView_textIsSelectable) json.put("TextView_textIsSelectable", a.getBoolean(attr, false)); else if (attr == TextView_textAllCaps) allCaps = a.getBoolean(attr, false); -- cgit v1.2.3