mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-03 23:16:13 +00:00
Let SvgViewManager handle removing node and view references.
This commit is contained in:
@@ -78,12 +78,6 @@ public class SvgView extends ViewGroup {
|
||||
SvgViewManager.setSvgView(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
SvgViewManager.dropSvgView(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
@@ -97,7 +91,11 @@ public class SvgView extends ViewGroup {
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (mBitmap == null) {
|
||||
mBitmap = getShadowNode().drawOutput();
|
||||
SvgViewShadowNode node = getShadowNode();
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
mBitmap = node.drawOutput();
|
||||
}
|
||||
canvas.drawBitmap(mBitmap, 0, 0, null);
|
||||
}
|
||||
|
||||
@@ -50,12 +50,6 @@ class SvgViewManager extends ViewGroupManager<SvgView> {
|
||||
mTagToSvgView.put(svg.getId(), svg);
|
||||
}
|
||||
|
||||
static void dropSvgView(SvgView view) {
|
||||
int tag = view.getId();
|
||||
mTagToShadowNode.remove(tag);
|
||||
mTagToSvgView.remove(tag);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
static @Nullable SvgView getSvgViewByTag(int tag) {
|
||||
return mTagToSvgView.get(tag);
|
||||
@@ -92,4 +86,12 @@ class SvgViewManager extends ViewGroupManager<SvgView> {
|
||||
root.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropViewInstance(SvgView view) {
|
||||
super.onDropViewInstance(view);
|
||||
|
||||
int tag = view.getId();
|
||||
mTagToShadowNode.remove(tag);
|
||||
mTagToSvgView.remove(tag);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user