@quicktvui/ai 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/package.json +1 -1
  2. package/rules/.clinerules +27 -4
  3. package/rules/.cursorrules +27 -4
  4. package/rules/.github/copilot-instructions.md +27 -4
  5. package/rules/.source/hippy/extend_views/CoverFlowHorizontalView.java +203 -0
  6. package/rules/.source/hippy/extend_views/CoverFlowVerticalView.java +203 -0
  7. package/rules/.source/hippy/extend_views/CoverFlowViewController.java +195 -0
  8. package/rules/.source/hippy/extend_views/EngineRootView.java +125 -0
  9. package/rules/.source/hippy/extend_views/ExtendTag.java +83 -0
  10. package/rules/.source/hippy/extend_views/FocusSearchHelper.java +124 -0
  11. package/rules/.source/hippy/extend_views/IRecyclerItemView.java +12 -0
  12. package/rules/.source/hippy/extend_views/JSEventHandleView.java +5 -0
  13. package/rules/.source/hippy/extend_views/MarqueeRelayManager.java +133 -0
  14. package/rules/.source/hippy/extend_views/MarqueeRelayTextView.java +211 -0
  15. package/rules/.source/hippy/extend_views/ProgressBarView.java +83 -0
  16. package/rules/.source/hippy/extend_views/ProgressBarViewController.java +145 -0
  17. package/rules/.source/hippy/extend_views/SeekBarView.java +104 -0
  18. package/rules/.source/hippy/extend_views/SeekBarViewController.java +218 -0
  19. package/rules/.source/hippy/extend_views/StateImageView.java +149 -0
  20. package/rules/.source/hippy/extend_views/StateImageViewController.java +34 -0
  21. package/rules/.source/hippy/extend_views/TVButtonView.java +314 -0
  22. package/rules/.source/hippy/extend_views/TVButtonViewController.java +89 -0
  23. package/rules/.source/hippy/extend_views/TVTextView.java +684 -0
  24. package/rules/.source/hippy/extend_views/TVViewActor.java +811 -0
  25. package/rules/.source/hippy/extend_views/TVViewActorHost.java +6 -0
  26. package/rules/.source/hippy/extend_views/TVViewActor/346/216/245/345/205/245.md +66 -0
  27. package/rules/.source/hippy/extend_views/TemplateUtil.java +336 -0
  28. package/rules/.source/hippy/extend_views/TextButtonNode.java +47 -0
  29. package/rules/.source/hippy/extend_views/TextViewController.java +377 -0
  30. package/rules/.source/hippy/extend_views/fastlist/CenterFlyInAnimator.java +96 -0
  31. package/rules/.source/hippy/extend_views/fastlist/ChildOnScreenScroller.java +548 -0
  32. package/rules/.source/hippy/extend_views/fastlist/ClonedViewTag.java +17 -0
  33. package/rules/.source/hippy/extend_views/fastlist/EventDeliverer.java +55 -0
  34. package/rules/.source/hippy/extend_views/fastlist/FastAdapter.java +4683 -0
  35. package/rules/.source/hippy/extend_views/fastlist/FastAdapterUtil.java +982 -0
  36. package/rules/.source/hippy/extend_views/fastlist/FastFlexNode.java +48 -0
  37. package/rules/.source/hippy/extend_views/fastlist/FastFlexView.java +873 -0
  38. package/rules/.source/hippy/extend_views/fastlist/FastFlexViewController.java +130 -0
  39. package/rules/.source/hippy/extend_views/fastlist/FastItemNode.java +67 -0
  40. package/rules/.source/hippy/extend_views/fastlist/FastItemView.java +306 -0
  41. package/rules/.source/hippy/extend_views/fastlist/FastItemViewController.java +106 -0
  42. package/rules/.source/hippy/extend_views/fastlist/FastListModule.java +95 -0
  43. package/rules/.source/hippy/extend_views/fastlist/FastListNode.java +90 -0
  44. package/rules/.source/hippy/extend_views/fastlist/FastListView.java +2466 -0
  45. package/rules/.source/hippy/extend_views/fastlist/FastListViewController.java +1038 -0
  46. package/rules/.source/hippy/extend_views/fastlist/FastListView/346/270/262/346/237/223/346/265/201/347/250/213/345/233/276.graffle +0 -0
  47. package/rules/.source/hippy/extend_views/fastlist/FastPendingView.java +47 -0
  48. package/rules/.source/hippy/extend_views/fastlist/ItemDecorations.java +71 -0
  49. package/rules/.source/hippy/extend_views/fastlist/ItemStoreNode.java +64 -0
  50. package/rules/.source/hippy/extend_views/fastlist/ItemStoreView.java +13 -0
  51. package/rules/.source/hippy/extend_views/fastlist/ItemStoreViewController.java +45 -0
  52. package/rules/.source/hippy/extend_views/fastlist/ListItemHolder.java +7 -0
  53. package/rules/.source/hippy/extend_views/fastlist/ListViewControlProp.java +41 -0
  54. package/rules/.source/hippy/extend_views/fastlist/MouseRecycleView.java +509 -0
  55. package/rules/.source/hippy/extend_views/fastlist/OnFastItemClickListener.java +12 -0
  56. package/rules/.source/hippy/extend_views/fastlist/OnFastItemFocusChangeListener.java +9 -0
  57. package/rules/.source/hippy/extend_views/fastlist/OnFastScrollStateChangedListener.java +7 -0
  58. package/rules/.source/hippy/extend_views/fastlist/PendingListNode.java +18 -0
  59. package/rules/.source/hippy/extend_views/fastlist/PendingViewController.java +13 -0
  60. package/rules/.source/hippy/extend_views/fastlist/PostHandlerView.java +6 -0
  61. package/rules/.source/hippy/extend_views/fastlist/PostTaskHolder.java +20 -0
  62. package/rules/.source/hippy/extend_views/fastlist/ReplaceChildController.java +105 -0
  63. package/rules/.source/hippy/extend_views/fastlist/ReplaceChildView.java +312 -0
  64. package/rules/.source/hippy/extend_views/fastlist/TVListView.java +3692 -0
  65. package/rules/.source/hippy/extend_views/fastlist/TemplateCodeParser.java +247 -0
  66. package/rules/.source/hippy/extend_views/fastlist/Utils.java +572 -0
  67. package/rules/.source/hippy/extend_views/fastlist/ViewTag.java +317 -0
  68. package/rules/.source/hippy/extend_views/fastlist/VirtualListView.java +8 -0
  69. package/rules/.source/hippy/extend_views/fastlist/diff/FastListDataBindingHelper.java +320 -0
  70. package/rules/.source/hippy/extend_views/fastlist/diff/KeyDiffHelper.java +289 -0
  71. package/rules/.source/hippy/extend_views/fastlist/diff/NoKeyDiffHelper.java +278 -0
  72. package/rules/.source/hippy/extend_views/tag/FontTag.java +53 -0
  73. package/rules/.source/hippy/extend_views/tag/HtmlTag.java +191 -0
  74. package/rules/.source/hippy/extend_views/tag/HtmlTagHandler.java +185 -0
  75. package/rules/.source/hippy/extend_views/tag/SpanTag.java +160 -0
  76. package/rules/.source/hippy/extend_views/tag/TextFontSpan.java +102 -0
  77. package/rules/.source/hippy/extend_views/waterfall/Chunk.java +10 -0
  78. package/rules/.source/hippy/extend_views/waterfall/ChunkGroup.java +5 -0
  79. package/rules/.source/hippy/extend_views/waterfall/Section.java +4 -0
  80. package/rules/.source/hippy/extend_views/waterfall/Tabs.java +5 -0
  81. package/rules/.source/hippy/extend_views/waterfall/WaterfallUtils.java +26 -0
  82. package/rules/.source/hippy/hippy_uimanager/ControllerHolder.java +30 -0
  83. package/rules/.source/hippy/hippy_uimanager/ControllerManager.java +651 -0
  84. package/rules/.source/hippy/hippy_uimanager/ControllerRegistry.java +102 -0
  85. package/rules/.source/hippy/hippy_uimanager/ControllerUpdateManger.java +252 -0
  86. package/rules/.source/hippy/hippy_uimanager/CustomControllerHelper.java +425 -0
  87. package/rules/.source/hippy/hippy_uimanager/DiffUtils.java +526 -0
  88. package/rules/.source/hippy/hippy_uimanager/ExtendViewGroup.java +36 -0
  89. package/rules/.source/hippy/hippy_uimanager/HippyCustomViewCreator.java +29 -0
  90. package/rules/.source/hippy/hippy_uimanager/HippyGroupController.java +83 -0
  91. package/rules/.source/hippy/hippy_uimanager/HippyViewBase.java +27 -0
  92. package/rules/.source/hippy/hippy_uimanager/HippyViewController.java +2189 -0
  93. package/rules/.source/hippy/hippy_uimanager/HippyViewEvent.java +52 -0
  94. package/rules/.source/hippy/hippy_uimanager/IHippyZIndexViewGroup.java +24 -0
  95. package/rules/.source/hippy/hippy_uimanager/InternalExtendViewUtil.java +395 -0
  96. package/rules/.source/hippy/hippy_uimanager/ListItemRenderNode.java +143 -0
  97. package/rules/.source/hippy/hippy_uimanager/ListViewRenderNode.java +44 -0
  98. package/rules/.source/hippy/hippy_uimanager/MatrixUtil.java +470 -0
  99. package/rules/.source/hippy/hippy_uimanager/NativeGestureDispatcher.java +349 -0
  100. package/rules/.source/hippy/hippy_uimanager/NativeGestureProcessor.java +188 -0
  101. package/rules/.source/hippy/hippy_uimanager/PullFooterRenderNode.java +43 -0
  102. package/rules/.source/hippy/hippy_uimanager/PullHeaderRenderNode.java +43 -0
  103. package/rules/.source/hippy/hippy_uimanager/RenderManager.java +304 -0
  104. package/rules/.source/hippy/hippy_uimanager/RenderNode.java +533 -0
  105. package/rules/.source/hippy/hippy_uimanager/StateView.java +17 -0
  106. package/rules/.source/hippy/hippy_uimanager/TransformUtil.java +125 -0
  107. package/rules/.source/hippy/hippy_uimanager/ViewGroupDrawingOrderHelper.java +108 -0
  108. package/rules/.source/hippy/hippy_uimanager/ViewStateProvider.java +10 -0
  109. package/rules/.source/hippy/hippy_views/audioview/AudioPlayManager.java +457 -0
  110. package/rules/.source/hippy/hippy_views/audioview/AudioView.java +225 -0
  111. package/rules/.source/hippy/hippy_views/audioview/AudioViewController.java +135 -0
  112. package/rules/.source/hippy/hippy_views/common/CommonBackgroundDrawable.java +58 -0
  113. package/rules/.source/hippy/hippy_views/common/CommonBorder.java +37 -0
  114. package/rules/.source/hippy/hippy_views/custom/HippyCustomPropsController.java +61 -0
  115. package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerListAdapter.java +399 -0
  116. package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerView.java +378 -0
  117. package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerViewController.java +187 -0
  118. package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerViewHolder.java +39 -0
  119. package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerViewWrapper.java +134 -0
  120. package/rules/.source/hippy/hippy_views/hippylist/NodePositionHelper.java +55 -0
  121. package/rules/.source/hippy/hippy_views/hippylist/PreloadHelper.java +54 -0
  122. package/rules/.source/hippy/hippy_views/hippylist/PullFooterEventHelper.java +61 -0
  123. package/rules/.source/hippy/hippy_views/hippylist/PullHeaderEventHelper.java +127 -0
  124. package/rules/.source/hippy/hippy_views/hippylist/RecyclerViewEventHelper.java +394 -0
  125. package/rules/.source/hippy/hippy_views/image/HippyContentDrawable.java +113 -0
  126. package/rules/.source/hippy/hippy_views/image/HippyImageView.java +1608 -0
  127. package/rules/.source/hippy/hippy_views/image/HippyImageViewController.java +382 -0
  128. package/rules/.source/hippy/hippy_views/image/IImageStateListener.java +7 -0
  129. package/rules/.source/hippy/hippy_views/list/ChildOnScreenScroller.java +255 -0
  130. package/rules/.source/hippy/hippy_views/list/HippyListAdapter.java +647 -0
  131. package/rules/.source/hippy/hippy_views/list/HippyListItemView.java +162 -0
  132. package/rules/.source/hippy/hippy_views/list/HippyListItemViewController.java +45 -0
  133. package/rules/.source/hippy/hippy_views/list/HippyListView.java +915 -0
  134. package/rules/.source/hippy/hippy_views/list/HippyListViewController.java +622 -0
  135. package/rules/.source/hippy/hippy_views/list/HippyRecycler.java +31 -0
  136. package/rules/.source/hippy/hippy_views/list/IRecycleItemTypeChange.java +23 -0
  137. package/rules/.source/hippy/hippy_views/list/ItemDecorations.java +70 -0
  138. package/rules/.source/hippy/hippy_views/list/NegativeLongKeyFlinger.java +156 -0
  139. package/rules/.source/hippy/hippy_views/list/NodeHolder.java +34 -0
  140. package/rules/.source/hippy/hippy_views/list/RecycleViewFlinger.java +126 -0
  141. package/rules/.source/hippy/hippy_views/list/TVRecyclerView.java +2070 -0
  142. package/rules/.source/hippy/hippy_views/list/TVSingleLineListView.java +15 -0
  143. package/rules/.source/hippy/hippy_views/modal/HippyModalHostManager.java +102 -0
  144. package/rules/.source/hippy/hippy_views/modal/HippyModalHostView.java +597 -0
  145. package/rules/.source/hippy/hippy_views/modal/ModalHostHelper.java +46 -0
  146. package/rules/.source/hippy/hippy_views/modal/ModalStyleNode.java +34 -0
  147. package/rules/.source/hippy/hippy_views/modal/RequestCloseEvent.java +32 -0
  148. package/rules/.source/hippy/hippy_views/modal/ShowEvent.java +31 -0
  149. package/rules/.source/hippy/hippy_views/navigator/Navigator.java +126 -0
  150. package/rules/.source/hippy/hippy_views/navigator/NavigatorController.java +120 -0
  151. package/rules/.source/hippy/hippy_views/refresh/HippyPullFooterView.java +47 -0
  152. package/rules/.source/hippy/hippy_views/refresh/HippyPullFooterViewController.java +65 -0
  153. package/rules/.source/hippy/hippy_views/refresh/HippyPullHeaderView.java +39 -0
  154. package/rules/.source/hippy/hippy_views/refresh/HippyPullHeaderViewController.java +104 -0
  155. package/rules/.source/hippy/hippy_views/refresh/RefreshWrapper.java +237 -0
  156. package/rules/.source/hippy/hippy_views/refresh/RefreshWrapperController.java +62 -0
  157. package/rules/.source/hippy/hippy_views/refresh/RefreshWrapperItemController.java +39 -0
  158. package/rules/.source/hippy/hippy_views/refresh/RefreshWrapperItemView.java +26 -0
  159. package/rules/.source/hippy/hippy_views/scroll/HippyHorizontalScrollView.java +500 -0
  160. package/rules/.source/hippy/hippy_views/scroll/HippyOnScrollHelper.java +39 -0
  161. package/rules/.source/hippy/hippy_views/scroll/HippyScrollView.java +46 -0
  162. package/rules/.source/hippy/hippy_views/scroll/HippyScrollViewController.java +178 -0
  163. package/rules/.source/hippy/hippy_views/scroll/HippyScrollViewEventHelper.java +92 -0
  164. package/rules/.source/hippy/hippy_views/scroll/HippyVerticalScrollView.java +522 -0
  165. package/rules/.source/hippy/hippy_views/text/HippyTextView.java +512 -0
  166. package/rules/.source/hippy/hippy_views/text/HippyTextViewController.java +77 -0
  167. package/rules/.source/hippy/hippy_views/textinput/HippyTextInput.java +668 -0
  168. package/rules/.source/hippy/hippy_views/textinput/HippyTextInputController.java +528 -0
  169. package/rules/.source/hippy/hippy_views/textinput/TextInputNode.java +115 -0
  170. package/rules/.source/hippy/hippy_views/videoview/APEZProvider.java +287 -0
  171. package/rules/.source/hippy/hippy_views/videoview/APKExpansionSupport.java +82 -0
  172. package/rules/.source/hippy/hippy_views/videoview/PivotPoint.java +13 -0
  173. package/rules/.source/hippy/hippy_views/videoview/ScalableType.java +34 -0
  174. package/rules/.source/hippy/hippy_views/videoview/ScalableVideoView.java +265 -0
  175. package/rules/.source/hippy/hippy_views/videoview/ScaleManager.java +191 -0
  176. package/rules/.source/hippy/hippy_views/videoview/Size.java +19 -0
  177. package/rules/.source/hippy/hippy_views/videoview/VideoHippyView.java +917 -0
  178. package/rules/.source/hippy/hippy_views/videoview/VideoHippyViewController.java +236 -0
  179. package/rules/.source/hippy/hippy_views/videoview/ZipResourceFile.java +427 -0
  180. package/rules/.source/hippy/hippy_views/view/CardRootView.java +28 -0
  181. package/rules/.source/hippy/hippy_views/view/CustomLayoutView.java +10 -0
  182. package/rules/.source/hippy/hippy_views/view/CustomNodeView.java +5 -0
  183. package/rules/.source/hippy/hippy_views/view/DialogViewGroup.java +113 -0
  184. package/rules/.source/hippy/hippy_views/view/HippyViewGroup.java +2042 -0
  185. package/rules/.source/hippy/hippy_views/view/HippyViewGroupController.java +583 -0
  186. package/rules/.source/hippy/hippy_views/view/WindowRoot.java +5 -0
  187. package/rules/.source/hippy/hippy_views/viewpager/HippyViewPager.java +308 -0
  188. package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerAdapter.java +148 -0
  189. package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerController.java +246 -0
  190. package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerItem.java +27 -0
  191. package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerItemController.java +42 -0
  192. package/rules/.source/hippy/hippy_views/viewpager/ViewPagerPageChangeListener.java +114 -0
  193. package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageItemExposureEvent.java +40 -0
  194. package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageScrollEvent.java +43 -0
  195. package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageScrollStateChangedEvent.java +42 -0
  196. package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageSelectedEvent.java +42 -0
  197. package/rules/.source/hippy/hippy_views/webview/HippyWebView.java +160 -0
  198. package/rules/.source/hippy/hippy_views/webview/HippyWebViewBridge.java +20 -0
  199. package/rules/.source/hippy/hippy_views/webview/HippyWebViewController.java +103 -0
  200. package/rules/.source/hippy/hippy_views/webview/HippyWebViewInner.java +77 -0
  201. package/rules/.windsurfrules +27 -4
  202. package/rules/AGENTS.md +27 -4
  203. package/rules/CLAUDE.md +27 -3
  204. package/rules/GEMINI.md +25 -3
