[android] #3276 - only update thumb Icon when needed, disabled background task for now, added view pool counter

This commit is contained in:
Tobrun
2016-05-10 16:41:34 +02:00
parent bdff43ba95
commit 8e57b455c5
4 changed files with 48 additions and 23 deletions

View File

@@ -250,8 +250,6 @@ public class MapView extends FrameLayout {
if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
mMapboxMap.getUiSettings().setZoomControlsEnabled(true);
}
}
private void setInitialState(MapboxMapOptions options) {
@@ -479,19 +477,19 @@ public class MapView extends FrameLayout {
}
mViewMarkerBoundsUpdateTime = currentTime + 300;
new ViewMarkerInBoundsTask().execute();
}
// new ViewMarkerInBoundsTask().execute();
// }
public class ViewMarkerInBoundsTask extends AsyncTask<Void, Void, ViewMarkerInBoundsTask.Result> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// public class ViewMarkerInBoundsTask extends AsyncTask<Void, Void, ViewMarkerInBoundsTask.Result> {
//
// @Override
// protected void onPreExecute() {
// super.onPreExecute();
mViewMarkersUpdateRunning = true;
}
// }
@Override
protected Result doInBackground(Void... params) {
// @Override
// protected Result doInBackground(Void... params) {
List<Marker> inBounds = new ArrayList<>();
Map<Marker, View> outBounds = new HashMap<>();
@@ -544,13 +542,14 @@ public class MapView extends FrameLayout {
}
}
}
Result result = new Result(inBounds, outBounds);
return new Result(inBounds, outBounds);
}
// return new Result(inBounds, outBounds);
// }
@Override
protected void onPostExecute(Result result) {
super.onPostExecute(result);
// @Override
// protected void onPostExecute(Result result) {
// super.onPostExecute(result);
mMapboxMap.setViewMarkersBoundsTaskResult(result);
mViewMarkersUpdateRunning = false;
Log.v(MapboxConstants.TAG, "Amount of child views " + getChildCount());
@@ -573,7 +572,7 @@ public class MapView extends FrameLayout {
return outBounds;
}
}
}
// }
/**
* You must call this method from the parent's {@link android.app.Activity#onSaveInstanceState(Bundle)}

View File

@@ -638,7 +638,7 @@ public class MapboxMap {
// Annotations
//
void setViewMarkersBoundsTaskResult(MapView.ViewMarkerInBoundsTask.Result result) {
void setViewMarkersBoundsTaskResult(MapView.Result result) {
Map<Marker, View> outBoundsMarker = result.getOutBounds();
View convertView;
@@ -660,11 +660,13 @@ public class MapboxMap {
if (adaptedView != null) {
// hack to hide old marker, todo replace with visibility
Icon icon = marker.getIcon();
if(mViewMarkerBitmap==null){
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
mViewMarkerBitmap = Bitmap.createBitmap(icon.getBitmap().getWidth(), icon.getBitmap().getHeight(), conf);
if(!icon.getBitmap().equals(mViewMarkerBitmap)) {
if (mViewMarkerBitmap == null) {
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
mViewMarkerBitmap = Bitmap.createBitmap(icon.getBitmap().getWidth(), icon.getBitmap().getHeight(), conf);
}
marker.setIcon(IconFactory.recreate(icon.getId(), mViewMarkerBitmap));
}
marker.setIcon(IconFactory.recreate(icon.getId(), mViewMarkerBitmap));
adaptedView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {