@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,2189 @@
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.content.Context;
19
+ import android.graphics.Color;
20
+ import android.graphics.Rect;
21
+ import android.os.Build;
22
+ import android.os.Looper;
23
+ import android.os.MessageQueue;
24
+ import android.support.annotation.Nullable;
25
+ import android.text.TextUtils;
26
+ import android.util.Log;
27
+ import android.view.View;
28
+ import android.view.ViewGroup;
29
+ import android.view.ViewParent;
30
+ import android.widget.ProgressBar;
31
+
32
+
33
+ import com.tencent.extend.AutoFocusManager;
34
+ import com.tencent.extend.FocusManagerModule;
35
+ import com.tencent.extend.FocusUtils;
36
+ import com.tencent.extend.ITVView;
37
+ import com.tencent.extend.RenderUtil;
38
+ import com.tencent.extend.TVBaseView;
39
+ import com.tencent.extend.TVFocusScaleExcuter;
40
+ import com.tencent.extend.TriggerTaskHost;
41
+ import com.tencent.extend.TriggerTaskManagerModule;
42
+ import com.tencent.extend.views.ExtendTag;
43
+ import com.tencent.extend.views.TVTextView;
44
+ import com.tencent.extend.views.fastlist.FastAdapter;
45
+ import com.tencent.extend.views.fastlist.FastItemView;
46
+ import com.tencent.extend.views.fastlist.FastListView;
47
+ import com.tencent.extend.views.fastlist.FastListViewController;
48
+ import com.tencent.extend.views.fastlist.ReplaceChildView;
49
+ import com.tencent.extend.views.fastlist.TemplateCodeParser;
50
+ import com.tencent.extend.views.fastlist.Utils;
51
+ import com.tencent.mtt.hippy.FocusDispatchView;
52
+ import com.tencent.mtt.hippy.HippyEngineContext;
53
+ import com.tencent.mtt.hippy.HippyInstanceContext;
54
+ import com.tencent.mtt.hippy.HippyRootView;
55
+ import com.tencent.mtt.hippy.R;
56
+ import com.tencent.mtt.hippy.TVFocusHelper;
57
+ import com.tencent.mtt.hippy.annotation.HippyControllerProps;
58
+ import com.tencent.mtt.hippy.common.HippyArray;
59
+ import com.tencent.mtt.hippy.common.HippyMap;
60
+ import com.tencent.mtt.hippy.common.HippyTag;
61
+ import com.tencent.mtt.hippy.dom.node.NodeProps;
62
+ import com.tencent.mtt.hippy.dom.node.StyleNode;
63
+ import com.tencent.mtt.hippy.modules.Promise;
64
+ import com.tencent.mtt.hippy.utils.ExtendUtil;
65
+ import com.tencent.mtt.hippy.utils.LogAdapterUtils;
66
+ import com.tencent.mtt.hippy.utils.LogUtils;
67
+ import com.tencent.mtt.hippy.utils.PixelUtil;
68
+ import com.tencent.mtt.hippy.views.common.CommonBorder;
69
+ import com.tencent.mtt.hippy.views.image.HippyImageView;
70
+ import com.tencent.mtt.hippy.views.list.HippyListView;
71
+ import com.tencent.mtt.hippy.views.list.HippyRecycler;
72
+ import com.tencent.mtt.hippy.views.list.TVSingleLineListView;
73
+ import com.tencent.mtt.hippy.views.text.HippyTextView;
74
+ import com.tencent.mtt.hippy.views.view.HippyViewGroup;
75
+ import com.tencent.mtt.hippy.views.view.HippyViewGroupController;
76
+ import com.tencent.mtt.supportui.views.IGradient;
77
+ import com.tencent.mtt.supportui.views.IShadow;
78
+ import com.tencent.mtt.supportui.views.asyncimage.AsyncImageView;
79
+
80
+ import java.io.File;
81
+ import java.util.ArrayList;
82
+ import java.util.HashMap;
83
+ import java.util.List;
84
+ import java.util.Map;
85
+
86
+ @SuppressWarnings({"deprecation", "unused"})
87
+ public abstract class HippyViewController<T extends View & HippyViewBase> implements
88
+ View.OnFocusChangeListener {
89
+
90
+ private static final String TAG = "HippyViewController";
91
+
92
+ private CacheMap cacheViewsPool;
93
+
94
+ private static final MatrixUtil.MatrixDecompositionContext sMatrixDecompositionContext = new MatrixUtil.MatrixDecompositionContext();
95
+ private static final double[] sTransformDecompositionArray = new double[16];
96
+ private boolean bUserChageFocus = false;
97
+ HippyViewEvent mFocusEvent;
98
+ HippyViewEvent mSelectEvent;
99
+
100
+ public void setCacheViewsPool(CacheMap cacheViews) {
101
+ this.cacheViewsPool = cacheViews;
102
+ }
103
+
104
+ @SuppressWarnings("deprecation")
105
+ public View createView(HippyRootView rootView, int id, HippyEngineContext hippyEngineContext,
106
+ String className,
107
+ HippyMap initialProps) {
108
+ View view = null;
109
+
110
+ if (rootView != null) {
111
+ Context rootViewContext = rootView.getContext();
112
+ if (rootViewContext instanceof HippyInstanceContext) {
113
+ @SuppressWarnings("rawtypes") Map nativeParam = ((HippyInstanceContext) rootViewContext)
114
+ .getNativeParams();
115
+ if (nativeParam != null) {
116
+ Object object = nativeParam.get(HippyCustomViewCreator.HIPPY_CUSTOM_VIEW_CREATOR);
117
+ if (object instanceof HippyCustomViewCreator) {
118
+ view = ((HippyCustomViewCreator) object)
119
+ .createCustomView(className, rootView.getContext(), initialProps);
120
+ }
121
+ }
122
+ }
123
+
124
+ final String cache = initialProps.getString("cacheType");
125
+ if (view == null && cacheViewsPool != null) {
126
+ view = cacheViewsPool.get(cache);
127
+ if (view instanceof HippyRecycler) {
128
+ ((HippyRecycler) view).resetProps();
129
+ }
130
+ if (view != null) {
131
+ onCreateViewByCache(view, cache, initialProps);
132
+ }
133
+ if (LogUtils.isDebug()) {
134
+ Log.d(TAG, "createView from cacheViews :" + view + ",type:" + initialProps.getString("cacheType"));
135
+ }
136
+ }
137
+ if (view == null) {
138
+ view = createViewImpl(rootView.getContext(), initialProps);
139
+ if (view == null) {
140
+ view = createViewImpl(rootView.getContext());
141
+ }
142
+ }
143
+
144
+ //zhaopeng add
145
+ onAfterCreateView(view, initialProps, className);
146
+
147
+ LogUtils.d(TAG, "createView id " + id);
148
+ view.setId(id);
149
+ //view.setTag(className);
150
+ HippyMap tagObj = HippyTag.createTagMap(className, initialProps, cache);
151
+ view.setTag(tagObj);
152
+
153
+ }
154
+ return view;
155
+ }
156
+
157
+ protected void onCreateViewByCache(View view, String type, HippyMap props) {
158
+
159
+ }
160
+
161
+ protected void onAfterCreateView(View view, HippyMap initialProps) {
162
+ //zhaopeng add 添加tag
163
+ ExtendTag.putTag(view, new ExtendTag());
164
+ CustomControllerHelper.dealCustomProp(view, initialProps);
165
+ }
166
+
167
+ protected void onAfterCreateView(View view, HippyMap initialProps, String className) {
168
+ //zhaopeng add 添加tag
169
+ onAfterCreateView(view, initialProps);
170
+ ExtendTag.obtainExtendTag(view).nodeClassName = className;
171
+
172
+ if (view.getContext() instanceof HippyInstanceContext) {
173
+ HippyEngineContext engineContext = ((HippyInstanceContext) view.getContext()).getEngineContext();
174
+ FocusManagerModule.GlobalFocusConfig config = FocusManagerModule.getGlobalFocusConfig(engineContext);
175
+ if (config.forceDisableFocus) {
176
+ view.setFocusable(false);
177
+ view.setFocusableInTouchMode(false);
178
+ }
179
+ }
180
+ }
181
+
182
+
183
+ public void onAfterUpdateProps(T v) {
184
+
185
+ }
186
+
187
+
188
+ // public void updateProps(View view, HippyMap props)
189
+ // {
190
+ // if (props == null)
191
+ // return;
192
+ // try
193
+ // {
194
+ // HippyMap styleProps = props.get(NodeProps.STYLE) != null ? (HippyMap) props.get(NodeProps.STYLE) : null;
195
+ // Method[] targetMethods = getClass().getMethods();
196
+ //
197
+ // for (Method targetMethod : targetMethods)
198
+ // {
199
+ // HippyControllerProps hippyProps = targetMethod.getAnnotation(HippyC ontrollerProps.class);
200
+ // if (hippyProps != null)
201
+ // {
202
+ // String propsName = hippyProps.name();
203
+ // if (props.get(propsName) != null) // try normal props first
204
+ // {
205
+ // targetMethod.invoke(this, view, props.get(propsName));
206
+ // }
207
+ // else if (styleProps != null && styleProps.get(propsName) != null) // then try styleprops
208
+ // {
209
+ // targetMethod.invoke(this, view, styleProps.get(propsName));
210
+ // }
211
+ // }
212
+ // }
213
+ // }
214
+ // catch (IllegalAccessException e)
215
+ // {
216
+ // e.printStackTrace();
217
+ // }
218
+ // catch (InvocationTargetException e)
219
+ // {
220
+ // e.printStackTrace();
221
+ // }
222
+ // catch (IllegalArgumentException e)
223
+ // {
224
+ // e.printStackTrace();
225
+ // }
226
+ // }
227
+
228
+
229
+ protected void updateExtra(View view, Object object) {
230
+
231
+ }
232
+
233
+ @SuppressWarnings("SameReturnValue")
234
+ protected StyleNode createNode(boolean isVirtual, int rootId) {
235
+ return null;
236
+ }
237
+
238
+ protected StyleNode createNode(boolean isVirtual) {
239
+ return new StyleNode();
240
+ }
241
+
242
+ public void updateLayout(int id, int x, int y, int width, int height,
243
+ ControllerRegistry componentHolder) {
244
+ View view = componentHolder.getView(id);
245
+ if (view != null) {
246
+ view.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
247
+ View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
248
+ if (!shouldInterceptLayout(view, x, y, width, height)) {
249
+ view.layout(x, y, x + width, y + height);
250
+ }
251
+ }
252
+ }
253
+
254
+ protected boolean shouldInterceptLayout(View view, int x, int y, int width, int height) {
255
+ return false;
256
+ }
257
+
258
+ @SuppressWarnings("BooleanMethodIsAlwaysInverted")
259
+ protected boolean handleGestureBySelf() {
260
+ return false;
261
+ }
262
+
263
+ @Deprecated
264
+ protected abstract View createViewImpl(Context context);
265
+
266
+ protected View createViewImpl(Context context, HippyMap iniProps) {
267
+ return null;
268
+ }
269
+
270
+
271
+ /**
272
+ * transform
273
+ **/
274
+ @HippyControllerProps(name = NodeProps.TRANSFORM, defaultType = HippyControllerProps.ARRAY)
275
+ public void setTransform(T view, HippyArray transformArray) {
276
+ if (transformArray == null) {
277
+ resetTransform(view);
278
+ } else {
279
+ applyTransform(view, transformArray);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * transform
285
+ **/
286
+ @HippyControllerProps(name = "layout", defaultType = HippyControllerProps.ARRAY)
287
+ public void setLayoutInfo(T view, HippyArray layout) {
288
+ if (layout.size() == 4) {
289
+ CustomControllerHelper.updateLayout(view, Utils.toPX(layout.getInt(0)), Utils.toPX(layout.getInt(1)), Utils.toPX(layout.getInt(2)), Utils.toPX(layout.getInt(3)));
290
+ }
291
+ }
292
+
293
+
294
+ @HippyControllerProps(name = NodeProps.PROP_ACCESSIBILITY_LABEL)
295
+ public void setAccessibilityLabel(T view, String accessibilityLabel) {
296
+ if (accessibilityLabel == null) {
297
+ accessibilityLabel = "";
298
+ }
299
+ view.setContentDescription(accessibilityLabel);
300
+ }
301
+
302
+ /**
303
+ * zIndex
304
+ **/
305
+ @HippyControllerProps(name = NodeProps.Z_INDEX, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
306
+ public void setZIndex(T view, int zIndex) {
307
+ HippyViewGroupController.setViewZIndex(view, zIndex);
308
+ ViewParent parent = view.getParent();
309
+ if (parent instanceof IHippyZIndexViewGroup) {
310
+ ((IHippyZIndexViewGroup) parent).updateDrawingOrder();
311
+ }
312
+ }
313
+
314
+ /**
315
+ * color/border/alpha
316
+ **/
317
+ @HippyControllerProps(name = NodeProps.BACKGROUND_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
318
+ public void setBackground(T view, int backgroundColor) {
319
+ view.setBackgroundColor(backgroundColor);
320
+ }
321
+
322
+ /**
323
+ * color/border/alpha
324
+ **/
325
+ @HippyControllerProps(name = "backgroundColorStr", defaultType = HippyControllerProps.STRING)
326
+ public void setBackgroundString(T view, String backgroundColor) {
327
+ try {
328
+ view.setBackgroundColor(Color.parseColor(backgroundColor));
329
+ ExtendTag.obtainExtendTag(view).pendingBackGroundColor = Color.parseColor(backgroundColor);
330
+ } catch (Exception e) {
331
+ e.printStackTrace();
332
+ }
333
+ }
334
+
335
+ @HippyControllerProps(name = NodeProps.OPACITY, defaultType = HippyControllerProps.NUMBER, defaultNumber = 1.f)
336
+ public void setOpacity(T view, float opacity) {
337
+ view.setAlpha(opacity);
338
+ }
339
+
340
+ @HippyControllerProps(name = NodeProps.BORDER_RADIUS, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
341
+ public void setBorderRadius(T view, float borderRadius) {
342
+ if (view instanceof CommonBorder) {
343
+ ((CommonBorder) view)
344
+ .setBorderRadius(borderRadius, CommonBorder.BorderRadiusDirection.ALL.ordinal());
345
+ }
346
+ }
347
+
348
+
349
+ @HippyControllerProps(name = NodeProps.BORDER_TOP_LEFT_RADIUS, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
350
+ public void setTopLeftBorderRadius(T view, float topLeftBorderRadius) {
351
+ if (view instanceof CommonBorder) {
352
+ ((CommonBorder) view).setBorderRadius(topLeftBorderRadius,
353
+ CommonBorder.BorderRadiusDirection.TOP_LEFT.ordinal());
354
+ }
355
+ }
356
+
357
+
358
+ @HippyControllerProps(name = NodeProps.BORDER_TOP_RIGHT_RADIUS, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
359
+ public void setTopRightBorderRadius(T view, float topRightBorderRadius) {
360
+ if (view instanceof CommonBorder) {
361
+ ((CommonBorder) view).setBorderRadius(topRightBorderRadius,
362
+ CommonBorder.BorderRadiusDirection.TOP_RIGHT.ordinal());
363
+ }
364
+ }
365
+
366
+
367
+ @HippyControllerProps(name = NodeProps.BORDER_BOTTOM_RIGHT_RADIUS, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
368
+ public void setBottomRightBorderRadius(T view, float bottomRightBorderRadius) {
369
+ if (view instanceof CommonBorder) {
370
+ ((CommonBorder) view).setBorderRadius(bottomRightBorderRadius,
371
+ CommonBorder.BorderRadiusDirection.BOTTOM_RIGHT.ordinal());
372
+ }
373
+ }
374
+
375
+
376
+ @HippyControllerProps(name = NodeProps.BORDER_BOTTOM_LEFT_RADIUS, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
377
+ public void setBottomLeftBorderRadius(T view, float bottomLeftBorderRadius) {
378
+ if (view instanceof CommonBorder) {
379
+ ((CommonBorder) view).setBorderRadius(bottomLeftBorderRadius,
380
+ CommonBorder.BorderRadiusDirection.BOTTOM_LEFT.ordinal());
381
+ }
382
+ }
383
+
384
+
385
+ @HippyControllerProps(name = NodeProps.BORDER_WIDTH, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
386
+ public void setBorderWidth(T view, float borderWidth) {
387
+ if (view instanceof CommonBorder) {
388
+ ((CommonBorder) view)
389
+ .setBorderWidth(borderWidth, CommonBorder.BorderWidthDirection.ALL.ordinal());
390
+ }
391
+ }
392
+
393
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_DOWN_ID, defaultType = HippyControllerProps.BOOLEAN)
394
+ public void setNextFocusDownId(T view, int id) {
395
+ view.setNextFocusDownId(id);
396
+ }
397
+
398
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_UP_ID, defaultType = HippyControllerProps.BOOLEAN)
399
+ public void setNextFocusUpId(T view, int id) {
400
+ view.setNextFocusUpId(id);
401
+ }
402
+
403
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_LEFT_ID, defaultType = HippyControllerProps.BOOLEAN)
404
+ public void setNextFocusLeftId(T view, int id) {
405
+ view.setNextFocusLeftId(id);
406
+ }
407
+
408
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_RIGHT_ID, defaultType = HippyControllerProps.BOOLEAN)
409
+ public void setNextFocusRightId(T view, int id) {
410
+ view.setNextFocusRightId(id);
411
+ }
412
+
413
+ //2.7 add 指定 nextFocus By sid
414
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_DOWN_SID, defaultType = HippyControllerProps.STRING)
415
+ public void setNextFocusDownSId(T view, String id) {
416
+ FocusUtils.setNextFocusDownSID(view, id);
417
+ }
418
+
419
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_UP_SID, defaultType = HippyControllerProps.STRING)
420
+ public void setNextFocusUpSId(T view, String id) {
421
+ FocusUtils.setNextFocusUpSID(view, id);
422
+ }
423
+
424
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_LEFT_SID, defaultType = HippyControllerProps.STRING)
425
+ public void setNextFocusLeftSId(T view, String id) {
426
+ FocusUtils.setNextFocusLeftSID(view, id);
427
+ }
428
+
429
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_RIGHT_SID, defaultType = HippyControllerProps.STRING)
430
+ public void setNextFocusRightSId(T view, String id) {
431
+ FocusUtils.setNextFocusRightSID(view, id);
432
+ }
433
+
434
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_SID, defaultType = HippyControllerProps.MAP)
435
+ public void setNextFocusSId(T view, HippyMap hippyMap) {
436
+ if (hippyMap != null) {
437
+ final String nextLeft = hippyMap.getString(TVFocusHelper.KEY_NEXT_FOCUS_LEFT_FRONT);
438
+ final String nextRight = hippyMap.getString(TVFocusHelper.KEY_NEXT_FOCUS_RIGHT_FRONT);
439
+ final String nextUP = hippyMap.getString(TVFocusHelper.KEY_NEXT_FOCUS_UP_FRONT);
440
+ final String nextDown = hippyMap.getString(TVFocusHelper.KEY_NEXT_FOCUS_DOWN_FRONT);
441
+ setNextFocusLeftSId(view, nextLeft);
442
+ setNextFocusRightSId(view, nextRight);
443
+ setNextFocusUpSId(view, nextUP);
444
+ setNextFocusDownSId(view, nextDown);
445
+ }
446
+ }
447
+
448
+ //nextFocus By sid
449
+
450
+ @Deprecated
451
+ @HippyControllerProps(name = "idTag", defaultType = HippyControllerProps.STRING)
452
+ public void setTagID(T view, String tagID) {
453
+ view.setTag(R.id.tag_item_id, tagID);
454
+ }
455
+
456
+ @HippyControllerProps(name = "sid", defaultType = HippyControllerProps.STRING)
457
+ public void setSID(T view, String sid) {
458
+ //给view设置string的id,整个view树里唯一
459
+ ExtendUtil.putViewSID(view, sid);
460
+ if (view instanceof TVBaseView) {
461
+ ((TVBaseView) view).onSetSid(sid);
462
+ }
463
+ if (LogUtils.isDebug()) {
464
+ Log.d("configID4Item", "call by vue setSID :" + sid + ",view:" + ExtendUtil.debugViewLite(view));
465
+ }
466
+ }
467
+
468
+ //此处vue是怎么传值的
469
+ @HippyControllerProps(name = "scrollOverride", defaultType = HippyControllerProps.MAP)
470
+ public void setScrollOverride(T view, HippyMap hippyMap) {
471
+ if (view instanceof HippyViewGroup) {
472
+ ((HippyViewGroup) view).setScrollOverride(hippyMap);
473
+ }
474
+ }
475
+
476
+ @HippyControllerProps(name = "focusableInTouchMode", defaultType = HippyControllerProps.BOOLEAN)
477
+ public void setFocusableInTouchMode(T view, boolean focusable) {
478
+ view.setFocusableInTouchMode(focusable);
479
+ }
480
+
481
+ @HippyControllerProps(name = NodeProps.FOCUSABLE, defaultType = HippyControllerProps.BOOLEAN)
482
+ public void setFocusable(T view, boolean focusable) {
483
+ // LogAdapterUtils.log(view.getContext(),FocusDispatchView.TAG,":setFocusable "+focusable+" view is :"+ExtendUtil.debugViewLite(view));
484
+ ExtendUtil.setViewFocusable(view, focusable);
485
+ if (view instanceof AsyncImageView) {
486
+ ((AsyncImageView) view).setEnableMouse(focusable);
487
+ }
488
+ if ((view.getId() != -1)) {//2022.05.18 zhaopeng itemView不需要在这里设置事件
489
+ if (focusable) {
490
+ if (LogUtils.isDebug()) {
491
+ Log.i("ViewController", "ElementCallback setFocusable this view:" + view + ",id:" + view.getId());
492
+ }
493
+ view.setOnFocusChangeListener(this);
494
+ } else {
495
+ if (LogUtils.isDebug()) {
496
+ Log.i("ViewController", "ElementCallback setFocusable null view:" + view + ",id:" + view.getId());
497
+ }
498
+ view.setOnFocusChangeListener(null);
499
+ }
500
+ } else {
501
+ if (LogUtils.isDebug()) {
502
+ Log.e(TAG, "setup Focus fail,itemView 不需要设置FOCUSABLE");
503
+ }
504
+ }
505
+ }
506
+
507
+ @HippyControllerProps(name = NodeProps.REQUEST_FOCUS, defaultType = HippyControllerProps.BOOLEAN)
508
+ public void requestFocus(final T view, boolean request) {
509
+ if (LogUtils.isDebug() && request) {
510
+ Log.w(FocusDispatchView.TAG, "requestFocus called !!!! view:" + ExtendUtil.debugViewLite(view));
511
+ }
512
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":requestFocus " + request + " view is :" + ExtendUtil.debugViewLite(view));
513
+ if (request) {
514
+ //noinspection AccessStaticViaInstance
515
+ Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
516
+ @Override
517
+ public boolean queueIdle() {
518
+ bUserChageFocus = true;
519
+ boolean result = view.requestFocusFromTouch();
520
+
521
+ if (!result) {
522
+ result = view.requestFocus();
523
+ LogUtils.d("requestFocus", "requestFocus result:" + result);
524
+ }
525
+ //Zhaopeng 20210421 解决9.0上有时候焦点请求慢的问题。
526
+ // view.requestFocus();
527
+ bUserChageFocus = false;
528
+ return false;
529
+ }
530
+ });
531
+ }
532
+
533
+ }
534
+
535
+ /*2.5 add**/
536
+ @HippyControllerProps(name = "fadingEdgeLength", defaultType = HippyControllerProps.NUMBER)
537
+ public void setFadingEdgeLength(View view, int length) {
538
+ view.setFadingEdgeLength(Utils.toPX(length));
539
+ }
540
+
541
+ @HippyControllerProps(name = "skipRequestFocus", defaultType = HippyControllerProps.BOOLEAN)
542
+ public void setSkipRequestFocus(View view, Boolean b) {
543
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":skipRequestFocus " + b + " view is :" + ExtendUtil.debugViewLite(view));
544
+ if (view instanceof ITVView) {
545
+ ((ITVView) view).setSkipRequestFocus(b);
546
+ }
547
+ if (view instanceof ExtendViewGroup) {
548
+ ((ExtendViewGroup) view).setSkipRequestFocus(b);
549
+ }
550
+ }
551
+
552
+ @HippyControllerProps(name = "fillParent", defaultType = HippyControllerProps.BOOLEAN)
553
+ public void setFillParentEnabled(View view, Boolean fillParent) {
554
+ if (view instanceof ITVView) {
555
+ ((ITVView) view).setFillParent(fillParent);
556
+ }
557
+ }
558
+
559
+ /*2.5 add**/
560
+ @HippyControllerProps(name = "horizontalFadingEdgeEnabled", defaultType = HippyControllerProps.BOOLEAN)
561
+ public void setHorizontalFadingEdgeEnabled(View view, boolean horizontalFadingEdgeEnabled) {
562
+ view.setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled);
563
+ }
564
+
565
+ /*2.5 add**/
566
+ @HippyControllerProps(name = "verticalFadingEdgeEnabled", defaultType = HippyControllerProps.BOOLEAN)
567
+ public void setVerticalFadingEdgeEnabled(View view, boolean verticalFadingEdgeEnabled) {
568
+ view.setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled);
569
+ }
570
+
571
+ @HippyControllerProps(name = "requestFocusFromTouchDirectly", defaultType = HippyControllerProps.BOOLEAN)
572
+ public void requestFocusFromTouch(final T view, final boolean request) {
573
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":requestFocusFromTouchDirectly request " + request + " view is :" + ExtendUtil.debugViewLite(view));
574
+ if (request) {
575
+
576
+ bUserChageFocus = true;
577
+ boolean result = view.requestFocusFromTouch();
578
+
579
+ if (!result) {
580
+ result = view.requestFocus();
581
+ LogUtils.d("requestFocus", "requestFocusFromTouch result:" + result);
582
+ }
583
+ if (LogUtils.isDebug()) {
584
+ LogUtils.e("requestFocus", "requestFocusFromTouch view:" + view.getId());
585
+ }
586
+ }
587
+
588
+ }
589
+
590
+ @HippyControllerProps(name = "requestFocusDirectly", defaultType = HippyControllerProps.BOOLEAN)
591
+ public void requestFocusDirectly(final T view, final boolean request) {
592
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":requestFocusDirectly request " + request + " view is :" + ExtendUtil.debugViewLite(view));
593
+ if (request) {
594
+ view.requestFocus();
595
+ if (LogUtils.isDebug()) {
596
+ LogUtils.e(FocusDispatchView.TAG, "requestFocusDirectly view:" + view.getId());
597
+ }
598
+ }
599
+ }
600
+ // @Deprecated
601
+ // //list controll属性
602
+ // @HippyControllerProps(name = "autoFocusID", defaultType = HippyControllerProps.STRING)
603
+ // public void setAutoFocus(final T view, final String autoFocusID) {
604
+ // final View rootView = HippyViewGroup.findPageRootView(view);
605
+ // if(rootView instanceof HippyViewGroup){
606
+ // ((HippyViewGroup) rootView).getAutoFocusManager().setAppearFocusTag(autoFocusID,0);
607
+ // }else{
608
+ // //final View rootView = HippyViewGroup.findPageRootView(view);
609
+ // Log.e(AutoFocusManager.TAG,"setAutoFocus called in controller error rootView is :"+rootView);
610
+ // }
611
+ // }
612
+
613
+ @Deprecated
614
+ @HippyControllerProps(name = "autoFocus", defaultType = HippyControllerProps.STRING)
615
+ public void setFocusSID(final T view, final String autoFocusID) {
616
+ LogUtils.i(AutoFocusManager.TAG, "set autoFocus by autoFocusID : " + autoFocusID + ",view:" + view);
617
+ final View rootView = HippyViewGroup.findPageRootView(view);
618
+ if (rootView instanceof HippyViewGroup) {
619
+ ((HippyViewGroup) rootView).getAutoFocusManager().setGlobalAutofocusSID(autoFocusID, 0);
620
+ } else {
621
+ //final View rootView = HippyViewGroup.findPageRootView(view);
622
+ Log.w(AutoFocusManager.TAG, "setAutoFocus 1 called in controller error rootView is :" + rootView);
623
+ }
624
+ }
625
+
626
+ @HippyControllerProps(name = "autofocusSID", defaultType = HippyControllerProps.STRING)
627
+ public void setAutoFocusSID(final T view, final String autoFocusID) {
628
+ if (TemplateCodeParser.isPendingProForce(autoFocusID)) {
629
+ return;
630
+ }
631
+ final View rootView = HippyViewGroup.findPageRootView(view);
632
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":autofocusSID " + autoFocusID + " view is :" + ExtendUtil.debugViewLite(view));
633
+ if (rootView instanceof HippyViewGroup) {
634
+ ((HippyViewGroup) rootView).getAutoFocusManager().setGlobalAutofocusSID(autoFocusID, 0);
635
+ } else {
636
+ //final View rootView = HippyViewGroup.findPageRootView(view);
637
+ Log.w(AutoFocusManager.TAG, "setAutofocusSID called in controller error rootView is :" + rootView);
638
+ }
639
+ }
640
+
641
+
642
+ //list controll属性
643
+ @HippyControllerProps(name = "autofocus", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
644
+ public void setAutoFocus(final T view, final boolean autoFocus) {
645
+ LogUtils.i(AutoFocusManager.TAG, "set autoFocus by bool : " + autoFocus + ",view:" + view);
646
+ if (view instanceof ITVView) {
647
+ ((ITVView) view).setAutoFocus(autoFocus, false);
648
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":setAutoFocus " + autoFocus + " view is :" + ExtendUtil.debugViewLite(view));
649
+ }
650
+ }
651
+
652
+ //list controll属性
653
+ @HippyControllerProps(name = "autofocusForce", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
654
+ public void setAutoFocusForce(final T view, final boolean autoFocus) {
655
+ LogUtils.i(AutoFocusManager.TAG, "set autoFocus by bool : " + autoFocus + ",view:" + view);
656
+ if (view instanceof ITVView) {
657
+ ((ITVView) view).setAutoFocus(autoFocus, true);
658
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ":setAutoFocusForce " + autoFocus + " view is :" + ExtendUtil.debugViewLite(view));
659
+ }
660
+ }
661
+
662
+ @Override
663
+ public void onFocusChange(final View v, boolean hasFocus) {
664
+ HippyMap hippyMap = new HippyMap();
665
+ hippyMap.pushBoolean("isFocused", hasFocus);
666
+ hippyMap.pushString("sid", ExtendUtil.getViewSID(v));
667
+ if (mFocusEvent == null) {
668
+ mFocusEvent = new HippyViewEvent("onFocus");
669
+ }
670
+ if (v instanceof TriggerTaskHost) {
671
+ if (hasFocus) {
672
+ TriggerTaskManagerModule.dispatchTriggerTask((TriggerTaskHost) v, "onFocused");
673
+ } else {
674
+ TriggerTaskManagerModule.dispatchTriggerTask((TriggerTaskHost) v, "unFocused");
675
+ }
676
+ }
677
+ mFocusEvent.send(v, hippyMap);
678
+
679
+ }
680
+
681
+
682
+ @HippyControllerProps(name = NodeProps.LINEAR_GRADIENT, defaultType = HippyControllerProps.MAP)
683
+ public void setLinearGradient(T view, HippyMap linearGradient) {
684
+ if (linearGradient != null && view instanceof IGradient) {
685
+ String angle = linearGradient.getString("angle");
686
+ HippyArray colorStopList = linearGradient.getArray("colorStopList");
687
+
688
+ if (TextUtils.isEmpty(angle) || colorStopList == null || colorStopList.size() == 0) {
689
+ return;
690
+ }
691
+
692
+ int size = colorStopList.size();
693
+ ArrayList<Integer> colorsArray = new ArrayList<>();
694
+ ArrayList<Float> positionsArray = new ArrayList<>();
695
+ for (int i = 0; i < size; i++) {
696
+ HippyMap colorStop = colorStopList.getMap(i);
697
+ if (colorStop == null) {
698
+ continue;
699
+ }
700
+
701
+ int color = colorStop.getInt("color");
702
+ colorsArray.add(color);
703
+
704
+ float ratio = 0.0f;
705
+ if (colorStop.containsKey("ratio")) {
706
+ ratio = (float) colorStop.getDouble("ratio");
707
+ } else if (i == (size - 1)) {
708
+ ratio = 1.0f;
709
+ }
710
+
711
+ positionsArray.add(ratio);
712
+ }
713
+
714
+ ((IGradient) view).setGradientAngle(angle);
715
+ ((IGradient) view).setGradientColors(colorsArray);
716
+ ((IGradient) view).setGradientPositions(positionsArray);
717
+ }
718
+ }
719
+
720
+ @HippyControllerProps(name = NodeProps.SHADOW_OFFSET, defaultType = HippyControllerProps.MAP)
721
+ public void setShadowOffset(T view, HippyMap shadowOffset) {
722
+ if (shadowOffset != null && view instanceof IShadow) {
723
+ float shadowOffsetX = shadowOffset.getInt("x");
724
+ float shadowOffsetY = shadowOffset.getInt("y");
725
+ ((IShadow) view).setShadowOffsetX(shadowOffsetX);
726
+ ((IShadow) view).setShadowOffsetY(shadowOffsetY);
727
+ }
728
+ }
729
+
730
+ @HippyControllerProps(name = NodeProps.SHADOW_OFFSET_X, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
731
+ public void setShadowOffsetX(T view, float shadowOffsetX) {
732
+ if (view instanceof IShadow)
733
+ ((IShadow) view).setShadowOffsetX(shadowOffsetX);
734
+ }
735
+
736
+ @HippyControllerProps(name = NodeProps.SHADOW_OFFSET_Y, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
737
+ public void setShadowOffsetY(T view, float shadowOffsetY) {
738
+ if (view instanceof IShadow)
739
+ ((IShadow) view).setShadowOffsetY(shadowOffsetY);
740
+ }
741
+
742
+ @HippyControllerProps(name = NodeProps.SHADOW_OPACITY, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
743
+ public void setShadowOpacity(T view, float shadowOpacity) {
744
+ if (view instanceof IShadow) {
745
+ ((IShadow) view).setShadowOpacity(shadowOpacity);
746
+ }
747
+ }
748
+
749
+ @HippyControllerProps(name = NodeProps.SHADOW_RADIUS, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
750
+ public void setShadowRadius(T view, float shadowRadius) {
751
+ if (view instanceof IShadow) {
752
+ ((IShadow) view).setShadowRadius(shadowRadius);
753
+ }
754
+ }
755
+
756
+ @HippyControllerProps(name = NodeProps.SHADOW_SPREAD, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
757
+ public void setShadowSpread(T view, float shadowSpread) {
758
+ if (view instanceof IShadow) {
759
+ ((IShadow) view).setShadowSpread(shadowSpread);
760
+ }
761
+ }
762
+
763
+ @HippyControllerProps(name = NodeProps.SHADOW_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
764
+ public void setShadowColor(T view, int shadowColor) {
765
+ if (view instanceof IShadow) {
766
+ ((IShadow) view).setShadowColor(shadowColor);
767
+ }
768
+ }
769
+
770
+ @HippyControllerProps(name = NodeProps.BORDER_LEFT_WIDTH, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
771
+ public void setLeftBorderWidth(T view, float borderLeftWidth) {
772
+ if (view instanceof CommonBorder) {
773
+ ((CommonBorder) view)
774
+ .setBorderWidth(borderLeftWidth, CommonBorder.BorderWidthDirection.LEFT.ordinal());
775
+ }
776
+ }
777
+
778
+
779
+ @HippyControllerProps(name = NodeProps.BORDER_TOP_WIDTH, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
780
+ public void setTopBorderWidth(T view, float borderTopWidth) {
781
+ if (view instanceof CommonBorder) {
782
+ ((CommonBorder) view)
783
+ .setBorderWidth(borderTopWidth, CommonBorder.BorderWidthDirection.TOP.ordinal());
784
+ }
785
+ }
786
+
787
+
788
+ @HippyControllerProps(name = NodeProps.BORDER_RIGHT_WIDTH, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
789
+ public void setRightBorderWidth(T view, float borderRightWidth) {
790
+ if (view instanceof CommonBorder) {
791
+ ((CommonBorder) view)
792
+ .setBorderWidth(borderRightWidth, CommonBorder.BorderWidthDirection.RIGHT.ordinal());
793
+ }
794
+ }
795
+
796
+
797
+ @HippyControllerProps(name = NodeProps.BORDER_BOTTOM_WIDTH, defaultType = HippyControllerProps.NUMBER, defaultNumber = 0)
798
+ public void setBottomBorderWidth(T view, float borderBottomWidth) {
799
+ if (view instanceof CommonBorder) {
800
+ ((CommonBorder) view)
801
+ .setBorderWidth(borderBottomWidth, CommonBorder.BorderWidthDirection.BOTTOM.ordinal());
802
+ }
803
+ }
804
+
805
+
806
+ @HippyControllerProps(name = NodeProps.BORDER_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
807
+ public void setBorderColor(T view, int borderColor) {
808
+ if (view instanceof CommonBorder) {
809
+ ((CommonBorder) view)
810
+ .setBorderColor(borderColor, CommonBorder.BorderWidthDirection.ALL.ordinal());
811
+ }
812
+ }
813
+
814
+ @HippyControllerProps(name = NodeProps.BORDER_LEFT_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
815
+ public void setBorderLeftColor(T view, int borderLeftColor) {
816
+ if (view instanceof CommonBorder) {
817
+ ((CommonBorder) view)
818
+ .setBorderColor(borderLeftColor, CommonBorder.BorderWidthDirection.LEFT.ordinal());
819
+ }
820
+ }
821
+
822
+
823
+ @HippyControllerProps(name = NodeProps.BORDER_TOP_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
824
+ public void setBorderTopWidth(T view, int borderTopColor) {
825
+ if (view instanceof CommonBorder) {
826
+ ((CommonBorder) view)
827
+ .setBorderColor(borderTopColor, CommonBorder.BorderWidthDirection.TOP.ordinal());
828
+ }
829
+ }
830
+
831
+ @HippyControllerProps(name = NodeProps.BORDER_RIGHT_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
832
+ public void setBorderRightWidth(T view, int borderRightColor) {
833
+ if (view instanceof CommonBorder) {
834
+ ((CommonBorder) view)
835
+ .setBorderColor(borderRightColor, CommonBorder.BorderWidthDirection.RIGHT.ordinal());
836
+ }
837
+ }
838
+
839
+
840
+ @HippyControllerProps(name = NodeProps.BORDER_BOTTOM_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
841
+ public void setBorderBottomWidth(T view, int borderBottomColor) {
842
+ if (view instanceof CommonBorder) {
843
+ ((CommonBorder) view)
844
+ .setBorderColor(borderBottomColor, CommonBorder.BorderWidthDirection.BOTTOM.ordinal());
845
+ }
846
+ }
847
+
848
+ /**
849
+ * touch/click
850
+ **/
851
+ @HippyControllerProps(name = NodeProps.ON_CLICK, defaultType = HippyControllerProps.BOOLEAN)
852
+ public void setClickable(T view, boolean flag) {
853
+ if (!handleGestureBySelf()) {
854
+ if (flag) {
855
+ view.setOnClickListener(NativeGestureDispatcher.getOnClickListener());
856
+ } else {
857
+ view.setOnClickListener(null);
858
+ view.setClickable(false);
859
+ }
860
+ }
861
+ }
862
+
863
+ /**
864
+ * 2.11.x
865
+ *
866
+ * @param view
867
+ * @param flag
868
+ */
869
+ @HippyControllerProps(name = "clickable", defaultType = HippyControllerProps.BOOLEAN)
870
+ public void setClickableDirect(T view, boolean flag) {
871
+ view.setClickable(flag);
872
+ }
873
+
874
+ /**
875
+ * 2.11.x
876
+ *
877
+ * @param view
878
+ * @param flag
879
+ */
880
+ @HippyControllerProps(name = "enabled", defaultType = HippyControllerProps.BOOLEAN)
881
+ public void setEnabled(T view, boolean flag) {
882
+ view.setEnabled(flag);
883
+ }
884
+
885
+
886
+ @HippyControllerProps(name = NodeProps.ON_LONG_CLICK, defaultType = HippyControllerProps.BOOLEAN)
887
+ public void setLongClickable(T view, boolean flag) {
888
+ if (!handleGestureBySelf()) {
889
+ if (flag) {
890
+ view.setOnLongClickListener(NativeGestureDispatcher.getOnLongClickListener());
891
+ } else {
892
+ view.setOnLongClickListener(null);
893
+ view.setLongClickable(false);
894
+ }
895
+ }
896
+ }
897
+
898
+ @HippyControllerProps(name = NodeProps.ON_PRESS_IN, defaultType = HippyControllerProps.BOOLEAN)
899
+ public void setPressInable(T view, boolean flag) {
900
+ if (!handleGestureBySelf()) {
901
+ setGestureType(view, NodeProps.ON_PRESS_IN, flag);
902
+ }
903
+ }
904
+
905
+ @HippyControllerProps(name = NodeProps.ON_PRESS_OUT, defaultType = HippyControllerProps.BOOLEAN)
906
+ public void setPressOutable(T view, boolean flag) {
907
+ if (!handleGestureBySelf()) {
908
+ setGestureType(view, NodeProps.ON_PRESS_OUT, flag);
909
+ }
910
+ }
911
+
912
+ @HippyControllerProps(name = NodeProps.ON_TOUCH_DOWN, defaultType = HippyControllerProps.BOOLEAN)
913
+ public void setTouchDownHandle(T view, boolean flag) {
914
+ if (!handleGestureBySelf()) {
915
+ setGestureType(view, NodeProps.ON_TOUCH_DOWN, flag);
916
+ }
917
+ }
918
+
919
+ @HippyControllerProps(name = NodeProps.ON_TOUCH_MOVE, defaultType = HippyControllerProps.BOOLEAN)
920
+ public void setTouchMoveHandle(T view, boolean flag) {
921
+ if (!handleGestureBySelf()) {
922
+ setGestureType(view, NodeProps.ON_TOUCH_MOVE, flag);
923
+ }
924
+ }
925
+
926
+ @HippyControllerProps(name = NodeProps.ON_TOUCH_END, defaultType = HippyControllerProps.BOOLEAN)
927
+ public void setTouchEndHandle(T view, boolean flag) {
928
+ if (!handleGestureBySelf()) {
929
+ setGestureType(view, NodeProps.ON_TOUCH_END, flag);
930
+ }
931
+ }
932
+
933
+ @HippyControllerProps(name = NodeProps.ON_TOUCH_CANCEL, defaultType = HippyControllerProps.BOOLEAN)
934
+ public void setTouchCancelHandle(T view, boolean flag) {
935
+ if (!handleGestureBySelf()) {
936
+ setGestureType(view, NodeProps.ON_TOUCH_CANCEL, flag);
937
+ }
938
+ }
939
+
940
+ @HippyControllerProps(name = NodeProps.ON_ATTACHED_TO_WINDOW, defaultType = HippyControllerProps.BOOLEAN)
941
+ public void setAttachedToWindowHandle(T view, boolean flag) {
942
+ if (flag) {
943
+ view.addOnAttachStateChangeListener(NativeGestureDispatcher.getOnAttachedToWindowListener());
944
+ } else {
945
+ view.removeOnAttachStateChangeListener(
946
+ NativeGestureDispatcher.getOnAttachedToWindowListener());
947
+ }
948
+ }
949
+
950
+ @HippyControllerProps(name = NodeProps.ON_DETACHED_FROM_WINDOW, defaultType = HippyControllerProps.BOOLEAN)
951
+ public void setDetachedFromWindowHandle(T view, boolean flag) {
952
+ if (flag) {
953
+ view.addOnAttachStateChangeListener(
954
+ NativeGestureDispatcher.getOnDetachedFromWindowListener());
955
+ } else {
956
+ view.removeOnAttachStateChangeListener(
957
+ NativeGestureDispatcher.getOnDetachedFromWindowListener());
958
+ }
959
+ }
960
+
961
+ @HippyControllerProps(name = "renderToHardwareTextureAndroid", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
962
+ public void setRenderToHardwareTexture(T view, boolean useHWTexture) {
963
+ view.setLayerType(useHWTexture ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE, null);
964
+ }
965
+
966
+ @SuppressWarnings("EmptyMethod")
967
+ @HippyControllerProps(name = NodeProps.CUSTOM_PROP)
968
+ public void setCustomProp(T view, String methodName, Object props) {
969
+
970
+ }
971
+
972
+ protected void setGestureType(T view, String type, boolean flag) {
973
+ // add by weipeng
974
+ // 自定义的组件为实现HippyViewBase接口,需要判断下
975
+ if (!(view instanceof HippyViewBase)) return;
976
+ if (flag) {
977
+ if (view.getGestureDispatcher() == null) {
978
+ view.setGestureDispatcher(new NativeGestureDispatcher(view));
979
+ }
980
+ view.getGestureDispatcher().addGestureType(type);
981
+ } else {
982
+ if (view.getGestureDispatcher() != null) {
983
+ view.getGestureDispatcher().removeGestureType(type);
984
+ }
985
+ }
986
+ }
987
+
988
+ public RenderNode createRenderNode(int id, HippyMap props, String className,
989
+ HippyRootView hippyRootView, ControllerManager controllerManager,
990
+ boolean lazy) {
991
+ return new RenderNode(id, props, className, hippyRootView, controllerManager, lazy);
992
+ }
993
+
994
+ private void applyTransform(T view, HippyArray transformArray) {
995
+ TransformUtil.processTransform(transformArray, sTransformDecompositionArray);
996
+ sMatrixDecompositionContext.reset();
997
+ MatrixUtil.decomposeMatrix(sTransformDecompositionArray, sMatrixDecompositionContext);
998
+ view.setTranslationX(PixelUtil.dp2px((float) sMatrixDecompositionContext.translation[0]));
999
+ view.setTranslationY(PixelUtil.dp2px((float) sMatrixDecompositionContext.translation[1]));
1000
+ view.setRotation((float) sMatrixDecompositionContext.rotationDegrees[2]);
1001
+ view.setRotationX((float) sMatrixDecompositionContext.rotationDegrees[0]);
1002
+ view.setRotationY((float) sMatrixDecompositionContext.rotationDegrees[1]);
1003
+ view.setScaleX((float) sMatrixDecompositionContext.scale[0]);
1004
+ view.setScaleY((float) sMatrixDecompositionContext.scale[1]);
1005
+ }
1006
+
1007
+ public static void resetTransform(View view) {
1008
+ view.setTranslationX(0);
1009
+ view.setTranslationY(0);
1010
+ view.setRotation(0);
1011
+ view.setRotationX(0);
1012
+ view.setRotationY(0);
1013
+ view.setScaleX(1);
1014
+ view.setScaleY(1);
1015
+ }
1016
+
1017
+ /***
1018
+ * dispatch the js call UI Function.
1019
+ * @see #dispatchFunction(View, String, HippyArray, Promise)
1020
+ * @param view
1021
+ * @param functionName
1022
+ * @param var
1023
+ */
1024
+ public void dispatchFunction(T view, String functionName, HippyArray var) {
1025
+ // if("dispatchFunctionBySid".equals(functionName)){
1026
+ // Log.e(ReplaceChildView.TAG,"native call dispatchFunctionBySid var"+var);
1027
+ // }
1028
+ if (LogUtils.isDebug()) {
1029
+ Log.d(TAG, "dispatchFunction functionName:" + functionName + ",var :" + var + ",callView:" + ExtendUtil.debugViewLite(view));
1030
+ //Log.d(FastListView.TAG_CLONED,"dispatchFunction functionName:"+functionName+",var :"+var+",view:"+view);
1031
+ }
1032
+ if (FastListViewController.dispatchFunctionByTemplate(this, view, functionName, var, null)) {
1033
+ // Log.e(ReplaceChildView.TAG,"native call dispatchFunctionBySid return on dispatchFunctionByTemplate");
1034
+ return;
1035
+ }
1036
+ switch (functionName) {
1037
+ case "requestFocus":
1038
+ if (LogUtils.isDebug()) {
1039
+ Log.e(FocusDispatchView.TAG, "requestFocus by dispatchFunction view:" + view.getId());
1040
+ }
1041
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">requestFocus view is :" + ExtendUtil.debugViewLite(view));
1042
+ if (var.size() > 0) {
1043
+ int direction = var.getInt(0);
1044
+ view.requestFocus(direction);
1045
+ } else {
1046
+ requestFocus(view, true);
1047
+ }
1048
+ break;
1049
+
1050
+ case "requestFocusDirectly":
1051
+ if (LogUtils.isDebug()) {
1052
+ Log.e(FocusDispatchView.TAG, "requestFocusDirectly by dispatchFunction view:" + view.getId());
1053
+ }
1054
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">requestFocusDirectly view is :" + ExtendUtil.debugViewLite(view));
1055
+ if (var.size() > 0) {
1056
+ int direction = var.getInt(0);
1057
+ view.requestFocus(direction);
1058
+ } else {
1059
+ view.requestFocus();
1060
+ }
1061
+ break;
1062
+ case "requestRootLayout":
1063
+ LogUtils.d("hippy", "requestRootLayout called by :" + view.getId());
1064
+ if (view.getRootView() != null) {
1065
+ view.getRootView().requestLayout();
1066
+ }
1067
+ break;
1068
+ case "requestLayout":
1069
+ LogUtils.d("hippy", "requestLayout called by :" + view.getId());
1070
+ view.requestLayout();
1071
+ break;
1072
+ case "setDescendantFocusability":
1073
+ if (view instanceof ViewGroup) {
1074
+ if (var.size() > 0) {
1075
+ int focusAbility = var.getInt(0);
1076
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">setDescendantFocusability " + focusAbility + "view is :" + ExtendUtil.debugViewLite(view));
1077
+ Log.d("hippy", "setDescendantFocusability :" + focusAbility);
1078
+ ((ViewGroup) view).setDescendantFocusability(focusAbility);
1079
+ }
1080
+ }
1081
+ break;
1082
+
1083
+ case "changeDescendantFocusability":
1084
+ if (view instanceof ViewGroup) {
1085
+ if (var.size() > 0) {
1086
+ String focusAbility = var.getString(0);
1087
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">changeDescendantFocusability " + focusAbility + "view is :" + ExtendUtil.debugViewLite(view));
1088
+ int focusAbilityInt = ViewGroup.FOCUS_AFTER_DESCENDANTS;
1089
+ switch (focusAbility) {
1090
+ case "beforeDescendants":
1091
+ ((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
1092
+ break;
1093
+ case "blockDescendants":
1094
+ ((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
1095
+ break;
1096
+ default:
1097
+ ((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
1098
+ break;
1099
+ }
1100
+ LogUtils.d(FocusDispatchView.TAG, "changeDescendantFocusability request focusAbility:" + focusAbility + " ,result :" + focusAbilityInt + ", view:" + view);
1101
+ }
1102
+ }
1103
+ break;
1104
+ case "forceUpdateRenderNode":
1105
+ if (view != null) {
1106
+ Log.d("viewController", "forceUpdateRenderNode called,id:" + view.getId());
1107
+ final Context context = view.getContext();
1108
+ if (context instanceof HippyInstanceContext) {
1109
+ final HippyEngineContext hippyContext = ((HippyInstanceContext) context).getEngineContext();
1110
+ if (context != null) {
1111
+ final RenderNode node = hippyContext.getRenderManager().getRenderNode(view.getId());
1112
+ if (node != null && !node.isDelete()) {
1113
+ node.updateViewLayoutRecursive();
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ break;
1119
+ case "setBackGroundColor":
1120
+ if (view != null) {
1121
+ try {
1122
+ setBackgroundString(view, var.getString(0));
1123
+ view.invalidate();
1124
+ } catch (Exception e) {
1125
+ if (LogUtils.isDebug()) {
1126
+ e.printStackTrace();
1127
+ }
1128
+ }
1129
+ }
1130
+ break;
1131
+ case "layoutViewManual":
1132
+ if (view != null) {
1133
+ ExtendUtil.layoutViewManual(view);
1134
+ }
1135
+ break;
1136
+ case "blockRootFocus":
1137
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">blockRootFocus view is :" + ExtendUtil.debugViewLite(view));
1138
+ InternalExtendViewUtil.blockRootFocus(view);
1139
+ break;
1140
+ case "clearFocus":
1141
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">clearFocus view is :" + ExtendUtil.debugViewLite(view));
1142
+ InternalExtendViewUtil.clearFocus(view);
1143
+ break;
1144
+ case "unBlockRootFocus":
1145
+ if (LogUtils.isDebug()) {
1146
+ LogUtils.e(FocusDispatchView.TAG, "unBlockRootFocus by ViewController view:" + view.getId());
1147
+ }
1148
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">unBlockRootFocus view is :" + ExtendUtil.debugViewLite(view));
1149
+ InternalExtendViewUtil.unBlockRootFocus(view);
1150
+ break;
1151
+ case "changeVisibility":
1152
+ final String visi = var.getString(0);
1153
+ switch (visi) {
1154
+ case "visible":
1155
+ view.setVisibility(View.VISIBLE);
1156
+ break;
1157
+ case "invisible":
1158
+ view.setVisibility(View.INVISIBLE);
1159
+ break;
1160
+ case "gone":
1161
+ view.setVisibility(View.GONE);
1162
+ break;
1163
+ }
1164
+ break;
1165
+ case "changeAlpha":
1166
+ final double alpha = var.getDouble(0);
1167
+ view.setAlpha((float) alpha);
1168
+ break;
1169
+ case "setScale":
1170
+ final double scaleX = var.getDouble(0);
1171
+ final double scaleY = var.getDouble(1);
1172
+ final int duration = var.getInt(2);
1173
+ if (duration <= 0) {
1174
+ view.setScaleX((float) scaleX);
1175
+ view.setScaleY((float) scaleY);
1176
+ view.invalidate();
1177
+ } else {
1178
+ TVFocusScaleExcuter.bounceScaleTo(view, (float) scaleX, (float) scaleY, duration);
1179
+ }
1180
+ break;
1181
+ case "setPosition":
1182
+ final int px = var.getInt(0);
1183
+ final int py = var.getInt(1);
1184
+ final int pz = var.getInt(2);
1185
+ view.setX(Utils.toPX(px));
1186
+ view.setY(Utils.toPX(py));
1187
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
1188
+ view.setZ(Utils.toPX(pz));
1189
+ }
1190
+ break;
1191
+ case "updateLayout":
1192
+ if (view != null) {
1193
+ final int width = Utils.toPX(var.getInt(0));
1194
+ final int height = Utils.toPX(var.getInt(1));
1195
+ final int x = Utils.toPX(var.getInt(2));
1196
+ final int y = Utils.toPX(var.getInt(3));
1197
+ if (var.size() >= 5 && var.getBoolean(4) && view.getId() != -1) {
1198
+ RenderUtil.updateDomLayout(x, y, width, height, view);
1199
+ } else {
1200
+ view.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
1201
+ View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
1202
+ if (!shouldInterceptLayout(view, x, y, width, height)) {
1203
+ view.layout(x, y, x + width, y + height);
1204
+ }
1205
+ }
1206
+ }
1207
+ break;
1208
+ case "invalidate":
1209
+ view.invalidate();
1210
+ break;
1211
+ case "deepInvalidate":
1212
+ deepInvalidate(view, var);
1213
+ break;
1214
+ case "changeProgress":
1215
+ if (view instanceof ProgressBar) {
1216
+ final ProgressBar pb = (ProgressBar) view;
1217
+ final int progress = var.getInt(0);
1218
+ final int secondProgress = var.getInt(1);
1219
+ final int max = var.getInt(2);
1220
+ pb.setProgress(progress);
1221
+ pb.setSecondaryProgress(secondProgress);
1222
+ pb.setMax(max);
1223
+ }
1224
+ break;
1225
+ case "dispatchFunctionForTarget":
1226
+ final String targetName = var.getString(0);
1227
+ final String functionTargetName = var.getString(1);
1228
+ final View root = InternalExtendViewUtil.getRootView(view);
1229
+ if (root != null) {
1230
+ final View target = ControllerManager.findViewByName(root, targetName);
1231
+ if (target != null && functionTargetName != null && !"dispatchFunctionForTarget".equals(functionTargetName)) {
1232
+ final HippyArray array = var.getArray(2);
1233
+ int delay = 0;
1234
+ if (var.size() > 3) {
1235
+ delay = var.getInt(3);
1236
+ }
1237
+ final Context context = view.getContext();
1238
+ if (context instanceof HippyInstanceContext) {
1239
+ final HippyEngineContext hippyContext = ((HippyInstanceContext) context).getEngineContext();
1240
+ final RenderNode node = hippyContext.getRenderManager().getRenderNode(view.getId());
1241
+ final String className = node.getClassName();
1242
+ if (LogUtils.isDebug()) {
1243
+ Log.v("hippy", "dispatchFunctionForTarget view:" + view.getId() + ",className:" + className + ",functionTargetName:" + functionTargetName + ",array :" + array + ",delay:" + delay);
1244
+ }
1245
+ hippyContext.getRenderManager().getControllerManager().dispatchUIFunction(view.getId(), className, functionTargetName, array, delay);
1246
+ }
1247
+ }
1248
+ }
1249
+ break;
1250
+
1251
+ case "setBlockFocusDirections":
1252
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">setBlockFocusDirections " + var.getArray(0) + " view is :" + ExtendUtil.debugViewLite(view));
1253
+ this.setBlockFocusDirectionsV2(view, var.getArray(0));
1254
+ break;
1255
+ case "setBlockFocusDirectionsOnFail":
1256
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">setBlockFocusDirectionsOnFail " + var.getArray(0) + " view is :" + ExtendUtil.debugViewLite(view));
1257
+ this.setBlockFocusDirectionsOnFail(view, var.getArray(0));
1258
+ break;
1259
+ case "dispatchTVItemFunction":
1260
+ this.dispatchTVItemFunction(view, var, null);
1261
+ break;
1262
+ //2.6
1263
+ case "setInitFocus":
1264
+ case "setAutoFocus":
1265
+ final View rootView = HippyViewGroup.findPageRootView(view);
1266
+ Log.i(AutoFocusManager.TAG, "setAutoFocus called rootView is :" + rootView + ",var:" + var);
1267
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">setAutoFocus params" + var + " view is :" + ExtendUtil.debugViewLite(view));
1268
+ if (rootView instanceof HippyViewGroup) {
1269
+ int delay = var.size() == 2 ? var.getInt(1) : -1;
1270
+ if (delay > 0 && view.getId() != -1) {
1271
+ ((HippyViewGroup) rootView).getAutoFocusManager().setGlobalAutofocusSID(var.getString(0), delay, view);
1272
+ } else {
1273
+ ((HippyViewGroup) rootView).getAutoFocusManager().setGlobalAutofocusSID(var.getString(0), var.size() == 2 ? var.getInt(1) : -1);
1274
+ }
1275
+ } else {
1276
+ //final View rootView = HippyViewGroup.findPageRootView(view);
1277
+ Log.e(AutoFocusManager.TAG, "setAutoFocus called error rootView is :" + rootView);
1278
+ }
1279
+ break;
1280
+ case "setAutofocus":
1281
+ boolean autofocus = var.getBoolean(0);
1282
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">setAutofocus " + autofocus + " view is :" + ExtendUtil.debugViewLite(view));
1283
+ if (view instanceof ITVView) {
1284
+ ((ITVView) view).setAutoFocus(autofocus, true);
1285
+ }
1286
+ break;
1287
+ case "dispatchFunctionBySid":
1288
+ dispatchFunctionBySid(view, var, null);
1289
+ break;
1290
+ case "requestAutofocus":
1291
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, ">requestAutofocus view is :" + ExtendUtil.debugViewLite(view));
1292
+ AutoFocusManager.requestAutofocusTraverse(view);
1293
+ break;
1294
+ case "keepScreenOn":
1295
+ if (var.size() == 0) {
1296
+ LogAdapterUtils.log(view.getContext(), TAG, ">keepScreenOn param is EMPTY");
1297
+ return;
1298
+ }
1299
+ view.setKeepScreenOn(var.getBoolean(0));
1300
+ break;
1301
+ }
1302
+ }
1303
+
1304
+ private void deepInvalidate(View view, HippyArray var) {
1305
+ int upLevel = 0;
1306
+ if (var != null && var.size() > 0) {
1307
+ HippyMap params = var.getMap(0);
1308
+ upLevel = params.getInt("upLevel");
1309
+ }
1310
+
1311
+ if(LogUtils.isDebug()) {
1312
+ Log.i(TAG, "deepInvalidate upLevel:" + upLevel);
1313
+ }
1314
+
1315
+ View targetView = view;
1316
+ while (--upLevel >= 0) {
1317
+ ViewParent parent = targetView.getParent();
1318
+ if (parent == null) break;
1319
+ if (!(parent instanceof View)) break;
1320
+ targetView = (View) parent;
1321
+ }
1322
+ if(LogUtils.isDebug()) {
1323
+ Log.i(TAG, "deepInvalidate view:" + targetView);
1324
+ }
1325
+ deepInvalidate(targetView);
1326
+ }
1327
+
1328
+ private void deepInvalidate(View view) {
1329
+ if (view instanceof ViewGroup) {
1330
+ int childCount = ((ViewGroup) view).getChildCount();
1331
+ for (int i = 0; i < childCount; i++) {
1332
+ deepInvalidate(((ViewGroup) view).getChildAt(i));
1333
+ }
1334
+ }
1335
+ view.invalidate();
1336
+ }
1337
+
1338
+ private void dispatchTVItemFunction(T view, HippyArray var, Promise promise) {
1339
+ final String id = var.getString(0);
1340
+ final String name = var.getString(1);
1341
+ final String functionName = var.getString(2);
1342
+ final HippyArray params = var.getArray(3);
1343
+ FastItemView templateItemView = FastItemView.findTemplateItemView(view);
1344
+ if (templateItemView == null) {
1345
+ Log.e(TAG, "dispatchTVItemFunction error on templateItemView == null id:" + id + ",name:" + name + ",functionName:" + functionName);
1346
+ return;
1347
+ }
1348
+ View rootView;
1349
+ rootView = FocusDispatchView.findRootFromContext(view);
1350
+ if (rootView == null) {
1351
+ View parentView = templateItemView.getParentListView();
1352
+ if (parentView == null) {
1353
+ parentView = templateItemView.getParentFlexView();
1354
+ }
1355
+ rootView = HippyViewGroup.findPageRootView(parentView);
1356
+ if (rootView == null) {
1357
+ rootView = FocusDispatchView.findRootView(parentView);
1358
+ }
1359
+ }
1360
+ final FastItemView itemView = FastAdapter.findTVItemViewById(rootView, id);
1361
+ // if(LogUtils.isDebug()){
1362
+ // FastAdapter.logTVItemViewById(rootView,id);
1363
+ // }
1364
+ final View targetView = ControllerManager.findViewByName(itemView, name);
1365
+ if (LogUtils.isDebug()) {
1366
+ Log.i(TAG, "dispatchTVItemFunction id:" + id + ",name:" + name + ",functionName:" + functionName + ",params:" + params);
1367
+ Log.i(TAG, "dispatchTVItemFunction itemView:" + itemView + ",targetView:" + targetView + ",rootView:" + rootView);
1368
+ }
1369
+ if (targetView != null) {
1370
+ if (promise != null) {
1371
+ this.dispatchFunction((T) targetView, functionName, params, promise);
1372
+ } else {
1373
+ this.dispatchFunction((T) targetView, functionName, params);
1374
+ }
1375
+ }
1376
+ }
1377
+
1378
+ private void setBlockFocusDirectionsV2(T view, HippyArray array) {
1379
+ if (view == null) {
1380
+ Log.e(TAG, "setBlockFocusDirectionsOnFail error array is null");
1381
+ return;
1382
+ }
1383
+ if (view instanceof TVSingleLineListView) {
1384
+ if (array == null || array.size() == 0) {
1385
+ ((TVSingleLineListView) view).setBlockFocusOn(null);
1386
+ return;
1387
+ }
1388
+ int[] directions = new int[array.size()];
1389
+ for (int i = 0; i < array.size(); i++) {
1390
+ switch (array.getString(i)) {
1391
+ case "up":
1392
+ directions[i] = View.FOCUS_UP;
1393
+ break;
1394
+ case "down":
1395
+ directions[i] = View.FOCUS_DOWN;
1396
+ break;
1397
+ case "left":
1398
+ directions[i] = View.FOCUS_LEFT;
1399
+ break;
1400
+ case "right":
1401
+ directions[i] = View.FOCUS_RIGHT;
1402
+ break;
1403
+ case "all":
1404
+ ((TVSingleLineListView) view).setBlockFocusOn(new int[]{View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT, View.FOCUS_RIGHT});
1405
+ return;
1406
+ }
1407
+ }
1408
+ ((TVSingleLineListView) view).setBlockFocusOn(directions);
1409
+ } else {
1410
+ int nextID = view.getId();
1411
+ if (array == null || array.size() == 0) {
1412
+ nextID = View.NO_ID;
1413
+ view.setNextFocusUpId(nextID);
1414
+ view.setNextFocusDownId(nextID);
1415
+ view.setNextFocusLeftId(nextID);
1416
+ view.setNextFocusRightId(nextID);
1417
+ return;
1418
+ }
1419
+ for (int i = 0; i < array.size(); i++) {
1420
+ switch (array.getString(i)) {
1421
+ case "up":
1422
+ view.setNextFocusUpId(nextID);
1423
+ break;
1424
+ case "down":
1425
+ view.setNextFocusDownId(nextID);
1426
+ break;
1427
+ case "left":
1428
+ view.setNextFocusLeftId(nextID);
1429
+ break;
1430
+ case "right":
1431
+ view.setNextFocusRightId(nextID);
1432
+ break;
1433
+ case "all":
1434
+ view.setNextFocusUpId(nextID);
1435
+ view.setNextFocusDownId(nextID);
1436
+ view.setNextFocusLeftId(nextID);
1437
+ view.setNextFocusRightId(nextID);
1438
+ break;
1439
+ }
1440
+ }
1441
+ }
1442
+ }
1443
+
1444
+ public void dispatchFunctionBySid(@Nullable View view, HippyArray var, Promise promise) {
1445
+ dispatchFunctionBySid(null, view, null, var.getString(0), var.getString(1), var.getArray(2), promise, TAG, false);
1446
+ }
1447
+
1448
+ /**
1449
+ * 通过一个view的sid来执行对应的方法
1450
+ *
1451
+ * @param rootView 执行方法的根view
1452
+ * @param view vue上层传递过来调用此方法的view
1453
+ * @param instanceContext instanceContext
1454
+ * @param targetSID 执行的目标sid
1455
+ * @param functionTargetName 方法名
1456
+ * @param params 传递过来的参数
1457
+ * @param promise 回调
1458
+ */
1459
+ public static void dispatchFunctionBySid(@Nullable View rootView, @Nullable View view, @Nullable HippyInstanceContext instanceContext, String targetSID, String functionTargetName, HippyArray params, @Nullable Promise promise, String TAG, boolean checkValid) {
1460
+ try {
1461
+ // final String targetSID = var.getString(0);
1462
+ // final String functionTargetName = var.getString(1);
1463
+ if (rootView == null && view == null) {
1464
+ Log.e(TAG, "dispatchFunctionBySid error on rootView and view both are null");
1465
+ if (promise != null) {
1466
+ promise.reject("dispatchFunctionBySid error on rootView and view both are null");
1467
+ }
1468
+ return;
1469
+ }
1470
+ final View root = rootView == null ? HippyViewGroup.findPageRootView(view) : rootView;
1471
+ // Log.e(ReplaceChildView.TAG, "dispatchFunctionBySid targetSID :" + targetSID + ",functionTargetName:" + functionTargetName +",root:"+root);
1472
+ Promise takeOverPromise = promise == null ? null : new FastListViewController.PromiseTakeover(promise, targetSID);
1473
+ if (root != null) {
1474
+
1475
+ // ExtendUtil.logView(ReplaceChildView.TAG,root);
1476
+
1477
+ final View target = ExtendUtil.findViewBySID(targetSID, root, checkValid);
1478
+ if (target != null && functionTargetName != null && !"dispatchFunctionBySid".equals(functionTargetName)) {
1479
+ // final HippyArray array = var.getArray(2);
1480
+ Context context = null;
1481
+ if (instanceContext != null) {
1482
+ context = instanceContext;
1483
+ } else {
1484
+ if (rootView != null) {
1485
+ context = rootView.getContext();
1486
+ } else {
1487
+ context = view.getContext();
1488
+ }
1489
+ }
1490
+ // instanceContext == null && view != null ? view.getContext() : instanceContext;
1491
+ if (context instanceof HippyInstanceContext) {
1492
+ final HippyEngineContext hippyContext = ((HippyInstanceContext) context).getEngineContext();
1493
+ final String targetNodeClassName = ExtendTag.obtainExtendTag(target).nodeClassName;
1494
+ String className = targetNodeClassName;
1495
+ boolean executeOnThisView = false;
1496
+ if (view != null && targetSID != null && targetSID.equals(ExtendUtil.getViewSID(view))) {
1497
+ executeOnThisView = true;
1498
+ }
1499
+ //Log.i(TAG,"dispatchFunctionBySid executeOnThisView : "+executeOnThisView+",sid:"+targetSID+",dispatch view:"+ExtendUtil.debugViewLite(view));
1500
+ if (TextUtils.isEmpty(targetNodeClassName) && view != null && executeOnThisView) {
1501
+ final RenderNode node = hippyContext.getRenderManager().getRenderNode(view.getId());
1502
+ className = node.getClassName();
1503
+ }
1504
+ if (view != null && view.getId() != -1 && executeOnThisView) {
1505
+ final RenderNode node = hippyContext.getRenderManager().getRenderNode(view.getId());
1506
+ // Log.i(TAG,"dispatchFunctionBySid node class:"+className+",dispatchUIFunction");
1507
+ node.dispatchUIFunction(functionTargetName, params, takeOverPromise);
1508
+ } else if (target.getId() != -1) {
1509
+ final RenderNode node = hippyContext.getRenderManager().getRenderNode(target.getId());
1510
+ // Log.i(TAG,"dispatchFunctionBySid node class:"+className+",dispatchUIFunction");
1511
+ node.dispatchUIFunction(functionTargetName, params, takeOverPromise);
1512
+ }
1513
+ //final String className = TextUtils.isEmpty(targetNodeClassName) ? node.getClassName() : targetNodeClassName;
1514
+ Log.e(TAG, "dispatchFunctionBySid execute !!! view:" + ExtendUtil.debugViewLite(target) + ",className:" + className + ",functionTargetName:" + functionTargetName + ",array :" + params);
1515
+ if (className != null) {
1516
+ CustomControllerHelper.dispatchUIFunction(hippyContext.getRenderManager().mControllerManager, target, className, functionTargetName, params, takeOverPromise);
1517
+ } else {
1518
+ Log.e(TAG, "dispatchFunctionBySid error className null func:" + functionTargetName + ",sid:" + targetSID);
1519
+ if (takeOverPromise != null) {
1520
+ takeOverPromise.reject("dispatchFunctionBySid error on className is null ");
1521
+ }
1522
+ }
1523
+ } else {
1524
+ Log.e(TAG, "dispatchFunctionBySid error on func:" + functionTargetName + ",sid:" + targetSID + ",context is not HippyInstanceContext context:" + context);
1525
+ }
1526
+ } else {
1527
+ if (takeOverPromise != null) {
1528
+ takeOverPromise.reject("dispatchFunctionBySid error on find target null");
1529
+ }
1530
+ Log.e(TAG, "dispatchFunctionBySid error on find target null func:" + functionTargetName + ",sid:" + targetSID);
1531
+ }
1532
+ } else {
1533
+ if (takeOverPromise != null) {
1534
+ takeOverPromise.reject("dispatchFunctionBySid error on find root null");
1535
+ }
1536
+ Log.e(TAG, "dispatchFunctionBySid error find root null func:" + functionTargetName + ",sid:" + targetSID);
1537
+ }
1538
+ } catch (Exception e) {
1539
+ Log.e(TAG, "dispatchFunctionBySid fatal error func:" + functionTargetName + ",sid:" + targetSID);
1540
+ e.printStackTrace();
1541
+ if (promise != null) {
1542
+ promise.reject("dispatchFunctionBySid fatal error");
1543
+ }
1544
+ }
1545
+ }
1546
+
1547
+ /***
1548
+ * dispatch the js call UI Function with Promise to call back.
1549
+ *
1550
+ * @param view view实例
1551
+ * @param functionName 函数名
1552
+ * @param params 函数参数
1553
+ * @param promise 回调
1554
+ */
1555
+ public void dispatchFunction(T view, String functionName, HippyArray params, Promise promise) {
1556
+ // if(LogUtils.isDebug()) {
1557
+ Log.d(TAG, "dispatchFunction withPromise:" + functionName + ",data:" + params);
1558
+ Log.d(FastListView.TAG_CLONED, "dispatchFunction withPromise:" + functionName + ",data:" + params + ",view:" + view);
1559
+ // }
1560
+ if ("dispatchFunctionBySid".equals(functionName)) {
1561
+ Log.e(ReplaceChildView.TAG, "native call dispatchFunctionBySid with promise var" + params);
1562
+ }
1563
+ if (FastListViewController.dispatchFunctionByTemplate(this, view, functionName, params, promise)) {
1564
+ Log.e(ReplaceChildView.TAG, "native call dispatchFunctionBySid return on dispatchFunctionByTemplate");
1565
+ return;
1566
+ }
1567
+ switch (functionName) {
1568
+ case "hasFocus":
1569
+ if (view != null) {
1570
+ promise.resolve(view.hasFocus());
1571
+ }
1572
+ break;
1573
+ case "isFocused":
1574
+ if (view != null) {
1575
+ promise.resolve(view.isFocused());
1576
+ }
1577
+ break;
1578
+ case "setBackGroundColor":
1579
+ if (view != null) {
1580
+ try {
1581
+ setBackgroundString(view, params.getString(0));
1582
+ view.invalidate();
1583
+ } catch (Exception e) {
1584
+ if (LogUtils.isDebug()) {
1585
+ e.printStackTrace();
1586
+ }
1587
+ }
1588
+ }
1589
+ break;
1590
+ case "getLocationOnScreen":
1591
+ int[] outputBuffer = new int[2];
1592
+ view.getLocationOnScreen(outputBuffer);
1593
+ int width = view.getWidth();
1594
+ int height = view.getHeight();
1595
+ HippyMap map = new HippyMap();
1596
+ map.pushInt("left", outputBuffer[0]);
1597
+ map.pushInt("top", outputBuffer[1]);
1598
+ map.pushInt("right", outputBuffer[0] + width);
1599
+ map.pushInt("bottom", outputBuffer[1] + height);
1600
+ map.pushInt("width", width);
1601
+ map.pushInt("height", height);
1602
+ map.pushDouble("density", PixelUtil.getDensity());
1603
+
1604
+ HippyMap result = new HippyMap();
1605
+ result.pushInt("code", 0);
1606
+ result.pushObject("data", map);
1607
+
1608
+ promise.resolve(result);
1609
+ break;
1610
+ case "getViewState":
1611
+ promise.resolve(ExtendUtil.getViewState(view));
1612
+ break;
1613
+ case "getChildViewState":
1614
+ HippyMap stateMap = null;
1615
+ try {
1616
+ stateMap = ExtendUtil.getChildState(view, params.getInt(0));
1617
+ } catch (Exception e) {
1618
+ e.printStackTrace();
1619
+ }
1620
+ if (stateMap != null) {
1621
+ stateMap.pushBoolean("valid", true);
1622
+ } else {
1623
+ stateMap = new HippyMap();
1624
+ stateMap.pushBoolean("valid", false);
1625
+ }
1626
+ promise.resolve(stateMap);
1627
+ break;
1628
+ case "dispatchTVItemFunction":
1629
+ this.dispatchTVItemFunction(view, params, promise);
1630
+ break;
1631
+ case "dispatchFunctionBySid":
1632
+ dispatchFunctionBySid(view, params, promise);
1633
+ break;
1634
+ //2.11.x
1635
+ case "isInTouchMode":
1636
+ promise.resolve(view.isInTouchMode());
1637
+ break;
1638
+ }
1639
+ }
1640
+
1641
+
1642
+ /***
1643
+ * batch complete
1644
+ *
1645
+ * @param view
1646
+ */
1647
+ public void onBatchComplete(T view) {
1648
+
1649
+ }
1650
+
1651
+ protected void deleteChild(ViewGroup parentView, View childView) {
1652
+ parentView.removeView(childView);
1653
+ }
1654
+
1655
+ protected void deleteChild(ViewGroup parentView, View childView, int childIndex) {
1656
+ deleteChild(parentView, childView);
1657
+ }
1658
+
1659
+ //zhaopeng add
1660
+ public void onBeforeViewDestroy(T t) {
1661
+ final String type = findViewCacheType(t);
1662
+ if (LogUtils.isDebug()) {
1663
+ Log.d(TAG, "onBeforeViewDestroy t :" + t.getId() + ",cacheType:" + type);
1664
+ }
1665
+ if (!TextUtils.isEmpty(type) && cacheViewsPool != null) {
1666
+ cacheViewsPool.put(type, t);
1667
+ }
1668
+ }
1669
+
1670
+ public void onViewDestroy(T t) {
1671
+ // add by weipeng
1672
+ // 自定义的组件为实现HippyViewBase接口,需要判断下
1673
+ if (t instanceof HippyViewBase) t.setGestureDispatcher(null);
1674
+ }
1675
+
1676
+ protected void addView(ViewGroup parentView, View view, int index) {
1677
+ // TODO: 这里需要复现场景来解,先上一个临时方案
1678
+ int realIndex = index;
1679
+ if (realIndex > parentView.getChildCount()) {
1680
+ realIndex = parentView.getChildCount();
1681
+ }
1682
+ try {
1683
+ parentView.addView(view, realIndex);
1684
+ } catch (Exception e) {
1685
+ e.printStackTrace();
1686
+ }
1687
+ }
1688
+
1689
+ protected void onManageChildComplete(T view) {
1690
+
1691
+ }
1692
+
1693
+ public int getChildCount(T viewGroup) {
1694
+ if (viewGroup instanceof ViewGroup) {
1695
+ return ((ViewGroup) viewGroup).getChildCount();
1696
+ }
1697
+ return 0;
1698
+ }
1699
+
1700
+ public View getChildAt(T viewGroup, int i) {
1701
+ if (viewGroup instanceof ViewGroup) {
1702
+ return ((ViewGroup) viewGroup).getChildAt(i);
1703
+ }
1704
+ return null;
1705
+ }
1706
+
1707
+ /**
1708
+ * add by zhaopeng 20201110
1709
+ */
1710
+ @HippyControllerProps(name = NodeProps.FOCUS_SCALE, defaultType = HippyControllerProps.NUMBER, defaultNumber = 1.1)
1711
+ public void setFocusScale(T view, float focusScale) {
1712
+ if (view instanceof HippyImageView) {
1713
+ ((HippyImageView) view).setFocusScale(focusScale);
1714
+ }
1715
+ }
1716
+
1717
+ /**
1718
+ * add by zhaopeng 20201110
1719
+ */
1720
+ @HippyControllerProps(name = NodeProps.CLIP_TO_PADDING, defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
1721
+ public void setClipToPadding(T view, boolean clip) {
1722
+ if (view instanceof ViewGroup) {
1723
+ ((ViewGroup) view).setClipToPadding(clip);
1724
+ }
1725
+ }
1726
+
1727
+
1728
+ /**
1729
+ * add by zhaopeng 20201110
1730
+ */
1731
+ @HippyControllerProps(name = NodeProps.CLIP_CHILDREN, defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
1732
+ public void setClip(T view, boolean clip) {
1733
+ if (view instanceof ViewGroup) {
1734
+ ((ViewGroup) view).setClipChildren(clip);
1735
+ }
1736
+ }
1737
+
1738
+ @HippyControllerProps(name = NodeProps.CLIP_BOUNDS, defaultType = HippyControllerProps.MAP)
1739
+ public void setClipBounds(T view, HippyMap hippyMap) {
1740
+ //int left, int top, int right, int bottom
1741
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
1742
+ if (view != null) {
1743
+ Rect rect = new Rect(hippyMap.getInt("left"), hippyMap.getInt("top"), hippyMap.getInt("right"), hippyMap.getInt("bottom"));
1744
+ view.setClipBounds(rect);
1745
+ }
1746
+ } else {
1747
+ Log.e(TAG, "setClipBounds is'nt support under JELLY_BEAN_MR2");
1748
+ }
1749
+ }
1750
+
1751
+
1752
+ @HippyControllerProps(name = NodeProps.LAYOUT_PADDING, defaultType = HippyControllerProps.MAP)
1753
+ public void setPadding(T view, HippyMap hippyMap) {
1754
+ if (view != null && hippyMap != null) {
1755
+ if (hippyMap.containsKey("all") && hippyMap.getInt("all") > 0) {
1756
+ final int all = Utils.toPX(hippyMap.getInt("all"));
1757
+ view.setPadding(all, all, all, all);
1758
+ } else {
1759
+ view.setPadding(hippyMap.containsKey("left") ? Utils.toPX(hippyMap.getInt("left")) : 0,
1760
+ hippyMap.containsKey("top") ? Utils.toPX(hippyMap.getInt("top")) : 0,
1761
+ hippyMap.containsKey("right") ? Utils.toPX(hippyMap.getInt("right")) : 0,
1762
+ hippyMap.containsKey("bottom") ? Utils.toPX(hippyMap.getInt("bottom")) : 0);
1763
+ }
1764
+ }
1765
+ }
1766
+
1767
+
1768
+ /**
1769
+ * add by zhaopeng 20201110
1770
+ */
1771
+ @HippyControllerProps(name = NodeProps.DESCENDANT_FOCUSABILITY, defaultType = HippyControllerProps.NUMBER, defaultNumber = -1)
1772
+ public void setDescendantFocusability(T view, int focusability) {
1773
+ LogUtils.d(FocusDispatchView.TAG, "setDescendantFocusability :" + focusability + " view:" + view);
1774
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, "setDescendantFocusability :" + focusability + " view:" + ExtendUtil.debugViewLite(view));
1775
+ if (view instanceof ViewGroup) {
1776
+ switch (focusability) {
1777
+ case 0:
1778
+ ((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
1779
+ break;
1780
+ case 1:
1781
+ ((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
1782
+ break;
1783
+ case 2:
1784
+ ((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
1785
+ break;
1786
+ }
1787
+
1788
+ }
1789
+ }
1790
+
1791
+ @HippyControllerProps(name = NodeProps.NEXT_FOCUS_NAME, defaultType = HippyControllerProps.MAP)
1792
+ public void steNextFocusName(T view, HippyMap hippyMap) {
1793
+
1794
+ FocusUtils.setNextFocusName(view, hippyMap);
1795
+ }
1796
+
1797
+
1798
+ @HippyControllerProps(name = "bringFocusChildToFront", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
1799
+ public void setBringFocusChildToFront(T view, boolean enable) {
1800
+ if (view instanceof HippyViewGroup) {
1801
+ ((HippyViewGroup) view).setBringFocusChildToFront(enable);
1802
+ } else if (view instanceof HippyListView) {
1803
+ ((HippyListView) view).setBringToFrontOnFocus(enable);
1804
+ }
1805
+ }
1806
+
1807
+ @HippyControllerProps(name = NodeProps.DUPLICATE_PARENT_STATE, defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
1808
+ public void setDuplicateParentStateEnabled(T view, boolean enable) {
1809
+ view.setDuplicateParentStateEnabled(enable);
1810
+ }
1811
+
1812
+ @HippyControllerProps(name = "focusScaleDuplicateParentState", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
1813
+ public void setFocusScaleOnDuplicateParentState(T view, boolean enable) {
1814
+ if (view instanceof HippyImageView) {
1815
+ ((HippyImageView) view).setFocusScaleOnDuplicateParentState(enable);
1816
+ }
1817
+ }
1818
+
1819
+ @HippyControllerProps(name = NodeProps.DUPLICATE_PARENT_STATE)
1820
+ public void setDuplicateParentStateEnabled(T view) {
1821
+ view.setDuplicateParentStateEnabled(true);
1822
+ }
1823
+
1824
+
1825
+ @HippyControllerProps(name = "dispatchChildFocusEvent", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
1826
+ public void setDispatchChildFocusEvent(T view, boolean enable) {
1827
+ if (view instanceof ExtendViewGroup) {
1828
+ ((ExtendViewGroup) view).setDispatchChildFocusEvent(enable);
1829
+ }
1830
+ }
1831
+
1832
+ @Deprecated
1833
+ @HippyControllerProps(name = "blockRootFocus", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
1834
+ public void setBlockRoot(T view, boolean enable) {
1835
+ if (view != null && view.getRootView() instanceof ViewGroup) {
1836
+ LogUtils.d(FocusDispatchView.TAG, "blockRootFocus called by view:" + view + ",enable:" + enable);
1837
+ LogAdapterUtils.log(view.getContext(), FocusDispatchView.TAG, "blockRootFocus called enable:" + enable + " view:" + ExtendUtil.debugViewLite(view));
1838
+ ((ViewGroup) view.getRootView()).setDescendantFocusability(enable ? ViewGroup.FOCUS_BLOCK_DESCENDANTS : ViewGroup.FOCUS_BEFORE_DESCENDANTS);
1839
+ }
1840
+ }
1841
+
1842
+ @HippyControllerProps(name = NodeProps.FOCUS_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
1843
+ public void setFocusColor(T view, int color) {
1844
+ if (view instanceof HippyTextView) {
1845
+ ((HippyTextView) view).setFocusColor(color);
1846
+ }
1847
+ if (view instanceof TVTextView) {
1848
+ ((TVTextView) view).setFocusColor(color);
1849
+ }
1850
+
1851
+ }
1852
+
1853
+ @HippyControllerProps(name = NodeProps.SELECT_COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
1854
+ public void selectColor(T view, int color) {
1855
+ if (view instanceof HippyTextView) {
1856
+ ((HippyTextView) view).setSelectColor(color);
1857
+ }
1858
+ if (view instanceof TVTextView) {
1859
+ ((TVTextView) view).setSelectColor(color);
1860
+ }
1861
+
1862
+ }
1863
+
1864
+ @HippyControllerProps(name = NodeProps.COLOR, defaultType = HippyControllerProps.NUMBER, defaultNumber = Color.TRANSPARENT)
1865
+ public void setColor(T view, int color) {
1866
+ if (view instanceof HippyTextView) {
1867
+ ((HippyTextView) view).setCustomColor(color);
1868
+ }
1869
+ if (view instanceof TVTextView) {
1870
+ ((TVTextView) view).setTextColor(color);
1871
+ }
1872
+ }
1873
+
1874
+ //此处vue是怎么传值的
1875
+ @Deprecated
1876
+ @HippyControllerProps(name = NodeProps.BLOCK_FOCUS_DIRECTIONS, defaultType = HippyControllerProps.ARRAY)
1877
+ public void setBlockFocusDirectionsOnFail(T view, HippyArray array) {
1878
+ if (view == null || array == null) {
1879
+ Log.e(TAG, "setBlockFocusDirectionsOnFail error array is null");
1880
+ return;
1881
+ }
1882
+ if (view instanceof TVSingleLineListView) {
1883
+ int[] directions = new int[array.size()];
1884
+ for (int i = 0; i < array.size(); i++) {
1885
+ switch (array.getString(i)) {
1886
+ case "up":
1887
+ directions[i] = View.FOCUS_UP;
1888
+ break;
1889
+ case "down":
1890
+ directions[i] = View.FOCUS_DOWN;
1891
+ break;
1892
+ case "left":
1893
+ directions[i] = View.FOCUS_LEFT;
1894
+ break;
1895
+ case "right":
1896
+ directions[i] = View.FOCUS_RIGHT;
1897
+ break;
1898
+ }
1899
+ }
1900
+ ((TVSingleLineListView) view).setBlockFocusOnFail(directions);
1901
+ } else {
1902
+ if (array.size() == 0) {
1903
+ view.setNextFocusUpId(View.NO_ID);
1904
+ view.setNextFocusDownId(View.NO_ID);
1905
+ view.setNextFocusLeftId(View.NO_ID);
1906
+ view.setNextFocusRightId(View.NO_ID);
1907
+ return;
1908
+ }
1909
+ int nextID = view.getId();
1910
+ for (int i = 0; i < array.size(); i++) {
1911
+ switch (array.getString(i)) {
1912
+ case "up":
1913
+ view.setNextFocusUpId(nextID);
1914
+ break;
1915
+ case "down":
1916
+ view.setNextFocusDownId(nextID);
1917
+ break;
1918
+ case "left":
1919
+ view.setNextFocusLeftId(nextID);
1920
+ break;
1921
+ case "right":
1922
+ view.setNextFocusRightId(nextID);
1923
+ break;
1924
+ }
1925
+ }
1926
+ }
1927
+ }
1928
+
1929
+ @HippyControllerProps(name = "selected", defaultType = HippyControllerProps.BOOLEAN)
1930
+ public void setSelected(T view, boolean selected) {
1931
+ view.setSelected(selected);
1932
+ }
1933
+
1934
+ @HippyControllerProps(name = "selectState", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
1935
+ public void setSelectState(T view, boolean selected) {
1936
+ if (view instanceof HippyTextView) {
1937
+ ((HippyTextView) view).setSelectState(selected);
1938
+ } else if (view instanceof HippyImageView) {
1939
+ ((HippyImageView) view).setSelectState(selected);
1940
+ }
1941
+ }
1942
+
1943
+
1944
+ @HippyControllerProps(name = "layoutAfterAttach", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
1945
+ public void setRelayoutAfterAttach(T view, boolean relayoutAfterAttach) {
1946
+ if (view instanceof HippyImageView) {
1947
+ ((HippyImageView) view).setRelayoutAfterAttach(relayoutAfterAttach);
1948
+ }
1949
+ }
1950
+
1951
+ @HippyControllerProps(name = "cacheType", defaultType = HippyControllerProps.STRING)
1952
+ public void setCacheType(T view, String cacheType) {
1953
+ // if(view instanceof HippyImageView){
1954
+ // ((HippyImageView) view).setRelayoutAfterAttach(relayoutAfterAttach);
1955
+ // }
1956
+ }
1957
+
1958
+ @HippyControllerProps(name = "cacheMax", defaultType = HippyControllerProps.ARRAY)
1959
+ public void setCacheMax(T view, HippyArray cache) {
1960
+ // if(view instanceof HippyImageView){
1961
+ // ((HippyImageView) view).setRelayoutAfterAttach(relayoutAfterAttach);
1962
+ // }
1963
+ if (cache != null && cacheViewsPool != null) {
1964
+ cacheViewsPool.setMaxCacheSize(cache.getString(0), cache.getInt(1));
1965
+ }
1966
+ }
1967
+
1968
+ @HippyControllerProps(name = "recycleOnDetach", defaultType = HippyControllerProps.BOOLEAN)
1969
+ public void setRecycleOnDetach(T view, boolean recycleOnDetach) {
1970
+ if (view instanceof AsyncImageView) {
1971
+ ((AsyncImageView) view).setRecycleOnDetach(recycleOnDetach);
1972
+ }
1973
+ }
1974
+
1975
+ @HippyControllerProps(name = "visible", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
1976
+ public void setVisible(T view, boolean visible) {
1977
+
1978
+ view.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
1979
+ }
1980
+
1981
+ @HippyControllerProps(name = "visibility", defaultType = HippyControllerProps.STRING)
1982
+ public void setVisibility(T view, String visibility) {
1983
+ switch (visibility) {
1984
+ case "visible":
1985
+ view.setVisibility(View.VISIBLE);
1986
+ break;
1987
+ case "invisible":
1988
+ view.setVisibility(View.INVISIBLE);
1989
+ break;
1990
+ case "gone":
1991
+ view.setVisibility(View.GONE);
1992
+ break;
1993
+ }
1994
+
1995
+ }
1996
+
1997
+ @HippyControllerProps(name = "viewLayerType", defaultType = HippyControllerProps.STRING)
1998
+ public void setLayerType(T view, String type) {
1999
+ switch (type) {
2000
+ case "hardware":
2001
+ view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
2002
+ break;
2003
+ case "soft":
2004
+ view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
2005
+ break;
2006
+ case "none":
2007
+ view.setLayerType(View.LAYER_TYPE_NONE, null);
2008
+ break;
2009
+ }
2010
+
2011
+ }
2012
+
2013
+
2014
+ protected String getInnerPath(HippyInstanceContext context, String path) {
2015
+ //hpfile://./assets/file_banner02.jpg
2016
+ if (path != null && path.startsWith("hpfile://")) {
2017
+ String relativePath = path.replace("hpfile://./", "");
2018
+ //hippysdk的图片加载协议
2019
+ String bundlePath = null;
2020
+ if (context.getBundleLoader() != null) {
2021
+ bundlePath = context.getBundleLoader().getPath();
2022
+ }
2023
+
2024
+ path = bundlePath == null ? null
2025
+ : bundlePath.subSequence(0, bundlePath.lastIndexOf(File.separator) + 1) + relativePath;
2026
+ //assets://index.android.jsbundle
2027
+ //file:sdcard/hippy/feeds/index.android.jsbundle
2028
+ }
2029
+ return path;
2030
+ }
2031
+
2032
+ public static class CacheMap {
2033
+ Map<String, CacheViewList> map = new HashMap<>();
2034
+
2035
+ View get(String type) {
2036
+ if (map.containsKey(type)) {
2037
+ return map.get(type).get();
2038
+ }
2039
+ return null;
2040
+ }
2041
+
2042
+ public void setMaxCacheSize(String type, int max) {
2043
+ if (!TextUtils.isEmpty(type)) {
2044
+ if (map.containsKey(type)) {
2045
+ map.get(type).setMaxCacheSize(max);
2046
+ } else {
2047
+ final CacheViewList c = new CacheViewList(type);
2048
+ c.setMaxCacheSize(max);
2049
+ map.put(type, c);
2050
+ }
2051
+ }
2052
+ }
2053
+
2054
+ void put(String type, View view) {
2055
+ if (view != null && !TextUtils.isEmpty(type)) {
2056
+ if (map.containsKey(type)) {
2057
+ map.get(type).put(view);
2058
+ } else {
2059
+ final CacheViewList c = new CacheViewList(type);
2060
+ c.put(view);
2061
+ map.put(type, c);
2062
+ }
2063
+ }
2064
+
2065
+ }
2066
+ }
2067
+
2068
+ @HippyControllerProps(name = "visible", defaultType = HippyControllerProps.BOOLEAN)
2069
+ public void setVisibleCompat(T view, boolean b) {
2070
+ //zhaopeng 2022 0908 兼容方法,勿删除
2071
+ this.setVisible(view, b);
2072
+ }
2073
+
2074
+ private static class CacheViewList {
2075
+ final String type;
2076
+ CacheList list;
2077
+
2078
+
2079
+ private CacheViewList(String type) {
2080
+ this.type = type;
2081
+ }
2082
+
2083
+
2084
+ public void setMaxCacheSize(int max) {
2085
+ if (list == null) {
2086
+ list = new CacheList();
2087
+ }
2088
+ list.max = max;
2089
+ }
2090
+
2091
+ void put(View view) {
2092
+ if (list == null) {
2093
+ list = new CacheList();
2094
+ }
2095
+ final boolean add = list.add(view);
2096
+ if (add) {
2097
+ if (LogUtils.isDebug()) {
2098
+ Log.d(TAG, "+++CacheViewList put size:" + list.size() + ",type:" + type);
2099
+ }
2100
+ } else {
2101
+ if (LogUtils.isDebug()) {
2102
+ Log.e(TAG, "+++CacheViewList put max items " + ",type:" + type);
2103
+ }
2104
+ }
2105
+ }
2106
+
2107
+ View get() {
2108
+ if (list != null && list.size() > 0) {
2109
+ if (LogUtils.isDebug()) {
2110
+ Log.d(TAG, "---CacheViewList popup size:" + list.size() + ",type:" + type);
2111
+ }
2112
+ return list.get();
2113
+ }
2114
+ return null;
2115
+ }
2116
+ }
2117
+
2118
+ public static class CacheList {
2119
+ int max = 20;
2120
+ List<View> list;
2121
+
2122
+ boolean add(View view) {
2123
+ if (list == null) {
2124
+ list = new ArrayList<>();
2125
+ }
2126
+ if (size() < max) {
2127
+
2128
+
2129
+ final boolean b = list.add(view);
2130
+ if (b) {
2131
+ if (view instanceof HippyRecycler) {
2132
+ ((HippyRecycler) view).onResetBeforeCache();
2133
+ }
2134
+ }
2135
+ return b;
2136
+ } else {
2137
+ return false;
2138
+ }
2139
+ }
2140
+
2141
+ View get() {
2142
+ if (list != null && list.size() > 0) {
2143
+ return list.remove(0);
2144
+ }
2145
+ return null;
2146
+ }
2147
+
2148
+ int size() {
2149
+ return list.size();
2150
+ }
2151
+
2152
+ }
2153
+
2154
+ public static String findViewCacheType(View v) {
2155
+ if (v.getTag() != null && v.getTag() instanceof HippyMap) {
2156
+ return ((HippyMap) v.getTag()).getString(HippyTag.TAG_CLASS_CACHE);
2157
+ }
2158
+ return null;
2159
+ }
2160
+
2161
+ /**
2162
+ * transform
2163
+ **/
2164
+ @HippyControllerProps(name = "translation", defaultType = HippyControllerProps.ARRAY)
2165
+ public void setTranslate(View view, HippyArray pos) {
2166
+ Log.d(TAG, "translation pos:" + pos + ",view :" + view);
2167
+ if (pos != null) {
2168
+ final int x = Utils.toPX(pos.getInt(0));
2169
+ final int y = Utils.toPX(pos.getInt(1));
2170
+ view.layout(x, y, x + view.getWidth(), y + view.getHeight());
2171
+ }
2172
+ }
2173
+
2174
+ /**
2175
+ * transform
2176
+ **/
2177
+ @HippyControllerProps(name = "size", defaultType = HippyControllerProps.ARRAY)
2178
+ public void setSize(View view, HippyArray size) {
2179
+ Log.d(TAG, "setSize size:" + size + ",view :" + view);
2180
+ if (size != null) {
2181
+ final int x = Utils.toPX((int) view.getX());
2182
+ final int y = Utils.toPX((int) view.getY());
2183
+ final int width = Utils.toPX(size.getInt(0));
2184
+ final int height = Utils.toPX(size.getInt(1));
2185
+ view.layout(x, y, x + view.getWidth(), y + view.getHeight());
2186
+ }
2187
+ }
2188
+
2189
+ }