@@ -0,0 +1,30 @@
1
+ /* Tencent is pleased to support the open source community by making Hippy available.
2
+ * Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package com.tencent.mtt.hippy.uimanager;
17
+
18
+ @SuppressWarnings("rawtypes")
19
+ public class ControllerHolder {
20
+
21
+ public final HippyViewController hippyViewController;
22
+ public final boolean isLazy;
23
+
24
+ public ControllerHolder(HippyViewController hippyViewController, boolean isLazy) {
25
+ this.hippyViewController = hippyViewController;
26
+ this.isLazy = isLazy;
27
+ }
28
+
29
+
30
+ }
@@ -0,0 +1,651 @@
1
+ /* Tencent is pleased to support the open source community by making Hippy available.
2
+ * Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package com.tencent.mtt.hippy.uimanager;
17
+
18
+ import android.annotation.SuppressLint;
19
+ import android.content.res.Resources.NotFoundException;
20
+ import android.support.annotation.Nullable;
21
+ import android.text.TextUtils;
22
+ import android.util.Log;
23
+ import android.util.SparseArray;
24
+ import android.view.View;
25
+ import android.view.ViewGroup;
26
+
27
+
28
+ import com.tencent.extend.views.ExtendTag;
29
+ import com.tencent.mtt.hippy.HippyEngineContext;
30
+ import com.tencent.mtt.hippy.HippyInstanceLifecycleEventListener;
31
+ import com.tencent.mtt.hippy.HippyAPIProvider;
32
+ import com.tencent.mtt.hippy.HippyRootView;
33
+ import com.tencent.mtt.hippy.annotation.HippyController;
34
+ import com.tencent.mtt.hippy.common.HippyArray;
35
+ import com.tencent.mtt.hippy.common.HippyMap;
36
+ import com.tencent.mtt.hippy.common.HippyTag;
37
+ import com.tencent.mtt.hippy.dom.node.NodeProps;
38
+ import com.tencent.mtt.hippy.dom.node.StyleNode;
39
+ import com.tencent.mtt.hippy.modules.Promise;
40
+ import com.tencent.mtt.hippy.utils.ContextHolder;
41
+ import com.tencent.mtt.hippy.utils.ExtendUtil;
42
+ import com.tencent.mtt.hippy.utils.LogUtils;
43
+ import com.tencent.mtt.hippy.utils.PixelUtil;
44
+ import com.tencent.mtt.hippy.utils.UIThreadUtils;
45
+ import com.tencent.mtt.hippy.views.custom.HippyCustomPropsController;
46
+ import com.tencent.mtt.hippy.views.list.HippyRecycler;
47
+ import com.tencent.mtt.hippy.views.scroll.HippyHorizontalScrollView;
48
+ import com.tencent.mtt.hippy.views.view.HippyViewGroupController;
49
+
50
+ import java.lang.reflect.Field;
51
+ import java.util.List;
52
+
53
+ @SuppressWarnings({"deprecation", "unchecked", "rawtypes", "unused"})
54
+ public class ControllerManager implements HippyInstanceLifecycleEventListener {
55
+
56
+ final HippyEngineContext mContext;
57
+ final ControllerRegistry mControllerRegistry;
58
+ final ControllerUpdateManger<HippyViewController, View> mControllerUpdateManger;
59
+ final SparseArray<View> mPreCacheView = new SparseArray<>();
60
+ //zhaopeng add
61
+ @Deprecated
62
+ final HippyViewController.CacheMap mViewCachePool = new HippyViewController.CacheMap();
63
+
64
+ public ControllerManager(HippyEngineContext context, List<HippyAPIProvider> hippyPackages) {
65
+ mContext = context;
66
+ mControllerRegistry = new ControllerRegistry(context);
67
+ mControllerUpdateManger = new ControllerUpdateManger();
68
+ mContext.addInstanceLifecycleEventListener(this);
69
+ processControllers(hippyPackages);
70
+ mControllerUpdateManger.setCustomPropsController(mControllerRegistry.getViewController(
71
+ HippyCustomPropsController.CLASS_NAME));
72
+
73
+ }
74
+
75
+ private void processControllers(List<HippyAPIProvider> hippyPackages) {
76
+ for (HippyAPIProvider hippyPackage : hippyPackages) {
77
+ List<Class<? extends HippyViewController>> components = hippyPackage.getControllers();
78
+ if (components != null) {
79
+ for (Class hippyComponent : components) {
80
+ HippyController hippyNativeModule = (HippyController) hippyComponent
81
+ .getAnnotation(HippyController.class);
82
+ assert hippyNativeModule != null;
83
+ String name = hippyNativeModule.name();
84
+ String[] names = hippyNativeModule.names();
85
+ boolean lazy = hippyNativeModule.isLazyLoad();
86
+ try {
87
+ ControllerHolder holder = new ControllerHolder(
88
+ (HippyViewController) hippyComponent.newInstance(), lazy);
89
+ mControllerRegistry.addControllerHolder(name, holder);
90
+ if (names.length > 0) {
91
+ for (String s : names) {
92
+ mControllerRegistry.addControllerHolder(s, holder);
93
+ }
94
+ }
95
+ } catch (Exception e) {
96
+ e.printStackTrace();
97
+ }
98
+ }
99
+ }
100
+ }
101
+ mControllerRegistry.addControllerHolder(NodeProps.ROOT_NODE,
102
+ new ControllerHolder(new HippyViewGroupController(), false));
103
+ }
104
+
105
+
106
+ /**
107
+ * 注册自定义的controller
108
+ * add by zhaopeng 2022 12 27
109
+ * 从processControllers方法拷贝实现
110
+ * @param hippyPackages
111
+ */
112
+ public void addCustomControllers(List<HippyAPIProvider> hippyPackages) {
113
+ for (HippyAPIProvider hippyPackage : hippyPackages) {
114
+ List<Class<? extends HippyViewController>> components = hippyPackage.getControllers();
115
+ if (components != null) {
116
+ for (Class hippyComponent : components) {
117
+ HippyController hippyNativeModule = (HippyController) hippyComponent
118
+ .getAnnotation(HippyController.class);
119
+ assert hippyNativeModule != null;
120
+ String name = hippyNativeModule.name();
121
+ String[] names = hippyNativeModule.names();
122
+ boolean lazy = hippyNativeModule.isLazyLoad();
123
+ try {
124
+ ControllerHolder holder = new ControllerHolder(
125
+ (HippyViewController) hippyComponent.newInstance(), lazy);
126
+ mControllerRegistry.addControllerHolder(name, holder);
127
+ if (names.length > 0) {
128
+ for (String s : names) {
129
+ mControllerRegistry.addControllerHolder(s, holder);
130
+ }
131
+ }
132
+ } catch (Exception e) {
133
+ e.printStackTrace();
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ public void destroy() {
141
+ mContext.removeInstanceLifecycleEventListener(this);
142
+ UIThreadUtils.runOnUiThread(new Runnable() {
143
+ @Override
144
+ public void run() {
145
+ int count = mControllerRegistry.getRootViewCount();
146
+ if (count > 0) {
147
+ for (int i = count - 1; i >= 0; i--) {
148
+ deleteRootView(mControllerRegistry.getRootIDAt(i));
149
+ }
150
+ }
151
+ mControllerUpdateManger.destroy();
152
+ }
153
+ });
154
+ }
155
+
156
+ public View findView(int id) {
157
+ return mControllerRegistry.getView(id);
158
+ }
159
+
160
+ public boolean hasView(int id) {
161
+ return mControllerRegistry.getView(id) != null;
162
+ }
163
+
164
+ public void createPreView(HippyRootView rootView, int id, String className,
165
+ HippyMap initialProps) {
166
+ View view = mControllerRegistry.getView(id);
167
+ if (view == null) {
168
+ HippyViewController controller = mControllerRegistry.getViewController(className);
169
+ controller.setCacheViewsPool(mViewCachePool);
170
+ view = controller.createView(rootView, id, mContext, className, initialProps);
171
+
172
+ mPreCacheView.put(id, view);
173
+ }
174
+
175
+ }
176
+
177
+ public View createView(HippyRootView rootView, int id, String className, HippyMap initialProps) {
178
+ View view = mControllerRegistry.getView(id);
179
+ if (view == null) {
180
+ //first get the preView
181
+ view = mPreCacheView.get(id);
182
+
183
+ mPreCacheView.remove(id);
184
+
185
+ HippyViewController controller = mControllerRegistry.getViewController(className);
186
+ if (view == null) {
187
+ controller.setCacheViewsPool(mViewCachePool);
188
+ view = controller.createView(rootView, id, mContext, className, initialProps);
189
+ }else{
190
+ if(LogUtils.isDebug()) {
191
+ Log.d("HippyViewController", "createView rom controllerManager preView id :" + id + ",prevView:" + view);
192
+ }
193
+ }
194
+
195
+ if (view != null) {
196
+ mControllerRegistry.addView(view);
197
+ mControllerUpdateManger.updateProps(controller, view, initialProps);
198
+ /**zhaopeng add **/
199
+ setNameIfNeed(initialProps,view);
200
+ controller.onAfterUpdateProps(view);
201
+ }
202
+ }
203
+ // mContext.getGlobalConfigs().getLogAdapter().log(TAG, " createView id:" + id + " className:" + className + " view is null" + (view == null));
204
+ return view;
205
+ }
206
+
207
+ public StyleNode createStyleNode(String className, boolean isVirtual, int rootId) {
208
+ StyleNode tempNode = mControllerRegistry.getViewController(className)
209
+ .createNode(isVirtual, rootId);
210
+ if (tempNode != null) {
211
+ return tempNode;
212
+ }
213
+ return mControllerRegistry.getViewController(className).createNode(isVirtual);
214
+ }
215
+
216
+
217
+
218
+ public void updateView(int id, String name, HippyMap newProps) {
219
+ View view = mControllerRegistry.getView(id);
220
+ HippyViewController viewComponent = mControllerRegistry.getViewController(name);
221
+ if (view != null && viewComponent != null && newProps != null) {
222
+ mControllerUpdateManger.updateProps(viewComponent, view, newProps);
223
+ if(newProps.containsKey(NodeProps.NAME)) {
224
+ setNameIfNeed(newProps, view);
225
+ }
226
+ viewComponent.onAfterUpdateProps(view);
227
+ }
228
+ }
229
+
230
+
231
+
232
+
233
+ public void updateLayout(String name, int id, int x, int y, int width, int height) {
234
+ HippyViewController component = mControllerRegistry.getViewController(name);
235
+ component.updateLayout(id, x, y, width, height, mControllerRegistry);
236
+ }
237
+
238
+ @Override
239
+ public void onInstanceLoad(int instanceId) {
240
+ if (mContext != null && mContext.getInstance(instanceId) != null) {
241
+ mControllerRegistry.addRootView(mContext.getInstance(instanceId));
242
+ }
243
+ }
244
+
245
+ @Override
246
+ public void onInstanceResume(int instanceId) {
247
+
248
+ }
249
+
250
+ @Override
251
+ public void onInstancePause(int instanceId) {
252
+
253
+ }
254
+
255
+ @Override
256
+ public void onInstanceDestroy(int instanceId) {
257
+
258
+ }
259
+
260
+ public void updateExtra(int viewID, String name, Object object) {
261
+ HippyViewController component = mControllerRegistry.getViewController(name);
262
+ View view = mControllerRegistry.getView(viewID);
263
+ component.updateExtra(view, object);
264
+ }
265
+
266
+
267
+ public void move(int id, int toId, int index) {
268
+ View view = mControllerRegistry.getView(id);
269
+
270
+ if (view != null) {
271
+ if (view.getParent() != null) {
272
+ ViewGroup oldParent = (ViewGroup) view.getParent();
273
+ oldParent.removeView(view);
274
+ }
275
+ ViewGroup newParent = (ViewGroup) mControllerRegistry.getView(toId);
276
+ if (newParent != null) {
277
+ String parentClassName = HippyTag.getClassName(newParent);
278
+ mControllerRegistry.getViewController(parentClassName).addView(newParent, view, index);
279
+ }
280
+
281
+ // newParent.addView(view, index);
282
+ LogUtils.d("ControllerManager", "move id: " + id + " toid: " + toId);
283
+ // mContext.getGlobalConfigs().getLogAdapter().log(TAG, "move id: " + id + " toid: " + toId);
284
+ }
285
+
286
+
287
+ }
288
+
289
+ public boolean isControllerLazy(String className) {
290
+ return mControllerRegistry.getControllerHolder(className).isLazy;
291
+ }
292
+
293
+ public void replaceID(int oldId, int newId) {
294
+ View view = mControllerRegistry.getView(oldId);
295
+ mControllerRegistry.removeView(oldId);
296
+
297
+ if (view == null) {
298
+ // Toast.makeText(mControllerRegistry.getRootView(mControllerRegistry.getRootIDAt(0)).getContext(),"replaceID时候出异常了",Toast.LENGTH_LONG).show();
299
+ // Debug.waitForDebugger();
300
+ LogUtils.d("HippyListView", "error replaceID null oldId " + oldId);
301
+ } else {
302
+ if (view instanceof HippyRecycler) {
303
+ ((HippyRecycler) view).clear();
304
+ }
305
+
306
+ view.setId(newId);
307
+
308
+ if (view instanceof HippyHorizontalScrollView) {
309
+ ((HippyHorizontalScrollView)view).setContentOffset4Reuse();
310
+ }
311
+
312
+ mControllerRegistry.addView(view);
313
+ }
314
+ }
315
+
316
+ public RenderNode createRenderNode(int id, HippyMap props, String className,
317
+ HippyRootView hippyRootView, boolean lazy) {
318
+ return mControllerRegistry.getViewController(className)
319
+ .createRenderNode(id, props, className, hippyRootView, this, lazy);
320
+ }
321
+
322
+ public void dispatchUIFunction(int id, String className, String functionName, HippyArray var,
323
+ Promise promise) {
324
+ HippyViewController hippyViewController = mControllerRegistry.getViewController(className);
325
+ View view = mControllerRegistry.getView(id);
326
+ if (promise == null || !promise.isCallback()) {
327
+ hippyViewController.dispatchFunction(view, functionName, var);
328
+ } else {
329
+ hippyViewController.dispatchFunction(view, functionName, var, promise);
330
+ }
331
+
332
+ }
333
+
334
+ public void onBatchComplete(String className, int id) {
335
+ HippyViewController hippyViewController = mControllerRegistry.getViewController(className);
336
+ View view = mControllerRegistry.getView(id);
337
+ if (view != null) {
338
+ hippyViewController.onBatchComplete(view);
339
+ }
340
+ }
341
+
342
+
343
+ public void deleteChildRecursive(ViewGroup viewParent, View child, int childIndex) {
344
+ if (viewParent == null || child == null) {
345
+ return;
346
+ }
347
+ HippyViewController hippyChildViewController = null;
348
+ String childTagString = HippyTag.getClassName(child);
349
+ if (!TextUtils.isEmpty(childTagString)) {
350
+ hippyChildViewController = mControllerRegistry.getViewController(childTagString);
351
+ if (hippyChildViewController != null) {
352
+ //zhaopeng add
353
+ hippyChildViewController.onBeforeViewDestroy(child);
354
+ hippyChildViewController.onViewDestroy(child);
355
+ }
356
+ }
357
+
358
+ if (child instanceof ViewGroup) {
359
+ ViewGroup childViewGroup = (ViewGroup) child;
360
+ if (hippyChildViewController != null) {
361
+ for (int i = hippyChildViewController.getChildCount(childViewGroup) - 1; i >= 0; i--) {
362
+ deleteChildRecursive(childViewGroup,
363
+ hippyChildViewController.getChildAt(childViewGroup, i), -1);
364
+ }
365
+ } else {
366
+ for (int i = childViewGroup.getChildCount() - 1; i >= 0; i--) {
367
+ deleteChildRecursive(childViewGroup, childViewGroup.getChildAt(i), -1);
368
+ }
369
+ }
370
+ }
371
+
372
+ if (mControllerRegistry.getView(child.getId()) != child
373
+ && mControllerRegistry.getView(viewParent.getId()) != viewParent) {
374
+ return;
375
+ }
376
+
377
+ String parentTagString = HippyTag.getClassName(viewParent);
378
+ if (parentTagString != null) {
379
+ //remove component Like listView there is a RecycleItemView is not js UI
380
+ if (mControllerRegistry.getControllerHolder(parentTagString) != null) {
381
+ HippyViewController hippyViewController = mControllerRegistry.getViewController(
382
+ parentTagString);
383
+ hippyViewController.deleteChild(viewParent, child, childIndex);
384
+ // LogUtils.d("HippyListView", "delete " + child.getId());
385
+ }
386
+ } else {
387
+ viewParent.removeView(child);
388
+ }
389
+
390
+ // mContext.getGlobalConfigs().getLogAdapter().log(TAG, "deleteChildRecursive id:" + child.getId() + " className:" + childTagString);
391
+ mControllerRegistry.removeView(child.getId());
392
+ }
393
+
394
+ public void deleteChild(int pId, int childId) {
395
+ deleteChild(pId, childId, -1);
396
+ }
397
+
398
+
399
+ public void deleteChild(int pId, int childId, int childIndex) {
400
+ View parentView = mControllerRegistry.getView(pId);
401
+ View childView = mControllerRegistry.getView(childId);
402
+
403
+ if (parentView instanceof ViewGroup && childView != null) {
404
+ deleteChildRecursive((ViewGroup) parentView, childView, childIndex);
405
+ }
406
+ // else
407
+ // {
408
+ // mContext.getGlobalConfigs().getLogAdapter().log(TAG, "deleteChild error pId: " + pId + " childId: " + childId +(parentView instanceof ViewGroup)+ (childView != null));
409
+ // }
410
+ }
411
+
412
+ private static int statusBarHeight = -1;
413
+
414
+ public static int getStatusBarHeightFromSystem() {
415
+ if (statusBarHeight > 0) {
416
+ return statusBarHeight;
417
+ }
418
+
419
+ Class<?> c;
420
+ Object obj;
421
+ Field field;
422
+ int x;
423
+ try {
424
+ c = Class.forName("com.android.internal.R$dimen");
425
+ obj = c.newInstance();
426
+ field = c.getField("status_bar_height");
427
+ //noinspection ConstantConditions
428
+ x = Integer.parseInt(field.get(obj).toString());
429
+ statusBarHeight = ContextHolder.getAppContext().getResources().getDimensionPixelSize(x);
430
+ } catch (Exception e1) {
431
+ statusBarHeight = -1;
432
+ e1.printStackTrace();
433
+ }
434
+
435
+ if (statusBarHeight < 1) {
436
+ try {
437
+ int statebarH_id = ContextHolder.getAppContext().getResources()
438
+ .getIdentifier("statebar_height", "dimen",
439
+ ContextHolder.getAppContext().getPackageName());
440
+ statusBarHeight = Math
441
+ .round(ContextHolder.getAppContext().getResources().getDimension(statebarH_id));
442
+ } catch (NotFoundException e) {
443
+ LogUtils.d("ControllerManager", "getStatusBarHeightFromSystem: " + e.getMessage());
444
+ }
445
+ }
446
+ return statusBarHeight;
447
+ }
448
+
449
+ @SuppressLint("Range")
450
+ public void measureInWindow(int id, Promise promise) {
451
+ View v = mControllerRegistry.getView(id);
452
+ if (v == null) {
453
+ promise.reject("this view is null");
454
+ } else {
455
+ int[] outputBuffer = new int[4];
456
+ int statusBarHeight;
457
+ try {
458
+ v.getLocationOnScreen(outputBuffer);
459
+
460
+ // We need to remove the status bar from the height. getLocationOnScreen will include the
461
+ // status bar.
462
+ statusBarHeight = getStatusBarHeightFromSystem();
463
+ if (statusBarHeight > 0) {
464
+ outputBuffer[1] -= statusBarHeight;
465
+ }
466
+
467
+ // outputBuffer[0,1] already contain what we want
468
+ outputBuffer[2] = v.getWidth();
469
+ outputBuffer[3] = v.getHeight();
470
+ } catch (Throwable e) {
471
+ promise.reject("exception" + e.getMessage());
472
+ e.printStackTrace();
473
+ return;
474
+ }
475
+
476
+ float x = PixelUtil.px2dp(outputBuffer[0]);
477
+ float y = PixelUtil.px2dp(outputBuffer[1]);
478
+ float width = PixelUtil.px2dp(outputBuffer[2]);
479
+ float height = PixelUtil.px2dp(outputBuffer[3]);
480
+ float fStatusbarHeight = PixelUtil.px2dp(statusBarHeight);
481
+
482
+ HippyMap hippyMap = new HippyMap();
483
+ hippyMap.pushDouble("x", x);
484
+ hippyMap.pushDouble("y", y);
485
+ hippyMap.pushDouble("width", width);
486
+ hippyMap.pushDouble("height", height);
487
+ hippyMap.pushDouble("statusBarHeight", fStatusbarHeight);
488
+ promise.resolve(hippyMap);
489
+ }
490
+
491
+ }
492
+
493
+ public void onManageChildComplete(String className, int id) {
494
+ HippyViewController hippyViewController = mControllerRegistry.getViewController(className);
495
+ View view = mControllerRegistry.getView(id);
496
+ if (view != null) {
497
+ hippyViewController.onManageChildComplete(view);
498
+ }
499
+ }
500
+
501
+ public void addChild(int pid, int id, int index) {
502
+ View childView = mControllerRegistry.getView(id);
503
+ View parentView = mControllerRegistry.getView(pid);
504
+
505
+ if (childView != null && parentView instanceof ViewGroup) {
506
+ if (childView.getParent() == null) {
507
+ LogUtils.d("ControllerManager", "addChild id: " + id + " pid: " + pid);
508
+ // mContext.getGlobalConfigs().getLogAdapter().log( TAG,"addChild id: " + id + " pid: " + pid);
509
+ // childView.getParent()==null this is the move action do first so the child has a parent we do nothing temp
510
+
511
+ String parentClassName = HippyTag.getClassName(parentView);
512
+ mControllerRegistry.getViewController(parentClassName)
513
+ .addView((ViewGroup) parentView, childView, index);
514
+ }
515
+ // else
516
+ // {
517
+ // mContext.getGlobalConfigs().getLogAdapter().log( TAG,"addChild error childView has parent id: " + id + " pid: " + pid);
518
+ // }
519
+ } else {
520
+ RenderNode parentNode = mContext.getRenderManager().getRenderNode(pid);
521
+ String renderNodeClass = "null";
522
+ if (parentNode != null) {
523
+ renderNodeClass = parentNode.getClassName();
524
+ }
525
+
526
+ // 上报重要错误
527
+ // 这个错误原因是:前端用了某个UI控件来做父亲,而这个UI控件实际上是不应该做父亲的(不是ViewGroup),务必要把这个parentView的className打出来
528
+ String parentTag = null, parentClass = null, childTag = null, childClass = null;
529
+ if (parentView != null) {
530
+ Object temp = HippyTag.getClassName(parentView);
531
+ if (temp != null) {
532
+ parentTag = temp.toString();
533
+ }
534
+ parentClass = parentView.getClass().getName();
535
+ }
536
+ if (childView != null) {
537
+ Object temp = HippyTag.getClassName(childView);
538
+ if (temp != null) {
539
+ childTag = temp.toString();
540
+ }
541
+ childClass = childView.getClass().getName();
542
+ }
543
+ Exception exception = new RuntimeException("child null or parent not ViewGroup pid " + pid
544
+ + " parentTag " + parentTag
545
+ + " parentClass " + parentClass
546
+ + " renderNodeClass " + renderNodeClass + " id " + id
547
+ + " childTag " + childTag
548
+ + " childClass " + childClass);
549
+ mContext.getGlobalConfigs().getExceptionHandler().handleNativeException(exception, true);
550
+ }
551
+ }
552
+
553
+ public void deleteRootView(int mId) {
554
+
555
+ View view = mControllerRegistry.getRootView(mId);
556
+ if (view != null) {
557
+ HippyRootView hippyRootView = (HippyRootView) view;
558
+ int count = hippyRootView.getChildCount();
559
+
560
+ for (int i = count - 1; i >= 0; i--) {
561
+ deleteChild(mId, hippyRootView.getChildAt(i).getId());
562
+ }
563
+ }
564
+ mControllerRegistry.removeRootView(mId);
565
+ }
566
+
567
+ /**
568
+ * zhaopeng add 2021/07/07
569
+ * @param id
570
+ * @param className
571
+ * @param functionName
572
+ * @param var
573
+ */
574
+ public void dispatchUIFunction(final int id, final String className, final String functionName, final HippyArray var,final int delay)
575
+ {
576
+ if(delay <= 0) {
577
+ HippyViewController hippyViewController = mControllerRegistry.getViewController(className);
578
+ View view = mControllerRegistry.getView(id);
579
+ hippyViewController.dispatchFunction(view, functionName, var);
580
+ }else{
581
+ final HippyViewController hippyViewController = mControllerRegistry.getViewController(className);
582
+ final View view = mControllerRegistry.getView(id);
583
+ InternalExtendViewUtil.postTaskByRootView(view, new Runnable() {
584
+ @Override
585
+ public void run() {
586
+ hippyViewController.dispatchFunction(view, functionName, var);
587
+ }
588
+ },delay);
589
+ }
590
+ }
591
+
592
+ // /**zhaopeng add **/
593
+ // private static @Nullable
594
+ // HippyMap getTagFromView(View v){
595
+ // if(v != null && v.getTag() instanceof HippyMap){
596
+ // return (HippyMap) v.getTag();
597
+ // }
598
+ // return null;
599
+ // }
600
+
601
+ /**向view的map里添加name*/
602
+ private void setNameIfNeed(HippyMap initPro,View v){
603
+ // String name = initPro.getString("name");
604
+ ExtendTag.obtainExtendTag(v).name = initPro.getString(NodeProps.NAME);
605
+ // Log.i("ZHAOPENG","setNameIfNeed on "+ExtendUtil.debugViewLite(v));
606
+ // Log.i(FocusDispatchView.TAG,"----setNameIfNeed on state"+state+", name :"+name+",view:"+ExtendUtil.debugView(v));
607
+ }
608
+
609
+ // /**向view的map里添加name*/
610
+ // public static void configName(HippyMap tagMap,String name){
611
+ // if(tagMap != null ) {
612
+ // tagMap.pushString(NodeProps.NAME, name);
613
+ // if(LogUtils.isDebug()){
614
+ // LogUtils.d("ControllerManager","configName :"+name);
615
+ // }
616
+ // }
617
+ // }
618
+
619
+ public static @Nullable String findName(View v){
620
+ // final HippyMap map = getTagFromView(v);
621
+ // if(map != null){
622
+ // return map.getString(NodeProps.NAME);
623
+ // }
624
+ final ExtendTag et = ExtendTag.getExtendTag(v);
625
+ if (et != null) {
626
+ return et.name;
627
+ }
628
+ return null;
629
+ }
630
+
631
+ public static @Nullable View findViewByName(View target,String name){
632
+ if(target != null && name != null){
633
+ final String targetName = findName(target);
634
+ if(name.equals(targetName)){
635
+ return target;
636
+ }
637
+ if(target instanceof ViewGroup){
638
+ ViewGroup g = (ViewGroup) target;
639
+ for(int i = 0; i < g.getChildCount(); i++){
640
+ View r = findViewByName(g.getChildAt(i),name);
641
+ if( r != null){
642
+ return r;
643
+ }
644
+ }
645
+ }
646
+ }
647
+ return null;
648
+ }
649
+
650
+ /**zhaopeng add **/
651
+ }