I'm getting a few exception reports coming in from my app caused by the RuntimeException
thrown from a custom UI component class I'm using. Here is the code (credit for this code goes to this post):
public class WrapingSlidingDrawer extends SlidingDrawer {
public WrapingSlidingDrawer(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
int orientation = attrs.getAttributeIntValue("android", "orientation", ORIENTATION_VERTICAL);
mTopOffset = attrs.getAttributeIntValue("android", "topOffset", 0);
mVertical = (orientation == SlidingDrawer.ORIENTATION_VERTICAL);
}
public WrapingSlidingDrawer(Context context, AttributeSet attrs)
{
super(context, attrs);
int orientation = attrs.getAttributeIntValue("android", "orientation", ORIENTATION_VERTICAL);
mTopOffset = attrs.getAttributeIntValue("android", "topOffset", 0);
mVertical = (orientation == SlidingDrawer.ORIENTATION_VERTICAL);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
if (widthSpecMode == MeasureSpec.UNSPECIFIED || heightSpecMode == MeasureSpec.UNSPECIFIED)
{
throw new RuntimeException("SlidingDrawer cannot have UNSPECIFIED dimensions");
}
and here is the declaritive XML I'm using:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/customDrawerLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<com.package.WrapingSlidingDrawer
android:id="@+id/slidingDrawer"
android:handle="@+id/Handle"
android:content="@+id/contentLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
Both the custom sliding drawer and parent both specify layout width and height attributes. Therefore, any ideas on what could cause UNSPECIFIED to show up? Its happening very rarely.