sulewicz / springlayout

RelativeLayout on steroids.
MIT License
79 stars 15 forks source link

UnsupportedOperationException #6

Open westito opened 9 years ago

westito commented 9 years ago

I get this exception from IntelliJ editor. The most weird thing is, there is no StringBuilder.append in cacheLayoutPositions()!

java.lang.UnsupportedOperationException at android.content.res.BridgeResources.getResourceTypeName(BridgeResources.java:485) at android.view.View.toString(View.java:4295) at java.lang.String.valueOf(String.java:2981) at java.lang.StringBuilder.append(StringBuilder.java:131) at org.coderoller.springlayout.SpringLayout.cacheLayoutPositions(SpringLayout.java:595) at org.coderoller.springlayout.SpringLayout.onMeasure(SpringLayout.java:393) at android.view.View.measure(View.java:17430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.view.View.measure(View.java:17430) at android.widget.LinearLayout.measureVertical(LinearLayout.java:875) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17430) at android.widget.LinearLayout.measureVertical(LinearLayout.java:875) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17430)

sulewicz commented 9 years ago

Hi!

Thank you for the bug report! Well, StringBuilder.append() is used - string concatenation with + operator is actually expanded to StringBuilder.append(). Seems that this is an issue with Android Studio / IntelliJ, someone already reported this: https://code.google.com/p/android/issues/detail?id=55626. Anyway, I'll try to find some workaround. If everything was normal, you would get "Horizontal weight defined but never used, please review your layout. (...)" exception :).

Cheers! Sz

westito commented 9 years ago

Mybe I can help.

@Override public String getResourceTypeName(int resid) throws NotFoundException { throw new UnsupportedOperationException(); }

View.toString() contains a call to this bridged method. The solution is, do not use the "+ v +". Maybe getId or somethin would be better.

The reported exception only showing when I assign an ID to the springlayout. If I remove the ID, the correct "weight defined but..." error appears.

Anyway, showing the ID of a view would make more readable exceptions.