Skip to content
This repository was archived by the owner on Jan 10, 2018. It is now read-only.

java.lang.IllegalArgumentException: width and height must be > 0 in AbstractWheelView.recreateAssets #56

Open
riyazJ opened this issue Jul 26, 2015 · 7 comments
Labels

Comments

@riyazJ
Copy link

riyazJ commented Jul 26, 2015

If i set abstractWheel.setCurrentItem(0), I am getting the above error.

07-26 14:39:23.702: W/System.err(23974): java.lang.IllegalArgumentException: width and height must be > 0
07-26 14:39:23.702: W/System.err(23974): at android.graphics.Bitmap.createBitmap(Bitmap.java:638)
07-26 14:39:23.702: W/System.err(23974): at android.graphics.Bitmap.createBitmap(Bitmap.java:620)
07-26 14:39:23.702: W/System.err(23974): at antistatic.spinnerwheel.AbstractWheelView.recreateAssets(AbstractWheelView.java:185)
07-26 14:39:23.712: W/System.err(23974): at antistatic.spinnerwheel.AbstractWheel.onLayout(AbstractWheel.java:457)
07-26 14:39:23.712: W/System.err(23974): at android.view.View.layout(View.java:13856)
07-26 14:39:23.712: W/System.err(23974): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
07-26 14:39:23.712: W/System.err(23974): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1644)
07-26 14:39:23.712: W/System.err(23974): at android.widget.LinearLayout.onLayout(LinearLayout.java:1428)
07-26 14:39:23.712: W/System.err(23974): at android.view.View.layout(View.java:13856)
07-26 14:39:23.712: W/System.err(23974): at android.view.ViewGroup.layout(ViewGroup.java:4424)
07-26 14:39:23.712: W/System.err(23974): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
07-26 14:39:23.722: W/System.err(23974): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
07-26 14:39:23.722: W/System.err(23974): at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
07-26 14:39:23.722: W/System.err(23974): at android.view.View.layout(View.java:13856)
07-26 14:39:23.722: W/System.err(23974): at android.view.ViewGroup.layout(ViewGroup.java:4424)
07-26 14:39:23.722: W/System.err(23974): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
07-26 14:39:23.732: W/System.err(23974): at android.view.View.layout(View.java:13856)
07-26 14:39:23.732: W/System.err(23974): at android.view.ViewGroup.layout(ViewGroup.java:4424)
07-26 14:39:23.732: W/System.err(23974): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
07-26 14:39:23.732: W/System.err(23974): at android.view.View.layout(View.java:13856)
07-26 14:39:23.732: W/System.err(23974): at android.view.ViewGroup.layout(ViewGroup.java:4424)
07-26 14:39:23.732: W/System.err(23974): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
07-26 14:39:23.732: W/System.err(23974): at android.view.View.layout(View.java:13856)
07-26 14:39:23.742: W/System.err(23974): at android.view.ViewGroup.layout(ViewGroup.java:4424)
07-26 14:39:23.742: W/System.err(23974): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1992)
07-26 14:39:23.742: W/System.err(23974): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1813)
07-26 14:39:23.742: W/System.err(23974): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
07-26 14:39:23.742: W/System.err(23974): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
07-26 14:39:23.742: W/System.err(23974): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
07-26 14:39:23.742: W/System.err(23974): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
07-26 14:39:23.742: W/System.err(23974): at android.view.Choreographer.doFrame(Choreographer.java:525)
07-26 14:39:23.742: W/System.err(23974): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)

@ai212983
Copy link
Owner

I'm pretty sure the problem is in your code.
have you tried to set current item programmatically in sample app?

@riyazJ
Copy link
Author

riyazJ commented Jul 28, 2015

yes, getting same error when i setCurrent item to 0 on sample app.

@ai212983 ai212983 added the bug label Jul 28, 2015
@ai212983
Copy link
Owner

I'll try to take a look at it this weekend. Thanks for report.

@riyazJ
Copy link
Author

riyazJ commented Jul 28, 2015

you are welcome buddy

@abhimanyu209
Copy link

I am getting the same issue, im not sure whether its a problem in importing the project, but the WheelHorizontalView is not even inflating in the xml and giving this error.

Also, has the project been put on maven central yet?

@ghost
Copy link

ghost commented Aug 27, 2015

I'm getting the same crash report on a few devices. (LG G2 - Android 4.4.2 and Sony Xperia Z3 - Android 5.1.1)

My app has 400 active users, so it does not occur on every device. I could not reproduce this issue.

@JoelJay
Copy link

JoelJay commented Mar 2, 2016

Edit the recreateAssets() method of AbstractWheelView class like this:

protected void recreateAssets(int width, int height) {
    if(width <= 0 || height <= 0) {
        return;
    }
    mSpinBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    mSeparatorsBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    setSelectorPaintCoeff(0);
}

It works for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants