Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception: java.lang.NegativeArraySizeException for 2.3.+ #159

Closed
omrimor1 opened this issue Jun 6, 2014 · 6 comments
Closed

Fatal Exception: java.lang.NegativeArraySizeException for 2.3.+ #159

omrimor1 opened this issue Jun 6, 2014 · 6 comments

Comments

@omrimor1
Copy link

omrimor1 commented Jun 6, 2014

java.lang.NegativeArraySizeException
at com.jjoe64.graphview.GraphView.generateVerlabels(GraphView.java:529)
at com.jjoe64.graphview.GraphView.access$9(GraphView.java:521)
at com.jjoe64.graphview.GraphView$GraphViewContentView.onDraw(GraphView.java:110)
at android.view.View.draw(View.java:7080)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.support.v4.view.ViewPager.draw(ViewPager.java:2171)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2119)
at android.view.ViewRoot.draw(ViewRoot.java:1540)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1276)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(NativeStart.java)

@jjoe64
Copy link
Owner

jjoe64 commented Jun 6, 2014

Please provide more information about your programm. How is your layout?
How do you create the graph view? Etc
Am 06.06.2014 14:33 schrieb "omrimor1" notifications@github.com:

java.lang.NegativeArraySizeException
at com.jjoe64.graphview.GraphView.generateVerlabels(GraphView.java:529)
at com.jjoe64.graphview.GraphView.access$9(GraphView.java:521)
at
com.jjoe64.graphview.GraphView$GraphViewContentView.onDraw(GraphView.java:110)
at android.view.View.draw(View.java:7080)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.support.v4.view.ViewPager.draw(ViewPager.java:2171)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:7083)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2119)
at android.view.ViewRoot.draw(ViewRoot.java:1540)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1276)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:507)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(NativeStart.java)


Reply to this email directly or view it on GitHub
#159.

@omrimor1
Copy link
Author

omrimor1 commented Jun 6, 2014

Layout:

<LinearLayout
    android:id="@+id/graph1"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/graph_size"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:orientation="vertical" >

    <TextView
        (Text above the graph)
        android:id="@+id/tvBuyTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

    <ProgressBar
        android:id="@+id/graphProgress"
        style="?android:attr/progressBarStyleLargeInverse"
        android:layout_width="wrap_content"
        android:layout_height="0dip"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:visibility="gone" />
</LinearLayout>

Creating the graph:

GraphViewData[] data = new GraphViewData[total];
for (int i = 0; i < total; i++) {
try {
ja = resultArray.getJSONArray(i);
data[i] = new GraphViewData(ja.getInt(0), ja.getDouble(1));
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}

LineGraphView graphView = new LineGraphView(getActivity(), "");
graphView.addSeries(new GraphViewSeries(data));
graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
@OverRide
public String formatLabel(double value, boolean isValueX) {
if (!isValueX) {
if (type_background.equals(Constants.Btc_China)) {
return String.format("%.2f", value)
+ Constants.currency_china;
} else {
return Constants.currency_dollar
+ String.format("%.2f", value);
}
} else {
// For x, don't show anything
return "";
}
}
});
// Make the graph with no horizontal labels
graphView.getGraphViewStyle().setNumHorizontalLabels(1);

Hope that helps,
Thanks!

@MarcDahlem
Copy link

Take a look at #118

You have to set NumVerticalLabels as well...Otherwise there is an integer overflow.

@jjoe64
Copy link
Owner

jjoe64 commented Jul 25, 2014

is this problem still there?

@MarcDahlem
Copy link

I didn't check it by myself, but the error shown above is exactly the same...

@omrimor1
Copy link
Author

Thanks, that fixed the problem!

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

No branches or pull requests

3 participants