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

Don't recycle bitmap for icon reuse. #9966

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}