1public class AMapCustomStyleLoader {
2
3 private byte[] buffStyle = null;
4 private byte[] buffStyleExtra = null;
5
6 @SuppressWarnings("ResultOfMethodCallIgnored")
7 public AMapCustomStyleLoader(String stylePath, String styleExtraPath, AssetManager assetManager) {
8 InputStream inputStreamStyle = null;
9 InputStream inputStreamStyleExtra = null;
10 try {
11 inputStreamStyle = assetManager.open(stylePath);
12 int lenStyle = inputStreamStyle.available();
13 buffStyle = new byte[lenStyle];
14 inputStreamStyle.read(buffStyle);
15 inputStreamStyleExtra = assetManager.open(styleExtraPath);
16 int lenStyleExtra = inputStreamStyle.available();
17 buffStyleExtra = new byte[lenStyleExtra];
18 inputStreamStyleExtra.read(buffStyleExtra);
19 } catch (IOException e) {
20 e.printStackTrace();
21 } finally {
22 try {
23 if (inputStreamStyle != null) inputStreamStyle.close();
24 if (inputStreamStyleExtra != null) inputStreamStyleExtra.close();
25 } catch (IOException e) {
26 e.printStackTrace();
27 }
28 }
29 }
30
31 public byte[] getStyle() {
32 return buffStyle;
33 }
34
35 public byte[] getStyleExtra() {
36 return buffStyleExtra;
37 }
38}