Silambarasanezeid / androidsvg

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

Enhancements: SVGImageView - Define an asset attribute and cache drawables. #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. My app uses a number of svg images, some of them in several places. All of 
them are use an asset.

What is the expected output? What do you see instead?

The app takes a performance hit. SVG images load slowly.

What version of the product are you using? On what operating system?

Version 1.2 (hg clone).

Please provide any additional information below.

My suggestion is that an "asset" attribute is defined to go along with the 
standard "svg" attribute. "asset" should be set to override "svg". When 
specified the SVGImageView should bypass the Resource and InternalURI logic and 
load the image straight from the asset. Gains a little speed and makes the use 
of the View in the layout more logical.

As far as caching is concerned, I have implemented a solution using a "cache" 
(boolean) attribute and an internal HashMap which caches the Drawable with the 
"svg" or "asset" attribute value as the key.

The first time a particular asset (resource or URI) is used with "cache" set to 
true the drawable is created and stored in the HashMap. The next time an 
SVGImageView accesses the same "asset" (again with "cache" set to true) we 
simply pull the stored drawable.

This introduces a significant speed boost. Find the modified SVGImageView.java 
file attached.

Original issue reported on code.google.com by a...@spoton.com on 6 Nov 2013 at 5:30

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by paul.leb...@gmail.com on 7 Nov 2013 at 4:53

GoogleCodeExporter commented 9 years ago

Original comment by paul.leb...@gmail.com on 7 Nov 2013 at 4:53