@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,27 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager;
|
|
17
|
+
|
|
18
|
+
import com.tencent.mtt.hippy.views.view.HippyViewGroup;
|
|
19
|
+
|
|
20
|
+
import android.content.Context;
|
|
21
|
+
|
|
22
|
+
public class HippyViewPagerItem extends HippyViewGroup {
|
|
23
|
+
|
|
24
|
+
public HippyViewPagerItem(Context context) {
|
|
25
|
+
super(context);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager;
|
|
17
|
+
|
|
18
|
+
import com.tencent.mtt.hippy.annotation.HippyController;
|
|
19
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewController;
|
|
20
|
+
|
|
21
|
+
import android.content.Context;
|
|
22
|
+
import android.view.View;
|
|
23
|
+
|
|
24
|
+
@SuppressWarnings({"unused"})
|
|
25
|
+
@HippyController(name = HippyViewPagerItemController.CLASS_NAME)
|
|
26
|
+
public class HippyViewPagerItemController extends HippyViewController<HippyViewPagerItem> {
|
|
27
|
+
|
|
28
|
+
public static final String CLASS_NAME = "ViewPagerItem";
|
|
29
|
+
|
|
30
|
+
private static final String TAG = "ViewPagerItem";
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
protected View createViewImpl(Context context) {
|
|
34
|
+
return new HippyViewPagerItem(context);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
protected boolean shouldInterceptLayout(View view, int x, int y, int width, int height) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager;
|
|
17
|
+
|
|
18
|
+
import android.view.View;
|
|
19
|
+
|
|
20
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
21
|
+
import com.tencent.mtt.hippy.modules.Promise;
|
|
22
|
+
import com.tencent.mtt.hippy.views.viewpager.event.HippyPageItemExposureEvent;
|
|
23
|
+
import com.tencent.mtt.hippy.views.viewpager.event.HippyPageScrollEvent;
|
|
24
|
+
import com.tencent.mtt.hippy.views.viewpager.event.HippyPageScrollStateChangedEvent;
|
|
25
|
+
import com.tencent.mtt.hippy.views.viewpager.event.HippyPageSelectedEvent;
|
|
26
|
+
import com.tencent.mtt.supportui.views.viewpager.ViewPager;
|
|
27
|
+
|
|
28
|
+
@SuppressWarnings({"deprecation", "unused"})
|
|
29
|
+
public class ViewPagerPageChangeListener implements ViewPager.OnPageChangeListener {
|
|
30
|
+
|
|
31
|
+
private final HippyPageScrollEvent mPageScrollEmitter;
|
|
32
|
+
private final HippyPageScrollStateChangedEvent mPageScrollStateChangeEmitter;
|
|
33
|
+
private final HippyPageSelectedEvent mPageSelectedEmitter;
|
|
34
|
+
private int mLastPageIndex;
|
|
35
|
+
private int mCurrPageIndex;
|
|
36
|
+
private final HippyViewPager mPager;
|
|
37
|
+
|
|
38
|
+
public ViewPagerPageChangeListener(HippyViewPager pager) {
|
|
39
|
+
mPager = pager;
|
|
40
|
+
mPageScrollEmitter = new HippyPageScrollEvent(pager);
|
|
41
|
+
mPageScrollStateChangeEmitter = new HippyPageScrollStateChangedEvent(pager);
|
|
42
|
+
mPageSelectedEmitter = new HippyPageSelectedEvent(pager);
|
|
43
|
+
mLastPageIndex = 0;
|
|
44
|
+
mCurrPageIndex = 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
49
|
+
mPageScrollEmitter.send(position, positionOffset);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public void onPageSelected(int position) {
|
|
54
|
+
mCurrPageIndex = position;
|
|
55
|
+
mPageSelectedEmitter.send(position);
|
|
56
|
+
if (mPager != null) {
|
|
57
|
+
View currView = mPager.getViewFromAdapter(mCurrPageIndex);
|
|
58
|
+
HippyPageItemExposureEvent eventWillAppear = new HippyPageItemExposureEvent(
|
|
59
|
+
HippyPageItemExposureEvent.EVENT_PAGER_ITEM_WILL_APPEAR);
|
|
60
|
+
eventWillAppear.send(currView, mCurrPageIndex);
|
|
61
|
+
|
|
62
|
+
View lastView = mPager.getViewFromAdapter(mLastPageIndex);
|
|
63
|
+
HippyPageItemExposureEvent eventWillDisAppear = new HippyPageItemExposureEvent(
|
|
64
|
+
HippyPageItemExposureEvent.EVENT_PAGER_ITEM_WILL_DISAPPEAR);
|
|
65
|
+
eventWillDisAppear.send(lastView, mLastPageIndex);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private void onScrollStateChangeToIdle() {
|
|
70
|
+
if (mPager != null && mCurrPageIndex != mLastPageIndex) {
|
|
71
|
+
Promise promise = mPager.getCallBackPromise();
|
|
72
|
+
if (promise != null) {
|
|
73
|
+
String msg = "on set index successful!";
|
|
74
|
+
HippyMap resultMap = new HippyMap();
|
|
75
|
+
resultMap.pushString("msg", msg);
|
|
76
|
+
promise.resolve(resultMap);
|
|
77
|
+
mPager.setCallBackPromise(null);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
View currView = mPager.getViewFromAdapter(mCurrPageIndex);
|
|
81
|
+
HippyPageItemExposureEvent eventWillAppear = new HippyPageItemExposureEvent(
|
|
82
|
+
HippyPageItemExposureEvent.EVENT_PAGER_ITEM_DID_APPEAR);
|
|
83
|
+
eventWillAppear.send(currView, mCurrPageIndex);
|
|
84
|
+
|
|
85
|
+
View lastView = mPager.getViewFromAdapter(mLastPageIndex);
|
|
86
|
+
HippyPageItemExposureEvent eventWillDisAppear = new HippyPageItemExposureEvent(
|
|
87
|
+
HippyPageItemExposureEvent.EVENT_PAGER_ITEM_DID_DISAPPEAR);
|
|
88
|
+
eventWillDisAppear.send(lastView, mLastPageIndex);
|
|
89
|
+
|
|
90
|
+
mLastPageIndex = mCurrPageIndex;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Override
|
|
95
|
+
public void onPageScrollStateChanged(int oldState, int newState) {
|
|
96
|
+
String pageScrollState;
|
|
97
|
+
switch (newState) {
|
|
98
|
+
case ViewPager.SCROLL_STATE_IDLE:
|
|
99
|
+
pageScrollState = "idle";
|
|
100
|
+
onScrollStateChangeToIdle();
|
|
101
|
+
break;
|
|
102
|
+
case ViewPager.SCROLL_STATE_DRAGGING:
|
|
103
|
+
pageScrollState = "dragging";
|
|
104
|
+
break;
|
|
105
|
+
case ViewPager.SCROLL_STATE_SETTLING:
|
|
106
|
+
pageScrollState = "settling";
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
throw new IllegalStateException("Unsupported pageScrollState");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
mPageScrollStateChangeEmitter.send(pageScrollState);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager.event;
|
|
17
|
+
|
|
18
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
19
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewEvent;
|
|
20
|
+
|
|
21
|
+
import android.view.View;
|
|
22
|
+
|
|
23
|
+
@SuppressWarnings("deprecation")
|
|
24
|
+
public class HippyPageItemExposureEvent extends HippyViewEvent {
|
|
25
|
+
|
|
26
|
+
public static final String EVENT_PAGER_ITEM_WILL_APPEAR = "onWillAppear";
|
|
27
|
+
public static final String EVENT_PAGER_ITEM_DID_APPEAR = "onDidAppear";
|
|
28
|
+
public static final String EVENT_PAGER_ITEM_WILL_DISAPPEAR = "onWillDisAppear";
|
|
29
|
+
public static final String EVENT_PAGER_ITEM_DID_DISAPPEAR = "onDidDisAppear";
|
|
30
|
+
|
|
31
|
+
public HippyPageItemExposureEvent(String eventName) {
|
|
32
|
+
super(eventName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void send(View view, int position) {
|
|
36
|
+
HippyMap map = new HippyMap();
|
|
37
|
+
map.pushInt("position", position);
|
|
38
|
+
super.send(view, map);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager.event;
|
|
17
|
+
|
|
18
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
19
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewEvent;
|
|
20
|
+
|
|
21
|
+
import android.view.View;
|
|
22
|
+
|
|
23
|
+
@SuppressWarnings("deprecation")
|
|
24
|
+
public class HippyPageScrollEvent extends HippyViewEvent {
|
|
25
|
+
|
|
26
|
+
public static final String EVENT_NAME = "onPageScroll";
|
|
27
|
+
|
|
28
|
+
private final View mTarget;
|
|
29
|
+
|
|
30
|
+
public HippyPageScrollEvent(View target) {
|
|
31
|
+
super(EVENT_NAME);
|
|
32
|
+
mTarget = target;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void send(int position, float offset) {
|
|
36
|
+
HippyMap map = new HippyMap();
|
|
37
|
+
map.pushInt("position", position);
|
|
38
|
+
map.pushDouble("offset", offset);
|
|
39
|
+
super.send(mTarget, map);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager.event;
|
|
17
|
+
|
|
18
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
19
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewEvent;
|
|
20
|
+
|
|
21
|
+
import android.view.View;
|
|
22
|
+
|
|
23
|
+
@SuppressWarnings("deprecation")
|
|
24
|
+
public class HippyPageScrollStateChangedEvent extends HippyViewEvent {
|
|
25
|
+
|
|
26
|
+
public static final String EVENT_NAME = "onPageScrollStateChanged";
|
|
27
|
+
|
|
28
|
+
private final View mTarget;
|
|
29
|
+
|
|
30
|
+
public HippyPageScrollStateChangedEvent(View target) {
|
|
31
|
+
super(EVENT_NAME);
|
|
32
|
+
mTarget = target;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void send(String pageScrollState) {
|
|
36
|
+
HippyMap map = new HippyMap();
|
|
37
|
+
map.pushString("pageScrollState", pageScrollState);
|
|
38
|
+
super.send(mTarget, map);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.viewpager.event;
|
|
17
|
+
|
|
18
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
19
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewEvent;
|
|
20
|
+
|
|
21
|
+
import android.view.View;
|
|
22
|
+
|
|
23
|
+
@SuppressWarnings("deprecation")
|
|
24
|
+
public class HippyPageSelectedEvent extends HippyViewEvent {
|
|
25
|
+
|
|
26
|
+
public static final String EVENT_NAME = "onPageSelected";
|
|
27
|
+
|
|
28
|
+
private final View mTarget;
|
|
29
|
+
|
|
30
|
+
public HippyPageSelectedEvent(View target) {
|
|
31
|
+
super(EVENT_NAME);
|
|
32
|
+
mTarget = target;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void send(int position) {
|
|
36
|
+
HippyMap map = new HippyMap();
|
|
37
|
+
map.pushInt("position", position);
|
|
38
|
+
super.send(mTarget, map);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.webview;
|
|
17
|
+
|
|
18
|
+
import android.content.Context;
|
|
19
|
+
import android.graphics.Bitmap;
|
|
20
|
+
import android.os.Build;
|
|
21
|
+
import android.webkit.WebChromeClient;
|
|
22
|
+
import android.webkit.WebResourceError;
|
|
23
|
+
import android.webkit.WebResourceRequest;
|
|
24
|
+
import android.webkit.WebView;
|
|
25
|
+
import android.webkit.WebViewClient;
|
|
26
|
+
import android.widget.FrameLayout;
|
|
27
|
+
|
|
28
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
29
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewBase;
|
|
30
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewEvent;
|
|
31
|
+
import com.tencent.mtt.hippy.uimanager.NativeGestureDispatcher;
|
|
32
|
+
import com.tencent.mtt.hippy.utils.UrlUtils;
|
|
33
|
+
|
|
34
|
+
import java.net.URLDecoder;
|
|
35
|
+
|
|
36
|
+
@SuppressWarnings("ALL")
|
|
37
|
+
public class HippyWebView extends FrameLayout implements HippyViewBase {
|
|
38
|
+
|
|
39
|
+
protected final HippyWebViewInner mWebView;
|
|
40
|
+
private HippyViewEvent mEventOnMessage = null;
|
|
41
|
+
|
|
42
|
+
public HippyWebView(Context context) {
|
|
43
|
+
super(context);
|
|
44
|
+
mWebView = new HippyWebViewInner(context);
|
|
45
|
+
addView(mWebView);
|
|
46
|
+
initWebView();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private void initWebView() {
|
|
50
|
+
mWebView.setWebViewClient(new WebViewClient() {
|
|
51
|
+
final HippyViewEvent mEventOnError = new HippyViewEvent("onError");
|
|
52
|
+
final HippyViewEvent mEventonLoad = new HippyViewEvent("onLoad");
|
|
53
|
+
final HippyViewEvent mEventonLoadEnd = new HippyViewEvent("onLoadEnd");
|
|
54
|
+
final HippyViewEvent mEventonLoadStart = new HippyViewEvent("onLoadStart");
|
|
55
|
+
final String mMessageUrlPre = "esbridge://postMessage?data=";
|
|
56
|
+
final String mMessageUrlPre2 = "esbridge://closePage";
|
|
57
|
+
|
|
58
|
+
@Override
|
|
59
|
+
public void onReceivedError(WebView view, WebResourceRequest request,
|
|
60
|
+
WebResourceError error) {
|
|
61
|
+
HippyMap event = new HippyMap();
|
|
62
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
63
|
+
event.pushString("error", (String) error.getDescription());
|
|
64
|
+
event.pushInt("errorCode", error.getErrorCode());
|
|
65
|
+
} else {
|
|
66
|
+
event.pushString("error", "unknown error");
|
|
67
|
+
event.pushInt("errorCode", Integer.MAX_VALUE);
|
|
68
|
+
}
|
|
69
|
+
mEventOnError.send(HippyWebView.this, event);
|
|
70
|
+
super.onReceivedError(view, request, error);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Override
|
|
74
|
+
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
75
|
+
if (url != null) {
|
|
76
|
+
if (url.startsWith(mMessageUrlPre)) {
|
|
77
|
+
postMessage(URLDecoder.decode(url.substring(mMessageUrlPre.length())));
|
|
78
|
+
return true;
|
|
79
|
+
}else if (url.startsWith(mMessageUrlPre2)) {
|
|
80
|
+
closePage();
|
|
81
|
+
return true;
|
|
82
|
+
} else if (UrlUtils.isWebUrl(url) || UrlUtils.isFileUrl(url)) {
|
|
83
|
+
view.loadUrl(url);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return super.shouldOverrideUrlLoading(view, url);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
|
91
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
92
|
+
return shouldOverrideUrlLoading(view, request.getUrl().toString());
|
|
93
|
+
}
|
|
94
|
+
return super.shouldOverrideUrlLoading(view, request);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public void onPageFinished(WebView view, String url) {
|
|
99
|
+
// android 4.2以下,使用注入js的方式来实现hippy.onMessage。4.2及以上使用addJavaScriptInterface实现
|
|
100
|
+
if (Build.VERSION.SDK_INT < 17) {
|
|
101
|
+
view.loadUrl("javascript:esbridge={};esbridge.onMessage=function(data){location.href='esbridge://postMessage?data='+encodeURIComponent(data)};esbridge.onClosePage=function(data){location.href='esbridge://closePage'");
|
|
102
|
+
}
|
|
103
|
+
HippyMap event = new HippyMap();
|
|
104
|
+
event.pushString("url", url);
|
|
105
|
+
mEventonLoad.send(HippyWebView.this, event);
|
|
106
|
+
mEventonLoadEnd.send(HippyWebView.this, event);
|
|
107
|
+
super.onPageFinished(view, url);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Override
|
|
111
|
+
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
112
|
+
HippyMap event = new HippyMap();
|
|
113
|
+
event.pushString("url", url);
|
|
114
|
+
mEventonLoadStart.send(HippyWebView.this, event);
|
|
115
|
+
super.onPageStarted(view, url, favicon);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
mWebView.setWebChromeClient(new WebChromeClient());
|
|
119
|
+
// 避免安全隐患
|
|
120
|
+
if (Build.VERSION.SDK_INT >= 17) {
|
|
121
|
+
// 为了让网页端可以通过:hippy.postMessage("hello");的方式发送数据给hippy前端
|
|
122
|
+
mWebView.addJavascriptInterface(new HippyWebViewBridge(this), "esbridge");
|
|
123
|
+
}
|
|
124
|
+
if (Build.VERSION.SDK_INT < 19) {
|
|
125
|
+
mWebView.removeJavascriptInterface("searchBoxJavaBridge_");
|
|
126
|
+
mWebView.removeJavascriptInterface("accessibility");
|
|
127
|
+
mWebView.removeJavascriptInterface("accessibilityTraversal");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public void closePage(){
|
|
132
|
+
new HippyViewEvent("onClosePage").send(this, null);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public void postMessage(String msg) {
|
|
136
|
+
if (mEventOnMessage == null) {
|
|
137
|
+
mEventOnMessage = new HippyViewEvent("onMessage");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
HippyMap event = new HippyMap();
|
|
141
|
+
event.pushString("data", msg);
|
|
142
|
+
mEventOnMessage.send(this, event);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Override
|
|
146
|
+
public NativeGestureDispatcher getGestureDispatcher() {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@Override
|
|
151
|
+
public void setGestureDispatcher(NativeGestureDispatcher dispatcher) {
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Override
|
|
155
|
+
public void setBackgroundColor(int color) {
|
|
156
|
+
super.setBackgroundColor(color);
|
|
157
|
+
if(mWebView == null) return;
|
|
158
|
+
mWebView.setBackgroundColor(color);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.tencent.mtt.hippy.views.webview;
|
|
2
|
+
|
|
3
|
+
import android.webkit.JavascriptInterface;
|
|
4
|
+
|
|
5
|
+
@SuppressWarnings({"unused"})
|
|
6
|
+
class HippyWebViewBridge {
|
|
7
|
+
|
|
8
|
+
private final HippyWebView hippyView;
|
|
9
|
+
|
|
10
|
+
public HippyWebViewBridge(HippyWebView webView) {
|
|
11
|
+
hippyView = webView;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@JavascriptInterface
|
|
15
|
+
public void postMessage(String msg) {
|
|
16
|
+
if (hippyView != null) {
|
|
17
|
+
hippyView.postMessage(msg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Hippy available.
|
|
2
|
+
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package com.tencent.mtt.hippy.views.webview;
|
|
17
|
+
|
|
18
|
+
import android.content.Context;
|
|
19
|
+
import android.os.Build;
|
|
20
|
+
import android.text.TextUtils;
|
|
21
|
+
import android.util.Base64;
|
|
22
|
+
import android.view.View;
|
|
23
|
+
|
|
24
|
+
import com.tencent.mtt.hippy.annotation.HippyController;
|
|
25
|
+
import com.tencent.mtt.hippy.annotation.HippyControllerProps;
|
|
26
|
+
import com.tencent.mtt.hippy.common.HippyArray;
|
|
27
|
+
import com.tencent.mtt.hippy.common.HippyMap;
|
|
28
|
+
import com.tencent.mtt.hippy.uimanager.HippyViewController;
|
|
29
|
+
|
|
30
|
+
@SuppressWarnings({"deprecation", "unused"})
|
|
31
|
+
@HippyController(name = HippyWebViewController.CLASS_NAME)
|
|
32
|
+
public class HippyWebViewController extends HippyViewController<HippyWebView> {
|
|
33
|
+
|
|
34
|
+
public static final String CLASS_NAME = "WebView";
|
|
35
|
+
|
|
36
|
+
@HippyControllerProps(name = "url", defaultType = HippyControllerProps.STRING)
|
|
37
|
+
public void loadUrl(HippyWebView view, String url) {
|
|
38
|
+
if (!TextUtils.isEmpty(url)) {
|
|
39
|
+
view.mWebView.loadUrl(url);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Override
|
|
44
|
+
public void dispatchFunction(HippyWebView view, String functionName, HippyArray var) {
|
|
45
|
+
super.dispatchFunction(view, functionName, var);
|
|
46
|
+
if ("loadUrl".equals(functionName)) {
|
|
47
|
+
if (var != null) {
|
|
48
|
+
String url = var.getString(0);
|
|
49
|
+
loadUrl(view, url);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Override
|
|
55
|
+
protected View createViewImpl(Context context) {
|
|
56
|
+
return new HippyWebView(context);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@HippyControllerProps(name = "source", defaultType = HippyControllerProps.MAP)
|
|
60
|
+
public void source(HippyWebView webView, HippyMap info) {
|
|
61
|
+
if (info != null) {
|
|
62
|
+
String userAgent = info.getString("userAgent");
|
|
63
|
+
if (!TextUtils.isEmpty(userAgent)) {
|
|
64
|
+
webView.mWebView.getSettings().setUserAgentString(userAgent);
|
|
65
|
+
}
|
|
66
|
+
String uri = info.getString("uri");
|
|
67
|
+
if (!TextUtils.isEmpty(uri)) {
|
|
68
|
+
String method = info.getString("method");
|
|
69
|
+
if ("POST".equalsIgnoreCase(method)) {
|
|
70
|
+
String body = info.getString("body");
|
|
71
|
+
webView.mWebView.postUrl(uri, body == null ? null : body.getBytes());
|
|
72
|
+
} else {
|
|
73
|
+
webView.mWebView.loadUrl(uri);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
String html = info.getString("html");
|
|
77
|
+
if (!TextUtils.isEmpty(html)) {
|
|
78
|
+
String baseUrl = info.getString("baseUrl");
|
|
79
|
+
if (!TextUtils.isEmpty(baseUrl)) {
|
|
80
|
+
webView.mWebView
|
|
81
|
+
.loadDataWithBaseURL(baseUrl, html, "text/html; charset=utf-8", "UTF-8", null);
|
|
82
|
+
} else {
|
|
83
|
+
// Android10 不显示的问题 将编译版本调到28没事,调高有问题可以这样解决
|
|
84
|
+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
|
|
85
|
+
webView.mWebView.loadData(html, "text/html; charset=utf-8", "UTF-8");
|
|
86
|
+
}else{
|
|
87
|
+
webView.mWebView.loadData(Base64.encodeToString(html.getBytes(), Base64.NO_PADDING), "text/html; charset=utf-8", "base64");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public void onViewDestroy(HippyWebView webView) {
|
|
96
|
+
webView.mWebView.destroy();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Override
|
|
100
|
+
protected boolean handleGestureBySelf() {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|