15
15
*/
16
16
package com .google .maps .android .data .kml ;
17
17
18
+ import android .content .Context ;
18
19
import android .graphics .Bitmap ;
19
20
import android .graphics .BitmapFactory ;
20
21
import android .util .Log ;
21
22
23
+ import androidx .annotation .RawRes ;
22
24
import androidx .fragment .app .FragmentActivity ;
23
25
24
26
import com .google .android .gms .maps .GoogleMap ;
27
29
import com .google .maps .android .collections .MarkerManager ;
28
30
import com .google .maps .android .collections .PolygonManager ;
29
31
import com .google .maps .android .collections .PolylineManager ;
32
+ import com .google .maps .android .data .Renderer ;
30
33
31
34
import org .xmlpull .v1 .XmlPullParser ;
32
35
import org .xmlpull .v1 .XmlPullParserException ;
@@ -51,13 +54,13 @@ public class KmlLayer extends Layer {
51
54
*
52
55
* @param map GoogleMap object
53
56
* @param resourceId Raw resource KML or KMZ file
54
- * @param activity Activity object
57
+ * @param context The Context
55
58
* @throws XmlPullParserException if file cannot be parsed
56
59
* @throws IOException if I/O error
57
60
*/
58
- public KmlLayer (GoogleMap map , int resourceId , FragmentActivity activity )
61
+ public KmlLayer (GoogleMap map , int resourceId , Context context )
59
62
throws XmlPullParserException , IOException {
60
- this (map , activity .getResources ().openRawResource (resourceId ), activity , new MarkerManager (map ), new PolygonManager (map ), new PolylineManager (map ), new GroundOverlayManager (map ));
63
+ this (map , context .getResources ().openRawResource (resourceId ), context , new MarkerManager (map ), new PolygonManager (map ), new PolylineManager (map ), new GroundOverlayManager (map ), null );
61
64
}
62
65
63
66
/**
@@ -67,13 +70,13 @@ public KmlLayer(GoogleMap map, int resourceId, FragmentActivity activity)
67
70
*
68
71
* @param map GoogleMap object
69
72
* @param stream InputStream containing KML or KMZ file
70
- * @param activity Activity object
73
+ * @param context The Context
71
74
* @throws XmlPullParserException if file cannot be parsed
72
75
* @throws IOException if I/O error
73
76
*/
74
- public KmlLayer (GoogleMap map , InputStream stream , FragmentActivity activity )
77
+ public KmlLayer (GoogleMap map , InputStream stream , Context context )
75
78
throws XmlPullParserException , IOException {
76
- this (map , stream , activity , new MarkerManager (map ), new PolygonManager (map ), new PolylineManager (map ), new GroundOverlayManager (map ));
79
+ this (map , stream , context , new MarkerManager (map ), new PolygonManager (map ), new PolylineManager (map ), new GroundOverlayManager (map ), null );
77
80
}
78
81
79
82
/**
@@ -86,17 +89,25 @@ public KmlLayer(GoogleMap map, InputStream stream, FragmentActivity activity)
86
89
*
87
90
* @param map GoogleMap object
88
91
* @param resourceId Raw resource KML or KMZ file
89
- * @param activity Activity object
92
+ * @param context The Context
90
93
* @param markerManager marker manager to create marker collection from
91
94
* @param polygonManager polygon manager to create polygon collection from
92
95
* @param polylineManager polyline manager to create polyline collection from
93
96
* @param groundOverlayManager ground overlay manager to create ground overlay collection from
97
+ * @param cache cache to be used for fetched images
94
98
* @throws XmlPullParserException if file cannot be parsed
95
99
* @throws IOException if I/O error
96
100
*/
97
- public KmlLayer (GoogleMap map , int resourceId , FragmentActivity activity , MarkerManager markerManager , PolygonManager polygonManager , PolylineManager polylineManager , GroundOverlayManager groundOverlayManager )
101
+ public KmlLayer (GoogleMap map ,
102
+ @ RawRes int resourceId ,
103
+ Context context ,
104
+ MarkerManager markerManager ,
105
+ PolygonManager polygonManager ,
106
+ PolylineManager polylineManager ,
107
+ GroundOverlayManager groundOverlayManager ,
108
+ Renderer .ImagesCache cache )
98
109
throws XmlPullParserException , IOException {
99
- this (map , activity .getResources ().openRawResource (resourceId ), activity , markerManager , polygonManager , polylineManager , groundOverlayManager );
110
+ this (map , context .getResources ().openRawResource (resourceId ), context , markerManager , polygonManager , polylineManager , groundOverlayManager , cache );
100
111
}
101
112
102
113
/**
@@ -109,20 +120,28 @@ public KmlLayer(GoogleMap map, int resourceId, FragmentActivity activity, Marker
109
120
*
110
121
* @param map GoogleMap object
111
122
* @param stream InputStream containing KML or KMZ file
112
- * @param activity Activity object
123
+ * @param context The Context
113
124
* @param markerManager marker manager to create marker collection from
114
125
* @param polygonManager polygon manager to create polygon collection from
115
126
* @param polylineManager polyline manager to create polyline collection from
116
127
* @param groundOverlayManager ground overlay manager to create ground overlay collection from
128
+ * @param cache cache to be used for fetched images
117
129
* @throws XmlPullParserException if file cannot be parsed
118
130
* @throws IOException if I/O error
119
131
*/
120
- public KmlLayer (GoogleMap map , InputStream stream , FragmentActivity activity , MarkerManager markerManager , PolygonManager polygonManager , PolylineManager polylineManager , GroundOverlayManager groundOverlayManager )
132
+ public KmlLayer (GoogleMap map ,
133
+ InputStream stream ,
134
+ Context context ,
135
+ MarkerManager markerManager ,
136
+ PolygonManager polygonManager ,
137
+ PolylineManager polylineManager ,
138
+ GroundOverlayManager groundOverlayManager ,
139
+ Renderer .ImagesCache cache )
121
140
throws XmlPullParserException , IOException {
122
141
if (stream == null ) {
123
142
throw new IllegalArgumentException ("KML InputStream cannot be null" );
124
143
}
125
- KmlRenderer renderer = new KmlRenderer (map , activity , markerManager , polygonManager , polylineManager , groundOverlayManager );
144
+ KmlRenderer renderer = new KmlRenderer (map , context , markerManager , polygonManager , polylineManager , groundOverlayManager , cache );
126
145
127
146
BufferedInputStream bis = new BufferedInputStream (stream );
128
147
bis .mark (1024 );
0 commit comments