@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,218 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Color;
|
|
5
|
+
import android.graphics.drawable.ClipDrawable;
|
|
6
|
+
import android.graphics.drawable.Drawable;
|
|
7
|
+
import android.graphics.drawable.GradientDrawable;
|
|
8
|
+
import android.graphics.drawable.LayerDrawable;
|
|
9
|
+
import android.graphics.drawable.StateListDrawable;
|
|
10
|
+
import android.os.Build;
|
|
11
|
+
import android.util.Log;
|
|
12
|
+
import android.view.MotionEvent;
|
|
13
|
+
import android.view.View;
|
|
14
|
+
import android.widget.ProgressBar;
|
|
15
|
+
import android.widget.SeekBar;
|
|
16
|
+
|
|
17
|
+
import com.tencent.mtt.hippy.R;
|
|
18
|
+
import com.tencent.mtt.hippy.annotation.HippyController;
|
|
19
|
+
import com.tencent.mtt.hippy.annotation.HippyControllerProps;
|
|
20
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
21
|
+
import com.tencent.mtt.hippy.dom.node.NodeProps;
|
|
22
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewBase;
|
|
23
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewEvent;
|
|
24
|
+
import com.tencent.mtt.hippy.uimanager.NativeGestureDispatcher;
|
|
25
|
+
|
|
26
|
+
import java.lang.reflect.Field;
|
|
27
|
+
|
|
28
|
+
@HippyController(name = "SeekBar")
|
|
29
|
+
public class SeekBarViewController extends ProgressBarViewController {
|
|
30
|
+
|
|
31
|
+
private HippyViewEvent mEvent;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
protected View createViewImpl(Context context) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private HippyViewEvent getSeekEvent(){
|
|
40
|
+
if(mEvent == null){
|
|
41
|
+
mEvent = new HippyViewEvent("onSeekBarChange");
|
|
42
|
+
}
|
|
43
|
+
return mEvent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
protected Drawable crateThumbDrawable(Context context,HippyMap iniProps){
|
|
48
|
+
return (StateListDrawable) context.getResources().getDrawable(R.drawable.seek_thumb);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected LayerDrawable crateProgressDrawable(Context context,HippyMap iniProps){
|
|
52
|
+
return (LayerDrawable) context.getResources().getDrawable(R.drawable.player_seekbar);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@HippyControllerProps(name = "listenProgress", defaultType = HippyControllerProps.BOOLEAN)
|
|
56
|
+
public void setListenProgress(ProgressBar pb,boolean listen){
|
|
57
|
+
if(pb instanceof SeekBarView) {
|
|
58
|
+
((SeekBarView) pb).setListenProgressEvent(listen);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@HippyControllerProps(name = "interceptKeyEvent", defaultType = HippyControllerProps.BOOLEAN)
|
|
63
|
+
public void setInterceptKeyEvent(ProgressBar pb,boolean listen){
|
|
64
|
+
if(pb instanceof SeekBarView) {
|
|
65
|
+
((SeekBarView) pb).setInterceptKeyEvent(listen);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
protected View createViewImpl(Context context, HippyMap iniProps) {
|
|
73
|
+
final SeekBarView seekBar = new SeekBarView(context);
|
|
74
|
+
final LayerDrawable drawable = crateProgressDrawable(context,iniProps);
|
|
75
|
+
fixDrawable(drawable,iniProps);
|
|
76
|
+
seekBar.setProgressDrawable(drawable);
|
|
77
|
+
Drawable thumb = crateThumbDrawable(context,iniProps);
|
|
78
|
+
|
|
79
|
+
seekBar.setThumb(thumb);
|
|
80
|
+
|
|
81
|
+
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
82
|
+
@Override
|
|
83
|
+
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
84
|
+
if(seekBar instanceof SeekBarView && ((SeekBarView) seekBar).isListenProgressEvent()) {
|
|
85
|
+
HippyMap hippyMap = new HippyMap();
|
|
86
|
+
hippyMap.pushInt("progress", progress);
|
|
87
|
+
hippyMap.pushBoolean("fromUser", fromUser);
|
|
88
|
+
getSeekEvent().send(seekBar, hippyMap);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Override
|
|
93
|
+
public void onStartTrackingTouch(SeekBar seekBar) {
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public void onStopTrackingTouch(SeekBar seekBar) {
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if(iniProps.containsKey("thumbSize")){
|
|
104
|
+
int size = iniProps.getInt("thumbSize");
|
|
105
|
+
thumb.setBounds(0,0,size,size);
|
|
106
|
+
}
|
|
107
|
+
return seekBar;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Override
|
|
111
|
+
protected void updateExtra(View view, Object object) {
|
|
112
|
+
super.updateExtra(view, object);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private void fixDrawable(LayerDrawable drawable, HippyMap map){
|
|
116
|
+
/*
|
|
117
|
+
* backGroundColor:
|
|
118
|
+
* startColor:
|
|
119
|
+
* endColor:
|
|
120
|
+
* cornerRadius:
|
|
121
|
+
* secondStartColor:
|
|
122
|
+
* secondEndColor:
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
if(map.containsKey("backGroundColor")){
|
|
126
|
+
//bg
|
|
127
|
+
GradientDrawable bg = (GradientDrawable) drawable.getDrawable(0);
|
|
128
|
+
int bgColor = Color.parseColor(map.getString("backGroundColor"));
|
|
129
|
+
bg.setColor(bgColor);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if(map.containsKey("cornerRadius")){
|
|
133
|
+
for(int i = 0; i < drawable.getNumberOfLayers(); i++){
|
|
134
|
+
final Drawable d = drawable.getDrawable(i);
|
|
135
|
+
if(d instanceof GradientDrawable) {
|
|
136
|
+
((GradientDrawable) d).setCornerRadius(map.getInt("cornerRadius"));
|
|
137
|
+
}else if(d instanceof ClipDrawable){
|
|
138
|
+
GradientDrawable gd = getDrawableFromClipDrawable((ClipDrawable) d);
|
|
139
|
+
if(gd != null){
|
|
140
|
+
gd.setCornerRadius(map.getInt("cornerRadius"));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if(map.containsKey("secondColor")){
|
|
147
|
+
ClipDrawable clipDrawable = (ClipDrawable) drawable.getDrawable(1);
|
|
148
|
+
int color = Color.parseColor(map.getString("secondColor"));
|
|
149
|
+
GradientDrawable gd = getDrawableFromClipDrawable(clipDrawable);
|
|
150
|
+
if(gd != null) {
|
|
151
|
+
gd.setColor(color);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if(map.containsKey("startColor")){
|
|
156
|
+
ClipDrawable clipDrawable = (ClipDrawable) drawable.getDrawable(2);
|
|
157
|
+
GradientDrawable gd = getDrawableFromClipDrawable(clipDrawable);
|
|
158
|
+
if(gd != null) {
|
|
159
|
+
int startColor = Color.parseColor(map.getString("startColor"));
|
|
160
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && map.containsKey("endColor")) {
|
|
161
|
+
int endColor = Color.parseColor(map.getString("endColor"));
|
|
162
|
+
int[] colors = new int[]{startColor, endColor};
|
|
163
|
+
gd.mutate();
|
|
164
|
+
gd.setColors(colors);
|
|
165
|
+
} else {
|
|
166
|
+
gd.setColor(startColor);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private GradientDrawable getDrawableFromClipDrawable(ClipDrawable clipDrawable){
|
|
174
|
+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
|
|
175
|
+
return (GradientDrawable) clipDrawable.getDrawable();
|
|
176
|
+
}else{
|
|
177
|
+
try {
|
|
178
|
+
Field field = clipDrawable.getClass().getSuperclass().getDeclaredField("mDrawable");
|
|
179
|
+
field.setAccessible(true);
|
|
180
|
+
Object o = new Object();
|
|
181
|
+
Log.d("hippy","o is :"+o);
|
|
182
|
+
Object r = field.get(o);
|
|
183
|
+
Log.d("hippy","r is :"+r);
|
|
184
|
+
return null;
|
|
185
|
+
}catch (Throwable t){
|
|
186
|
+
Log.e("hippy","SeekBarViewController getDrawableFromClipDrawable fail ANDROID_VERSION:"+Build.VERSION.SDK_INT);
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@Override
|
|
194
|
+
public void setProgress(ProgressBar pb, int progress) {
|
|
195
|
+
super.setProgress(pb, progress);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
@Override
|
|
200
|
+
public void setMaxProgress(ProgressBar pb, int max) {
|
|
201
|
+
super.setMaxProgress(pb, max);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@Override
|
|
205
|
+
public void setSecondProgress(ProgressBar pb, int progress) {
|
|
206
|
+
super.setSecondProgress(pb, progress);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
@HippyControllerProps(name = "keyProgressIncrement", defaultType = HippyControllerProps.NUMBER)
|
|
211
|
+
public void setKeyProgressIncrement(ProgressBar pb,int number){
|
|
212
|
+
if(pb instanceof SeekBarView) {
|
|
213
|
+
((SeekBarView) pb).setKeyProgressIncrement(number);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Canvas;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
import android.view.View;
|
|
7
|
+
|
|
8
|
+
import com.tencent.extend.RenderUtil;
|
|
9
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
10
|
+
|
|
11
|
+
import com.tencent.mtt.hippy.utils.LogUtils;
|
|
12
|
+
import com.tencent.mtt.hippy.views.image.HippyImageView;
|
|
13
|
+
import com.tencent.mtt.hippy.views.view.HippyViewGroup;
|
|
14
|
+
|
|
15
|
+
import java.util.HashMap;
|
|
16
|
+
|
|
17
|
+
public class StateImageView extends HippyViewGroup {
|
|
18
|
+
private boolean needUpdate = true;
|
|
19
|
+
|
|
20
|
+
private HashMap<Integer,HippyImageView> mChildren;
|
|
21
|
+
private HashMap<Integer,String> mStateUrl;
|
|
22
|
+
|
|
23
|
+
int imgLoadDelay = 0;
|
|
24
|
+
|
|
25
|
+
public StateImageView(Context context) {
|
|
26
|
+
super(context);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static String NotNullStr(String str){
|
|
30
|
+
if (str == null) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
return str;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public void setImgLoadDelay(int imgLoadDelay) {
|
|
37
|
+
this.imgLoadDelay = imgLoadDelay;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private void clearChildren(){
|
|
41
|
+
removeAllViews();
|
|
42
|
+
if (mChildren != null) {
|
|
43
|
+
mChildren.clear();
|
|
44
|
+
mChildren = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public void setStateSrc(HippyMap map){
|
|
49
|
+
boolean noChange = false;
|
|
50
|
+
int oldSize = mStateUrl != null ? mStateUrl.size() : 0;
|
|
51
|
+
int newSize = map != null ? map.size() : 0;
|
|
52
|
+
if (oldSize == newSize && newSize > 0) {
|
|
53
|
+
//全部相同就是没有变化
|
|
54
|
+
noChange = !NotNullStr(map.getString("focused")).equals(mStateUrl.get(android.R.attr.state_focused))
|
|
55
|
+
&& !NotNullStr(map.getString("normal")).equals(mStateUrl.get(-1))
|
|
56
|
+
&& !NotNullStr(map.getString("selected")).equals(mStateUrl.get(android.R.attr.state_selected));
|
|
57
|
+
}
|
|
58
|
+
if (!noChange) {
|
|
59
|
+
clearChildren();
|
|
60
|
+
}else{
|
|
61
|
+
if (LogUtils.isDebug()) {
|
|
62
|
+
Log.w(TAG,"return on noChanged");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (map == null || map.size() < 1) {
|
|
66
|
+
this.mStateUrl = null;
|
|
67
|
+
}else{
|
|
68
|
+
if (mStateUrl == null) {
|
|
69
|
+
mStateUrl = new HashMap<>();
|
|
70
|
+
}else{
|
|
71
|
+
mStateUrl.clear();
|
|
72
|
+
}
|
|
73
|
+
for(String key : map.keySet()){
|
|
74
|
+
switch (key){
|
|
75
|
+
case "focused":
|
|
76
|
+
mStateUrl.put(android.R.attr.state_focused,map.getString(key));
|
|
77
|
+
break;
|
|
78
|
+
case "normal":
|
|
79
|
+
mStateUrl.put(-1,map.getString(key));
|
|
80
|
+
break;
|
|
81
|
+
case "selected":
|
|
82
|
+
mStateUrl.put(android.R.attr.state_selected,map.getString(key));
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (!noChange) {
|
|
88
|
+
markUpdate();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Override
|
|
93
|
+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
94
|
+
super.onSizeChanged(w, h, oldw, oldh);
|
|
95
|
+
layoutChildren();
|
|
96
|
+
if (getChildCount() > 0 && w > 0 && h > 0) {
|
|
97
|
+
this.markUpdate();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
public void markUpdate(){
|
|
103
|
+
this.needUpdate = true;
|
|
104
|
+
this.invalidate();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Override
|
|
108
|
+
protected void dispatchDraw(Canvas canvas) {
|
|
109
|
+
super.dispatchDraw(canvas);
|
|
110
|
+
if (needUpdate) {
|
|
111
|
+
needUpdate = false;
|
|
112
|
+
crateChildrenIfNeed();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void crateChildrenIfNeed(){
|
|
117
|
+
if (mStateUrl != null && getWidth() > 0 && getHeight() > 0) {
|
|
118
|
+
if (mChildren == null) {
|
|
119
|
+
mChildren = new HashMap<>();
|
|
120
|
+
for(int state : mStateUrl.keySet()){
|
|
121
|
+
HippyImageView view = new HippyImageView(getContext());
|
|
122
|
+
view.setFocusable(false);
|
|
123
|
+
view.setFocusableInTouchMode(false);
|
|
124
|
+
view.setDuplicateParentStateEnabled(true);
|
|
125
|
+
//view.refreshDrawableState();
|
|
126
|
+
if (imgLoadDelay > 0) {
|
|
127
|
+
view.setDelayLoad(imgLoadDelay);
|
|
128
|
+
}
|
|
129
|
+
addView(view);
|
|
130
|
+
view.setShowOnState(new int[]{state});
|
|
131
|
+
RenderUtil.reLayoutView(view,0,0,getWidth(),getHeight());
|
|
132
|
+
view.setUrl(mStateUrl.get(state));
|
|
133
|
+
mChildren.put(state,view);
|
|
134
|
+
}
|
|
135
|
+
refreshDrawableState();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
void layoutChildren() {
|
|
141
|
+
for(int i = 0; i < getChildCount(); i ++){
|
|
142
|
+
View v = getChildAt(i);
|
|
143
|
+
RenderUtil.reLayoutView(v,0,0,getWidth(),getHeight());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
|
|
6
|
+
import com.tencent.mtt.hippy.annotation.HippyController;
|
|
7
|
+
import com.tencent.mtt.hippy.annotation.HippyControllerProps;
|
|
8
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
9
|
+
import com.tencent.mtt.hippy.views.view.HippyViewGroupController;
|
|
10
|
+
|
|
11
|
+
@HippyController(name = "StateImageView")
|
|
12
|
+
public class StateImageViewController extends HippyViewGroupController {
|
|
13
|
+
@Override
|
|
14
|
+
protected View createViewImpl(Context context) {
|
|
15
|
+
return new StateImageView(context);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@HippyControllerProps(name = "src", defaultType = HippyControllerProps.MAP)
|
|
19
|
+
public void setStateDrawable(View tv, HippyMap map) {
|
|
20
|
+
if (tv instanceof StateImageView) {
|
|
21
|
+
((StateImageView) tv).setStateSrc(map);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/*** zhaopeng add8***/
|
|
26
|
+
@HippyControllerProps(name = "loadImgDelay", defaultType = HippyControllerProps.NUMBER, defaultNumber = -1)
|
|
27
|
+
public void setDelayLoadImage(View tv, int delay)
|
|
28
|
+
{
|
|
29
|
+
if (tv instanceof StateImageView) {
|
|
30
|
+
((StateImageView) tv).setImgLoadDelay(delay);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
package com.tencent.extend.views;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.res.ColorStateList;
|
|
5
|
+
import android.graphics.Canvas;
|
|
6
|
+
import android.graphics.Color;
|
|
7
|
+
import android.graphics.Paint;
|
|
8
|
+
import android.graphics.Rect;
|
|
9
|
+
import android.graphics.RectF;
|
|
10
|
+
import android.graphics.drawable.Drawable;
|
|
11
|
+
import android.text.Layout;
|
|
12
|
+
import android.text.TextUtils;
|
|
13
|
+
import android.util.Log;
|
|
14
|
+
import android.view.Gravity;
|
|
15
|
+
import android.view.ViewGroup;
|
|
16
|
+
import android.widget.FrameLayout;
|
|
17
|
+
import android.widget.TextView;
|
|
18
|
+
|
|
19
|
+
import android.support.annotation.NonNull;
|
|
20
|
+
import android.support.annotation.Nullable;
|
|
21
|
+
|
|
22
|
+
import com.tencent.extend.RenderUtil;
|
|
23
|
+
import com.tencent.mtt.hippy.HippyEngineContext;
|
|
24
|
+
import com.tencent.mtt.hippy.HippyInstanceContext;
|
|
25
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
26
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewBase;
|
|
27
|
+
import com.tencent.mtt.hippy.uimanager.NativeGestureDispatcher;
|
|
28
|
+
import com.tencent.mtt.hippy.utils.ExtendUtil;
|
|
29
|
+
import com.tencent.mtt.hippy.utils.LogUtils;
|
|
30
|
+
|
|
31
|
+
import java.util.List;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public class TVButtonView extends FrameLayout implements HippyViewBase {
|
|
35
|
+
|
|
36
|
+
TextView tx;
|
|
37
|
+
|
|
38
|
+
Drawable drawable;
|
|
39
|
+
Drawable drawableFocused;
|
|
40
|
+
Rect padding = new Rect();
|
|
41
|
+
|
|
42
|
+
RectF markRect;
|
|
43
|
+
|
|
44
|
+
Paint mPaint;
|
|
45
|
+
|
|
46
|
+
int markWidth = 36;
|
|
47
|
+
int markHeight = 6;
|
|
48
|
+
int rounder = 4;
|
|
49
|
+
int markMargin = 2;
|
|
50
|
+
|
|
51
|
+
boolean enableMark = false;
|
|
52
|
+
boolean needUpdate = true;
|
|
53
|
+
boolean isAutoWidth = false;
|
|
54
|
+
|
|
55
|
+
public static final String TAG = "TVButtonViewLog";
|
|
56
|
+
|
|
57
|
+
public TVButtonView(@NonNull Context context,HippyMap iniProps) {
|
|
58
|
+
super(context);
|
|
59
|
+
|
|
60
|
+
tx = new TextView(getContext());
|
|
61
|
+
tx.setDuplicateParentStateEnabled(true);
|
|
62
|
+
tx.setSingleLine();
|
|
63
|
+
// tx.setEllipsize(TextUtils.TruncateAt);
|
|
64
|
+
|
|
65
|
+
setClipChildren(false);
|
|
66
|
+
// setBackgroundResource(R.drawable.item_background);
|
|
67
|
+
if(iniProps != null && iniProps.containsKey("autoWidth")){
|
|
68
|
+
this.isAutoWidth = true;
|
|
69
|
+
}
|
|
70
|
+
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
71
|
+
lp.gravity = Gravity.CENTER;
|
|
72
|
+
tx.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));
|
|
73
|
+
addView(tx,lp);
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
mPaint = new Paint();
|
|
77
|
+
mPaint.setAntiAlias(true);
|
|
78
|
+
mPaint.setColor(Color.WHITE);
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public void setColorStateList(ColorStateList color){
|
|
83
|
+
this.tx.setTextColor(color);
|
|
84
|
+
invalidate();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public void setColorStateListMap(HippyMap map){
|
|
88
|
+
final ColorStateList color = TemplateUtil.createColorStateListByMap(map);
|
|
89
|
+
this.tx.setTextColor(color);
|
|
90
|
+
invalidate();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public void setTextSize(int textSize){
|
|
94
|
+
tx.setTextSize(textSize);
|
|
95
|
+
updateSize();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public void setMarkWidth(int width){
|
|
99
|
+
this.markWidth = width;
|
|
100
|
+
updateSize();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public void setMarkHeight(int markHeight) {
|
|
104
|
+
this.markHeight = markHeight;
|
|
105
|
+
updateSize();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public void setMarkMargin(int margin) {
|
|
109
|
+
this.markMargin = margin;
|
|
110
|
+
updateSize();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@Override
|
|
114
|
+
public void requestLayout() {
|
|
115
|
+
super.requestLayout();
|
|
116
|
+
RenderUtil.requestNodeLayout(this);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Override
|
|
120
|
+
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
121
|
+
super.onLayout(changed, left, top, right, bottom);
|
|
122
|
+
//CustomControllerHelper.updateLayout(tx,left, top, right - left, bottom - top);
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public void setEnableMark(boolean enableMark) {
|
|
127
|
+
this.enableMark = enableMark;
|
|
128
|
+
if(enableMark) {
|
|
129
|
+
this.markRect = new RectF();
|
|
130
|
+
}else{
|
|
131
|
+
this.markRect = null;
|
|
132
|
+
}
|
|
133
|
+
updateSize();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public void setMarkRounder(int rounder) {
|
|
137
|
+
this.rounder = rounder;
|
|
138
|
+
invalidate();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public void setMarkColor(int color){
|
|
142
|
+
this.mPaint.setColor(color);
|
|
143
|
+
invalidate();
|
|
144
|
+
}
|
|
145
|
+
// public void setStateDrawable(@NotNull Drawable drawable) {
|
|
146
|
+
// this.drawable = drawable;
|
|
147
|
+
// drawable.setVisible(false,false);
|
|
148
|
+
// updateSize();
|
|
149
|
+
// }
|
|
150
|
+
|
|
151
|
+
public void setStateDrawableMap(HippyMap map) {
|
|
152
|
+
final List<? extends Drawable> list = TemplateUtil.createStateListDrawableByMap(map);
|
|
153
|
+
///Log.d(TAG,"setStateDrawableMap :"+list);
|
|
154
|
+
if(list .size() == 2) {
|
|
155
|
+
this.drawable = list.get(0);
|
|
156
|
+
this.drawableFocused = list.get(1);
|
|
157
|
+
}
|
|
158
|
+
updateSize();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
public void updateSize(){
|
|
163
|
+
this.needUpdate = true;
|
|
164
|
+
this.invalidate();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public void setBackgroundPadding(int[] padding){
|
|
168
|
+
if(padding != null && padding.length == 2){
|
|
169
|
+
final int h = padding[0];
|
|
170
|
+
final int v = padding[1];
|
|
171
|
+
this.padding = new Rect(-h,-v,h,v);
|
|
172
|
+
}else{
|
|
173
|
+
if(this.padding != null) {
|
|
174
|
+
this.padding.setEmpty();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
updateSize();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@Override
|
|
182
|
+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
183
|
+
super.onSizeChanged(w, h, oldw, oldh);
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
updateSize();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void validSize(){
|
|
190
|
+
if(needUpdate) {
|
|
191
|
+
needUpdate = false;
|
|
192
|
+
final int w = getWidth();
|
|
193
|
+
final int h = getHeight();
|
|
194
|
+
Log.d(TAG,"validSize w:"+w+",h:"+h);
|
|
195
|
+
if(drawable != null) {
|
|
196
|
+
drawable.setBounds(padding.left, padding.top, w + padding.right, h + padding.bottom);
|
|
197
|
+
}
|
|
198
|
+
if(drawableFocused != null){
|
|
199
|
+
drawableFocused.setBounds(padding.left, padding.top, w + padding.right, h + padding.bottom);
|
|
200
|
+
}
|
|
201
|
+
if(markRect != null){
|
|
202
|
+
if (w > 0 & h > 0) {
|
|
203
|
+
int left = (int) ((w - markWidth) * 0.5f);
|
|
204
|
+
int top = h + markMargin;
|
|
205
|
+
markRect.set(left, top, left + markWidth, top + markHeight);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
fixSize();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@Override
|
|
214
|
+
protected void dispatchDraw(Canvas canvas) {
|
|
215
|
+
validSize();
|
|
216
|
+
if(drawable != null && drawable.isVisible()) {
|
|
217
|
+
drawable.draw(canvas);
|
|
218
|
+
}
|
|
219
|
+
if(drawableFocused != null && drawableFocused.isVisible()){
|
|
220
|
+
drawableFocused.draw(canvas);
|
|
221
|
+
}
|
|
222
|
+
if(markRect != null && isSelected() && !isFocused()){
|
|
223
|
+
canvas.drawRoundRect(markRect,rounder,rounder,mPaint);
|
|
224
|
+
}
|
|
225
|
+
super.dispatchDraw(canvas);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@Override
|
|
229
|
+
protected void onFocusChanged(boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) {
|
|
230
|
+
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@Override
|
|
234
|
+
protected void drawableStateChanged() {
|
|
235
|
+
super.drawableStateChanged();
|
|
236
|
+
refreshState();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
protected void refreshState(){
|
|
240
|
+
final int[] state = getDrawableState();
|
|
241
|
+
if(isFocusable() || isDuplicateParentStateEnabled() ) {
|
|
242
|
+
final boolean focused = ExtendUtil.stateContainsAttribute(state, android.R.attr.state_focused);
|
|
243
|
+
Log.d(TAG,"refreshState focused:"+focused);
|
|
244
|
+
if(focused){
|
|
245
|
+
if(drawableFocused != null){
|
|
246
|
+
drawableFocused.setVisible(true,false);
|
|
247
|
+
invalidate();
|
|
248
|
+
}
|
|
249
|
+
if(drawable != null) {
|
|
250
|
+
drawable.setVisible(false, false);
|
|
251
|
+
invalidate();
|
|
252
|
+
}
|
|
253
|
+
}else{
|
|
254
|
+
if(drawable != null) {
|
|
255
|
+
drawable.setVisible(true, false);
|
|
256
|
+
invalidate();
|
|
257
|
+
}
|
|
258
|
+
if(drawableFocused != null){
|
|
259
|
+
drawableFocused.setVisible(false,false);
|
|
260
|
+
invalidate();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
public void setText(String text){
|
|
268
|
+
tx.setText(text);
|
|
269
|
+
updateSize();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
void fixSize(){
|
|
274
|
+
if(LogUtils.isDebug()){
|
|
275
|
+
Log.d(TAG,"fixSize text:"+tx.getText());
|
|
276
|
+
}
|
|
277
|
+
if(tx != null && isAutoWidth) {
|
|
278
|
+
final TextButtonNode node = (TextButtonNode) getHippyContext().getDomManager().getNode(getId());
|
|
279
|
+
if(node == null){
|
|
280
|
+
needUpdate = true;
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if(LogUtils.isDebug()){
|
|
284
|
+
Log.e(TAG,"fixSize measure getWidth:"+getWidth()+",node getPaddingWidth:"+node.getPaddingWidth()+",text:"+tx.getText());
|
|
285
|
+
}
|
|
286
|
+
int width;
|
|
287
|
+
if(TextUtils.isEmpty(tx.getText())){
|
|
288
|
+
width = 0;
|
|
289
|
+
}else{
|
|
290
|
+
// width = (int) tx.getPaint().measureText(tx.getText(), 0, tx.getText().length());
|
|
291
|
+
width = (int) Layout.getDesiredWidth(tx.getText(), 0, tx.getText().length(),tx.getPaint());
|
|
292
|
+
}
|
|
293
|
+
if(LogUtils.isDebug()){
|
|
294
|
+
Log.e(TAG,"fixSize measure width:"+width+",node:"+node+",text:"+tx.getText());
|
|
295
|
+
}
|
|
296
|
+
node.setTextWidth(width);
|
|
297
|
+
node.markUpdated();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
HippyEngineContext getHippyContext(){
|
|
302
|
+
return ((HippyInstanceContext)getContext()).getEngineContext();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@Override
|
|
306
|
+
public NativeGestureDispatcher getGestureDispatcher() {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
@Override
|
|
311
|
+
public void setGestureDispatcher(NativeGestureDispatcher dispatcher) {
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
}
|