diff --git a/doric-android/app/src/main/java/pub/doric/demo/DoricSSRActivity.java b/doric-android/app/src/main/java/pub/doric/demo/DoricSSRActivity.java index 4367f35a..dde22d56 100644 --- a/doric-android/app/src/main/java/pub/doric/demo/DoricSSRActivity.java +++ b/doric-android/app/src/main/java/pub/doric/demo/DoricSSRActivity.java @@ -61,10 +61,11 @@ public class DoricSSRActivity extends AppCompatActivity { ViewGroup.LayoutParams.WRAP_CONTENT)); doricNavBar.setRight(textView); final DoricPanel doricPanel = findViewById(R.id.doric_panel); - RootNode rootNode = new RootNode(DoricContext.MOCK_CONTEXT); + DoricContext doricContext = DoricContext.create(this, "", "", ""); + RootNode rootNode = new RootNode(doricContext); rootNode.setRootView(doricPanel); String filePath = getIntent().getStringExtra("file"); - String json = DoricUtils.readAssetFile("src/"+filePath); + String json = DoricUtils.readAssetFile("src/" + filePath); try { long start = System.currentTimeMillis(); JSONObject jsonObject = new JSONObject(json); @@ -76,6 +77,8 @@ public class DoricSSRActivity extends AppCompatActivity { Log.d("Timing", "SSR cost " + (System.currentTimeMillis() - start) + " ms"); } catch (Exception e) { e.printStackTrace(); + } finally { + doricContext.teardown(); } } } diff --git a/doric-android/doric/src/main/java/pub/doric/DoricContext.java b/doric-android/doric/src/main/java/pub/doric/DoricContext.java index b469738a..7d02ce17 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricContext.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricContext.java @@ -17,7 +17,6 @@ package pub.doric; import android.animation.Animator; import android.animation.AnimatorSet; -import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.text.TextUtils; @@ -72,8 +71,6 @@ public class DoricContext { private final Map animators = new HashMap<>(); private final Map cachedResources = new WeakHashMap<>(); private final Set> retainedJavaValues = new HashSet<>(); - @SuppressLint("StaticFieldLeak") - public static final DoricContext MOCK_CONTEXT = new DoricContext(Doric.application(), "", "", ""); public Collection> allHeadNodes(String type) { Map> headNode = mHeadNodes.get(type);