@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,195 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.text.TextUtils;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
|
|
8
|
+
import com.tencent.extend.ICoverFlow;
|
|
9
|
+
import com.tencent.mtt.hippy.annotation.HippyController;
|
|
10
|
+
import com.tencent.mtt.hippy.annotation.HippyControllerProps;
|
|
11
|
+
import com.tencent.mtt.hippy.common.HippyArray;
|
|
12
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
13
|
+
import com.tencent.mtt.hippy.modules.Promise;
|
|
14
|
+
import com.tencent.mtt.hippy.uimanager.HippyGroupController;
|
|
15
|
+
import com.tencent.mtt.hippy.utils.PixelUtil;
|
|
16
|
+
import com.tencent.mtt.hippy.views.scroll.HippyScrollView;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @Description: TODO
|
|
20
|
+
* @author: edsheng
|
|
21
|
+
* @date: 2018/8/27 9:55
|
|
22
|
+
* @version: V1.0
|
|
23
|
+
*/
|
|
24
|
+
@HippyController(name = CoverFlowViewController.CLASS_NAME)
|
|
25
|
+
public class CoverFlowViewController<T extends ViewGroup & HippyScrollView> extends HippyGroupController
|
|
26
|
+
{
|
|
27
|
+
protected static final String SCROLL_TO = "scrollTo";
|
|
28
|
+
private static final String SCROLL_TO_WITHOPTIONS = "scrollToWithOptions";
|
|
29
|
+
|
|
30
|
+
public static final String CLASS_NAME = "CoverFlow";
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
protected View createViewImpl(Context context, HippyMap iniProps)
|
|
34
|
+
{
|
|
35
|
+
if (iniProps.getBoolean("isVertical")) {
|
|
36
|
+
return new CoverFlowVerticalView(context);
|
|
37
|
+
}
|
|
38
|
+
return new CoverFlowHorizontalView(context);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
protected View createViewImpl(Context context)
|
|
43
|
+
{
|
|
44
|
+
return null;
|
|
45
|
+
// return new HippyScrollView(context);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@HippyControllerProps(name = "scrollEnabled", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
|
|
49
|
+
public void setScrollEnabled(HippyScrollView view, boolean flag)
|
|
50
|
+
{
|
|
51
|
+
view.setScrollEnabled(flag);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@HippyControllerProps(name = "showScrollIndicator", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
55
|
+
public void setShowScrollIndicator(HippyScrollView view, boolean flag)
|
|
56
|
+
{
|
|
57
|
+
view.showScrollIndicator(flag);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@HippyControllerProps(name = "onScrollEnable", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
61
|
+
public void setScrollEventEnable(HippyScrollView view, boolean flag)
|
|
62
|
+
{
|
|
63
|
+
view.setScrollEventEnable(flag);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@HippyControllerProps(name = "onScrollBeginDrag", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
67
|
+
public void setScrollBeginDragEventEnable(HippyScrollView view, boolean flag)
|
|
68
|
+
{
|
|
69
|
+
view.setScrollBeginDragEventEnable(flag);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@HippyControllerProps(name = "onScrollEndDrag", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
73
|
+
public void setScrollEndDragEventEnable(HippyScrollView view, boolean flag)
|
|
74
|
+
{
|
|
75
|
+
view.setScrollEndDragEventEnable(flag);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@HippyControllerProps(name = "onMomentumScrollBegin", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
79
|
+
public void setMomentumScrollBeginEventEnable(HippyScrollView view, boolean flag)
|
|
80
|
+
{
|
|
81
|
+
view.setMomentumScrollBeginEventEnable(flag);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@HippyControllerProps(name = "onMomentumScrollEnd", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
85
|
+
public void setMomentumScrollEndEventEnable(HippyScrollView view, boolean flag)
|
|
86
|
+
{
|
|
87
|
+
view.setMomentumScrollEndEventEnable(flag);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@HippyControllerProps(name = "onScrollAnimationEnd", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
91
|
+
public void setScrollAnimationEndEventEnable(HippyScrollView view, boolean flag)
|
|
92
|
+
{
|
|
93
|
+
// view.setScrollAnimationEndEventEnable(flag);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@HippyControllerProps(name = "flingEnabled", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = true)
|
|
97
|
+
public void setFlingEnabled(HippyScrollView view, boolean flag)
|
|
98
|
+
{
|
|
99
|
+
view.setFlingEnabled(flag);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@HippyControllerProps(name = "contentOffset4Reuse")
|
|
103
|
+
public void setContentOffset4Reuse(HippyScrollView view, HippyMap offsetMap)
|
|
104
|
+
{
|
|
105
|
+
view.setContentOffset4Reuse(offsetMap);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@HippyControllerProps(name = "pagingEnabled", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
|
|
109
|
+
public void setPagingEnabled(HippyScrollView view, boolean pagingEnabled)
|
|
110
|
+
{
|
|
111
|
+
view.setPagingEnabled(pagingEnabled);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@HippyControllerProps(name = "scrollEventThrottle", defaultType = HippyControllerProps.NUMBER, defaultNumber = 30.0D)
|
|
115
|
+
public void setScrollEventThrottle(HippyScrollView view, int scrollEventThrottle)
|
|
116
|
+
{
|
|
117
|
+
view.setScrollEventThrottle(scrollEventThrottle);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@HippyControllerProps(name = "scrollMinOffset", defaultType = HippyControllerProps.NUMBER, defaultNumber = 5)
|
|
121
|
+
public void setScrollMinOffset(HippyScrollView view, int scrollMinOffset)
|
|
122
|
+
{
|
|
123
|
+
view.setScrollMinOffset(scrollMinOffset);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Override
|
|
127
|
+
public void dispatchFunction(View view, String functionName, HippyArray args) {
|
|
128
|
+
super.dispatchFunction((ViewGroup) view, functionName, args);
|
|
129
|
+
if(view instanceof HippyScrollView)
|
|
130
|
+
{
|
|
131
|
+
|
|
132
|
+
if (TextUtils.equals(SCROLL_TO, functionName))
|
|
133
|
+
{
|
|
134
|
+
int destX = Math.round(PixelUtil.dp2px(args.getDouble(0)));
|
|
135
|
+
int destY = Math.round(PixelUtil.dp2px(args.getDouble(1)));
|
|
136
|
+
boolean animated = args.getBoolean(2);
|
|
137
|
+
|
|
138
|
+
if (animated)
|
|
139
|
+
{
|
|
140
|
+
((HippyScrollView)view).callSmoothScrollTo(destX, destY,0);//用默认的动画事件
|
|
141
|
+
}
|
|
142
|
+
else
|
|
143
|
+
{
|
|
144
|
+
view.scrollTo(destX, destY);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (TextUtils.equals(SCROLL_TO_WITHOPTIONS, functionName) && args != null && args.size() > 0)
|
|
148
|
+
{
|
|
149
|
+
HippyMap hippyMap = args.getMap(0); //取第一个元素
|
|
150
|
+
int destX = Math.round(PixelUtil.dp2px(hippyMap.getInt("x")));
|
|
151
|
+
int destY = Math.round(PixelUtil.dp2px(hippyMap.getInt("y")));
|
|
152
|
+
int duration = hippyMap.getInt("duration");
|
|
153
|
+
if(duration > 0 )
|
|
154
|
+
{
|
|
155
|
+
((HippyScrollView)view).callSmoothScrollTo(destX, destY,duration);//用默认的动画事件
|
|
156
|
+
}
|
|
157
|
+
else
|
|
158
|
+
{
|
|
159
|
+
view.scrollTo(destX, destY);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@Override
|
|
166
|
+
public void dispatchFunction(View view, String functionName, HippyArray params, Promise promise) {
|
|
167
|
+
if (TextUtils.equals("getCurrentIndex", functionName)) {
|
|
168
|
+
if (view instanceof ICoverFlow && promise != null) {
|
|
169
|
+
ICoverFlow cView = (ICoverFlow) view;
|
|
170
|
+
int index = cView.getCurrentIndex();
|
|
171
|
+
HippyMap resultMap = new HippyMap();
|
|
172
|
+
resultMap.pushInt("index", index);
|
|
173
|
+
promise.resolve(resultMap);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
super.dispatchFunction(view, functionName, params, promise);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@HippyControllerProps(name = "autoScrollInterval", defaultType = HippyControllerProps.NUMBER,defaultNumber = 0)
|
|
181
|
+
public void setAutoScrollInterval(HippyScrollView view, int interval){
|
|
182
|
+
if (view instanceof ICoverFlow) {
|
|
183
|
+
((ICoverFlow) view).setAutoScrollInterval(interval);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@HippyControllerProps(name = "zoomInValue", defaultType = HippyControllerProps.NUMBER,defaultNumber = 0)
|
|
188
|
+
public void setZoomInValue(HippyScrollView view, float value){
|
|
189
|
+
if (view instanceof ICoverFlow) {
|
|
190
|
+
((ICoverFlow) view).setZoomInValue(value);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.graphics.Canvas;
|
|
6
|
+
import android.graphics.Color;
|
|
7
|
+
import android.os.Build;
|
|
8
|
+
import android.support.annotation.NonNull;
|
|
9
|
+
import android.support.annotation.Nullable;
|
|
10
|
+
import android.support.annotation.RequiresApi;
|
|
11
|
+
import android.util.AttributeSet;
|
|
12
|
+
import android.util.Log;
|
|
13
|
+
import android.widget.FrameLayout;
|
|
14
|
+
|
|
15
|
+
import com.tencent.mtt.hippy.HippyInstanceContext;
|
|
16
|
+
import com.tencent.mtt.hippy.utils.PixelUtil;
|
|
17
|
+
|
|
18
|
+
public class EngineRootView extends FrameLayout {
|
|
19
|
+
|
|
20
|
+
private static int translateX = 0;
|
|
21
|
+
private static int translateY = 0;
|
|
22
|
+
|
|
23
|
+
int overrideWidth = 0;
|
|
24
|
+
int overrideHeight = 0;
|
|
25
|
+
|
|
26
|
+
public EngineRootView(@NonNull Context context) {
|
|
27
|
+
super(context);
|
|
28
|
+
init();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public EngineRootView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
|
32
|
+
super(context, attrs);
|
|
33
|
+
init();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public EngineRootView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
37
|
+
super(context, attrs, defStyleAttr);
|
|
38
|
+
init();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
|
42
|
+
public EngineRootView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
43
|
+
super(context, attrs, defStyleAttr, defStyleRes);
|
|
44
|
+
init();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void init(){
|
|
48
|
+
// Log.i("EngineRootView","PixelUtil.getsScreenAdaptType() : "+PixelUtil.getsScreenAdaptType());
|
|
49
|
+
// Toast.makeText(getContext(), "width:"+PixelUtil.getScreenWidth()+",height:"+PixelUtil.getScreenHeight()+",ratio:"+PixelUtil.getScreenAspectRatio(), Toast.LENGTH_LONG).show();
|
|
50
|
+
if (PixelUtil.getsScreenAdaptType() == PixelUtil.SCREEN_ADAPT_TYPE_SCALE_WIDTH) {
|
|
51
|
+
try {
|
|
52
|
+
Activity activity;
|
|
53
|
+
if(getContext() instanceof Activity) {
|
|
54
|
+
activity = (Activity) getContext();
|
|
55
|
+
}else if(getContext() instanceof HippyInstanceContext) {
|
|
56
|
+
activity = (Activity) ((HippyInstanceContext) getContext()).getBaseContext();
|
|
57
|
+
}else {
|
|
58
|
+
activity = null;
|
|
59
|
+
Log.w("EngineRootView ","screen adapter error cant find activity context:"+getContext());
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// Log.i("EngineRootView"," base context:"+activity);
|
|
63
|
+
if(activity != null){
|
|
64
|
+
// int oldWidth = PixelUtil.getScreenWidth();
|
|
65
|
+
// int oldHeight = PixelUtil.getScreenHeight();
|
|
66
|
+
PixelUtil.adjustScreenSizeByActivity(activity);
|
|
67
|
+
// Log.i("EngineRootView"," after adjustScreenSizeByActivity screenWidth:"+PixelUtil.getScreenWidth()
|
|
68
|
+
// +" screenHeight:"+PixelUtil.getScreenHeight()+",oldWidth:"+oldWidth+",oldHeight:"+oldHeight);
|
|
69
|
+
}
|
|
70
|
+
final float currentAspectRatio = PixelUtil.getScreenAspectRatio();
|
|
71
|
+
//因为当前适配比例是16/9,如果不是16/9,则将页面整体居中
|
|
72
|
+
if (currentAspectRatio > PixelUtil.ASPECT_RATIO_16_9) {//相对16:9偏宽
|
|
73
|
+
overrideHeight = PixelUtil.getScreenHeight(); // 1080
|
|
74
|
+
float rate = PixelUtil.getDevHeightF() / PixelUtil.getScreenHeight(); //1.00f
|
|
75
|
+
overrideWidth = (int) (PixelUtil.getDevWidthF() / rate);
|
|
76
|
+
translateX = (int) ((PixelUtil.getScreenWidth() - overrideWidth) * 0.5f);
|
|
77
|
+
//1.0465
|
|
78
|
+
// setBackgroundColor(Color.GREEN);
|
|
79
|
+
} else if (currentAspectRatio < PixelUtil.ASPECT_RATIO_16_9) {//相对16:9偏长
|
|
80
|
+
overrideWidth = PixelUtil.getScreenWidth();
|
|
81
|
+
float rate = PixelUtil.getDevWidthF() / PixelUtil.getScreenWidth();
|
|
82
|
+
overrideHeight = (int) (PixelUtil.getDevHeightF() / rate);
|
|
83
|
+
translateY = (int) ((PixelUtil.getScreenHeight() - overrideHeight) * 0.5f);
|
|
84
|
+
// setBackgroundColor(Color.GREEN);
|
|
85
|
+
}
|
|
86
|
+
}catch (Throwable t){
|
|
87
|
+
t.printStackTrace();
|
|
88
|
+
Log.e("EngineRootView","init error:"+t.getMessage());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
Log.i("EngineRootView","init overrideWidth:"+overrideWidth+" overrideHeight:"+overrideHeight+" translateX:"+translateX+" translateY:"+translateY);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public static int getScreenTranslateX() {
|
|
95
|
+
return translateX;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public static int getScreenTranslateY() {
|
|
99
|
+
return translateY;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
// @Override
|
|
104
|
+
// protected void dispatchDraw(Canvas canvas) {
|
|
105
|
+
// if (translateX != 0 || translateY != 0) {
|
|
106
|
+
// canvas.save();
|
|
107
|
+
// canvas.translate(translateX,translateY);
|
|
108
|
+
// super.dispatchDraw(canvas);
|
|
109
|
+
// canvas.restore();
|
|
110
|
+
// }else{
|
|
111
|
+
// super.dispatchDraw(canvas);
|
|
112
|
+
// }
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
@Override
|
|
116
|
+
public String toString() {
|
|
117
|
+
return "EngineRootView{" +
|
|
118
|
+
"translateX=" + translateX +
|
|
119
|
+
", translateY=" + translateY +
|
|
120
|
+
", overrideWidth=" + overrideWidth +
|
|
121
|
+
", overrideHeight=" + overrideHeight +
|
|
122
|
+
", super=" + super.toString() +
|
|
123
|
+
'}';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.support.annotation.NonNull;
|
|
4
|
+
import android.support.annotation.Nullable;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
|
|
7
|
+
import com.tencent.mtt.hippy.R;
|
|
8
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
|
|
13
|
+
public class ExtendTag {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
public String nodeClassName;
|
|
17
|
+
public String sid;
|
|
18
|
+
public String nextFocusUpSID;
|
|
19
|
+
public String nextFocusDownSID;
|
|
20
|
+
public String nextFocusLeftSID;
|
|
21
|
+
public String nextFocusRightSID;
|
|
22
|
+
public HippyMap nextFocusFocusName;
|
|
23
|
+
public String name;
|
|
24
|
+
public int pendingBackGroundColor = -1;
|
|
25
|
+
|
|
26
|
+
public HashMap<String,Object> extra;
|
|
27
|
+
|
|
28
|
+
public static void putExtraValue(@NonNull View view, @NonNull String key, @NonNull Object value){
|
|
29
|
+
ExtendTag tag = obtainExtendTag(view);
|
|
30
|
+
if(tag.extra == null){
|
|
31
|
+
tag.extra = new HashMap<>();
|
|
32
|
+
}
|
|
33
|
+
tag.extra.put(key,value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public Object getExtraValue(@NonNull String key){
|
|
37
|
+
if(extra == null){
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return extra.get(key);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public boolean getBooleanExtraValue(@NonNull String key){
|
|
44
|
+
Object value = getExtraValue(key);
|
|
45
|
+
if(value instanceof Boolean){
|
|
46
|
+
return (Boolean) value;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
public static void putTag(View view, @Nullable ExtendTag tag){
|
|
53
|
+
view.setTag(R.id.tag_view_extend_4tv,tag);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
public static @NonNull
|
|
58
|
+
ExtendTag obtainExtendTag(@NonNull View view){
|
|
59
|
+
Object tag = view.getTag(R.id.tag_view_extend_4tv);
|
|
60
|
+
if(tag instanceof ExtendTag){
|
|
61
|
+
return (ExtendTag) tag;
|
|
62
|
+
}else{
|
|
63
|
+
tag = new ExtendTag();
|
|
64
|
+
putTag(view, (ExtendTag) tag);
|
|
65
|
+
}
|
|
66
|
+
return (ExtendTag) tag;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public static @Nullable
|
|
70
|
+
ExtendTag getExtendTag(@Nullable View view){
|
|
71
|
+
if (view == null) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
Object tag = view.getTag(R.id.tag_view_extend_4tv);
|
|
75
|
+
if(tag instanceof ExtendTag){
|
|
76
|
+
return (ExtendTag) tag;
|
|
77
|
+
}else{
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
|
|
8
|
+
import com.tencent.extend.views.fastlist.FastPendingView;
|
|
9
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
10
|
+
import com.tencent.mtt.hippy.uimanager.InternalExtendViewUtil;
|
|
11
|
+
import com.tencent.mtt.hippy.utils.ExtendUtil;
|
|
12
|
+
|
|
13
|
+
import java.util.ArrayList;
|
|
14
|
+
|
|
15
|
+
public class FocusSearchHelper {
|
|
16
|
+
|
|
17
|
+
private final ViewGroup viewGroup;
|
|
18
|
+
|
|
19
|
+
private HippyMap firstFocusChildMap;
|
|
20
|
+
private boolean isFindAtStart = false;
|
|
21
|
+
public final static String TAG = "DebugFocusParent";
|
|
22
|
+
private static boolean DEBUG = false;
|
|
23
|
+
|
|
24
|
+
public FocusSearchHelper(ViewGroup viewGroup) {
|
|
25
|
+
this.viewGroup = viewGroup;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
public void setFindAtStart(boolean findAtStart) {
|
|
30
|
+
isFindAtStart = findAtStart;
|
|
31
|
+
if(DEBUG) {
|
|
32
|
+
Log.i(TAG,"setFindAtStart :"+findAtStart+",view:"+ExtendUtil.debugViewLite(viewGroup));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public void setFirstFocusChildMap(HippyMap firstFocusChildMap) {
|
|
37
|
+
this.firstFocusChildMap = firstFocusChildMap;
|
|
38
|
+
if(DEBUG) {
|
|
39
|
+
Log.i(TAG,"setFirstFocusChildMap :"+firstFocusChildMap+",view:"+ExtendUtil.debugViewLite(viewGroup));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static View findSpecifiedNext(ViewGroup parent,HippyMap map,int direction){
|
|
44
|
+
if (map == null || parent == null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
View next = null;
|
|
48
|
+
final Object value = map.get(ExtendUtil.getDirectionName(direction));
|
|
49
|
+
if(DEBUG) {
|
|
50
|
+
Log.i(TAG,"findSpecifiedNext map:"+map+",value:"+value+",parent:"+ExtendUtil.debugViewLite(parent));
|
|
51
|
+
}
|
|
52
|
+
if (value instanceof Integer) {
|
|
53
|
+
//位置,childIndex
|
|
54
|
+
int index = (int) value;
|
|
55
|
+
if(parent instanceof FastPendingView){
|
|
56
|
+
next = ((FastPendingView) parent).findViewByPosition(index);
|
|
57
|
+
}else{
|
|
58
|
+
if (parent.getChildCount() > index && index > -1) {
|
|
59
|
+
next = parent.getChildAt(index);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if(DEBUG) {
|
|
63
|
+
if (next != null) {
|
|
64
|
+
Log.e(TAG,"findSpecifiedNext by index:"+index+",next:"+ExtendUtil.debugViewLite(next)+",parent:"+ExtendUtil.debugViewLite(parent));
|
|
65
|
+
} else {
|
|
66
|
+
Log.i(TAG,"findSpecifiedNext by index:"+index+",next:"+null);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
} else if (value instanceof String) {
|
|
71
|
+
next = ExtendUtil.findViewBySID((String) value,parent);
|
|
72
|
+
if(DEBUG) {
|
|
73
|
+
Log.i(TAG,"findSpecifiedNext by sid:"+value+",next:"+ExtendUtil.debugViewLite(next));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return next;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
public View findFirstFocusChildByDirection(int direction){
|
|
81
|
+
View nextChild = null;
|
|
82
|
+
nextChild = findSpecifiedNext(viewGroup,firstFocusChildMap,direction);
|
|
83
|
+
if(DEBUG) {
|
|
84
|
+
if (firstFocusChildMap != null) {
|
|
85
|
+
Log.i(TAG,"findFirstFocusChildByDirection firstFocusChildMap :"+firstFocusChildMap+",viewGroup:"+ExtendUtil.debugViewLite(viewGroup));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (nextChild == null){
|
|
89
|
+
if(isFindAtStart){
|
|
90
|
+
if (viewGroup instanceof FastPendingView) {
|
|
91
|
+
nextChild = ((FastPendingView) viewGroup).findFirstFocusByDirection(direction);
|
|
92
|
+
if(DEBUG) {
|
|
93
|
+
Log.i(TAG, "findFirstFocusChildByDirection from FastPendingView :" + ExtendUtil.debugViewLite(nextChild) + ",isFindAtStart:" + isFindAtStart);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}else{
|
|
98
|
+
if(DEBUG) {
|
|
99
|
+
Log.e(TAG,"findFirstFocusChildByDirection specified :"+ExtendUtil.debugViewLite(nextChild));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return nextChild;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public boolean addFocusables(ArrayList<View> views, int direction){
|
|
106
|
+
if (viewGroup == null || viewGroup.hasFocus()) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
View next = findFirstFocusChildByDirection(direction);
|
|
110
|
+
if (InternalExtendViewUtil.testFocusable(next)) {
|
|
111
|
+
if(DEBUG) {
|
|
112
|
+
Log.e(TAG,"addFocusables view :"+ExtendUtil.debugViewLite(next));
|
|
113
|
+
}
|
|
114
|
+
views.add(next);
|
|
115
|
+
return true;
|
|
116
|
+
}else{
|
|
117
|
+
if(DEBUG) {
|
|
118
|
+
Log.i(TAG,"addFocusables view :"+ExtendUtil.debugViewLite(null));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.view.View;
|
|
4
|
+
|
|
5
|
+
public interface IRecyclerItemView {
|
|
6
|
+
void onCreate(View rootList);
|
|
7
|
+
void onBind(View rootList, int position, Object item);
|
|
8
|
+
void onAttachToWindow(View rootList, int position, Object item);
|
|
9
|
+
void onDetachFromWindow(View rootList, int position, Object item);
|
|
10
|
+
void onUnBind(View rootList, int position, Object item);
|
|
11
|
+
void setJSEventViewID(int JSEventViewID);
|
|
12
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import java.util.ArrayList;
|
|
4
|
+
import java.util.Collections;
|
|
5
|
+
import java.util.HashMap;
|
|
6
|
+
import java.util.List;
|
|
7
|
+
import java.util.Map;
|
|
8
|
+
|
|
9
|
+
public class MarqueeRelayManager {
|
|
10
|
+
private static MarqueeRelayManager instance;
|
|
11
|
+
private final Map<String, List<MarqueeRelayTextView>> groups = new HashMap<>();
|
|
12
|
+
private final Map<String, Boolean> groupBusyMap = new HashMap<>();
|
|
13
|
+
private final Map<String, Boolean> activeGroups = new HashMap<>();
|
|
14
|
+
// 焦点计数器,用于判断组内是否还有焦点
|
|
15
|
+
private final Map<String, Integer> groupFocusCount = new HashMap<>();
|
|
16
|
+
|
|
17
|
+
public static synchronized MarqueeRelayManager getInstance() {
|
|
18
|
+
if (instance == null) instance = new MarqueeRelayManager();
|
|
19
|
+
return instance;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 注册组件到指定组
|
|
23
|
+
public void register(String key, MarqueeRelayTextView view) {
|
|
24
|
+
if (key == null) return;
|
|
25
|
+
if (!groups.containsKey(key)) {
|
|
26
|
+
groups.put(key, new ArrayList<>());
|
|
27
|
+
groupBusyMap.put(key, false);
|
|
28
|
+
activeGroups.put(key, false);
|
|
29
|
+
groupFocusCount.put(key, 0);
|
|
30
|
+
}
|
|
31
|
+
List<MarqueeRelayTextView> list = groups.get(key);
|
|
32
|
+
if (!list.contains(view)) {
|
|
33
|
+
list.add(view);
|
|
34
|
+
// 确保按 Index 升序排列
|
|
35
|
+
Collections.sort(list, (v1, v2) -> Integer.compare(v1.getGroupIndex(), v2.getGroupIndex()));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 当组件获得焦点时调用
|
|
40
|
+
public void onFocusGain(String key, MarqueeRelayTextView view) {
|
|
41
|
+
if (key == null) return;
|
|
42
|
+
Integer count = groupFocusCount.get(key);
|
|
43
|
+
if (count == null) count = 0;
|
|
44
|
+
groupFocusCount.put(key, count + 1);
|
|
45
|
+
|
|
46
|
+
// 只要有焦点,就尝试启动(如果已经在跑,startCycle 会忽略)
|
|
47
|
+
startCycle(key, view);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 当组件失去焦点时调用
|
|
51
|
+
public void onFocusLost(String key) {
|
|
52
|
+
if (key == null) return;
|
|
53
|
+
Integer count = groupFocusCount.get(key);
|
|
54
|
+
if (count == null || count <= 0) return;
|
|
55
|
+
|
|
56
|
+
int newCount = count - 1;
|
|
57
|
+
groupFocusCount.put(key, newCount);
|
|
58
|
+
|
|
59
|
+
// 如果没有任何焦点了,停止循环
|
|
60
|
+
if (newCount == 0) {
|
|
61
|
+
stopCycle(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 手动请求启动(用于 setSelected 等非焦点场景)
|
|
66
|
+
public void requestRelay(String key, MarqueeRelayTextView view) {
|
|
67
|
+
// 视为一次临时的焦点获取?或者直接启动
|
|
68
|
+
// 为了兼容 setSelected 逻辑,我们直接启动,不计入 FocusCount
|
|
69
|
+
// 但 setSelected(false) 必须负责停止。
|
|
70
|
+
// 这是一个混合模式,比较复杂。
|
|
71
|
+
// 简单起见,requestRelay 只负责 startCycle,不涉及 focus 计数。
|
|
72
|
+
// 但这意味着 setSelected(false) 必须显式调用 stopCycle,或者我们假设 setSelected 也会触发 focus 变化(如果 View 是 focusable 的)。
|
|
73
|
+
startCycle(key, view);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public void startCycle(String key, MarqueeRelayTextView triggerView) {
|
|
77
|
+
if (key == null) return;
|
|
78
|
+
activeGroups.put(key, true);
|
|
79
|
+
Boolean isBusy = groupBusyMap.get(key);
|
|
80
|
+
if (isBusy != null && !isBusy) {
|
|
81
|
+
groupBusyMap.put(key, true);
|
|
82
|
+
triggerView.startRelayAnimation();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public void stopCycle(String key) {
|
|
87
|
+
if (key == null) return;
|
|
88
|
+
activeGroups.put(key, false);
|
|
89
|
+
List<MarqueeRelayTextView> list = groups.get(key);
|
|
90
|
+
if (list != null) {
|
|
91
|
+
for (MarqueeRelayTextView view : list) {
|
|
92
|
+
view.stopRelay();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
groupBusyMap.put(key, false);
|
|
96
|
+
// 注意:stopCycle 不重置 focusCount,因为可能是手动停止但焦点还在
|
|
97
|
+
// 但如果是因为 focusCount 归零调用的 stopCycle,那也没问题。
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 调度下一个需要滚动的组件
|
|
101
|
+
public void dispatchNext(String key, int currentIndex) {
|
|
102
|
+
Boolean isActive = activeGroups.get(key);
|
|
103
|
+
if (isActive == null || !isActive) {
|
|
104
|
+
groupBusyMap.put(key, false);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
List<MarqueeRelayTextView> list = groups.get(key);
|
|
108
|
+
if (list == null || list.isEmpty()) {
|
|
109
|
+
groupBusyMap.put(key, false);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
int currentPosInList = -1;
|
|
114
|
+
for (int i = 0; i < list.size(); i++) {
|
|
115
|
+
if (list.get(i).getGroupIndex() == currentIndex) {
|
|
116
|
+
currentPosInList = i;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
MarqueeRelayTextView nextView = list.get((currentPosInList + 1) % list.size());
|
|
122
|
+
nextView.startRelayAnimation();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public void unregister(String key, MarqueeRelayTextView view) {
|
|
126
|
+
if (key != null && groups.containsKey(key)) {
|
|
127
|
+
groups.get(key).remove(view);
|
|
128
|
+
// 如果移除的 View 占用了 FocusCount,应该减掉吗?
|
|
129
|
+
// 很难判断它是否持有焦点。
|
|
130
|
+
// 但 View destroy 时通常会先 lose focus。
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|