wangyao5 / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

do not use getClass() to get the class - use <classname>.class #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In GraphicalView, there are lines like this:
fitZoomImage = 
BitmapFactory.decodeStream(getClass().getResourceAsStream("image/zoom-1.png"));

The problem occurs when someone extends GraphicalView. Now, getClass() resolves 
to the class doing the extending, so getResourceAsStream cannot find the 
requested file (as it exists in GraphicalView's resources, not in the extending 
class's) so it returns null, which in turn causes problems later.

Instead, IMHO the line should look like this:
BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom-1
.png"));

Original issue reported on code.google.com by candrews...@gmail.com on 25 Jul 2011 at 10:28

GoogleCodeExporter commented 9 years ago
Very valid point, thanks!
Fixed in SVN rev. r262.

Original comment by dandrome...@gmail.com on 26 Jul 2011 at 2:29