@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.
- package/package.json +1 -1
- package/rules/.clinerules +27 -4
- package/rules/.cursorrules +27 -4
- package/rules/.github/copilot-instructions.md +27 -4
- package/rules/.source/hippy/extend_views/CoverFlowHorizontalView.java +203 -0
- package/rules/.source/hippy/extend_views/CoverFlowVerticalView.java +203 -0
- package/rules/.source/hippy/extend_views/CoverFlowViewController.java +195 -0
- package/rules/.source/hippy/extend_views/EngineRootView.java +125 -0
- package/rules/.source/hippy/extend_views/ExtendTag.java +83 -0
- package/rules/.source/hippy/extend_views/FocusSearchHelper.java +124 -0
- package/rules/.source/hippy/extend_views/IRecyclerItemView.java +12 -0
- package/rules/.source/hippy/extend_views/JSEventHandleView.java +5 -0
- package/rules/.source/hippy/extend_views/MarqueeRelayManager.java +133 -0
- package/rules/.source/hippy/extend_views/MarqueeRelayTextView.java +211 -0
- package/rules/.source/hippy/extend_views/ProgressBarView.java +83 -0
- package/rules/.source/hippy/extend_views/ProgressBarViewController.java +145 -0
- package/rules/.source/hippy/extend_views/SeekBarView.java +104 -0
- package/rules/.source/hippy/extend_views/SeekBarViewController.java +218 -0
- package/rules/.source/hippy/extend_views/StateImageView.java +149 -0
- package/rules/.source/hippy/extend_views/StateImageViewController.java +34 -0
- package/rules/.source/hippy/extend_views/TVButtonView.java +314 -0
- package/rules/.source/hippy/extend_views/TVButtonViewController.java +89 -0
- package/rules/.source/hippy/extend_views/TVTextView.java +684 -0
- package/rules/.source/hippy/extend_views/TVViewActor.java +811 -0
- package/rules/.source/hippy/extend_views/TVViewActorHost.java +6 -0
- package/rules/.source/hippy/extend_views/TVViewActor/346/216/245/345/205/245.md +66 -0
- package/rules/.source/hippy/extend_views/TemplateUtil.java +336 -0
- package/rules/.source/hippy/extend_views/TextButtonNode.java +47 -0
- package/rules/.source/hippy/extend_views/TextViewController.java +377 -0
- package/rules/.source/hippy/extend_views/fastlist/CenterFlyInAnimator.java +96 -0
- package/rules/.source/hippy/extend_views/fastlist/ChildOnScreenScroller.java +548 -0
- package/rules/.source/hippy/extend_views/fastlist/ClonedViewTag.java +17 -0
- package/rules/.source/hippy/extend_views/fastlist/EventDeliverer.java +55 -0
- package/rules/.source/hippy/extend_views/fastlist/FastAdapter.java +4683 -0
- package/rules/.source/hippy/extend_views/fastlist/FastAdapterUtil.java +982 -0
- package/rules/.source/hippy/extend_views/fastlist/FastFlexNode.java +48 -0
- package/rules/.source/hippy/extend_views/fastlist/FastFlexView.java +873 -0
- package/rules/.source/hippy/extend_views/fastlist/FastFlexViewController.java +130 -0
- package/rules/.source/hippy/extend_views/fastlist/FastItemNode.java +67 -0
- package/rules/.source/hippy/extend_views/fastlist/FastItemView.java +306 -0
- package/rules/.source/hippy/extend_views/fastlist/FastItemViewController.java +106 -0
- package/rules/.source/hippy/extend_views/fastlist/FastListModule.java +95 -0
- package/rules/.source/hippy/extend_views/fastlist/FastListNode.java +90 -0
- package/rules/.source/hippy/extend_views/fastlist/FastListView.java +2466 -0
- package/rules/.source/hippy/extend_views/fastlist/FastListViewController.java +1038 -0
- 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
- package/rules/.source/hippy/extend_views/fastlist/FastPendingView.java +47 -0
- package/rules/.source/hippy/extend_views/fastlist/ItemDecorations.java +71 -0
- package/rules/.source/hippy/extend_views/fastlist/ItemStoreNode.java +64 -0
- package/rules/.source/hippy/extend_views/fastlist/ItemStoreView.java +13 -0
- package/rules/.source/hippy/extend_views/fastlist/ItemStoreViewController.java +45 -0
- package/rules/.source/hippy/extend_views/fastlist/ListItemHolder.java +7 -0
- package/rules/.source/hippy/extend_views/fastlist/ListViewControlProp.java +41 -0
- package/rules/.source/hippy/extend_views/fastlist/MouseRecycleView.java +509 -0
- package/rules/.source/hippy/extend_views/fastlist/OnFastItemClickListener.java +12 -0
- package/rules/.source/hippy/extend_views/fastlist/OnFastItemFocusChangeListener.java +9 -0
- package/rules/.source/hippy/extend_views/fastlist/OnFastScrollStateChangedListener.java +7 -0
- package/rules/.source/hippy/extend_views/fastlist/PendingListNode.java +18 -0
- package/rules/.source/hippy/extend_views/fastlist/PendingViewController.java +13 -0
- package/rules/.source/hippy/extend_views/fastlist/PostHandlerView.java +6 -0
- package/rules/.source/hippy/extend_views/fastlist/PostTaskHolder.java +20 -0
- package/rules/.source/hippy/extend_views/fastlist/ReplaceChildController.java +105 -0
- package/rules/.source/hippy/extend_views/fastlist/ReplaceChildView.java +312 -0
- package/rules/.source/hippy/extend_views/fastlist/TVListView.java +3692 -0
- package/rules/.source/hippy/extend_views/fastlist/TemplateCodeParser.java +247 -0
- package/rules/.source/hippy/extend_views/fastlist/Utils.java +572 -0
- package/rules/.source/hippy/extend_views/fastlist/ViewTag.java +317 -0
- package/rules/.source/hippy/extend_views/fastlist/VirtualListView.java +8 -0
- package/rules/.source/hippy/extend_views/fastlist/diff/FastListDataBindingHelper.java +320 -0
- package/rules/.source/hippy/extend_views/fastlist/diff/KeyDiffHelper.java +289 -0
- package/rules/.source/hippy/extend_views/fastlist/diff/NoKeyDiffHelper.java +278 -0
- package/rules/.source/hippy/extend_views/tag/FontTag.java +53 -0
- package/rules/.source/hippy/extend_views/tag/HtmlTag.java +191 -0
- package/rules/.source/hippy/extend_views/tag/HtmlTagHandler.java +185 -0
- package/rules/.source/hippy/extend_views/tag/SpanTag.java +160 -0
- package/rules/.source/hippy/extend_views/tag/TextFontSpan.java +102 -0
- package/rules/.source/hippy/extend_views/waterfall/Chunk.java +10 -0
- package/rules/.source/hippy/extend_views/waterfall/ChunkGroup.java +5 -0
- package/rules/.source/hippy/extend_views/waterfall/Section.java +4 -0
- package/rules/.source/hippy/extend_views/waterfall/Tabs.java +5 -0
- package/rules/.source/hippy/extend_views/waterfall/WaterfallUtils.java +26 -0
- package/rules/.source/hippy/hippy_uimanager/ControllerHolder.java +30 -0
- package/rules/.source/hippy/hippy_uimanager/ControllerManager.java +651 -0
- package/rules/.source/hippy/hippy_uimanager/ControllerRegistry.java +102 -0
- package/rules/.source/hippy/hippy_uimanager/ControllerUpdateManger.java +252 -0
- package/rules/.source/hippy/hippy_uimanager/CustomControllerHelper.java +425 -0
- package/rules/.source/hippy/hippy_uimanager/DiffUtils.java +526 -0
- package/rules/.source/hippy/hippy_uimanager/ExtendViewGroup.java +36 -0
- package/rules/.source/hippy/hippy_uimanager/HippyCustomViewCreator.java +29 -0
- package/rules/.source/hippy/hippy_uimanager/HippyGroupController.java +83 -0
- package/rules/.source/hippy/hippy_uimanager/HippyViewBase.java +27 -0
- package/rules/.source/hippy/hippy_uimanager/HippyViewController.java +2189 -0
- package/rules/.source/hippy/hippy_uimanager/HippyViewEvent.java +52 -0
- package/rules/.source/hippy/hippy_uimanager/IHippyZIndexViewGroup.java +24 -0
- package/rules/.source/hippy/hippy_uimanager/InternalExtendViewUtil.java +395 -0
- package/rules/.source/hippy/hippy_uimanager/ListItemRenderNode.java +143 -0
- package/rules/.source/hippy/hippy_uimanager/ListViewRenderNode.java +44 -0
- package/rules/.source/hippy/hippy_uimanager/MatrixUtil.java +470 -0
- package/rules/.source/hippy/hippy_uimanager/NativeGestureDispatcher.java +349 -0
- package/rules/.source/hippy/hippy_uimanager/NativeGestureProcessor.java +188 -0
- package/rules/.source/hippy/hippy_uimanager/PullFooterRenderNode.java +43 -0
- package/rules/.source/hippy/hippy_uimanager/PullHeaderRenderNode.java +43 -0
- package/rules/.source/hippy/hippy_uimanager/RenderManager.java +304 -0
- package/rules/.source/hippy/hippy_uimanager/RenderNode.java +533 -0
- package/rules/.source/hippy/hippy_uimanager/StateView.java +17 -0
- package/rules/.source/hippy/hippy_uimanager/TransformUtil.java +125 -0
- package/rules/.source/hippy/hippy_uimanager/ViewGroupDrawingOrderHelper.java +108 -0
- package/rules/.source/hippy/hippy_uimanager/ViewStateProvider.java +10 -0
- package/rules/.source/hippy/hippy_views/audioview/AudioPlayManager.java +457 -0
- package/rules/.source/hippy/hippy_views/audioview/AudioView.java +225 -0
- package/rules/.source/hippy/hippy_views/audioview/AudioViewController.java +135 -0
- package/rules/.source/hippy/hippy_views/common/CommonBackgroundDrawable.java +58 -0
- package/rules/.source/hippy/hippy_views/common/CommonBorder.java +37 -0
- package/rules/.source/hippy/hippy_views/custom/HippyCustomPropsController.java +61 -0
- package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerListAdapter.java +399 -0
- package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerView.java +378 -0
- package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerViewController.java +187 -0
- package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerViewHolder.java +39 -0
- package/rules/.source/hippy/hippy_views/hippylist/HippyRecyclerViewWrapper.java +134 -0
- package/rules/.source/hippy/hippy_views/hippylist/NodePositionHelper.java +55 -0
- package/rules/.source/hippy/hippy_views/hippylist/PreloadHelper.java +54 -0
- package/rules/.source/hippy/hippy_views/hippylist/PullFooterEventHelper.java +61 -0
- package/rules/.source/hippy/hippy_views/hippylist/PullHeaderEventHelper.java +127 -0
- package/rules/.source/hippy/hippy_views/hippylist/RecyclerViewEventHelper.java +394 -0
- package/rules/.source/hippy/hippy_views/image/HippyContentDrawable.java +113 -0
- package/rules/.source/hippy/hippy_views/image/HippyImageView.java +1608 -0
- package/rules/.source/hippy/hippy_views/image/HippyImageViewController.java +382 -0
- package/rules/.source/hippy/hippy_views/image/IImageStateListener.java +7 -0
- package/rules/.source/hippy/hippy_views/list/ChildOnScreenScroller.java +255 -0
- package/rules/.source/hippy/hippy_views/list/HippyListAdapter.java +647 -0
- package/rules/.source/hippy/hippy_views/list/HippyListItemView.java +162 -0
- package/rules/.source/hippy/hippy_views/list/HippyListItemViewController.java +45 -0
- package/rules/.source/hippy/hippy_views/list/HippyListView.java +915 -0
- package/rules/.source/hippy/hippy_views/list/HippyListViewController.java +622 -0
- package/rules/.source/hippy/hippy_views/list/HippyRecycler.java +31 -0
- package/rules/.source/hippy/hippy_views/list/IRecycleItemTypeChange.java +23 -0
- package/rules/.source/hippy/hippy_views/list/ItemDecorations.java +70 -0
- package/rules/.source/hippy/hippy_views/list/NegativeLongKeyFlinger.java +156 -0
- package/rules/.source/hippy/hippy_views/list/NodeHolder.java +34 -0
- package/rules/.source/hippy/hippy_views/list/RecycleViewFlinger.java +126 -0
- package/rules/.source/hippy/hippy_views/list/TVRecyclerView.java +2070 -0
- package/rules/.source/hippy/hippy_views/list/TVSingleLineListView.java +15 -0
- package/rules/.source/hippy/hippy_views/modal/HippyModalHostManager.java +102 -0
- package/rules/.source/hippy/hippy_views/modal/HippyModalHostView.java +597 -0
- package/rules/.source/hippy/hippy_views/modal/ModalHostHelper.java +46 -0
- package/rules/.source/hippy/hippy_views/modal/ModalStyleNode.java +34 -0
- package/rules/.source/hippy/hippy_views/modal/RequestCloseEvent.java +32 -0
- package/rules/.source/hippy/hippy_views/modal/ShowEvent.java +31 -0
- package/rules/.source/hippy/hippy_views/navigator/Navigator.java +126 -0
- package/rules/.source/hippy/hippy_views/navigator/NavigatorController.java +120 -0
- package/rules/.source/hippy/hippy_views/refresh/HippyPullFooterView.java +47 -0
- package/rules/.source/hippy/hippy_views/refresh/HippyPullFooterViewController.java +65 -0
- package/rules/.source/hippy/hippy_views/refresh/HippyPullHeaderView.java +39 -0
- package/rules/.source/hippy/hippy_views/refresh/HippyPullHeaderViewController.java +104 -0
- package/rules/.source/hippy/hippy_views/refresh/RefreshWrapper.java +237 -0
- package/rules/.source/hippy/hippy_views/refresh/RefreshWrapperController.java +62 -0
- package/rules/.source/hippy/hippy_views/refresh/RefreshWrapperItemController.java +39 -0
- package/rules/.source/hippy/hippy_views/refresh/RefreshWrapperItemView.java +26 -0
- package/rules/.source/hippy/hippy_views/scroll/HippyHorizontalScrollView.java +500 -0
- package/rules/.source/hippy/hippy_views/scroll/HippyOnScrollHelper.java +39 -0
- package/rules/.source/hippy/hippy_views/scroll/HippyScrollView.java +46 -0
- package/rules/.source/hippy/hippy_views/scroll/HippyScrollViewController.java +178 -0
- package/rules/.source/hippy/hippy_views/scroll/HippyScrollViewEventHelper.java +92 -0
- package/rules/.source/hippy/hippy_views/scroll/HippyVerticalScrollView.java +522 -0
- package/rules/.source/hippy/hippy_views/text/HippyTextView.java +512 -0
- package/rules/.source/hippy/hippy_views/text/HippyTextViewController.java +77 -0
- package/rules/.source/hippy/hippy_views/textinput/HippyTextInput.java +668 -0
- package/rules/.source/hippy/hippy_views/textinput/HippyTextInputController.java +528 -0
- package/rules/.source/hippy/hippy_views/textinput/TextInputNode.java +115 -0
- package/rules/.source/hippy/hippy_views/videoview/APEZProvider.java +287 -0
- package/rules/.source/hippy/hippy_views/videoview/APKExpansionSupport.java +82 -0
- package/rules/.source/hippy/hippy_views/videoview/PivotPoint.java +13 -0
- package/rules/.source/hippy/hippy_views/videoview/ScalableType.java +34 -0
- package/rules/.source/hippy/hippy_views/videoview/ScalableVideoView.java +265 -0
- package/rules/.source/hippy/hippy_views/videoview/ScaleManager.java +191 -0
- package/rules/.source/hippy/hippy_views/videoview/Size.java +19 -0
- package/rules/.source/hippy/hippy_views/videoview/VideoHippyView.java +917 -0
- package/rules/.source/hippy/hippy_views/videoview/VideoHippyViewController.java +236 -0
- package/rules/.source/hippy/hippy_views/videoview/ZipResourceFile.java +427 -0
- package/rules/.source/hippy/hippy_views/view/CardRootView.java +28 -0
- package/rules/.source/hippy/hippy_views/view/CustomLayoutView.java +10 -0
- package/rules/.source/hippy/hippy_views/view/CustomNodeView.java +5 -0
- package/rules/.source/hippy/hippy_views/view/DialogViewGroup.java +113 -0
- package/rules/.source/hippy/hippy_views/view/HippyViewGroup.java +2042 -0
- package/rules/.source/hippy/hippy_views/view/HippyViewGroupController.java +583 -0
- package/rules/.source/hippy/hippy_views/view/WindowRoot.java +5 -0
- package/rules/.source/hippy/hippy_views/viewpager/HippyViewPager.java +308 -0
- package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerAdapter.java +148 -0
- package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerController.java +246 -0
- package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerItem.java +27 -0
- package/rules/.source/hippy/hippy_views/viewpager/HippyViewPagerItemController.java +42 -0
- package/rules/.source/hippy/hippy_views/viewpager/ViewPagerPageChangeListener.java +114 -0
- package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageItemExposureEvent.java +40 -0
- package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageScrollEvent.java +43 -0
- package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageScrollStateChangedEvent.java +42 -0
- package/rules/.source/hippy/hippy_views/viewpager/event/HippyPageSelectedEvent.java +42 -0
- package/rules/.source/hippy/hippy_views/webview/HippyWebView.java +160 -0
- package/rules/.source/hippy/hippy_views/webview/HippyWebViewBridge.java +20 -0
- package/rules/.source/hippy/hippy_views/webview/HippyWebViewController.java +103 -0
- package/rules/.source/hippy/hippy_views/webview/HippyWebViewInner.java +77 -0
- package/rules/.windsurfrules +27 -4
- package/rules/AGENTS.md +27 -4
- package/rules/CLAUDE.md +27 -3
- package/rules/GEMINI.md +25 -3
|
@@ -0,0 +1,982 @@
|
|
|
1
|
+
package com.tencent.extend.views.fastlist;
|
|
2
|
+
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
import android.text.TextUtils;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
import android.view.View;
|
|
7
|
+
import android.view.ViewGroup;
|
|
8
|
+
import android.widget.TextView;
|
|
9
|
+
|
|
10
|
+
import android.support.annotation.Nullable;
|
|
11
|
+
|
|
12
|
+
import com.tencent.extend.views.TVTextView;
|
|
13
|
+
import com.tencent.mtt.hippy.common.HippyArray;
|
|
14
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
15
|
+
import com.tencent.mtt.hippy.dom.node.NodeProps;
|
|
16
|
+
import com.tencent.mtt.hippy.dom.node.StyleNode;
|
|
17
|
+
import com.tencent.mtt.hippy.uimanager.CustomControllerHelper;
|
|
18
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewController;
|
|
19
|
+
import com.tencent.mtt.hippy.uimanager.RenderNode;
|
|
20
|
+
import com.tencent.mtt.hippy.utils.ExtendUtil;
|
|
21
|
+
import com.tencent.mtt.hippy.utils.LogUtils;
|
|
22
|
+
|
|
23
|
+
import java.util.Set;
|
|
24
|
+
|
|
25
|
+
public final class FastAdapterUtil {
|
|
26
|
+
|
|
27
|
+
public static final String TAG = "FastAdapterUtil";
|
|
28
|
+
|
|
29
|
+
static void preGeneratePropsToUpdate(FastAdapter.ElementNode node, HippyMap itemData, HippyMap rawMap, HippyMap toMap){
|
|
30
|
+
Set<String> props = node.pendingProps.keySet();
|
|
31
|
+
for (String prop : props) {
|
|
32
|
+
if (TemplateCodeParser.isEquationProp(rawMap.get(prop))) {//showIf="${detailStyle=2}"
|
|
33
|
+
//将等式的值计算出来放进去
|
|
34
|
+
final boolean b = TemplateCodeParser.parseBooleanFromPendingProp(prop, itemData, rawMap.get(prop));
|
|
35
|
+
toMap.pushObject(prop, b);
|
|
36
|
+
} else {
|
|
37
|
+
final String pendingProp = TemplateCodeParser.parsePlaceholderProp(prop, rawMap);
|
|
38
|
+
if (!TextUtils.isEmpty(pendingProp)) {
|
|
39
|
+
//用item中的数据,替换map中的数据
|
|
40
|
+
final Object dataFromValue = TemplateCodeParser.getValueFromCode(itemData, pendingProp);
|
|
41
|
+
toMap.pushObject(prop, dataFromValue);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//不是pending什么也不做
|
|
45
|
+
}
|
|
46
|
+
node.pendingProps = toMap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static void preGeneratePropsToUpdateWithoutPendingProp(FastAdapter.ElementNode node, HippyMap itemData, HippyMap rawMap, HippyMap toMap){
|
|
50
|
+
Set<String> props = node.pendingProps.keySet();
|
|
51
|
+
for (String prop : props) {
|
|
52
|
+
// Log.v("DebugReplaceItem","set prop "+prop+" value "+itemData.get(prop));
|
|
53
|
+
if (TemplateCodeParser.isEquationProp(rawMap.get(prop))) {//showIf="${detailStyle=2}"
|
|
54
|
+
//将等式的值计算出来放进去
|
|
55
|
+
final boolean b = TemplateCodeParser.parseBooleanFromPendingProp(prop, itemData, rawMap.get(prop));
|
|
56
|
+
toMap.pushObject(prop, b);
|
|
57
|
+
} else {
|
|
58
|
+
final String pendingProp = TemplateCodeParser.parsePlaceholderProp(prop, rawMap);
|
|
59
|
+
if (!TextUtils.isEmpty(pendingProp)) {
|
|
60
|
+
//用item中的数据,替换map中的数据
|
|
61
|
+
final Object dataFromValue = TemplateCodeParser.getValueFromCode(itemData, pendingProp);
|
|
62
|
+
toMap.pushObject(prop, dataFromValue);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//不是pending什么也不做
|
|
66
|
+
}
|
|
67
|
+
node.pendingProps = toMap;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static void preInitElementNodeProps(FastAdapter.ElementNode node, HippyMap itemData, HippyMap rawMap, HippyMap toMap){
|
|
71
|
+
preInitElementNodeProps(node,itemData,rawMap,toMap,false);
|
|
72
|
+
}
|
|
73
|
+
static void preInitElementNodeProps(FastAdapter.ElementNode node, HippyMap itemData, HippyMap rawMap, HippyMap toMap,boolean force){
|
|
74
|
+
node.pendingProps = new HippyMap();
|
|
75
|
+
Set<String> props = rawMap.keySet();
|
|
76
|
+
for (String prop : props) { // 遍历的是模板的属性
|
|
77
|
+
if(TemplateCodeParser.PENDING_PROP_CREATE_IF.equals(prop)){
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (TemplateCodeParser.isEquationProp(rawMap.get(prop))) {//showIf="${detailStyle=2}"
|
|
81
|
+
//将等式的值计算出来放进去
|
|
82
|
+
final boolean b = TemplateCodeParser.parseBooleanFromPendingProp(prop, itemData, rawMap.get(prop));
|
|
83
|
+
toMap.pushObject(prop, b);
|
|
84
|
+
node.pendingProps.pushObject(prop, b);
|
|
85
|
+
} else {//pending的属性 比如type="${itemType}"中的
|
|
86
|
+
final String pendingProp = TemplateCodeParser.parsePlaceholderProp(prop, rawMap);
|
|
87
|
+
// Log.d(TAG,"prepareItemViewAndCreatePatches pendingProp:"+pendingProp+",isTextProp:"+isTextProp+",isPendingProp:"+isPendingProp+",prop:"+prop);
|
|
88
|
+
if (!TextUtils.isEmpty(pendingProp)) {// 获取的是pending属性或者eventClick、eventFouces
|
|
89
|
+
//用item中的数据,替换map中的数据
|
|
90
|
+
final Object dataFromValue = TemplateCodeParser.getValueFromCode(itemData, pendingProp);
|
|
91
|
+
toMap.pushObject(prop, dataFromValue);
|
|
92
|
+
node.pendingProps.pushObject(prop, dataFromValue);
|
|
93
|
+
// if(itemTag != null) {
|
|
94
|
+
// //反过来,把prop当value
|
|
95
|
+
// itemTag.rawPendingPropsReverse.pushString(pendingProp,prop);
|
|
96
|
+
// }
|
|
97
|
+
} else if (!node.hasInit || force) {
|
|
98
|
+
//直接复制一份
|
|
99
|
+
toMap.pushObject(prop, rawMap.get(prop));
|
|
100
|
+
} else if (LogUtils.isDebug()) {
|
|
101
|
+
//Log.v("FastAdapterUtil", "diffPatch path return on hasCreated true prop:" + prop);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
node.hasInit = true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static View findFocusableView(View view){
|
|
109
|
+
if(view != null && view.isFocusable()){
|
|
110
|
+
return view;
|
|
111
|
+
}
|
|
112
|
+
if(view instanceof ViewGroup){
|
|
113
|
+
for(int i = 0; i < ((ViewGroup) view).getChildCount(); i++){
|
|
114
|
+
View child = ((ViewGroup) view).getChildAt(i);
|
|
115
|
+
View result = findFocusableView(child);
|
|
116
|
+
if (result != null) {
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static boolean parseBoolean(Object object){
|
|
125
|
+
if(object instanceof String){
|
|
126
|
+
return Boolean.parseBoolean((String) object);
|
|
127
|
+
}else if((object instanceof Boolean)){
|
|
128
|
+
return (boolean) object;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static void invokePropsSync(@Nullable HippyViewController vc, HippyMap props, int position, FastAdapter.ElementNode en, FastAdapter adapter,int step) {
|
|
134
|
+
if (vc == null) {
|
|
135
|
+
Log.e(TAG,"FastAdapterUtil invokePropsSync error ,viewController is null");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// if(LogUtils.isDebug()){
|
|
139
|
+
// final String tag = getStepStr(step);
|
|
140
|
+
// Log.e(tag,"----------------:invokePropsSync on templateNode "+en.templateNode+",view :"+en.boundView+"---------------");
|
|
141
|
+
// }
|
|
142
|
+
for (String prop : props.keySet()) {
|
|
143
|
+
if (prop == null) {
|
|
144
|
+
Log.e(TAG, "doDiffProps prop is null en:" + en + ",position:" + position + ",vc:" + vc);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
// if(LogUtils.isDebug()) {
|
|
148
|
+
// Log.v(TAG, "-----------------WorkLOG prop:" + prop + ",this:" + Utils.hashCode(adapter));
|
|
149
|
+
// }
|
|
150
|
+
if (prop.equals(NodeProps.STYLE) && props.get(prop) instanceof HippyMap) {
|
|
151
|
+
invokePropsSync(vc, props.getMap(prop), position, en, adapter,step);
|
|
152
|
+
} else {
|
|
153
|
+
invokeProp(vc, props, prop, position, en, adapter,step);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static String getStepStr(int step){
|
|
159
|
+
String stepPrefix;
|
|
160
|
+
switch (step){
|
|
161
|
+
case FastAdapter.STEP_INIT:
|
|
162
|
+
stepPrefix = "STEP_INIT";
|
|
163
|
+
break;
|
|
164
|
+
case FastAdapter.STEP_ON_BIND:
|
|
165
|
+
stepPrefix = "STEP_ON_BIND";
|
|
166
|
+
break;
|
|
167
|
+
case FastAdapter.STEP_DELAY_POST:
|
|
168
|
+
stepPrefix = "STEP_DELAY_POST";
|
|
169
|
+
break;
|
|
170
|
+
case FastAdapter.STEP_VIF:
|
|
171
|
+
stepPrefix = "STEP_VIF";
|
|
172
|
+
break;
|
|
173
|
+
case FastAdapter.STEP_PLACEHOLDER_TO_CONTENT:
|
|
174
|
+
stepPrefix = "STEP_PLACEHOLDER";
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
stepPrefix = "UNKNOWN";
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
return stepPrefix;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
// 处理已经拿到的数据
|
|
185
|
+
static void invokeProp(HippyViewController vc, HippyMap props, String prop, int position, FastAdapter.ElementNode en, FastAdapter adapter,int step) {
|
|
186
|
+
|
|
187
|
+
// if (LogUtils.isDebug()) {
|
|
188
|
+
// Log.i(TAG, "invokePropU position: " + position + " Prop:" + prop + ",templateNode:" + en.templateNode + ",vc:" + vc + ",view:" + en.boundView);
|
|
189
|
+
// }
|
|
190
|
+
if (en.boundView == null) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (vc instanceof PendingViewController && PendingViewController.PROP_LIST.equals(prop)) {
|
|
194
|
+
if (en.templateNode instanceof FastAdapter.ListNode) {
|
|
195
|
+
FastAdapter.ListNodeTag tag = ((FastAdapter.ListNode) en.templateNode).getBoundTag();
|
|
196
|
+
if (tag == null) {
|
|
197
|
+
tag = new FastAdapter.ListNodeTag();
|
|
198
|
+
((FastAdapter.ListNode) en.templateNode).setBoundTag(tag);
|
|
199
|
+
}
|
|
200
|
+
// if (LogUtils.isDebug()) {
|
|
201
|
+
// Log.d(TAG, "setTagPosition:" + position + ",en:" + en + ",prop:" + prop);
|
|
202
|
+
// }
|
|
203
|
+
tag.position = position;
|
|
204
|
+
tag.parent = adapter.listNode;
|
|
205
|
+
}
|
|
206
|
+
if (en.boundView instanceof FastPendingView) {
|
|
207
|
+
//这里设置RootList,用住嵌套使用
|
|
208
|
+
((FastPendingView) en.boundView).setRootList(adapter.getRootListView(), adapter);
|
|
209
|
+
((FastPendingView) en.boundView).setHandleEventNodeId(adapter.rootListNodeID);
|
|
210
|
+
if (adapter.getRootListView() != null) {
|
|
211
|
+
((FastPendingView) en.boundView).getEventDeliverer().setOnEventListener(adapter.getRootListView().getEventDeliverer().onEventListener);
|
|
212
|
+
}
|
|
213
|
+
// if (en.boundView instanceof FastListView) {
|
|
214
|
+
// ((FastListView) en.boundView).setUseDiff(true);
|
|
215
|
+
// }
|
|
216
|
+
}
|
|
217
|
+
final Object dataFromValue = props.get(prop);
|
|
218
|
+
//fixme 这里嵌套list的时候,强制使用diff,有可能造成未知问题,后续需要优化
|
|
219
|
+
((PendingViewController) vc).setPendingData(en.boundView, dataFromValue, en.templateNode);
|
|
220
|
+
} else { // 非嵌套list的情况处理
|
|
221
|
+
setOnElementListenerIfNeed(adapter,position,en);
|
|
222
|
+
if (!dispatchCustomPendingProp(prop, en, props, position, adapter)) { // 一些自定义属性的处理
|
|
223
|
+
final Object dataFromValue = props.get(prop);
|
|
224
|
+
// if("focusScale".equals(prop)){
|
|
225
|
+
// Log.i("DebugPlaceholder","set focusScale value "+dataFromValue+",view : "+ExtendUtil.debugViewLite(en.boundView));
|
|
226
|
+
// }
|
|
227
|
+
|
|
228
|
+
// if (LogUtils.isDebug()) {
|
|
229
|
+
// String stepPrefix = getStepStr(step);
|
|
230
|
+
// Log.i(stepPrefix, "invokePropMethodForPending position:" + position +",prop: "+prop+",targetView:"+en.boundView+",dataFromValue:"+dataFromValue+",visibility:"+en.boundView.getVisibility());
|
|
231
|
+
// }
|
|
232
|
+
CustomControllerHelper.invokePropMethodForPending(vc, en.boundView, prop, dataFromValue); // 通常属性的处理
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
//设置view的点击和焦点事件
|
|
238
|
+
static void setOnElementListenerIfNeed(FastAdapter adapter, int position, FastAdapter.ElementNode en){
|
|
239
|
+
if(en.boundView.isFocusable() || en.templateNode.getProps().containsKey("eventClick")) {
|
|
240
|
+
final View.OnClickListener clickListener = new FastAdapter.ElementClickListener(adapter, adapter.rootListNodeID, en, adapter.eventDeliverer);
|
|
241
|
+
final View.OnLongClickListener longClickListener = new FastAdapter.ElementLongClickListener(adapter, adapter.rootListNodeID, en, adapter.eventDeliverer);
|
|
242
|
+
// if (LogUtils.isDebug()) {
|
|
243
|
+
// Log.e("DebugClick", "setOnElementListenerIfNeed ElementCallback setupClick ,boundView:" + en.boundView.hashCode() + ",viewName:" + en.name + ",clickListener:" + clickListener.hashCode()+",position:"+position);
|
|
244
|
+
// }
|
|
245
|
+
final FastAdapter.ItemFocusListener listener = new FastAdapter.ItemFocusListener(adapter, adapter.rootListNodeID, en, adapter.eventDeliverer);
|
|
246
|
+
en.boundView.setOnFocusChangeListener(listener);
|
|
247
|
+
|
|
248
|
+
setClickListener4BoundView(adapter,en,position, clickListener, longClickListener);
|
|
249
|
+
// en.boundView.setOnClickListener(clickListener);
|
|
250
|
+
// en.boundView.setOnLongClickListener(longClickListener);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
static void setClickListener4BoundView(FastAdapter adapter,FastAdapter.ElementNode en,int position, View.OnClickListener listener, View.OnLongClickListener longClickListener) {
|
|
255
|
+
if (en.boundView != null) {
|
|
256
|
+
FastAdapter.ItemRootView irv = en.isRootItem ? adapter.findItemRootViewByPosition(position) : null;
|
|
257
|
+
// if(irv != null && LogUtils.isDebug()){
|
|
258
|
+
// Log.d("DebugClick","setClickListener4BoundView findItemRoot from adapter :"+ExtendUtil.debugViewLite(irv));
|
|
259
|
+
// }
|
|
260
|
+
if(irv == null && en.rootNode != null && en.rootNode.boundView != null && en.rootNode.boundView.getParent() instanceof FastAdapter.ItemRootView){
|
|
261
|
+
irv = (FastAdapter.ItemRootView) en.rootNode.boundView.getParent();
|
|
262
|
+
}
|
|
263
|
+
// if(irv == null && LogUtils.isDebug()) {
|
|
264
|
+
// Log.e("DebugClick", "setClickListener4BoundView findItemRoot null");
|
|
265
|
+
// }
|
|
266
|
+
if(en.boundView.isInTouchMode()){
|
|
267
|
+
en.boundView.setFocusable(false);
|
|
268
|
+
en.boundView.setClickable(false);
|
|
269
|
+
}
|
|
270
|
+
if (irv != null) {
|
|
271
|
+
irv.setContentOnClickListener(listener);
|
|
272
|
+
irv.setContentLongClickListener(longClickListener);
|
|
273
|
+
}else {
|
|
274
|
+
if(adapter.onFastItemClickListener instanceof FastAdapter.FastItemDispatchedClickListener){
|
|
275
|
+
//fixme 这里目前逻辑不太完整,没有层级嵌套问题,理论上item点击只能在一个生效
|
|
276
|
+
// if(LogUtils.isDebug()) {
|
|
277
|
+
// Log.e("DebugClick", "setClickListener4BoundView irv setOnClickListener boundView :"+ExtendUtil.debugViewLite(en.boundView));
|
|
278
|
+
// }
|
|
279
|
+
FastAdapter.FastItemDispatchedClickListener fd = (FastAdapter.FastItemDispatchedClickListener) adapter.onFastItemClickListener;
|
|
280
|
+
fd.putClickListener(position,en.boundView,listener,longClickListener);
|
|
281
|
+
}else {
|
|
282
|
+
// if(LogUtils.isDebug()) {
|
|
283
|
+
// Log.e("DebugClick", "setClickListener4BoundView boundView setOnClickListener directly :"+ExtendUtil.debugViewLite(en.boundView));
|
|
284
|
+
// }
|
|
285
|
+
en.boundView.setOnClickListener(listener);
|
|
286
|
+
en.boundView.setOnLongClickListener(longClickListener);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
static void removeFromParentIfNeed(View view){
|
|
297
|
+
if (view != null && view.getParent() instanceof ViewGroup) {
|
|
298
|
+
//删除view
|
|
299
|
+
if(LogUtils.isDebug()) {
|
|
300
|
+
Log.i(ReplaceChildView.TAG, "removeFromParentIfNeed view:" + ExtendUtil.debugView(view) + ",parent:" + ExtendUtil.debugView((View) view.getParent()));
|
|
301
|
+
}
|
|
302
|
+
((ViewGroup) view.getParent()).removeView(view);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static View getRealContent(FastAdapter.Holder holder){
|
|
307
|
+
if(holder.itemView instanceof FastAdapter.ItemRootView){
|
|
308
|
+
return ((FastAdapter.ItemRootView) holder.itemView).getContentView();
|
|
309
|
+
}else{
|
|
310
|
+
return holder.itemView;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 因为adapter中现在包了一层itemRootView,所以如果想获取一个itemView的实例,
|
|
316
|
+
* 需要从ItemRootView中获取
|
|
317
|
+
* @param view
|
|
318
|
+
* @return
|
|
319
|
+
*/
|
|
320
|
+
public static View finalRealContent(View view){
|
|
321
|
+
if(view instanceof FastAdapter.ItemRootView){
|
|
322
|
+
return ((FastAdapter.ItemRootView) view).getContentView();
|
|
323
|
+
}else{
|
|
324
|
+
return view;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public static View findClonedViewByTemplateView(View view,FastAdapter.ElementNode node){
|
|
329
|
+
// if(LogUtils.isDebug()) {
|
|
330
|
+
// Log.i(FastListView.TAG_CLONED, "findClonedViewByTemplateView view :" + ",node:" + node.templateNode);
|
|
331
|
+
// }
|
|
332
|
+
if(node.templateNode != null){
|
|
333
|
+
if(node.templateNode.getId() == view.getId()){
|
|
334
|
+
if(LogUtils.isDebug()) {
|
|
335
|
+
Log.e(FastListView.TAG_CLONED, "findClonedViewByTemplateView find target view:" + node.boundView);
|
|
336
|
+
}
|
|
337
|
+
return node.boundView;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
for(int i = 0; i < node.getChildCount(); i ++){
|
|
341
|
+
FastAdapter.ElementNode child = (FastAdapter.ElementNode) node.getChildAt(i);
|
|
342
|
+
final View result = findClonedViewByTemplateView(view,child);
|
|
343
|
+
if (result != null) {
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
static void setDuplicateParentStateEnabled4AllParent(@Nullable View view, boolean b){
|
|
351
|
+
if (view != null) {
|
|
352
|
+
if(!view.isFocusable()) {
|
|
353
|
+
Log.i("ItemContainerLog","setDuplicateParentStateEnabled4AllParent view : "+view);
|
|
354
|
+
view.setDuplicateParentStateEnabled(b);
|
|
355
|
+
}
|
|
356
|
+
if (view.getParent() instanceof View) {
|
|
357
|
+
setDuplicateParentStateEnabled4AllParent((View) view.getParent(),b);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
static void setFocusListener4BoundView(FastAdapter.ElementNode en, FastAdapter.ItemFocusListener listener){
|
|
363
|
+
if (en.boundView != null) {
|
|
364
|
+
if (en.rootNode != null && en.rootNode.boundView != null && en.rootNode.boundView.getParent() instanceof FastAdapter.ItemRootView) {
|
|
365
|
+
final FastAdapter.ItemRootView irv = (FastAdapter.ItemRootView) en.rootNode.boundView.getParent();
|
|
366
|
+
// irv.setChicl
|
|
367
|
+
irv.setContentItemFocusListener(listener);
|
|
368
|
+
}else {
|
|
369
|
+
en.boundView.setOnFocusChangeListener(listener);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
static boolean dispatchCustomPendingProp(String prop, FastAdapter.ElementNode en, HippyMap props, int position, FastAdapter adapter) {
|
|
376
|
+
// if (LogUtils.isDebug()) {
|
|
377
|
+
// Log.i(TAG, "dispatchCustomPendingProp prop:" + prop + ",position:" + position);
|
|
378
|
+
// }
|
|
379
|
+
boolean handled = true;
|
|
380
|
+
switch (prop) {
|
|
381
|
+
case TemplateCodeParser.PENDING_PROP_TRANSLATION: {
|
|
382
|
+
final Object dataFromValue = props.get(prop);
|
|
383
|
+
// if (LogUtils.isDebug()) {
|
|
384
|
+
// Log.e(TAG, "dispatchCustomPendingProp position dataFromValue:" + dataFromValue+",view:"+en.boundView);
|
|
385
|
+
// }
|
|
386
|
+
final HippyArray posArray = (HippyArray) dataFromValue;
|
|
387
|
+
if (posArray != null && posArray.size() == 2) {
|
|
388
|
+
//tempPatchLayout.add(new UpdateLayoutPatch(posArray.getInt(0), posArray.getInt(1), boundNode.getWidth(), boundNode.getHeight(), p.view, boundNode));
|
|
389
|
+
en.setMarginLeft(posArray.getInt(0));
|
|
390
|
+
en.setMarginTop(posArray.getInt(1));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
case TemplateCodeParser.PENDING_PROP_SIZE: {
|
|
395
|
+
final Object dataFromValue = props.get(prop);
|
|
396
|
+
// if (LogUtils.isDebug()) {
|
|
397
|
+
// Log.e(TAG, "dispatchCustomPendingProp size dataFromValue:" + dataFromValue+",view:"+en.boundView);
|
|
398
|
+
// }
|
|
399
|
+
final HippyArray posArray = (HippyArray) dataFromValue;
|
|
400
|
+
if (posArray != null && posArray.size() == 2) {
|
|
401
|
+
//tempPatchLayout.add(new UpdateLayoutPatch(boundNode.getX(),boundNode.getY(),posArray.getInt(0), posArray.getInt(1), p.view, boundNode));
|
|
402
|
+
en.setStyleWidth(Utils.toPX(posArray.getInt(0)));
|
|
403
|
+
en.setStyleHeight(Utils.toPX(posArray.getInt(1)));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
break;
|
|
407
|
+
case TemplateCodeParser.PENDING_PROP_LAYOUT: {
|
|
408
|
+
final Object dataFromValue = props.get(prop);
|
|
409
|
+
// if (LogUtils.isDebug()) {
|
|
410
|
+
// Log.e(TAG, "dispatchCustomPendingProp layout dataFromValue:" + dataFromValue+",view:"+en.boundView);
|
|
411
|
+
// }
|
|
412
|
+
final HippyArray posArray = (HippyArray) dataFromValue;
|
|
413
|
+
if (posArray != null && posArray.size() == 4) {
|
|
414
|
+
//tempPatchLayout.add(new UpdateLayoutPatch(posArray.getInt(0), posArray.getInt(1), posArray.getInt(2),posArray.getInt(3), p.view, boundNode));
|
|
415
|
+
en.setMarginLeft(posArray.getInt(0));
|
|
416
|
+
en.setMarginTop(posArray.getInt(1));
|
|
417
|
+
en.setStyleWidth(Utils.toPX(posArray.getInt(2)));
|
|
418
|
+
en.setStyleHeight(Utils.toPX(posArray.getInt(3)));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
case TemplateCodeParser.PENDING_PROP_FLEX_STYLE: {
|
|
423
|
+
final Object dataFromValue = props.get(prop);
|
|
424
|
+
// if (LogUtils.isDebug()) {
|
|
425
|
+
// Log.i(TAG, "dispatchCustomPendingProp PROP_FLEX_STYLE layout dataFromValue:" + dataFromValue + ",node:" + en+",view:"+en.boundView);
|
|
426
|
+
// }
|
|
427
|
+
final HippyMap style = (HippyMap) dataFromValue;
|
|
428
|
+
//Utils.updateStyleSlot(en,style);
|
|
429
|
+
adapter.domUpdateManager.updateStyle(en, style);
|
|
430
|
+
if(style != null) {
|
|
431
|
+
//Log.i("fixElementNodeSize","flexStyle style :"+style);
|
|
432
|
+
if (style.containsKey("left")) {
|
|
433
|
+
en.setMarginLeft(getViewPXValueFromStyle(style, "left"));
|
|
434
|
+
}
|
|
435
|
+
if (style.containsKey("top")) {
|
|
436
|
+
en.setMarginTop(getViewPXValueFromStyle(style, "top"));
|
|
437
|
+
}
|
|
438
|
+
if (style.containsKey("width")) {
|
|
439
|
+
// Log.i("fixElementNodeSize","flexStyle getViewPXValueFromStyle width :"+getViewPXValueFromStyle(style, "width"));
|
|
440
|
+
en.setStyleWidth(getViewPXValueFromStyle(style, "width"));
|
|
441
|
+
}
|
|
442
|
+
if (style.containsKey("height")) {
|
|
443
|
+
// Log.i("fixElementNodeSize","flexStyle getViewPXValueFromStyle height :"+getViewPXValueFromStyle(style, "height"));
|
|
444
|
+
en.setStyleHeight(getViewPXValueFromStyle(style, "height"));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// if (LogUtils.isDebug()) {
|
|
448
|
+
// Log.e(TAG, "dispatchCustomPendingProp PROP_FLEX_STYLE layout after dataFromValue:" + dataFromValue + ",node:" + en+",view:"+en.boundView);
|
|
449
|
+
// }
|
|
450
|
+
}
|
|
451
|
+
break;
|
|
452
|
+
case TemplateCodeParser.PLACEHOLDER_STYLE:
|
|
453
|
+
if (en.rootNode != null) {
|
|
454
|
+
final Object dataFromValue = props.get(prop);
|
|
455
|
+
if(dataFromValue instanceof HippyMap){
|
|
456
|
+
en.rootNode.placeholderStyle = (HippyMap) dataFromValue;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
break;
|
|
460
|
+
case TemplateCodeParser.ITEM_SID:
|
|
461
|
+
if (en.rootNode != null) {
|
|
462
|
+
final Object dataFromValue = props.get(prop);
|
|
463
|
+
// Log.e("configID4Item","dispatchCustomPendingProp ITEM_SID dataFromValue:" + dataFromValue+",view:"+en.boundView);
|
|
464
|
+
if(dataFromValue instanceof String){
|
|
465
|
+
en.rootNode.itemSID = (String) dataFromValue;
|
|
466
|
+
}else{
|
|
467
|
+
en.rootNode.itemSID = "";
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
break;
|
|
471
|
+
case TemplateCodeParser.PENDING_PROP_EVENT_CLICK: {
|
|
472
|
+
// int parentPos = -1;
|
|
473
|
+
// if(adapter.listNode != null && adapter.listNode.getBoundTag() != null){
|
|
474
|
+
// parentPos = adapter.listNode.getBoundTag().position;
|
|
475
|
+
// }
|
|
476
|
+
final View.OnClickListener clickListener = new FastAdapter.ElementClickListener(adapter, adapter.rootListNodeID, en, adapter.eventDeliverer);
|
|
477
|
+
final View.OnLongClickListener longClickListener = new FastAdapter.ElementLongClickListener(adapter, adapter.rootListNodeID, en, adapter.eventDeliverer);
|
|
478
|
+
// if (LogUtils.isDebug()) {
|
|
479
|
+
// Log.e("DebugClick", "dispatchCustomPendingProp ElementCallback setupClick isRoot:" + en.isRootItem + ",boundView:" + en.boundView + ",viewName:" + en.name + ",clickListener:" + clickListener);
|
|
480
|
+
// }
|
|
481
|
+
//en.boundView.setOnClickListener(clickListener);
|
|
482
|
+
setClickListener4BoundView(adapter,en, position,clickListener, longClickListener);
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
case TemplateCodeParser.PENDING_PROP_EVENT_FOCUS: {
|
|
486
|
+
final Object dataFromValue = props.get(prop);
|
|
487
|
+
// if (LogUtils.isDebug()) {
|
|
488
|
+
// Log.e(TAG, "dispatchCustomPendingProp ElementCallback setupFocus dataFromValue:" + dataFromValue + ",boundView:" + en.boundView + ",viewName:" + en.name);
|
|
489
|
+
// }
|
|
490
|
+
final FastAdapter.ItemFocusListener listener = new FastAdapter.ItemFocusListener(adapter, adapter.rootListNodeID, en, adapter.eventDeliverer);
|
|
491
|
+
//en.boundView.setOnFocusChangeListener(listener);
|
|
492
|
+
setFocusListener4BoundView(en,listener);
|
|
493
|
+
}
|
|
494
|
+
break;
|
|
495
|
+
case TemplateCodeParser.PENDING_PROP_SHOW_IF: {
|
|
496
|
+
final Object dataFromValue = props.get(prop);
|
|
497
|
+
// if (LogUtils.isDebug()) {
|
|
498
|
+
// Log.i(TemplateCodeParser.TAG, "dispatchCustomPendingProp dataFromValue " + dataFromValue+",view:"+en.boundView);
|
|
499
|
+
// }
|
|
500
|
+
final boolean isEquationTrue = dataFromValue != null && (boolean) dataFromValue;
|
|
501
|
+
// if (LogUtils.isDebug()) {
|
|
502
|
+
// Log.i(TemplateCodeParser.TAG, "dispatchCustomPendingProp isEquationTrue " + isEquationTrue);
|
|
503
|
+
// }
|
|
504
|
+
changeViewShowIf(en.boundView, isEquationTrue);
|
|
505
|
+
}
|
|
506
|
+
default:
|
|
507
|
+
handled = false;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
if ("visibility".equals(prop)) {
|
|
511
|
+
final Object dataFromValue = props.get(prop);
|
|
512
|
+
if ("gone".equals(dataFromValue)) {
|
|
513
|
+
if (LogUtils.isDebug()) {
|
|
514
|
+
Log.e(TAG, "doPatch4Prepare change visibility gone en:" + en);
|
|
515
|
+
}
|
|
516
|
+
Utils.clearLayout(en);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return handled;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
static void changeViewShowIf(View view, boolean b) {
|
|
524
|
+
if (view != null) {
|
|
525
|
+
view.setVisibility(b ? View.VISIBLE : View.INVISIBLE);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
static Object getPropValue(RenderNode renderNode, int position, String prop, HippyMap itemData){
|
|
530
|
+
final HippyMap rawMap = renderNode.getProps();
|
|
531
|
+
Object value = null;
|
|
532
|
+
if (TemplateCodeParser.isEquationProp(rawMap.get(prop))) {//showIf="${detailStyle=2}"
|
|
533
|
+
//将等式的值计算出来放进去
|
|
534
|
+
value = TemplateCodeParser.parseBooleanFromPendingProp(prop, itemData, rawMap.get(prop));
|
|
535
|
+
} else {
|
|
536
|
+
final String pendingProp = TemplateCodeParser.parsePlaceholderProp(prop, rawMap);
|
|
537
|
+
if (!TextUtils.isEmpty(pendingProp)) {
|
|
538
|
+
//用item中的数据,替换map中的数据
|
|
539
|
+
value = TemplateCodeParser.getValueFromCode(itemData, pendingProp);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return value;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
static void findItemViewSize4FlexView(RenderNode templateNode, int position, HippyMap itemData, int[] layout){
|
|
546
|
+
|
|
547
|
+
if (itemData.containsKey("width")) {
|
|
548
|
+
layout[2] = Utils.toPX(itemData.getInt("width"));
|
|
549
|
+
}
|
|
550
|
+
if (itemData.containsKey("height")) {
|
|
551
|
+
layout[3] = Utils.toPX(itemData.getInt("height"));
|
|
552
|
+
}
|
|
553
|
+
Log.i(TAG,"findItemViewSize findItemViewSize4FlexView layout position:"+position+",itemData:"+itemData);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
static void notifyDetachFromParent(View view){
|
|
557
|
+
if (view instanceof FastAdapter.ScrollTaskHandler) {
|
|
558
|
+
((FastAdapter.ScrollTaskHandler) view).notifyDetachFromParent();
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
// //2023 11、14,FastList里嵌套时应该直接是一个list,但考虑到性能和功能平衡这里再深入一层
|
|
562
|
+
if(view instanceof ViewGroup){
|
|
563
|
+
for(int i = 0; i < ((ViewGroup) view).getChildCount(); i ++){
|
|
564
|
+
if (((ViewGroup) view).getChildAt(i) instanceof FastAdapter.ScrollTaskHandler) {
|
|
565
|
+
((FastAdapter.ScrollTaskHandler) ((ViewGroup) view).getChildAt(i)).notifyDetachFromParent();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
static void notifyAttachToParent(View view){
|
|
572
|
+
// Log.v(AutoFocusManager.TAG,"****FastList notifyAttachToParent view:"+view);
|
|
573
|
+
if (view instanceof FastAdapter.ScrollTaskHandler) {
|
|
574
|
+
((FastAdapter.ScrollTaskHandler) view).notifyAttachToParent();
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
//2023 11、14,FastList里嵌套时应该直接是一个list,但考虑到性能和功能平衡这里再深入一层
|
|
578
|
+
if(view instanceof ViewGroup){
|
|
579
|
+
for(int i = 0; i < ((ViewGroup) view).getChildCount(); i ++){
|
|
580
|
+
if (((ViewGroup) view).getChildAt(i) instanceof FastAdapter.ScrollTaskHandler) {
|
|
581
|
+
((FastAdapter.ScrollTaskHandler) ((ViewGroup) view).getChildAt(i)).notifyAttachToParent();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
static void findItemViewSize(RenderNode templateNode, int position, HippyMap itemData, int[] layout){
|
|
588
|
+
if(itemData.containsKey("layout")){
|
|
589
|
+
final HippyArray array = itemData.getArray("layout");
|
|
590
|
+
for(int i =0; i < 4; i ++){
|
|
591
|
+
layout[i] = Utils.toPX(array.getInt(i));
|
|
592
|
+
}
|
|
593
|
+
// if(LogUtils.isDebug()) {
|
|
594
|
+
// Log.i(TAG, "findItemViewSize 1 layout position:" + position + ",itemData:" + itemData);
|
|
595
|
+
// }
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (itemData.containsKey("size")) {
|
|
599
|
+
final HippyArray array = itemData.getArray("size");
|
|
600
|
+
layout[2] = Utils.toPX(array.getInt(0));
|
|
601
|
+
layout[3] = Utils.toPX(array.getInt(1));
|
|
602
|
+
// if(LogUtils.isDebug()) {
|
|
603
|
+
// Log.i(TAG, "findItemViewSize 2 size position:" + position);
|
|
604
|
+
// }
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (itemData.containsKey("flexStyle")) {
|
|
608
|
+
final HippyMap styleMap = itemData.getMap("flexStyle");
|
|
609
|
+
layout[0] = getViewPXValueFromStyle(styleMap,"left");
|
|
610
|
+
layout[1] = getViewPXValueFromStyle(styleMap,"top");
|
|
611
|
+
layout[2] = getViewPXValueFromStyle(styleMap,"width");
|
|
612
|
+
layout[3] = getViewPXValueFromStyle(styleMap,"height");
|
|
613
|
+
// if(LogUtils.isDebug()) {
|
|
614
|
+
// Log.i(TAG, "findItemViewSize 3 size position:" + position);
|
|
615
|
+
// }
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (layout[2] < 1 && itemData.containsKey("width")) {
|
|
619
|
+
// if(LogUtils.isDebug()) {
|
|
620
|
+
// Log.i(TAG, "findItemViewSize 4 size position:" + position);
|
|
621
|
+
// }
|
|
622
|
+
layout[2] = Utils.toPX(itemData.getInt("width"));
|
|
623
|
+
}
|
|
624
|
+
if (layout[3] < 1 && itemData.containsKey("height")) {
|
|
625
|
+
// if(LogUtils.isDebug()) {
|
|
626
|
+
// Log.i(TAG, "findItemViewSize 5 size position:" + position);
|
|
627
|
+
// }
|
|
628
|
+
layout[3] = Utils.toPX(itemData.getInt("height"));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if(layout[2] < 1 || layout[3] < 1) {
|
|
632
|
+
if (templateNode != null && templateNode.getProps().containsKey("style")) {
|
|
633
|
+
final HippyMap map = templateNode.getProps().getMap("style");
|
|
634
|
+
// if(LogUtils.isDebug()) {
|
|
635
|
+
// Log.i(TAG, "findItemViewSize 6 size position:" + position + ",itemData:" + itemData);
|
|
636
|
+
// }
|
|
637
|
+
if (layout[2] < 1) {
|
|
638
|
+
layout[2] = getViewPXValueFromStyle(map,"width");
|
|
639
|
+
}
|
|
640
|
+
if (layout[3] < 1) {
|
|
641
|
+
layout[3] = getViewPXValueFromStyle(map,"height");
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}else{
|
|
645
|
+
if(LogUtils.isDebug()) {
|
|
646
|
+
Log.i(TAG, "findItemViewSize 7 size position:" + position + ",itemData:" + itemData + ",height:" + layout[3]);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
static int getViewPXValueFromStyle(HippyMap styleMap,String prop){
|
|
653
|
+
return Utils.toPX(styleMap.getInt(prop)) ;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
public static FastAdapter.ItemRootView findItemRootViewFromParent(View contentView){
|
|
657
|
+
if (contentView == null) {
|
|
658
|
+
return null;
|
|
659
|
+
}
|
|
660
|
+
if(contentView.getParent() instanceof FastAdapter.ItemRootView){
|
|
661
|
+
return (FastAdapter.ItemRootView) contentView.getParent();
|
|
662
|
+
}
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
public static void updateLayout(View view, FastAdapter.ElementNode node) {
|
|
667
|
+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
|
|
668
|
+
//某些4.4设备存在崩溃
|
|
669
|
+
try{
|
|
670
|
+
final int lw = (int) node.getLayoutWidth();
|
|
671
|
+
final int lh = (int) node.getLayoutHeight();
|
|
672
|
+
final int x = (int) node.getLayoutX();
|
|
673
|
+
final int y = (int) node.getLayoutY();
|
|
674
|
+
if (view.getWidth() < 1 || view.getHeight() < 1 ||
|
|
675
|
+
view.getWidth() != lw || view.getHeight() != lh) {
|
|
676
|
+
//尺寸有变化
|
|
677
|
+
if(view instanceof TVTextView && lh < 1){
|
|
678
|
+
//bugfix:这里如果尺寸==0,证明尺寸不确定,将尺寸改为View.MeasureSpec.UNSPECIFIED
|
|
679
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(lw, View.MeasureSpec.EXACTLY),
|
|
680
|
+
View.MeasureSpec.makeMeasureSpec(lh, View.MeasureSpec.UNSPECIFIED));
|
|
681
|
+
}else {
|
|
682
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(lw, View.MeasureSpec.EXACTLY),
|
|
683
|
+
View.MeasureSpec.makeMeasureSpec(lh, View.MeasureSpec.EXACTLY));
|
|
684
|
+
}
|
|
685
|
+
view.layout(x, y, x + lw, y + lh);
|
|
686
|
+
} else if (view.getLeft() != x || view.getTop() != y) {
|
|
687
|
+
view.layout(x, y, x + view.getWidth(), y + view.getHeight());
|
|
688
|
+
}
|
|
689
|
+
}catch (Throwable ignored){}
|
|
690
|
+
}else {
|
|
691
|
+
try {
|
|
692
|
+
final int lw = (int) node.getLayoutWidth();
|
|
693
|
+
final int lh = (int) node.getLayoutHeight();
|
|
694
|
+
final int x = (int) node.getLayoutX();
|
|
695
|
+
final int y = (int) node.getLayoutY();
|
|
696
|
+
// if (LogUtils.isDebug()) {
|
|
697
|
+
// if (view instanceof TVTextView) {
|
|
698
|
+
// Log.i(TAG, "layoutTextView 1 text:" + ((TVTextView) view).getText() + ",lw : " + lw + ",lh :" + lh + ",x:" + x + ",y:" + y);
|
|
699
|
+
// }
|
|
700
|
+
// }
|
|
701
|
+
if (view.getWidth() < 1 || view.getHeight() < 1 ||
|
|
702
|
+
view.getWidth() != lw || view.getHeight() != lh) {
|
|
703
|
+
//尺寸有变化
|
|
704
|
+
if (view instanceof TVTextView && lh < 1) {
|
|
705
|
+
//bugfix:这里如果尺寸==0,证明尺寸不确定,将尺寸改为View.MeasureSpec.UNSPECIFIED
|
|
706
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(lw, View.MeasureSpec.EXACTLY),
|
|
707
|
+
View.MeasureSpec.makeMeasureSpec(lh, View.MeasureSpec.UNSPECIFIED));
|
|
708
|
+
} else {
|
|
709
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(lw, View.MeasureSpec.EXACTLY),
|
|
710
|
+
View.MeasureSpec.makeMeasureSpec(lh, View.MeasureSpec.EXACTLY));
|
|
711
|
+
}
|
|
712
|
+
view.layout(x, y, x + lw, y + lh);
|
|
713
|
+
// if (LogUtils.isDebug()) {
|
|
714
|
+
// if (view instanceof TVTextView) {
|
|
715
|
+
// Log.i(TAG, "layoutTextView 2 text:" + ((TVTextView) view).getText() + ",lw : " + lw + ",lh :" + lh + ",x:" + x + ",y:" + y);
|
|
716
|
+
// }
|
|
717
|
+
// }
|
|
718
|
+
} else if (view.getLeft() != x || view.getTop() != y) {
|
|
719
|
+
view.layout(x, y, x + view.getWidth(), y + view.getHeight());
|
|
720
|
+
}
|
|
721
|
+
}catch (Throwable ignored){}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
public static void measureWidth(View view, int height) {
|
|
727
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
|
|
728
|
+
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
public static void measureHeight(View view, int width) {
|
|
732
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
|
|
733
|
+
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
public static void updateLayoutF(View view, float x, float y, float width, float height) {
|
|
737
|
+
updateLayout(view, (int) x, (int) y, (int) width, (int) height);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
public static void updateLayout(View view, int x, int y, int width, int height) {
|
|
741
|
+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
|
|
742
|
+
//某些4.4设备存在崩溃
|
|
743
|
+
try{
|
|
744
|
+
if (view.getWidth() < 1 || view.getHeight() < 1 ||
|
|
745
|
+
view.getWidth() != width || view.getHeight() != height) {
|
|
746
|
+
//尺寸有变化
|
|
747
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
|
|
748
|
+
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
|
|
749
|
+
view.layout(x, y, x + width, y + height);
|
|
750
|
+
} else if (view.getLeft() != x || view.getTop() != y) {
|
|
751
|
+
view.layout(x, y, x + view.getWidth(), y + view.getHeight());
|
|
752
|
+
}
|
|
753
|
+
}catch (Throwable ignored){}
|
|
754
|
+
}else{
|
|
755
|
+
try {
|
|
756
|
+
if (view.getWidth() < 1 || view.getHeight() < 1 ||
|
|
757
|
+
view.getWidth() != width || view.getHeight() != height) {
|
|
758
|
+
//尺寸有变化
|
|
759
|
+
|
|
760
|
+
// if (LogUtils.isDebug()) {
|
|
761
|
+
// if (view instanceof TVTextView) {
|
|
762
|
+
// Log.i(TAG, "layoutTextView 3 text:" + ((TVTextView) view).getText() + ",lw : " + width + ",lh :" + height + ",x:" + x + ",y:" + y);
|
|
763
|
+
// }
|
|
764
|
+
// }
|
|
765
|
+
if (view instanceof TextView && height < 1) {
|
|
766
|
+
//bugfix:这里如果尺寸==0,证明尺寸不确定,将尺寸改为View.MeasureSpec.UNSPECIFIED
|
|
767
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
|
|
768
|
+
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.UNSPECIFIED));
|
|
769
|
+
} else {
|
|
770
|
+
view.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
|
|
771
|
+
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
|
|
772
|
+
}
|
|
773
|
+
view.layout(x, y, x + width, y + height);
|
|
774
|
+
} else if (view.getLeft() != x || view.getTop() != y) {
|
|
775
|
+
view.layout(x, y, x + view.getWidth(), y + view.getHeight());
|
|
776
|
+
}
|
|
777
|
+
}catch (Throwable ignored){}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
static void keepWithChildSize(StyleNode node){
|
|
783
|
+
if(node.getChildCount() == 1){
|
|
784
|
+
final StyleNode child = (StyleNode) node.getChildAt(0);
|
|
785
|
+
if (LogUtils.isDebug()) {
|
|
786
|
+
Log.i(TAG,"keepWithChildSize child :"+child.getLayoutWidth()+" node:"+node);
|
|
787
|
+
}
|
|
788
|
+
// node.(child.getStyleWidth());
|
|
789
|
+
// node.setStyleHeight(child.getStyleHeight());
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
public static HippyMap getRawItemFromFastList(Object item){
|
|
794
|
+
if (item instanceof HippyMap) {
|
|
795
|
+
return (HippyMap) item;
|
|
796
|
+
}
|
|
797
|
+
if (item instanceof FastAdapter.ItemEntity) {
|
|
798
|
+
return ((FastAdapter.ItemEntity) item).getMap();
|
|
799
|
+
}
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
public static void replaceItem4FastAdapter(HippyArray array,int pos,Object item){
|
|
804
|
+
if(array == null || array.size() == 0){
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
if(pos < 0 || pos >= array.size()){
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
if (array.get(pos) instanceof FastAdapter.ItemEntity) {
|
|
811
|
+
if(item instanceof FastAdapter.ItemEntity) {
|
|
812
|
+
if(LogUtils.isDebug()) {
|
|
813
|
+
Log.e("DebugReplaceItem", "replaceItem4FastAdapter on pos " + pos + ",item:" + item);
|
|
814
|
+
}
|
|
815
|
+
array.setObject(pos, item);
|
|
816
|
+
// ((FastAdapter.ItemEntity) item).updateItemDirty = true;
|
|
817
|
+
}else {
|
|
818
|
+
FastAdapter.ItemEntity ie = new FastAdapter.ItemEntity(item, pos);
|
|
819
|
+
if(LogUtils.isDebug()) {
|
|
820
|
+
Log.e("DebugReplaceItem", "replaceItem4FastAdapter on pos " + pos + ",ie:" + ie);
|
|
821
|
+
}
|
|
822
|
+
// ie.updateItemDirty = true;
|
|
823
|
+
array.setObject(pos, ie);
|
|
824
|
+
}
|
|
825
|
+
}else {
|
|
826
|
+
if(LogUtils.isDebug()) {
|
|
827
|
+
Log.e("DebugReplaceItem", "replaceItem4FastAdapter on pos " + pos + ",item:" + item);
|
|
828
|
+
}
|
|
829
|
+
array.setObject(pos, item);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
public static boolean updateItemData4FastAdapterTraverse(String sid, Object newData, HippyArray dataList, boolean traverse, String post){
|
|
835
|
+
if(dataList == null || dataList.size() == 0){
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
838
|
+
for(int i = 0;i < dataList.size();i++){
|
|
839
|
+
final Object io = dataList.get(i);
|
|
840
|
+
HippyMap item = getRawItemFromFastList(io);
|
|
841
|
+
if(item != null){
|
|
842
|
+
final Object itemSid = getIDFromData(item);
|
|
843
|
+
if(itemSid != null && itemSid.equals(sid)){
|
|
844
|
+
//item.pushMap("data",data);
|
|
845
|
+
//dataList.setObject(i,newData);
|
|
846
|
+
replaceItem4FastAdapter(dataList,i,newData);
|
|
847
|
+
if(LogUtils.isDebug()) {
|
|
848
|
+
Log.e("DebugReplaceItem", "exe replace data itemSID:" + itemSid + ",post:" + post);
|
|
849
|
+
}
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
if(traverse){
|
|
854
|
+
HippyArray children = findDefaultChildrenFromItem(item);
|
|
855
|
+
if(LogUtils.isDebug()) {
|
|
856
|
+
Log.d("DebugReplaceItem", "updateItemDataBySidTraverse findDefaultChildrenFromItem children:" + children + "," + post + ",item:" + item);
|
|
857
|
+
}
|
|
858
|
+
if (children != null) {
|
|
859
|
+
boolean b = updateItemData4FastAdapterTraverse(sid,newData,children,true,post);
|
|
860
|
+
if (b) {
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
}else if(item != null){
|
|
864
|
+
//从所有列表里遍历
|
|
865
|
+
for(String key : item.keySet()){
|
|
866
|
+
Object value = item.get(key);
|
|
867
|
+
if(value instanceof HippyArray){
|
|
868
|
+
if(LogUtils.isDebug()) {
|
|
869
|
+
Log.i("DebugReplaceItem", "search from item key:" + key);
|
|
870
|
+
}
|
|
871
|
+
boolean b = updateItemData4FastAdapterTraverse(sid,newData,(HippyArray) value,true,post);
|
|
872
|
+
if (b) {
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
public static HippyArray findDefaultChildrenFromItem(Object item){
|
|
884
|
+
|
|
885
|
+
HippyArray children = null;
|
|
886
|
+
HippyMap itemMap = getRawItemFromFastList(item);
|
|
887
|
+
if (itemMap != null) {
|
|
888
|
+
children = itemMap.getArray("children");
|
|
889
|
+
if (children == null) {
|
|
890
|
+
children = itemMap.getArray("itemList");
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
return children;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
static Object getIDFromData(Object item){
|
|
897
|
+
|
|
898
|
+
Object id = null;
|
|
899
|
+
HippyMap map = getRawItemFromFastList(item);
|
|
900
|
+
if(map != null){
|
|
901
|
+
HippyMap data = map;
|
|
902
|
+
if (data.containsKey("id")) {
|
|
903
|
+
//holder.itemView.setTag(R.id.tag_item_id, map.get("id"));
|
|
904
|
+
id = data.get("id");
|
|
905
|
+
}
|
|
906
|
+
if (id == null) {
|
|
907
|
+
if (data.containsKey("key")) {
|
|
908
|
+
id = data.get("key");
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
if (id == null) {
|
|
912
|
+
if (data.containsKey("_id")) {
|
|
913
|
+
id = data.get("_id");
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return id;
|
|
917
|
+
}else{
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
public static int updateItemViewByItemID(View view,String id, Object data, boolean traverse) {
|
|
925
|
+
//1. 通过sid找到需要更新的item的位置
|
|
926
|
+
int pos = -1;
|
|
927
|
+
if(view instanceof FastPendingView){
|
|
928
|
+
FastPendingView listView = (FastPendingView) view;
|
|
929
|
+
pos = listView.findItemPositionBySID(id);
|
|
930
|
+
}
|
|
931
|
+
//2. 通过updateItem()更新itemView
|
|
932
|
+
if(pos > -1 ){
|
|
933
|
+
((FastPendingView)view).updateItem(pos,data,false);
|
|
934
|
+
return pos;
|
|
935
|
+
}else if(traverse && view instanceof ViewGroup){
|
|
936
|
+
//没有找到对应的位置,在子view中查找
|
|
937
|
+
ViewGroup viewGroup = (ViewGroup) view;
|
|
938
|
+
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
|
939
|
+
View child = viewGroup.getChildAt(i);
|
|
940
|
+
if(updateItemViewByItemID(child,id,data,true) > -1){
|
|
941
|
+
return i;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return -1;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
*
|
|
950
|
+
* @param view
|
|
951
|
+
* @param name
|
|
952
|
+
* @param itemID
|
|
953
|
+
* @param prop
|
|
954
|
+
* @param updateView
|
|
955
|
+
* @return
|
|
956
|
+
*/
|
|
957
|
+
public static int updateItemPropsByItemID(View view,String name,String itemID,String prop,Object newValue,boolean updateView) {
|
|
958
|
+
//1. 通过sid找到需要更新的item的位置
|
|
959
|
+
int pos = -1;
|
|
960
|
+
if(view instanceof FastPendingView){
|
|
961
|
+
FastPendingView listView = (FastPendingView) view;
|
|
962
|
+
pos = listView.findItemPositionBySID(itemID);
|
|
963
|
+
}
|
|
964
|
+
//2. 通过updateItem()更新itemView
|
|
965
|
+
if(pos > -1 ){
|
|
966
|
+
((FastPendingView)view).updateItemSpecificProp(name,pos,prop,newValue,updateView);
|
|
967
|
+
return pos;
|
|
968
|
+
}else if(view instanceof ViewGroup){
|
|
969
|
+
//没有找到对应的位置,在子view中查找
|
|
970
|
+
ViewGroup viewGroup = (ViewGroup) view;
|
|
971
|
+
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
|
972
|
+
View child = viewGroup.getChildAt(i);
|
|
973
|
+
if(updateItemPropsByItemID(child,name,itemID,prop,newValue,updateView) > -1){
|
|
974
|
+
return i;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return -1;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
}
|