Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - don't recycle bitmap for icon reuse.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Sep 12, 2017
1 parent 738f682 commit 8e01f52
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.maps;

import android.graphics.Bitmap;
import android.os.Build;

import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Icon;
Expand Down Expand Up @@ -143,7 +142,7 @@ private void setTopOffsetPixels(Marker marker, MapboxMap mapboxMap, Icon icon) {
}
}

public void iconCleanup(Icon icon) {
void iconCleanup(Icon icon) {
int refCounter = iconMap.get(icon) - 1;
if (refCounter == 0) {
remove(icon);
Expand All @@ -155,18 +154,10 @@ public void iconCleanup(Icon icon) {
private void remove(Icon icon) {
nativeMapView.removeAnnotationIcon(icon.getId());
iconMap.remove(icon);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
recycleBitmap(icon.getBitmap());
}
}

private void updateIconRefCounter(Icon icon, int refCounter) {
iconMap.put(icon, refCounter);
}

private void recycleBitmap(Bitmap bitmap) {
if (!bitmap.isRecycled()) {
bitmap.recycle();
}
}
}

0 comments on commit 8e01f52

Please sign in to comment.