android: create empty doric context instead of static one
This commit is contained in:
		| @@ -61,10 +61,11 @@ public class DoricSSRActivity extends AppCompatActivity { | |||||||
|                 ViewGroup.LayoutParams.WRAP_CONTENT)); |                 ViewGroup.LayoutParams.WRAP_CONTENT)); | ||||||
|         doricNavBar.setRight(textView); |         doricNavBar.setRight(textView); | ||||||
|         final DoricPanel doricPanel = findViewById(R.id.doric_panel); |         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); |         rootNode.setRootView(doricPanel); | ||||||
|         String filePath = getIntent().getStringExtra("file"); |         String filePath = getIntent().getStringExtra("file"); | ||||||
|         String json = DoricUtils.readAssetFile("src/"+filePath); |         String json = DoricUtils.readAssetFile("src/" + filePath); | ||||||
|         try { |         try { | ||||||
|             long start = System.currentTimeMillis(); |             long start = System.currentTimeMillis(); | ||||||
|             JSONObject jsonObject = new JSONObject(json); |             JSONObject jsonObject = new JSONObject(json); | ||||||
| @@ -76,6 +77,8 @@ public class DoricSSRActivity extends AppCompatActivity { | |||||||
|             Log.d("Timing", "SSR cost " + (System.currentTimeMillis() - start) + " ms"); |             Log.d("Timing", "SSR cost " + (System.currentTimeMillis() - start) + " ms"); | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             e.printStackTrace(); |             e.printStackTrace(); | ||||||
|  |         } finally { | ||||||
|  |             doricContext.teardown(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ package pub.doric; | |||||||
|  |  | ||||||
| import android.animation.Animator; | import android.animation.Animator; | ||||||
| import android.animation.AnimatorSet; | import android.animation.AnimatorSet; | ||||||
| import android.annotation.SuppressLint; |  | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.content.Intent; | import android.content.Intent; | ||||||
| import android.text.TextUtils; | import android.text.TextUtils; | ||||||
| @@ -72,8 +71,6 @@ public class DoricContext { | |||||||
|     private final Map<String, Animator> animators = new HashMap<>(); |     private final Map<String, Animator> animators = new HashMap<>(); | ||||||
|     private final Map<String, DoricResource> cachedResources = new WeakHashMap<>(); |     private final Map<String, DoricResource> cachedResources = new WeakHashMap<>(); | ||||||
|     private final Set<SoftReference<RetainedJavaValue>> retainedJavaValues = new HashSet<>(); |     private final Set<SoftReference<RetainedJavaValue>> retainedJavaValues = new HashSet<>(); | ||||||
|     @SuppressLint("StaticFieldLeak") |  | ||||||
|     public static final DoricContext MOCK_CONTEXT = new DoricContext(Doric.application(), "", "", ""); |  | ||||||
|  |  | ||||||
|     public Collection<ViewNode<?>> allHeadNodes(String type) { |     public Collection<ViewNode<?>> allHeadNodes(String type) { | ||||||
|         Map<String, ViewNode<?>> headNode = mHeadNodes.get(type); |         Map<String, ViewNode<?>> headNode = mHeadNodes.get(type); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user