pangula / osmdroid

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

New implementation of ResourceProxy #489

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Let's say we want to use a different icon for my location instead of the 
default person.png, but keeping the default direction_arrow.png
So we construct MyLocationNewOverlay and pass to it the new 
org.osmdroid.util.ResourceProxyImpl
But several issues now happen:

- The new ResourceProxyImpl does not have a getBitmap method.
So the MyLocationNewOverlay which uses getBitmap for retrieving its icons, uses 
the default ones (We see the old person.png)

- Even if we implement a getBitmap method (like the previous one):

@Override
public Bitmap getBitmap(final bitmap pResId) {
    final int id = getId("drawable", pResId.name());
    return id != 0 ? BitmapFactory.decodeResource(mResources, id) : super.getBitmap(pResId);
}

The different packages of the org.osmdroid.DefaultResourceProxyImpl and the 
org.osmdroid.util.ResourceProxyImpl cause problem at 
DefaultResourceProxyImpl.getBitmap line 116:
is = getClass().getResourceAsStream(resName)
The getClass() is now the org.osmdroid.util.ResourceProxyImpl and tries to find 
the png at org.osmdroid.util location, where they aren't.

Regards.

Original issue reported on code.google.com by devemu...@gmail.com on 19 Oct 2013 at 2:49

GoogleCodeExporter commented 9 years ago
I'm not sure exactly what this issue is about.  If it's just about the package 
name, would it be enough to just replace getClass() with ResourceProxy.class?

I deliberately didn't implement getBitmap because I had the impression that the 
scaling for different resolutions isn't working as intended.  This 
implementation only uses resources because then it avoids that problem.  Of 
course it contains the base implementation, so if that's broken it should be 
fixed.

It would be better to look for bitmaps a bit more intelligently, as you 
suggested in the discussion group.  Please feel free to suggest a patch :)

Original comment by neilboyd on 27 Oct 2013 at 7:39

GoogleCodeExporter commented 9 years ago
Well it's actually about 2 issues:

1) There is no new implementation of getBitmap, but the osmdroid MyLocation 
overlays use the getBitmap method for retrieving their icons (person, arrow 
etc).
So with the new ResourceProxyImpl we cannot use custom MyLocation icons as the 
called getBitmap always use the super.getBitmap of DefaultResourceProxyImpl.

2) Also if the new ResourceProxyImpl is at different package (as now) vs the 
DefaultResourceProxyImpl, there is always a conflict between them.
That's why I suggested the move of the icons to the root of the project src.
Another fix would be indeed to replace getClass() with ResourceProxy.class

Best regards.

Original comment by devemu...@gmail.com on 28 Oct 2013 at 12:54

GoogleCodeExporter commented 9 years ago
I've done the simple fix in revision 1382.

Original comment by neilboyd on 28 Oct 2013 at 7:32

GoogleCodeExporter commented 9 years ago
Hi,

About (1) are there any thoughts?

Because the lack of getBitmap method at new ResourceProxyImpl
prevents us from using custom icons.

As osmdroid classes use bitmaps and not drawables (e.g. MyLocation overlays).

Best regards, Emux

Original comment by devemu...@gmail.com on 4 Dec 2013 at 7:54

GoogleCodeExporter commented 9 years ago
Hi,

I wanted to attach a patch regarding the missing getBitmap method from the new 
ResourceProxyImpl,
but I cannot because of the message "Issue attachment storage quota exceeded".

I posted at:
https://groups.google.com/forum/#!topic/osmdroid/dGBMkkyZgic

I think it's essential, as right now we cannot use custom icons with osmdroid.

Best regards, Emux
https://play.google.com/store/apps/details?id=gr.talent.cruiser

Original comment by devemu...@gmail.com on 13 Feb 2014 at 8:12

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1432.

Original comment by neilboyd on 16 Feb 2014 at 8:15