Open sontqq opened 5 years ago
Before returning at the end of onTouchEvent
refresh the heatmap:
if (event.getAction() == MotionEvent.ACTION_UP)
heatMap.forceRefresh();
Everytime I try to refresh the heatmap I get:
/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sontme.esp.getlocation, PID: 21362
java.lang.NegativeArraySizeException: -8920
However I didn't try to add any negative values. Any idea?
case MotionEvent.ACTION_UP:
heatMap.setMinimum(0.0);
heatMap.setMaximum(10000.0);
HeatMap.DataPoint point = new HeatMap.DataPoint(xrf, yrf, xrf);
heatMap.addData(point);
heatMap.forceRefresh();
break;
Your xrf
and yrf
need divided by 100 to turn them into a decimal percent. The library doesn't do a lot of bounds checking so when it's trying to clip the region it needs to draw to if you have values that are greater than 100% (1.0) it will cause negative values in array sizes and cause the crash you're seeing.
For me, heatMap.forceRefresh(); after heatMap.addData(point); clears the whole canvas except for the point I added recently. How can I add points one after another by touching?
what is the range of the points ? x=670 and y =870 for me
Hey I am trying to add points to the heatmap each time the user touches the screen, but it doesn't work from the @Override public boolean onTouchEvent(MotionEvent event) method. Could anyone help? I've also tried invalidating and refreshing the heatmap without any success.
https://pastebin.com/4mHGyf1y
Here is my code.