mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-04 15:44:24 +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);
|
SvgViewManager.setSvgView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDetachedFromWindow() {
|
|
||||||
super.onDetachedFromWindow();
|
|
||||||
SvgViewManager.dropSvgView(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
@@ -97,7 +91,11 @@ public class SvgView extends ViewGroup {
|
|||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
if (mBitmap == null) {
|
if (mBitmap == null) {
|
||||||
mBitmap = getShadowNode().drawOutput();
|
SvgViewShadowNode node = getShadowNode();
|
||||||
|
if (node == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mBitmap = node.drawOutput();
|
||||||
}
|
}
|
||||||
canvas.drawBitmap(mBitmap, 0, 0, null);
|
canvas.drawBitmap(mBitmap, 0, 0, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,12 +50,6 @@ class SvgViewManager extends ViewGroupManager<SvgView> {
|
|||||||
mTagToSvgView.put(svg.getId(), svg);
|
mTagToSvgView.put(svg.getId(), svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dropSvgView(SvgView view) {
|
|
||||||
int tag = view.getId();
|
|
||||||
mTagToShadowNode.remove(tag);
|
|
||||||
mTagToSvgView.remove(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
static @Nullable SvgView getSvgViewByTag(int tag) {
|
static @Nullable SvgView getSvgViewByTag(int tag) {
|
||||||
return mTagToSvgView.get(tag);
|
return mTagToSvgView.get(tag);
|
||||||
@@ -92,4 +86,12 @@ class SvgViewManager extends ViewGroupManager<SvgView> {
|
|||||||
root.invalidate();
|
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