You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2019/09/06 08:16:44 UTC
[incubator-weex] 01/01: [Android] Rename packageName from
`com.taobao.weex` to `org.apache.weex`
This is an automated email from the ASF dual-hosted git repository.
kyork pushed a commit to branch feature/android_package_name
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
commit 2d83481e2008e6a8c8ca37de65a9767e382834b3
Author: YorkShen <sh...@gmail.com>
AuthorDate: Fri Sep 6 16:16:10 2019 +0800
[Android] Rename packageName from `com.taobao.weex` to `org.apache.weex`
---
android/sdk/build.gradle | 1 +
android/sdk/proguard-rules.pro | 10 +-
android/sdk/src/main/AndroidManifest.xml | 2 +-
.../java/com/taobao/weex/ComponentObserver.java | 50 -
.../com/taobao/weex/IWXActivityStateListener.java | 41 -
.../java/com/taobao/weex/IWXRenderListener.java | 49 -
.../com/taobao/weex/IWXStatisticsListener.java | 66 -
.../src/main/java/com/taobao/weex/InitConfig.java | 249 --
.../main/java/com/taobao/weex/RenderContainer.java | 96 -
.../sdk/src/main/java/com/taobao/weex/Script.java | 55 -
.../main/java/com/taobao/weex/WXEnvironment.java | 691 ----
.../java/com/taobao/weex/WXGlobalEventModule.java | 52 -
.../com/taobao/weex/WXGlobalEventReceiver.java | 57 -
.../main/java/com/taobao/weex/WXHttpListener.java | 307 --
.../src/main/java/com/taobao/weex/WXSDKEngine.java | 603 ----
.../main/java/com/taobao/weex/WXSDKInstance.java | 2400 -------------
.../main/java/com/taobao/weex/WXSDKManager.java | 540 ---
.../java/com/taobao/weex/WeexFrameRateControl.java | 110 -
.../taobao/weex/adapter/ClassLoaderAdapter.java | 55 -
.../com/taobao/weex/adapter/DefaultUriAdapter.java | 98 -
.../taobao/weex/adapter/DefaultWXHttpAdapter.java | 248 --
.../com/taobao/weex/adapter/DrawableStrategy.java | 27 -
.../taobao/weex/adapter/ICrashInfoReporter.java | 27 -
.../com/taobao/weex/adapter/IDrawableLoader.java | 41 -
.../com/taobao/weex/adapter/ITracingAdapter.java | 31 -
.../weex/adapter/IWXAccessibilityRoleAdapter.java | 27 -
.../com/taobao/weex/adapter/IWXConfigAdapter.java | 27 -
.../com/taobao/weex/adapter/IWXHttpAdapter.java | 68 -
.../taobao/weex/adapter/IWXImgLoaderAdapter.java | 32 -
.../taobao/weex/adapter/IWXJSExceptionAdapter.java | 32 -
.../weex/adapter/IWXJsFileLoaderAdapter.java | 25 -
.../taobao/weex/adapter/IWXJscProcessManager.java | 29 -
.../taobao/weex/adapter/IWXSoLoaderAdapter.java | 50 -
.../taobao/weex/adapter/IWXUserTrackAdapter.java | 56 -
.../java/com/taobao/weex/adapter/URIAdapter.java | 80 -
.../java/com/taobao/weex/annotation/Component.java | 33 -
.../java/com/taobao/weex/annotation/JSMethod.java | 39 -
.../weex/appfram/clipboard/IWXClipboard.java | 31 -
.../weex/appfram/clipboard/WXClipboardModule.java | 148 -
.../appfram/navigator/IActivityNavBarSetter.java | 44 -
.../taobao/weex/appfram/navigator/INavigator.java | 31 -
.../weex/appfram/navigator/WXNavigatorModule.java | 365 --
.../weex/appfram/pickers/DatePickerImpl.java | 198 --
.../weex/appfram/pickers/WXPickersModule.java | 310 --
.../weex/appfram/storage/DefaultWXStorage.java | 335 --
.../taobao/weex/appfram/storage/IWXStorage.java | 32 -
.../weex/appfram/storage/IWXStorageAdapter.java | 52 -
.../weex/appfram/storage/StorageResultHandler.java | 107 -
.../weex/appfram/storage/WXSQLiteOpenHelper.java | 226 --
.../weex/appfram/storage/WXStorageModule.java | 180 -
.../weex/appfram/websocket/IWebSocketAdapter.java | 48 -
.../websocket/IWebSocketAdapterFactory.java | 27 -
.../appfram/websocket/WebSocketCloseCodes.java | 51 -
.../weex/appfram/websocket/WebSocketModule.java | 188 -
.../java/com/taobao/weex/base/CalledByNative.java | 22 -
.../main/java/com/taobao/weex/base/FloatUtil.java | 31 -
.../com/taobao/weex/base/SystemMessageHandler.java | 106 -
.../java/com/taobao/weex/bridge/EventResult.java | 46 -
.../main/java/com/taobao/weex/bridge/Invoker.java | 33 -
.../java/com/taobao/weex/bridge/JSCallback.java | 36 -
.../taobao/weex/bridge/JavascriptInvokable.java | 28 -
.../java/com/taobao/weex/bridge/MethodInvoker.java | 66 -
.../java/com/taobao/weex/bridge/ModuleFactory.java | 32 -
.../com/taobao/weex/bridge/ModuleFactoryImpl.java | 37 -
.../com/taobao/weex/bridge/NativeInvokeHelper.java | 125 -
.../com/taobao/weex/bridge/RequestHandler.java | 155 -
.../com/taobao/weex/bridge/ResultCallback.java | 23 -
.../taobao/weex/bridge/ResultCallbackManager.java | 48 -
.../com/taobao/weex/bridge/SimpleJSCallback.java | 61 -
.../main/java/com/taobao/weex/bridge/WXBridge.java | 934 -----
.../com/taobao/weex/bridge/WXBridgeManager.java | 3647 --------------------
.../com/taobao/weex/bridge/WXDebugJsBridge.java | 101 -
.../java/com/taobao/weex/bridge/WXHashMap.java | 90 -
.../java/com/taobao/weex/bridge/WXJSObject.java | 72 -
.../com/taobao/weex/bridge/WXModuleManager.java | 535 ---
.../main/java/com/taobao/weex/bridge/WXParams.java | 290 --
.../com/taobao/weex/bridge/WXServiceManager.java | 99 -
.../main/java/com/taobao/weex/bridge/WXTask.java | 45 -
.../taobao/weex/bridge/WXValidateProcessor.java | 58 -
.../java/com/taobao/weex/common/Constants.java | 388 ---
.../java/com/taobao/weex/common/Destroyable.java | 26 -
.../taobao/weex/common/ICheckBindingScroller.java | 27 -
.../java/com/taobao/weex/common/IWXBridge.java | 234 --
.../com/taobao/weex/common/IWXDebugConfig.java | 29 -
.../java/com/taobao/weex/common/IWXObject.java | 23 -
.../com/taobao/weex/common/OnWXScrollListener.java | 56 -
.../java/com/taobao/weex/common/RenderTypes.java | 27 -
.../com/taobao/weex/common/TypeModuleFactory.java | 98 -
.../com/taobao/weex/common/WXCompatModule.java | 84 -
.../main/java/com/taobao/weex/common/WXConfig.java | 44 -
.../java/com/taobao/weex/common/WXErrorCode.java | 339 --
.../java/com/taobao/weex/common/WXException.java | 28 -
.../com/taobao/weex/common/WXImageSharpen.java | 24 -
.../com/taobao/weex/common/WXImageStrategy.java | 83 -
.../com/taobao/weex/common/WXInstanceWrap.java | 41 -
.../com/taobao/weex/common/WXJSBridgeMsgType.java | 38 -
.../com/taobao/weex/common/WXJSEngineListener.java | 36 -
.../com/taobao/weex/common/WXJSExceptionInfo.java | 142 -
.../java/com/taobao/weex/common/WXJSService.java | 43 -
.../main/java/com/taobao/weex/common/WXModule.java | 137 -
.../java/com/taobao/weex/common/WXModuleAnno.java | 37 -
.../java/com/taobao/weex/common/WXPerformance.java | 568 ---
.../java/com/taobao/weex/common/WXRefreshData.java | 31 -
.../com/taobao/weex/common/WXRenderStrategy.java | 39 -
.../java/com/taobao/weex/common/WXRequest.java | 60 -
.../com/taobao/weex/common/WXRequestListener.java | 27 -
.../java/com/taobao/weex/common/WXResponse.java | 56 -
.../com/taobao/weex/common/WXRuntimeException.java | 28 -
.../main/java/com/taobao/weex/common/WXThread.java | 202 --
.../taobao/weex/common/WXWorkThreadManager.java | 56 -
.../java/com/taobao/weex/dom/CSSConstants.java | 28 -
.../java/com/taobao/weex/dom/CSSShorthand.java | 120 -
.../java/com/taobao/weex/dom/RenderContext.java | 32 -
.../com/taobao/weex/dom/TextDecorationSpan.java | 55 -
.../src/main/java/com/taobao/weex/dom/WXAttr.java | 591 ----
.../com/taobao/weex/dom/WXCustomStyleSpan.java | 68 -
.../src/main/java/com/taobao/weex/dom/WXEvent.java | 188 -
.../java/com/taobao/weex/dom/WXImageQuality.java | 32 -
.../java/com/taobao/weex/dom/WXLineHeightSpan.java | 46 -
.../src/main/java/com/taobao/weex/dom/WXStyle.java | 558 ---
.../java/com/taobao/weex/dom/binding/ELUtils.java | 127 -
.../com/taobao/weex/dom/binding/JSONUtils.java | 51 -
.../com/taobao/weex/dom/binding/WXStatement.java | 83 -
.../taobao/weex/dom/transition/WXTransition.java | 762 ----
.../java/com/taobao/weex/el/parse/ArrayStack.java | 72 -
.../main/java/com/taobao/weex/el/parse/Block.java | 71 -
.../java/com/taobao/weex/el/parse/Operator.java | 106 -
.../java/com/taobao/weex/el/parse/Operators.java | 502 ---
.../main/java/com/taobao/weex/el/parse/Parser.java | 486 ---
.../main/java/com/taobao/weex/el/parse/Symbol.java | 38 -
.../main/java/com/taobao/weex/el/parse/Token.java | 89 -
.../java/com/taobao/weex/font/FontAdapter.java | 56 -
.../java/com/taobao/weex/font/FontListener.java | 26 -
.../main/java/com/taobao/weex/http/Options.java | 138 -
.../src/main/java/com/taobao/weex/http/Status.java | 94 -
.../main/java/com/taobao/weex/http/WXHttpUtil.java | 67 -
.../java/com/taobao/weex/http/WXStreamModule.java | 382 --
.../instance/InstanceOnFireEventInterceptor.java | 61 -
.../taobao/weex/layout/ContentBoxMeasurement.java | 78 -
.../java/com/taobao/weex/layout/MeasureMode.java | 29 -
.../java/com/taobao/weex/layout/MeasureSize.java | 42 -
.../measurefunc/TextContentBoxMeasurement.java | 500 ---
.../com/taobao/weex/performance/IApmGenerator.java | 27 -
.../com/taobao/weex/performance/IWXAnalyzer.java | 35 -
.../weex/performance/IWXApmMonitorAdapter.java | 82 -
.../weex/performance/WXAnalyzerDataTransfer.java | 168 -
.../com/taobao/weex/performance/WXInstanceApm.java | 683 ----
.../com/taobao/weex/performance/WXStateRecord.java | 205 --
.../taobao/weex/performance/WhiteScreenUtils.java | 179 -
.../weex/render/WXAbstractRenderContainer.java | 82 -
.../java/com/taobao/weex/tracing/Stopwatch.java | 132 -
.../java/com/taobao/weex/tracing/WXTracing.java | 129 -
.../java/com/taobao/weex/ui/ComponentCreator.java | 33 -
.../weex/ui/ExternalLoaderComponentHolder.java | 103 -
.../taobao/weex/ui/IExternalComponentGetter.java | 29 -
.../com/taobao/weex/ui/IExternalModuleGetter.java | 30 -
.../java/com/taobao/weex/ui/IFComponentHolder.java | 34 -
.../java/com/taobao/weex/ui/RenderContextImpl.java | 82 -
.../com/taobao/weex/ui/SimpleComponentHolder.java | 235 --
.../com/taobao/weex/ui/WXComponentRegistry.java | 148 -
.../java/com/taobao/weex/ui/WXRenderHandler.java | 42 -
.../java/com/taobao/weex/ui/WXRenderManager.java | 312 --
.../com/taobao/weex/ui/action/ActionAddRule.java | 87 -
.../weex/ui/action/ActionGetComponentRect.java | 120 -
.../weex/ui/action/ActionGetLayoutDirection.java | 117 -
.../taobao/weex/ui/action/ActionInvokeMethod.java | 54 -
.../taobao/weex/ui/action/ActionReloadPage.java | 49 -
.../taobao/weex/ui/action/BasicComponentData.java | 310 --
.../taobao/weex/ui/action/BasicGraphicAction.java | 79 -
.../ui/action/GraphicActionAbstractAddElement.java | 102 -
.../ui/action/GraphicActionAddChildToRichtext.java | 47 -
.../weex/ui/action/GraphicActionAddElement.java | 214 --
.../weex/ui/action/GraphicActionAddEvent.java | 53 -
.../weex/ui/action/GraphicActionAnimation.java | 289 --
.../GraphicActionAppendTreeCreateFinish.java | 47 -
.../weex/ui/action/GraphicActionBatchAction.java | 41 -
.../weex/ui/action/GraphicActionBatchBegin.java | 34 -
.../weex/ui/action/GraphicActionBatchEnd.java | 34 -
.../weex/ui/action/GraphicActionCreateBody.java | 93 -
.../weex/ui/action/GraphicActionCreateFinish.java | 72 -
.../taobao/weex/ui/action/GraphicActionLayout.java | 50 -
.../weex/ui/action/GraphicActionMoveElement.java | 70 -
.../weex/ui/action/GraphicActionRefreshFinish.java | 53 -
.../GraphicActionRemoveChildFromRichtext.java | 43 -
.../weex/ui/action/GraphicActionRemoveElement.java | 66 -
.../weex/ui/action/GraphicActionRemoveEvent.java | 50 -
.../weex/ui/action/GraphicActionRenderSuccess.java | 48 -
.../ui/action/GraphicActionScrollToElement.java | 52 -
.../weex/ui/action/GraphicActionUpdateAttr.java | 54 -
.../ui/action/GraphicActionUpdateRichtextAttr.java | 43 -
.../action/GraphicActionUpdateRichtextStyle.java | 45 -
.../weex/ui/action/GraphicActionUpdateStyle.java | 142 -
.../com/taobao/weex/ui/action/GraphicPosition.java | 74 -
.../com/taobao/weex/ui/action/GraphicSize.java | 51 -
.../com/taobao/weex/ui/action/IExecutable.java | 25 -
.../weex/ui/action/UpdateComponentDataAction.java | 70 -
.../weex/ui/animation/BackgroundColorProperty.java | 66 -
.../weex/ui/animation/CameraDistanceProperty.java | 54 -
.../taobao/weex/ui/animation/HeightProperty.java | 35 -
.../weex/ui/animation/LayoutParamsProperty.java | 64 -
.../taobao/weex/ui/animation/TransformParser.java | 310 --
.../taobao/weex/ui/animation/WXAnimationBean.java | 175 -
.../weex/ui/animation/WXAnimationModule.java | 66 -
.../taobao/weex/ui/animation/WidthProperty.java | 35 -
.../weex/ui/component/AbstractEditComponent.java | 1066 ------
.../taobao/weex/ui/component/AppearanceHelper.java | 121 -
.../taobao/weex/ui/component/NestedContainer.java | 51 -
.../com/taobao/weex/ui/component/Scrollable.java | 59 -
.../com/taobao/weex/ui/component/Textarea.java | 119 -
.../java/com/taobao/weex/ui/component/WXA.java | 64 -
.../taobao/weex/ui/component/WXBaseRefresh.java | 64 -
.../weex/ui/component/WXBasicComponentType.java | 59 -
.../com/taobao/weex/ui/component/WXComponent.java | 2455 -------------
.../weex/ui/component/WXComponentFactory.java | 73 -
.../taobao/weex/ui/component/WXComponentProp.java | 31 -
.../java/com/taobao/weex/ui/component/WXDiv.java | 126 -
.../java/com/taobao/weex/ui/component/WXEmbed.java | 644 ----
.../com/taobao/weex/ui/component/WXHeader.java | 57 -
.../java/com/taobao/weex/ui/component/WXImage.java | 549 ---
.../com/taobao/weex/ui/component/WXIndicator.java | 167 -
.../java/com/taobao/weex/ui/component/WXInput.java | 47 -
.../com/taobao/weex/ui/component/WXLoading.java | 114 -
.../weex/ui/component/WXLoadingIndicator.java | 81 -
.../com/taobao/weex/ui/component/WXRefresh.java | 119 -
.../com/taobao/weex/ui/component/WXScroller.java | 1048 ------
.../com/taobao/weex/ui/component/WXSlider.java | 619 ----
.../taobao/weex/ui/component/WXSliderNeighbor.java | 412 ---
.../com/taobao/weex/ui/component/WXSwitch.java | 144 -
.../java/com/taobao/weex/ui/component/WXText.java | 241 --
.../taobao/weex/ui/component/WXTextDecoration.java | 26 -
.../com/taobao/weex/ui/component/WXVContainer.java | 629 ----
.../java/com/taobao/weex/ui/component/WXVideo.java | 269 --
.../java/com/taobao/weex/ui/component/WXWeb.java | 228 --
.../weex/ui/component/basic/WXBasicComponent.java | 232 --
.../weex/ui/component/binding/AsynLayoutTask.java | 69 -
.../taobao/weex/ui/component/binding/Layouts.java | 134 -
.../weex/ui/component/binding/Statements.java | 701 ----
.../ui/component/helper/ScrollStartEndHelper.java | 153 -
.../ui/component/helper/SoftKeyboardDetector.java | 148 -
.../weex/ui/component/helper/WXStickyHelper.java | 68 -
.../ui/component/helper/WXTimeInputHelper.java | 70 -
.../weex/ui/component/list/BasicListComponent.java | 1475 --------
.../weex/ui/component/list/DefaultDragHelper.java | 173 -
.../taobao/weex/ui/component/list/DragHelper.java | 57 -
.../ui/component/list/DragSupportCallback.java | 146 -
.../weex/ui/component/list/EventTrigger.java | 25 -
.../weex/ui/component/list/GapItemDecoration.java | 81 -
.../ui/component/list/HorizontalListComponent.java | 41 -
.../weex/ui/component/list/ListComponentView.java | 35 -
.../weex/ui/component/list/RecyclerTransform.java | 90 -
.../ui/component/list/SimpleListComponent.java | 45 -
.../weex/ui/component/list/SimpleRecyclerView.java | 78 -
.../weex/ui/component/list/StickyHeaderHelper.java | 207 --
.../com/taobao/weex/ui/component/list/WXCell.java | 280 --
.../weex/ui/component/list/WXListComponent.java | 341 --
.../weex/ui/component/list/WXPagerSnapHelper.java | 75 -
.../component/list/template/AsyncCellLoadTask.java | 129 -
.../component/list/template/CellDataManager.java | 271 --
.../component/list/template/CellRenderContext.java | 79 -
.../component/list/template/CellRenderState.java | 122 -
.../ui/component/list/template/PositionRef.java | 72 -
.../weex/ui/component/list/template/Selector.java | 120 -
.../ui/component/list/template/TemplateCache.java | 32 -
.../ui/component/list/template/TemplateDom.java | 226 --
.../list/template/TemplateStickyHelper.java | 250 --
.../list/template/TemplateViewHolder.java | 79 -
.../list/template/VirtualComponentLifecycle.java | 45 -
.../list/template/WXRecyclerTemplateList.java | 2019 -----------
.../template/jni/NativeRenderLayoutDirection.java | 25 -
.../list/template/jni/NativeRenderObjectUtils.java | 79 -
.../ui/component/pesudo/OnActivePseudoListner.java | 26 -
.../weex/ui/component/pesudo/PesudoStatus.java | 131 -
.../pesudo/TouchActivePseudoListener.java | 50 -
.../weex/ui/component/richtext/WXRichText.java | 159 -
.../weex/ui/component/richtext/WXRichTextView.java | 116 -
.../weex/ui/component/richtext/node/ANode.java | 80 -
.../weex/ui/component/richtext/node/ImgNode.java | 123 -
.../ui/component/richtext/node/RichTextNode.java | 291 --
.../richtext/node/RichTextNodeCreator.java | 29 -
.../richtext/node/RichTextNodeManager.java | 73 -
.../weex/ui/component/richtext/node/SpanNode.java | 77 -
.../weex/ui/component/richtext/span/ASpan.java | 47 -
.../weex/ui/component/richtext/span/ImgSpan.java | 96 -
.../ui/component/richtext/span/ItemClickSpan.java | 51 -
.../weex/ui/config/AutoScanConfigRegister.java | 143 -
.../weex/ui/config/ConfigComponentHolder.java | 161 -
.../taobao/weex/ui/config/ConfigModuleFactory.java | 155 -
.../com/taobao/weex/ui/flat/FlatComponent.java | 35 -
.../com/taobao/weex/ui/flat/FlatGUIContext.java | 146 -
.../com/taobao/weex/ui/flat/WidgetContainer.java | 98 -
.../weex/ui/flat/widget/AndroidViewWidget.java | 80 -
.../com/taobao/weex/ui/flat/widget/BaseWidget.java | 130 -
.../com/taobao/weex/ui/flat/widget/TextWidget.java | 50 -
.../com/taobao/weex/ui/flat/widget/Widget.java | 55 -
.../taobao/weex/ui/flat/widget/WidgetGroup.java | 56 -
.../taobao/weex/ui/module/ConsoleLogModule.java | 86 -
.../taobao/weex/ui/module/WXDeviceInfoModule.java | 48 -
.../com/taobao/weex/ui/module/WXDomModule.java | 207 --
.../com/taobao/weex/ui/module/WXLocaleModule.java | 112 -
.../com/taobao/weex/ui/module/WXMetaModule.java | 115 -
.../com/taobao/weex/ui/module/WXModalUIModule.java | 264 --
.../com/taobao/weex/ui/module/WXTimerModule.java | 217 --
.../com/taobao/weex/ui/module/WXWebViewModule.java | 70 -
.../com/taobao/weex/ui/view/BaseFrameLayout.java | 79 -
.../com/taobao/weex/ui/view/IRenderResult.java | 26 -
.../com/taobao/weex/ui/view/IRenderStatus.java | 28 -
.../java/com/taobao/weex/ui/view/IWXScroller.java | 24 -
.../java/com/taobao/weex/ui/view/IWXTextView.java | 24 -
.../java/com/taobao/weex/ui/view/IWebView.java | 52 -
.../taobao/weex/ui/view/WXBaseCircleIndicator.java | 228 --
.../taobao/weex/ui/view/WXBaseRefreshLayout.java | 28 -
.../com/taobao/weex/ui/view/WXCircleIndicator.java | 29 -
.../taobao/weex/ui/view/WXCirclePageAdapter.java | 203 --
.../com/taobao/weex/ui/view/WXCircleViewPager.java | 341 --
.../java/com/taobao/weex/ui/view/WXEditText.java | 156 -
.../com/taobao/weex/ui/view/WXFrameLayout.java | 140 -
.../weex/ui/view/WXHorizontalScrollView.java | 134 -
.../java/com/taobao/weex/ui/view/WXImageView.java | 262 --
.../com/taobao/weex/ui/view/WXLoadingLayout.java | 31 -
.../com/taobao/weex/ui/view/WXRefreshLayout.java | 31 -
.../java/com/taobao/weex/ui/view/WXScrollView.java | 467 ---
.../com/taobao/weex/ui/view/WXSmoothScroller.java | 58 -
.../java/com/taobao/weex/ui/view/WXSwitchView.java | 59 -
.../java/com/taobao/weex/ui/view/WXTextView.java | 185 -
.../java/com/taobao/weex/ui/view/WXVideoView.java | 304 --
.../java/com/taobao/weex/ui/view/WXWebView.java | 376 --
.../taobao/weex/ui/view/border/BorderCorner.java | 202 --
.../taobao/weex/ui/view/border/BorderDrawable.java | 496 ---
.../com/taobao/weex/ui/view/border/BorderEdge.java | 89 -
.../weex/ui/view/border/BorderRadiusType.java | 36 -
.../taobao/weex/ui/view/border/BorderStyle.java | 65 -
.../com/taobao/weex/ui/view/border/BorderUtil.java | 46 -
.../weex/ui/view/border/BottomLeftCorner.java | 64 -
.../weex/ui/view/border/BottomRightCorner.java | 64 -
.../taobao/weex/ui/view/border/TopLeftCorner.java | 64 -
.../taobao/weex/ui/view/border/TopRightCorner.java | 64 -
.../com/taobao/weex/ui/view/gesture/WXGesture.java | 663 ----
.../weex/ui/view/gesture/WXGestureObservable.java | 49 -
.../taobao/weex/ui/view/gesture/WXGestureType.java | 71 -
.../view/listview/ExtendedLinearLayoutManager.java | 115 -
.../ExtendedStaggeredGridLayoutManager.java | 49 -
.../weex/ui/view/listview/WXRecyclerView.java | 157 -
.../view/listview/adapter/IOnLoadMoreListener.java | 27 -
.../listview/adapter/IRecyclerAdapterListener.java | 42 -
.../view/listview/adapter/ListBaseViewHolder.java | 106 -
.../listview/adapter/RecyclerViewBaseAdapter.java | 110 -
.../listview/adapter/TransformItemDecoration.java | 93 -
.../adapter/WXRecyclerViewOnScrollListener.java | 180 -
.../view/refresh/circlebar/CircleProgressBar.java | 329 --
.../circlebar/MaterialProgressDrawable.java | 797 -----
.../weex/ui/view/refresh/core/WXRefreshView.java | 149 -
.../weex/ui/view/refresh/core/WXSwipeLayout.java | 854 -----
.../ui/view/refresh/wrapper/BaseBounceView.java | 226 --
.../view/refresh/wrapper/BounceRecyclerView.java | 135 -
.../view/refresh/wrapper/BounceScrollerView.java | 51 -
.../main/java/com/taobao/weex/utils/ATagUtil.java | 42 -
.../java/com/taobao/weex/utils/BoxShadowUtil.java | 669 ----
.../main/java/com/taobao/weex/utils/FontDO.java | 185 -
.../java/com/taobao/weex/utils/FunctionParser.java | 240 --
.../java/com/taobao/weex/utils/ImageDrawable.java | 155 -
.../java/com/taobao/weex/utils/ImgURIUtil.java | 42 -
.../main/java/com/taobao/weex/utils/LogLevel.java | 57 -
.../main/java/com/taobao/weex/utils/OsVersion.java | 47 -
.../taobao/weex/utils/SingleFunctionParser.java | 83 -
.../com/taobao/weex/utils/StaticLayoutProxy.java | 78 -
.../src/main/java/com/taobao/weex/utils/Trace.java | 113 -
.../java/com/taobao/weex/utils/TypefaceUtil.java | 298 --
.../com/taobao/weex/utils/WXDataStructureUtil.java | 69 -
.../java/com/taobao/weex/utils/WXDeviceUtils.java | 54 -
.../java/com/taobao/weex/utils/WXDomUtils.java | 106 -
.../com/taobao/weex/utils/WXExceptionUtils.java | 240 --
.../java/com/taobao/weex/utils/WXFileUtils.java | 299 --
.../java/com/taobao/weex/utils/WXInterception.java | 88 -
.../java/com/taobao/weex/utils/WXJsonUtils.java | 93 -
.../java/com/taobao/weex/utils/WXLogUtils.java | 344 --
.../src/main/java/com/taobao/weex/utils/WXMap.java | 29 -
.../com/taobao/weex/utils/WXReflectionUtils.java | 142 -
.../com/taobao/weex/utils/WXResourceUtils.java | 451 ---
.../com/taobao/weex/utils/WXSoInstallMgrSdk.java | 607 ----
.../main/java/com/taobao/weex/utils/WXUtils.java | 607 ----
.../com/taobao/weex/utils/WXViewToImageUtil.java | 151 -
.../java/com/taobao/weex/utils/WXViewUtils.java | 644 ----
.../com/taobao/weex/utils/WXWsonJSONSwitch.java | 128 -
.../taobao/weex/utils/batch/BactchExecutor.java | 28 -
.../weex/utils/batch/BatchOperationHelper.java | 72 -
.../com/taobao/weex/utils/batch/Interceptor.java | 26 -
.../com/taobao/weex/utils/cache/RegisterCache.java | 181 -
.../java/com/taobao/weex/utils/tools/Info.java | 55 -
.../com/taobao/weex/utils/tools/LogDetail.java | 86 -
.../com/taobao/weex/utils/tools/LogSwitch.java | 54 -
.../java/com/taobao/weex/utils/tools/TaskInfo.java | 39 -
.../java/com/taobao/weex/utils/tools/Time.java | 83 -
.../taobao/weex/utils/tools/TimeCalculator.java | 67 -
.../src/main/java/com/taobao/weex/wson/Wson.java | 820 -----
.../main/java/com/taobao/weex/wson/WsonUtils.java | 54 -
.../java/org/apache/weex/ComponentObserver.java | 50 +
.../org/apache/weex/IWXActivityStateListener.java | 41 +
.../java/org/apache/weex/IWXRenderListener.java | 50 +
.../org/apache/weex/IWXStatisticsListener.java | 66 +
.../src/main/java/org/apache/weex/InitConfig.java | 249 ++
.../main/java/org/apache/weex/RenderContainer.java | 96 +
.../sdk/src/main/java/org/apache/weex/Script.java | 55 +
.../main/java/org/apache/weex/WXEnvironment.java | 691 ++++
.../java/org/apache/weex/WXGlobalEventModule.java | 52 +
.../org/apache/weex/WXGlobalEventReceiver.java | 57 +
.../main/java/org/apache/weex/WXHttpListener.java | 307 ++
.../src/main/java/org/apache/weex/WXSDKEngine.java | 601 ++++
.../main/java/org/apache/weex/WXSDKInstance.java | 2402 +++++++++++++
.../main/java/org/apache/weex/WXSDKManager.java | 540 +++
.../java/org/apache/weex/WeexFrameRateControl.java | 110 +
.../apache/weex/adapter/ClassLoaderAdapter.java | 55 +
.../org/apache/weex/adapter/DefaultUriAdapter.java | 98 +
.../apache/weex/adapter/DefaultWXHttpAdapter.java | 248 ++
.../org/apache/weex/adapter/DrawableStrategy.java | 27 +
.../apache/weex/adapter/ICrashInfoReporter.java | 27 +
.../org/apache/weex/adapter/IDrawableLoader.java | 41 +
.../org/apache/weex/adapter/ITracingAdapter.java | 31 +
.../weex/adapter/IWXAccessibilityRoleAdapter.java | 27 +
.../org/apache/weex/adapter/IWXConfigAdapter.java | 27 +
.../org/apache/weex/adapter/IWXHttpAdapter.java | 68 +
.../apache/weex/adapter/IWXImgLoaderAdapter.java | 32 +
.../apache/weex/adapter/IWXJSExceptionAdapter.java | 32 +
.../weex/adapter/IWXJsFileLoaderAdapter.java | 25 +
.../apache/weex/adapter/IWXJscProcessManager.java | 29 +
.../apache/weex/adapter/IWXSoLoaderAdapter.java | 50 +
.../apache/weex/adapter/IWXUserTrackAdapter.java | 56 +
.../java/org/apache/weex/adapter/URIAdapter.java | 80 +
.../java/org/apache/weex/annotation/Component.java | 33 +
.../java/org/apache/weex/annotation/JSMethod.java | 39 +
.../weex/appfram/clipboard/IWXClipboard.java | 31 +
.../weex/appfram/clipboard/WXClipboardModule.java | 148 +
.../appfram/navigator/IActivityNavBarSetter.java | 44 +
.../apache/weex/appfram/navigator/INavigator.java | 31 +
.../weex/appfram/navigator/WXNavigatorModule.java | 365 ++
.../weex/appfram/pickers/DatePickerImpl.java | 198 ++
.../weex/appfram/pickers/WXPickersModule.java | 310 ++
.../weex/appfram/storage/DefaultWXStorage.java | 335 ++
.../apache/weex/appfram/storage/IWXStorage.java | 32 +
.../weex/appfram/storage/IWXStorageAdapter.java | 53 +
.../weex/appfram/storage/StorageResultHandler.java | 107 +
.../weex/appfram/storage/WXSQLiteOpenHelper.java | 227 ++
.../weex/appfram/storage/WXStorageModule.java | 181 +
.../weex/appfram/websocket/IWebSocketAdapter.java | 48 +
.../websocket/IWebSocketAdapterFactory.java | 27 +
.../appfram/websocket/WebSocketCloseCodes.java | 51 +
.../weex/appfram/websocket/WebSocketModule.java | 188 +
.../java/org/apache/weex/base/CalledByNative.java | 22 +
.../main/java/org/apache/weex/base/FloatUtil.java | 31 +
.../org/apache/weex/base/SystemMessageHandler.java | 105 +
.../java/org/apache/weex/bridge/EventResult.java | 46 +
.../main/java/org/apache/weex/bridge/Invoker.java | 33 +
.../java/org/apache/weex/bridge/JSCallback.java | 36 +
.../apache/weex/bridge/JavascriptInvokable.java | 28 +
.../java/org/apache/weex/bridge/MethodInvoker.java | 66 +
.../java/org/apache/weex/bridge/ModuleFactory.java | 29 +
.../org/apache/weex/bridge/ModuleFactoryImpl.java | 37 +
.../org/apache/weex/bridge/NativeInvokeHelper.java | 124 +
.../org/apache/weex/bridge/RequestHandler.java | 154 +
.../org/apache/weex/bridge/ResultCallback.java | 23 +
.../apache/weex/bridge/ResultCallbackManager.java | 48 +
.../org/apache/weex/bridge/SimpleJSCallback.java | 61 +
.../main/java/org/apache/weex/bridge/WXBridge.java | 935 +++++
.../org/apache/weex/bridge/WXBridgeManager.java | 3647 ++++++++++++++++++++
.../org/apache/weex/bridge/WXDebugJsBridge.java | 101 +
.../java/org/apache/weex/bridge/WXHashMap.java | 90 +
.../java/org/apache/weex/bridge/WXJSObject.java | 72 +
.../org/apache/weex/bridge/WXModuleManager.java | 534 +++
.../main/java/org/apache/weex/bridge/WXParams.java | 290 ++
.../org/apache/weex/bridge/WXServiceManager.java | 98 +
.../main/java/org/apache/weex/bridge/WXTask.java | 45 +
.../apache/weex/bridge/WXValidateProcessor.java | 58 +
.../java/org/apache/weex/common/Constants.java | 388 +++
.../java/org/apache/weex/common/Destroyable.java | 26 +
.../apache/weex/common/ICheckBindingScroller.java | 27 +
.../java/org/apache/weex/common/IWXBridge.java | 234 ++
.../org/apache/weex/common/IWXDebugConfig.java | 29 +
.../java/org/apache/weex/common/IWXObject.java | 23 +
.../org/apache/weex/common/OnWXScrollListener.java | 56 +
.../java/org/apache/weex/common/RenderTypes.java | 27 +
.../org/apache/weex/common/TypeModuleFactory.java | 98 +
.../org/apache/weex/common/WXCompatModule.java | 84 +
.../main/java/org/apache/weex/common/WXConfig.java | 44 +
.../java/org/apache/weex/common/WXErrorCode.java | 339 ++
.../java/org/apache/weex/common/WXException.java | 28 +
.../org/apache/weex/common/WXImageSharpen.java | 24 +
.../org/apache/weex/common/WXImageStrategy.java | 83 +
.../org/apache/weex/common/WXInstanceWrap.java | 41 +
.../org/apache/weex/common/WXJSBridgeMsgType.java | 38 +
.../org/apache/weex/common/WXJSEngineListener.java | 36 +
.../org/apache/weex/common/WXJSExceptionInfo.java | 142 +
.../java/org/apache/weex/common/WXJSService.java | 43 +
.../main/java/org/apache/weex/common/WXModule.java | 137 +
.../java/org/apache/weex/common/WXModuleAnno.java | 37 +
.../java/org/apache/weex/common/WXPerformance.java | 569 +++
.../java/org/apache/weex/common/WXRefreshData.java | 31 +
.../org/apache/weex/common/WXRenderStrategy.java | 39 +
.../java/org/apache/weex/common/WXRequest.java | 60 +
.../org/apache/weex/common/WXRequestListener.java | 27 +
.../java/org/apache/weex/common/WXResponse.java | 56 +
.../org/apache/weex/common/WXRuntimeException.java | 28 +
.../main/java/org/apache/weex/common/WXThread.java | 201 ++
.../apache/weex/common/WXWorkThreadManager.java | 56 +
.../java/org/apache/weex/dom/CSSConstants.java | 28 +
.../java/org/apache/weex/dom/CSSShorthand.java | 120 +
.../java/org/apache/weex/dom/RenderContext.java | 32 +
.../org/apache/weex/dom/TextDecorationSpan.java | 55 +
.../src/main/java/org/apache/weex/dom/WXAttr.java | 590 ++++
.../org/apache/weex/dom/WXCustomStyleSpan.java | 68 +
.../src/main/java/org/apache/weex/dom/WXEvent.java | 187 +
.../java/org/apache/weex/dom/WXImageQuality.java | 32 +
.../java/org/apache/weex/dom/WXLineHeightSpan.java | 46 +
.../src/main/java/org/apache/weex/dom/WXStyle.java | 558 +++
.../java/org/apache/weex/dom/binding/ELUtils.java | 127 +
.../org/apache/weex/dom/binding/JSONUtils.java | 51 +
.../org/apache/weex/dom/binding/WXStatement.java | 83 +
.../apache/weex/dom/transition/WXTransition.java | 757 ++++
.../java/org/apache/weex/el/parse/ArrayStack.java | 72 +
.../main/java/org/apache/weex/el/parse/Block.java | 71 +
.../java/org/apache/weex/el/parse/Operator.java | 106 +
.../java/org/apache/weex/el/parse/Operators.java | 502 +++
.../main/java/org/apache/weex/el/parse/Parser.java | 486 +++
.../main/java/org/apache/weex/el/parse/Symbol.java | 38 +
.../main/java/org/apache/weex/el/parse/Token.java | 89 +
.../java/org/apache/weex/font/FontAdapter.java | 56 +
.../java/org/apache/weex/font/FontListener.java | 26 +
.../main/java/org/apache/weex/http/Options.java | 138 +
.../src/main/java/org/apache/weex/http/Status.java | 94 +
.../main/java/org/apache/weex/http/WXHttpUtil.java | 67 +
.../java/org/apache/weex/http/WXStreamModule.java | 381 ++
.../instance/InstanceOnFireEventInterceptor.java | 57 +
.../apache/weex/layout/ContentBoxMeasurement.java | 77 +
.../java/org/apache/weex/layout/MeasureMode.java | 29 +
.../java/org/apache/weex/layout/MeasureSize.java | 42 +
.../measurefunc/TextContentBoxMeasurement.java | 493 +++
.../org/apache/weex/performance/IApmGenerator.java | 27 +
.../org/apache/weex/performance/IWXAnalyzer.java | 35 +
.../weex/performance/IWXApmMonitorAdapter.java | 82 +
.../weex/performance/WXAnalyzerDataTransfer.java | 167 +
.../org/apache/weex/performance/WXInstanceApm.java | 683 ++++
.../org/apache/weex/performance/WXStateRecord.java | 203 ++
.../apache/weex/performance/WhiteScreenUtils.java | 176 +
.../weex/render/WXAbstractRenderContainer.java | 82 +
.../java/org/apache/weex/tracing/Stopwatch.java | 132 +
.../java/org/apache/weex/tracing/WXTracing.java | 129 +
.../java/org/apache/weex/ui/ComponentCreator.java | 33 +
.../weex/ui/ExternalLoaderComponentHolder.java | 103 +
.../apache/weex/ui/IExternalComponentGetter.java | 29 +
.../org/apache/weex/ui/IExternalModuleGetter.java | 30 +
.../java/org/apache/weex/ui/IFComponentHolder.java | 34 +
.../java/org/apache/weex/ui/RenderContextImpl.java | 77 +
.../org/apache/weex/ui/SimpleComponentHolder.java | 235 ++
.../org/apache/weex/ui/WXComponentRegistry.java | 145 +
.../java/org/apache/weex/ui/WXRenderHandler.java | 42 +
.../java/org/apache/weex/ui/WXRenderManager.java | 311 ++
.../org/apache/weex/ui/action/ActionAddRule.java | 87 +
.../weex/ui/action/ActionGetComponentRect.java | 120 +
.../weex/ui/action/ActionGetLayoutDirection.java | 118 +
.../apache/weex/ui/action/ActionInvokeMethod.java | 55 +
.../apache/weex/ui/action/ActionReloadPage.java | 49 +
.../apache/weex/ui/action/BasicComponentData.java | 310 ++
.../apache/weex/ui/action/BasicGraphicAction.java | 79 +
.../ui/action/GraphicActionAbstractAddElement.java | 102 +
.../ui/action/GraphicActionAddChildToRichtext.java | 46 +
.../weex/ui/action/GraphicActionAddElement.java | 212 ++
.../weex/ui/action/GraphicActionAddEvent.java | 54 +
.../weex/ui/action/GraphicActionAnimation.java | 288 ++
.../GraphicActionAppendTreeCreateFinish.java | 46 +
.../weex/ui/action/GraphicActionBatchAction.java | 41 +
.../weex/ui/action/GraphicActionBatchBegin.java | 34 +
.../weex/ui/action/GraphicActionBatchEnd.java | 34 +
.../weex/ui/action/GraphicActionCreateBody.java | 92 +
.../weex/ui/action/GraphicActionCreateFinish.java | 72 +
.../apache/weex/ui/action/GraphicActionLayout.java | 50 +
.../weex/ui/action/GraphicActionMoveElement.java | 71 +
.../weex/ui/action/GraphicActionRefreshFinish.java | 52 +
.../GraphicActionRemoveChildFromRichtext.java | 42 +
.../weex/ui/action/GraphicActionRemoveElement.java | 66 +
.../weex/ui/action/GraphicActionRemoveEvent.java | 51 +
.../weex/ui/action/GraphicActionRenderSuccess.java | 48 +
.../ui/action/GraphicActionScrollToElement.java | 53 +
.../weex/ui/action/GraphicActionUpdateAttr.java | 54 +
.../ui/action/GraphicActionUpdateRichtextAttr.java | 43 +
.../action/GraphicActionUpdateRichtextStyle.java | 44 +
.../weex/ui/action/GraphicActionUpdateStyle.java | 142 +
.../org/apache/weex/ui/action/GraphicPosition.java | 74 +
.../org/apache/weex/ui/action/GraphicSize.java | 51 +
.../org/apache/weex/ui/action/IExecutable.java | 25 +
.../weex/ui/action/UpdateComponentDataAction.java | 71 +
.../weex/ui/animation/BackgroundColorProperty.java | 66 +
.../weex/ui/animation/CameraDistanceProperty.java | 54 +
.../apache/weex/ui/animation/HeightProperty.java | 35 +
.../weex/ui/animation/LayoutParamsProperty.java | 64 +
.../apache/weex/ui/animation/TransformParser.java | 310 ++
.../apache/weex/ui/animation/WXAnimationBean.java | 169 +
.../weex/ui/animation/WXAnimationModule.java | 65 +
.../apache/weex/ui/animation/WidthProperty.java | 35 +
.../weex/ui/component/AbstractEditComponent.java | 1064 ++++++
.../apache/weex/ui/component/AppearanceHelper.java | 120 +
.../apache/weex/ui/component/NestedContainer.java | 51 +
.../org/apache/weex/ui/component/Scrollable.java | 60 +
.../org/apache/weex/ui/component/Textarea.java | 119 +
.../java/org/apache/weex/ui/component/WXA.java | 64 +
.../apache/weex/ui/component/WXBaseRefresh.java | 64 +
.../weex/ui/component/WXBasicComponentType.java | 59 +
.../org/apache/weex/ui/component/WXComponent.java | 2459 +++++++++++++
.../weex/ui/component/WXComponentFactory.java | 67 +
.../apache/weex/ui/component/WXComponentProp.java | 31 +
.../java/org/apache/weex/ui/component/WXDiv.java | 122 +
.../java/org/apache/weex/ui/component/WXEmbed.java | 646 ++++
.../org/apache/weex/ui/component/WXHeader.java | 57 +
.../java/org/apache/weex/ui/component/WXImage.java | 549 +++
.../org/apache/weex/ui/component/WXIndicator.java | 167 +
.../java/org/apache/weex/ui/component/WXInput.java | 47 +
.../org/apache/weex/ui/component/WXLoading.java | 114 +
.../weex/ui/component/WXLoadingIndicator.java | 81 +
.../org/apache/weex/ui/component/WXRefresh.java | 119 +
.../org/apache/weex/ui/component/WXScroller.java | 1048 ++++++
.../org/apache/weex/ui/component/WXSlider.java | 619 ++++
.../apache/weex/ui/component/WXSliderNeighbor.java | 412 +++
.../org/apache/weex/ui/component/WXSwitch.java | 143 +
.../java/org/apache/weex/ui/component/WXText.java | 241 ++
.../apache/weex/ui/component/WXTextDecoration.java | 26 +
.../org/apache/weex/ui/component/WXVContainer.java | 629 ++++
.../java/org/apache/weex/ui/component/WXVideo.java | 270 ++
.../java/org/apache/weex/ui/component/WXWeb.java | 228 ++
.../weex/ui/component/basic/WXBasicComponent.java | 231 ++
.../weex/ui/component/binding/AsynLayoutTask.java | 69 +
.../apache/weex/ui/component/binding/Layouts.java | 133 +
.../weex/ui/component/binding/Statements.java | 702 ++++
.../ui/component/helper/ScrollStartEndHelper.java | 154 +
.../ui/component/helper/SoftKeyboardDetector.java | 148 +
.../weex/ui/component/helper/WXStickyHelper.java | 67 +
.../ui/component/helper/WXTimeInputHelper.java | 70 +
.../weex/ui/component/list/BasicListComponent.java | 1475 ++++++++
.../weex/ui/component/list/DefaultDragHelper.java | 173 +
.../apache/weex/ui/component/list/DragHelper.java | 57 +
.../ui/component/list/DragSupportCallback.java | 146 +
.../weex/ui/component/list/EventTrigger.java | 25 +
.../weex/ui/component/list/GapItemDecoration.java | 81 +
.../ui/component/list/HorizontalListComponent.java | 41 +
.../weex/ui/component/list/ListComponentView.java | 35 +
.../weex/ui/component/list/RecyclerTransform.java | 90 +
.../ui/component/list/SimpleListComponent.java | 45 +
.../weex/ui/component/list/SimpleRecyclerView.java | 72 +
.../weex/ui/component/list/StickyHeaderHelper.java | 206 ++
.../org/apache/weex/ui/component/list/WXCell.java | 279 ++
.../weex/ui/component/list/WXListComponent.java | 341 ++
.../weex/ui/component/list/WXPagerSnapHelper.java | 75 +
.../component/list/template/AsyncCellLoadTask.java | 129 +
.../component/list/template/CellDataManager.java | 271 ++
.../component/list/template/CellRenderContext.java | 79 +
.../component/list/template/CellRenderState.java | 122 +
.../ui/component/list/template/PositionRef.java | 71 +
.../weex/ui/component/list/template/Selector.java | 119 +
.../ui/component/list/template/TemplateCache.java | 32 +
.../ui/component/list/template/TemplateDom.java | 227 ++
.../list/template/TemplateStickyHelper.java | 250 ++
.../list/template/TemplateViewHolder.java | 79 +
.../list/template/VirtualComponentLifecycle.java | 45 +
.../list/template/WXRecyclerTemplateList.java | 2019 +++++++++++
.../template/jni/NativeRenderLayoutDirection.java | 25 +
.../list/template/jni/NativeRenderObjectUtils.java | 77 +
.../ui/component/pesudo/OnActivePseudoListner.java | 26 +
.../weex/ui/component/pesudo/PesudoStatus.java | 132 +
.../pesudo/TouchActivePseudoListener.java | 50 +
.../weex/ui/component/richtext/WXRichText.java | 160 +
.../weex/ui/component/richtext/WXRichTextView.java | 116 +
.../weex/ui/component/richtext/node/ANode.java | 78 +
.../weex/ui/component/richtext/node/ImgNode.java | 121 +
.../ui/component/richtext/node/RichTextNode.java | 289 ++
.../richtext/node/RichTextNodeCreator.java | 29 +
.../richtext/node/RichTextNodeManager.java | 73 +
.../weex/ui/component/richtext/node/SpanNode.java | 75 +
.../weex/ui/component/richtext/span/ASpan.java | 47 +
.../weex/ui/component/richtext/span/ImgSpan.java | 96 +
.../ui/component/richtext/span/ItemClickSpan.java | 51 +
.../weex/ui/config/AutoScanConfigRegister.java | 141 +
.../weex/ui/config/ConfigComponentHolder.java | 162 +
.../apache/weex/ui/config/ConfigModuleFactory.java | 155 +
.../org/apache/weex/ui/flat/FlatComponent.java | 35 +
.../org/apache/weex/ui/flat/FlatGUIContext.java | 146 +
.../org/apache/weex/ui/flat/WidgetContainer.java | 98 +
.../weex/ui/flat/widget/AndroidViewWidget.java | 80 +
.../org/apache/weex/ui/flat/widget/BaseWidget.java | 130 +
.../org/apache/weex/ui/flat/widget/TextWidget.java | 50 +
.../org/apache/weex/ui/flat/widget/Widget.java | 55 +
.../apache/weex/ui/flat/widget/WidgetGroup.java | 56 +
.../apache/weex/ui/module/ConsoleLogModule.java | 85 +
.../apache/weex/ui/module/WXDeviceInfoModule.java | 46 +
.../org/apache/weex/ui/module/WXDomModule.java | 207 ++
.../org/apache/weex/ui/module/WXLocaleModule.java | 112 +
.../org/apache/weex/ui/module/WXMetaModule.java | 115 +
.../org/apache/weex/ui/module/WXModalUIModule.java | 264 ++
.../org/apache/weex/ui/module/WXTimerModule.java | 216 ++
.../org/apache/weex/ui/module/WXWebViewModule.java | 70 +
.../org/apache/weex/ui/view/BaseFrameLayout.java | 79 +
.../org/apache/weex/ui/view/IRenderResult.java | 26 +
.../org/apache/weex/ui/view/IRenderStatus.java | 28 +
.../java/org/apache/weex/ui/view/IWXScroller.java | 24 +
.../java/org/apache/weex/ui/view/IWXTextView.java | 24 +
.../java/org/apache/weex/ui/view/IWebView.java | 52 +
.../apache/weex/ui/view/WXBaseCircleIndicator.java | 228 ++
.../apache/weex/ui/view/WXBaseRefreshLayout.java | 28 +
.../org/apache/weex/ui/view/WXCircleIndicator.java | 29 +
.../apache/weex/ui/view/WXCirclePageAdapter.java | 203 ++
.../org/apache/weex/ui/view/WXCircleViewPager.java | 341 ++
.../java/org/apache/weex/ui/view/WXEditText.java | 156 +
.../org/apache/weex/ui/view/WXFrameLayout.java | 141 +
.../weex/ui/view/WXHorizontalScrollView.java | 135 +
.../java/org/apache/weex/ui/view/WXImageView.java | 262 ++
.../org/apache/weex/ui/view/WXLoadingLayout.java | 31 +
.../org/apache/weex/ui/view/WXRefreshLayout.java | 31 +
.../java/org/apache/weex/ui/view/WXScrollView.java | 467 +++
.../org/apache/weex/ui/view/WXSmoothScroller.java | 58 +
.../java/org/apache/weex/ui/view/WXSwitchView.java | 59 +
.../java/org/apache/weex/ui/view/WXTextView.java | 185 +
.../java/org/apache/weex/ui/view/WXVideoView.java | 304 ++
.../java/org/apache/weex/ui/view/WXWebView.java | 376 ++
.../apache/weex/ui/view/border/BorderCorner.java | 201 ++
.../apache/weex/ui/view/border/BorderDrawable.java | 490 +++
.../org/apache/weex/ui/view/border/BorderEdge.java | 88 +
.../weex/ui/view/border/BorderRadiusType.java | 36 +
.../apache/weex/ui/view/border/BorderStyle.java | 65 +
.../org/apache/weex/ui/view/border/BorderUtil.java | 45 +
.../weex/ui/view/border/BottomLeftCorner.java | 64 +
.../weex/ui/view/border/BottomRightCorner.java | 64 +
.../apache/weex/ui/view/border/TopLeftCorner.java | 64 +
.../apache/weex/ui/view/border/TopRightCorner.java | 64 +
.../org/apache/weex/ui/view/gesture/WXGesture.java | 662 ++++
.../weex/ui/view/gesture/WXGestureObservable.java | 49 +
.../apache/weex/ui/view/gesture/WXGestureType.java | 71 +
.../view/listview/ExtendedLinearLayoutManager.java | 115 +
.../ExtendedStaggeredGridLayoutManager.java | 49 +
.../weex/ui/view/listview/WXRecyclerView.java | 157 +
.../view/listview/adapter/IOnLoadMoreListener.java | 27 +
.../listview/adapter/IRecyclerAdapterListener.java | 42 +
.../view/listview/adapter/ListBaseViewHolder.java | 106 +
.../listview/adapter/RecyclerViewBaseAdapter.java | 110 +
.../listview/adapter/TransformItemDecoration.java | 93 +
.../adapter/WXRecyclerViewOnScrollListener.java | 180 +
.../view/refresh/circlebar/CircleProgressBar.java | 329 ++
.../circlebar/MaterialProgressDrawable.java | 797 +++++
.../weex/ui/view/refresh/core/WXRefreshView.java | 149 +
.../weex/ui/view/refresh/core/WXSwipeLayout.java | 854 +++++
.../ui/view/refresh/wrapper/BaseBounceView.java | 226 ++
.../view/refresh/wrapper/BounceRecyclerView.java | 135 +
.../view/refresh/wrapper/BounceScrollerView.java | 51 +
.../main/java/org/apache/weex/utils/ATagUtil.java | 42 +
.../java/org/apache/weex/utils/BoxShadowUtil.java | 669 ++++
.../main/java/org/apache/weex/utils/FontDO.java | 185 +
.../java/org/apache/weex/utils/FunctionParser.java | 240 ++
.../java/org/apache/weex/utils/ImageDrawable.java | 155 +
.../java/org/apache/weex/utils/ImgURIUtil.java | 42 +
.../main/java/org/apache/weex/utils/LogLevel.java | 57 +
.../main/java/org/apache/weex/utils/OsVersion.java | 47 +
.../apache/weex/utils/SingleFunctionParser.java | 83 +
.../org/apache/weex/utils/StaticLayoutProxy.java | 78 +
.../src/main/java/org/apache/weex/utils/Trace.java | 113 +
.../java/org/apache/weex/utils/TypefaceUtil.java | 297 ++
.../org/apache/weex/utils/WXDataStructureUtil.java | 69 +
.../java/org/apache/weex/utils/WXDeviceUtils.java | 54 +
.../java/org/apache/weex/utils/WXDomUtils.java | 105 +
.../org/apache/weex/utils/WXExceptionUtils.java | 240 ++
.../java/org/apache/weex/utils/WXFileUtils.java | 299 ++
.../java/org/apache/weex/utils/WXInterception.java | 88 +
.../java/org/apache/weex/utils/WXJsonUtils.java | 93 +
.../java/org/apache/weex/utils/WXLogUtils.java | 338 ++
.../src/main/java/org/apache/weex/utils/WXMap.java | 29 +
.../org/apache/weex/utils/WXReflectionUtils.java | 142 +
.../org/apache/weex/utils/WXResourceUtils.java | 451 +++
.../org/apache/weex/utils/WXSoInstallMgrSdk.java | 607 ++++
.../main/java/org/apache/weex/utils/WXUtils.java | 607 ++++
.../org/apache/weex/utils/WXViewToImageUtil.java | 151 +
.../java/org/apache/weex/utils/WXViewUtils.java | 644 ++++
.../org/apache/weex/utils/WXWsonJSONSwitch.java | 128 +
.../apache/weex/utils/batch/BactchExecutor.java | 28 +
.../weex/utils/batch/BatchOperationHelper.java | 68 +
.../org/apache/weex/utils/batch/Interceptor.java | 26 +
.../org/apache/weex/utils/cache/RegisterCache.java | 181 +
.../java/org/apache/weex/utils/tools/Info.java | 55 +
.../org/apache/weex/utils/tools/LogDetail.java | 86 +
.../org/apache/weex/utils/tools/LogSwitch.java | 54 +
.../java/org/apache/weex/utils/tools/TaskInfo.java | 39 +
.../java/org/apache/weex/utils/tools/Time.java | 83 +
.../apache/weex/utils/tools/TimeCalculator.java | 67 +
.../src/main/java/org/apache/weex/wson/Wson.java | 820 +++++
.../main/java/org/apache/weex/wson/WsonUtils.java | 54 +
.../test/java/com/taobao/weex/TestActivity.java | 29 -
.../test/java/com/taobao/weex/TestApplication.java | 27 -
.../test/java/com/taobao/weex/WXSDKEngineTest.java | 108 -
.../java/com/taobao/weex/WXSDKInstanceTest.java | 198 --
.../java/com/taobao/weex/WXSDKManagerTest.java | 49 -
.../taobao/weex/adapter/DefaultUriAdapterTest.java | 116 -
.../appfram/clipboard/WXClipboardModuleTest.java | 75 -
.../appfram/navigator/WXNavigatorModuleTest.java | 174 -
.../weex/appfram/storage/DefaultWXStorageTest.java | 107 -
.../weex/appfram/storage/WXStorageModuleTest.java | 130 -
.../taobao/weex/bridge/WXBridgeManagerTest.java | 168 -
.../java/com/taobao/weex/bridge/WXBridgeTest.java | 77 -
.../java/com/taobao/weex/bridge/WXHashMapTest.java | 85 -
.../taobao/weex/bridge/WXModuleManagerTest.java | 103 -
.../java/com/taobao/weex/common/TestModule.java | 44 -
.../com/taobao/weex/common/TestModuleFactory.java | 37 -
.../java/com/taobao/weex/common/WXModuleTest.java | 28 -
.../test/java/com/taobao/weex/dom/WXAttrTest.java | 137 -
.../java/com/taobao/weex/dom/WXDomManagerTest.java | 69 -
.../com/taobao/weex/dom/WXDomStatementTest.java | 292 --
.../test/java/com/taobao/weex/dom/WXStyleTest.java | 138 -
.../com/taobao/weex/dom/WXTextDomObjectTest.java | 87 -
.../com/taobao/weex/http/WXStreamModuleTest.java | 188 -
.../com/taobao/weex/ui/ComponentHolderTest.java | 66 -
.../com/taobao/weex/ui/WXRenderStatementTest.java | 137 -
.../weex/ui/animation/WXAnimationModuleTest.java | 61 -
.../taobao/weex/ui/component/ComponentTest.java | 94 -
.../weex/ui/component/EditComponentTest.java | 136 -
.../taobao/weex/ui/component/TestComponent.java | 35 -
.../taobao/weex/ui/component/TestConstants.java | 36 -
.../com/taobao/weex/ui/component/TextareaTest.java | 69 -
.../taobao/weex/ui/component/WXComponentTest.java | 114 -
.../com/taobao/weex/ui/component/WXDivTest.java | 120 -
.../com/taobao/weex/ui/component/WXEmbedTest.java | 69 -
.../com/taobao/weex/ui/component/WXHeaderTest.java | 35 -
.../com/taobao/weex/ui/component/WXImageTest.java | 155 -
.../taobao/weex/ui/component/WXLoadingTest.java | 70 -
.../taobao/weex/ui/component/WXRefreshTest.java | 74 -
.../taobao/weex/ui/component/WXScrollerTest.java | 80 -
.../weex/ui/component/WXSliderNeighborTest.java | 101 -
.../com/taobao/weex/ui/component/WXSliderTest.java | 151 -
.../com/taobao/weex/ui/component/WXSwitchTest.java | 72 -
.../com/taobao/weex/ui/component/WXTextTest.java | 161 -
.../com/taobao/weex/ui/component/WXVideoTest.java | 80 -
.../com/taobao/weex/ui/component/WXWebTest.java | 174 -
.../ui/component/helper/WXTimeInputHelperTest.java | 68 -
.../ui/component/list/DefaultDragHelperTest.java | 129 -
.../ui/component/list/WXListComponentTest.java | 123 -
.../taobao/weex/ui/module/WXMetaModuleTest.java | 77 -
.../taobao/weex/ui/module/WXModalUIModuleTest.java | 80 -
.../taobao/weex/ui/module/WXTimerModuleTest.java | 197 --
.../taobao/weex/ui/module/WXWebViewModuleTest.java | 65 -
.../weex/ui/view/WXCirclePageAdapterTest.java | 107 -
.../com/taobao/weex/ui/view/WXScrollViewTest.java | 87 -
.../com/taobao/weex/ui/view/WXWebViewTest.java | 128 -
.../weex/ui/view/border/BorderCornerTest.java | 320 --
.../weex/ui/view/border/BorderDrawableTest.java | 377 --
.../taobao/weex/ui/view/gesture/WXGestureTest.java | 77 -
.../com/taobao/weex/utils/FunctionParserTest.java | 40 -
.../com/taobao/weex/utils/TypefaceUtilTest.java | 51 -
.../com/taobao/weex/utils/WXFileUtilsTest.java | 65 -
.../com/taobao/weex/utils/WXJsonUtilsTest.java | 100 -
.../java/com/taobao/weex/utils/WXLogUtilsTest.java | 95 -
.../taobao/weex/utils/WXReflectionUtilsTest.java | 126 -
.../com/taobao/weex/utils/WXResourceUtilsTest.java | 145 -
.../java/com/taobao/weex/utils/WXUtilsTest.java | 184 -
.../test/java/org/apache/weex/TestActivity.java | 29 +
.../test/java/org/apache/weex/TestApplication.java | 27 +
.../test/java/org/apache/weex/WXSDKEngineTest.java | 108 +
.../java/org/apache/weex/WXSDKInstanceTest.java | 198 ++
.../java/org/apache/weex/WXSDKManagerTest.java | 47 +
.../apache/weex/adapter/DefaultUriAdapterTest.java | 116 +
.../appfram/clipboard/WXClipboardModuleTest.java | 72 +
.../appfram/navigator/WXNavigatorModuleTest.java | 169 +
.../weex/appfram/storage/DefaultWXStorageTest.java | 107 +
.../weex/appfram/storage/WXStorageModuleTest.java | 130 +
.../apache/weex/bridge/WXBridgeManagerTest.java | 168 +
.../java/org/apache/weex/bridge/WXBridgeTest.java | 75 +
.../java/org/apache/weex/bridge/WXHashMapTest.java | 85 +
.../apache/weex/bridge/WXModuleManagerTest.java | 100 +
.../java/org/apache/weex/common/TestModule.java | 44 +
.../org/apache/weex/common/TestModuleFactory.java | 32 +
.../java/org/apache/weex/common/WXModuleTest.java | 28 +
.../test/java/org/apache/weex/dom/WXAttrTest.java | 135 +
.../java/org/apache/weex/dom/WXDomManagerTest.java | 66 +
.../org/apache/weex/dom/WXDomStatementTest.java | 292 ++
.../test/java/org/apache/weex/dom/WXStyleTest.java | 138 +
.../org/apache/weex/dom/WXTextDomObjectTest.java | 86 +
.../org/apache/weex/http/WXStreamModuleTest.java | 177 +
.../org/apache/weex/ui/ComponentHolderTest.java | 66 +
.../org/apache/weex/ui/WXRenderStatementTest.java | 137 +
.../weex/ui/animation/WXAnimationModuleTest.java | 61 +
.../apache/weex/ui/component/ComponentTest.java | 94 +
.../weex/ui/component/EditComponentTest.java | 135 +
.../apache/weex/ui/component/TestComponent.java | 35 +
.../apache/weex/ui/component/TestConstants.java | 36 +
.../org/apache/weex/ui/component/TextareaTest.java | 67 +
.../apache/weex/ui/component/WXComponentTest.java | 114 +
.../org/apache/weex/ui/component/WXDivTest.java | 121 +
.../org/apache/weex/ui/component/WXEmbedTest.java | 69 +
.../org/apache/weex/ui/component/WXHeaderTest.java | 35 +
.../org/apache/weex/ui/component/WXImageTest.java | 156 +
.../apache/weex/ui/component/WXLoadingTest.java | 70 +
.../apache/weex/ui/component/WXRefreshTest.java | 74 +
.../apache/weex/ui/component/WXScrollerTest.java | 80 +
.../weex/ui/component/WXSliderNeighborTest.java | 102 +
.../org/apache/weex/ui/component/WXSliderTest.java | 152 +
.../org/apache/weex/ui/component/WXSwitchTest.java | 72 +
.../org/apache/weex/ui/component/WXTextTest.java | 161 +
.../org/apache/weex/ui/component/WXVideoTest.java | 80 +
.../org/apache/weex/ui/component/WXWebTest.java | 174 +
.../ui/component/helper/WXTimeInputHelperTest.java | 68 +
.../ui/component/list/DefaultDragHelperTest.java | 129 +
.../ui/component/list/WXListComponentTest.java | 123 +
.../apache/weex/ui/module/WXMetaModuleTest.java | 77 +
.../apache/weex/ui/module/WXModalUIModuleTest.java | 80 +
.../apache/weex/ui/module/WXTimerModuleTest.java | 197 ++
.../apache/weex/ui/module/WXWebViewModuleTest.java | 62 +
.../weex/ui/view/WXCirclePageAdapterTest.java | 107 +
.../org/apache/weex/ui/view/WXScrollViewTest.java | 84 +
.../org/apache/weex/ui/view/WXWebViewTest.java | 128 +
.../weex/ui/view/border/BorderCornerTest.java | 315 ++
.../weex/ui/view/border/BorderDrawableTest.java | 377 ++
.../apache/weex/ui/view/gesture/WXGestureTest.java | 77 +
.../org/apache/weex/utils/FunctionParserTest.java | 40 +
.../org/apache/weex/utils/TypefaceUtilTest.java | 49 +
.../org/apache/weex/utils/WXFileUtilsTest.java | 65 +
.../org/apache/weex/utils/WXJsonUtilsTest.java | 99 +
.../java/org/apache/weex/utils/WXLogUtilsTest.java | 95 +
.../apache/weex/utils/WXReflectionUtilsTest.java | 126 +
.../org/apache/weex/utils/WXResourceUtilsTest.java | 145 +
.../java/org/apache/weex/utils/WXUtilsTest.java | 184 +
919 files changed, 75339 insertions(+), 75484 deletions(-)
diff --git a/android/sdk/build.gradle b/android/sdk/build.gradle
index 2a9654e..6572415 100755
--- a/android/sdk/build.gradle
+++ b/android/sdk/build.gradle
@@ -298,6 +298,7 @@ install {
packaging 'aar'
name 'weex_sdk'
url siteUrl
+ //groupId 'org.apache.weex'
licenses {
license {
name 'The Apache Software License, Version 2.0'
diff --git a/android/sdk/proguard-rules.pro b/android/sdk/proguard-rules.pro
index 957227f..19b57c0 100755
--- a/android/sdk/proguard-rules.pro
+++ b/android/sdk/proguard-rules.pro
@@ -34,8 +34,8 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
--keep class com.taobao.weex.bridge.** { *; }
--keep class com.taobao.weex.layout.** { *; }
--keep class com.taobao.weex.WXSDKEngine { *; }
--keep class com.taobao.weex.base.SystemMessageHandler { *; }
--dontwarn com.taobao.weex.bridge.**
+-keep class org.apache.weex.bridge.** { *; }
+-keep class org.apache.weex.layout.** { *; }
+-keep class org.apache.weex.WXSDKEngine { *; }
+-keep class org.apache.weex.base.SystemMessageHandler { *; }
+-dontwarn org.apache.weex.bridge.**
diff --git a/android/sdk/src/main/AndroidManifest.xml b/android/sdk/src/main/AndroidManifest.xml
index 5360c0c..3c06bb4 100755
--- a/android/sdk/src/main/AndroidManifest.xml
+++ b/android/sdk/src/main/AndroidManifest.xml
@@ -18,6 +18,6 @@ specific language governing permissions and limitations
under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.taobao.weex">
+ package="org.apache.weex">
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
</manifest>
\ No newline at end of file
diff --git a/android/sdk/src/main/java/com/taobao/weex/ComponentObserver.java b/android/sdk/src/main/java/com/taobao/weex/ComponentObserver.java
deleted file mode 100644
index a2bcd09..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/ComponentObserver.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.view.View;
-
-import com.taobao.weex.ui.component.WXComponent;
-
-/**
- * Created by sospartan on 14/06/2017.
- */
-
-public interface ComponentObserver {
-
- /**
- * Called after component is create.
- * Notice: View is not created at this moment.
- * @param component
- */
- void onCreate(WXComponent component);
-
- /**
- * Called before component destroy.
- * @param component
- */
- void onPreDestory(WXComponent component);
-
- /**
- * Called when component's view is created
- * @param component
- * @param view
- */
- void onViewCreated(WXComponent component,View view);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/IWXActivityStateListener.java b/android/sdk/src/main/java/com/taobao/weex/IWXActivityStateListener.java
deleted file mode 100644
index cc2d413..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/IWXActivityStateListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-/**
- * Listener class for activity lifecycle
- */
-
-@Deprecated
-public interface IWXActivityStateListener {
-
- void onActivityCreate();
-
- void onActivityStart();
-
- void onActivityPause();
-
- void onActivityResume();
-
- void onActivityStop();
-
- void onActivityDestroy();
-
- boolean onActivityBack();
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/IWXRenderListener.java b/android/sdk/src/main/java/com/taobao/weex/IWXRenderListener.java
deleted file mode 100644
index fd78d60..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/IWXRenderListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.view.View;
-
-public interface IWXRenderListener {
-
- /**
- * If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ASYNC} is applied, this method
- * will be invoked when the rendering of first view is finish.
- * If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ONCE} is applied, this method will
- * be invoked when the rendering of the view tree is finished.
- */
- void onViewCreated(WXSDKInstance instance, View view);
-
- /**
- * Called when the render view phase of weex has finished.
- * It can be invoked at most once in the entire life of a {@link WXSDKInstance}
- */
- void onRenderSuccess(WXSDKInstance instance, int width, int height);
-
- /**
- * Callback method, called when refresh is finished
- */
- void onRefreshSuccess(WXSDKInstance instance, int width, int height);
-
- /**
- * Report exception occurred when weex instance is running. Exception <strong>may not</strong>
- * cause user-noticeable failure of weex.
- */
- void onException(WXSDKInstance instance, String errCode, String msg);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/IWXStatisticsListener.java b/android/sdk/src/main/java/com/taobao/weex/IWXStatisticsListener.java
deleted file mode 100644
index 814edae..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/IWXStatisticsListener.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-public interface IWXStatisticsListener {
- /**
- * Called when weex sdk engine begin to initialize.
- */
- void onSDKEngineInitialize();
-
- /**
- * Called when begin to load js framework.
- */
- void onJsFrameworkStart();
-
- /**
- * Called when finish loading js framework.
- */
- void onJsFrameworkReady();
-
- /**
- * Called when the render view phase of first view reached.
- */
- void onFirstView();
-
- /**
- * Called when the render view phase of first screen reached.
- */
- void onFirstScreen();
-
- /**
- * Called when to start a http request.
- */
- void onHttpStart();
-
- /**
- * Called when received a http response header data.
- */
- void onHeadersReceived();
-
- /**
- * Called when to finish a http request.
- */
- void onHttpFinish();
-
- /**
- * Called when an exception occured.
- */
- void onException(String instanceid, String errCode, String msg);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/InitConfig.java b/android/sdk/src/main/java/com/taobao/weex/InitConfig.java
deleted file mode 100644
index 053fb82..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/InitConfig.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.support.annotation.NonNull;
-import com.taobao.weex.adapter.ClassLoaderAdapter;
-import com.taobao.weex.adapter.IDrawableLoader;
-import com.taobao.weex.adapter.IWXHttpAdapter;
-import com.taobao.weex.adapter.IWXImgLoaderAdapter;
-import com.taobao.weex.adapter.IWXJSExceptionAdapter;
-import com.taobao.weex.adapter.IWXJsFileLoaderAdapter;
-import com.taobao.weex.adapter.IWXJscProcessManager;
-import com.taobao.weex.adapter.IWXSoLoaderAdapter;
-import com.taobao.weex.adapter.IWXUserTrackAdapter;
-import com.taobao.weex.adapter.URIAdapter;
-import com.taobao.weex.appfram.storage.IWXStorageAdapter;
-import com.taobao.weex.appfram.websocket.IWebSocketAdapterFactory;
-import com.taobao.weex.performance.IApmGenerator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Created by sospartan on 5/31/16.
- */
-public class InitConfig {
- private IWXHttpAdapter httpAdapter;
- private IDrawableLoader drawableLoader;
- private IWXImgLoaderAdapter imgAdapter;
- private IWXUserTrackAdapter utAdapter;
- private IWXStorageAdapter storageAdapter;
- private IWXSoLoaderAdapter soLoader;
- private URIAdapter mURIAdapter;
- private IWebSocketAdapterFactory webSocketAdapterFactory;
- private IWXJSExceptionAdapter mJSExceptionAdapter;
- private String framework;
- private ClassLoaderAdapter classLoaderAdapter;
- private IApmGenerator apmGenerater;
- private IWXJsFileLoaderAdapter jsFileLoaderAdapter;
- private IWXJscProcessManager jscProcessManager;
- private List<String> nativeLibraryList;
-
- public IWXHttpAdapter getHttpAdapter() {
- return httpAdapter;
- }
-
- public IWXImgLoaderAdapter getImgAdapter() {
- return imgAdapter;
- }
-
- public IDrawableLoader getDrawableLoader() {
- return drawableLoader;
- }
-
- public IWXUserTrackAdapter getUtAdapter() {
- return utAdapter;
- }
-
- public IWXSoLoaderAdapter getIWXSoLoaderAdapter() {
- return soLoader;
- }
-
- public String getFramework() {
- return framework;
- }
-
- public IWXStorageAdapter getStorageAdapter() {
- return storageAdapter;
- }
-
- public URIAdapter getURIAdapter() {
- return mURIAdapter;
- }
-
- public IWebSocketAdapterFactory getWebSocketAdapterFactory() {
- return webSocketAdapterFactory;
- }
-
- public ClassLoaderAdapter getClassLoaderAdapter() {
- return classLoaderAdapter;
- }
-
- public IApmGenerator getApmGenerater() {
- return apmGenerater;
- }
-
- public IWXJsFileLoaderAdapter getJsFileLoaderAdapter() {
- return jsFileLoaderAdapter;
- }
-
- public InitConfig setClassLoaderAdapter(ClassLoaderAdapter classLoaderAdapter) {
- this.classLoaderAdapter = classLoaderAdapter;
- return this;
- }
-
- public IWXJSExceptionAdapter getJSExceptionAdapter() {
- return mJSExceptionAdapter;
- }
- public IWXJscProcessManager getJscProcessManager() {
- return jscProcessManager;
- }
-
- @NonNull Iterable<String> getNativeLibraryList() {
- if(nativeLibraryList == null){
- nativeLibraryList = new LinkedList<>();
- }
- return nativeLibraryList;
- }
-
- private InitConfig() {
- }
-
- public static class Builder{
- IWXHttpAdapter httpAdapter;
- IWXImgLoaderAdapter imgAdapter;
- IDrawableLoader drawableLoader;
- IWXUserTrackAdapter utAdapter;
- IWXStorageAdapter storageAdapter;
- IWXSoLoaderAdapter soLoader;
- URIAdapter mURIAdapter;
- IWXJSExceptionAdapter mJSExceptionAdapter;
- String framework;
- IWebSocketAdapterFactory webSocketAdapterFactory;
- ClassLoaderAdapter classLoaderAdapter;
- IApmGenerator apmGenerater;
- private IWXJsFileLoaderAdapter jsFileLoaderAdapter;
- private List<String> nativeLibraryList = new LinkedList<>();
-
- public IWXJscProcessManager getJscProcessManager() {
- return jscProcessManager;
- }
-
- public Builder setJscProcessManager(IWXJscProcessManager jscProcessManager) {
- this.jscProcessManager = jscProcessManager;
- return this;
- }
-
- IWXJscProcessManager jscProcessManager;
-
- public Builder(){
-
- }
-
- public Builder setHttpAdapter(IWXHttpAdapter httpAdapter) {
- this.httpAdapter = httpAdapter;
- return this;
- }
-
- public Builder setImgAdapter(IWXImgLoaderAdapter imgAdapter) {
- this.imgAdapter = imgAdapter;
- return this;
- }
-
- public Builder setDrawableLoader(IDrawableLoader drawableLoader){
- this.drawableLoader=drawableLoader;
- return this;
- }
-
- public Builder setUtAdapter(IWXUserTrackAdapter utAdapter) {
- this.utAdapter = utAdapter;
- return this;
- }
-
- public Builder setStorageAdapter(IWXStorageAdapter storageAdapter) {
- this.storageAdapter = storageAdapter;
- return this;
- }
-
- public Builder setURIAdapter(URIAdapter URIAdapter) {
- mURIAdapter = URIAdapter;
- return this;
- }
-
- public Builder setJSExceptionAdapter(IWXJSExceptionAdapter JSExceptionAdapter) {
- mJSExceptionAdapter = JSExceptionAdapter;
- return this;
- }
-
- public Builder setSoLoader(IWXSoLoaderAdapter loader) {
- this.soLoader = loader;
- return this;
- }
-
- public Builder setFramework(String framework){
- this.framework=framework;
- return this;
- }
-
- public Builder setWebSocketAdapterFactory(IWebSocketAdapterFactory factory) {
- this.webSocketAdapterFactory = factory;
- return this;
- }
-
- public Builder setClassLoaderAdapter(ClassLoaderAdapter classLoaderAdapter) {
- this.classLoaderAdapter = classLoaderAdapter;
- return this;
- }
-
- public Builder setApmGenerater(IApmGenerator apmGenerater){
- this.apmGenerater =apmGenerater;
- return this;
- }
-
- public Builder setJsFileLoaderAdapter(IWXJsFileLoaderAdapter jsFileLoaderAdapter) {
- this.jsFileLoaderAdapter = jsFileLoaderAdapter;
- return this;
- }
-
- public Builder addNativeLibrary(String name){
- nativeLibraryList.add(name);
- return this;
- }
-
- public InitConfig build(){
- InitConfig config = new InitConfig();
- config.httpAdapter = this.httpAdapter;
- config.imgAdapter = this.imgAdapter;
- config.drawableLoader = this.drawableLoader;
- config.utAdapter = this.utAdapter;
- config.storageAdapter = this.storageAdapter;
- config.soLoader=this.soLoader;
- config.framework=this.framework;
- config.mURIAdapter = this.mURIAdapter;
- config.webSocketAdapterFactory = this.webSocketAdapterFactory;
- config.mJSExceptionAdapter=this.mJSExceptionAdapter;
- config.classLoaderAdapter = this.classLoaderAdapter;
- config.apmGenerater = this.apmGenerater;
- config.jsFileLoaderAdapter = this.jsFileLoaderAdapter;
- config.jscProcessManager = this.jscProcessManager;
- config.nativeLibraryList = this.nativeLibraryList;
- return config;
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/RenderContainer.java b/android/sdk/src/main/java/com/taobao/weex/RenderContainer.java
deleted file mode 100644
index cec6eaf..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/RenderContainer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.view.View;
-
-
-import com.taobao.weex.render.WXAbstractRenderContainer;
-
-/**
- * Created by sospartan on 08/10/2016.
- */
-
-public class RenderContainer extends WXAbstractRenderContainer implements WeexFrameRateControl.VSyncListener{
- private WeexFrameRateControl mFrameRateControl;
-
- public RenderContainer(Context context) {
- super(context);
- mFrameRateControl = new WeexFrameRateControl(this);
- }
-
- public RenderContainer(Context context, AttributeSet attrs) {
- super(context, attrs);
- mFrameRateControl = new WeexFrameRateControl(this);
- }
-
- public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mFrameRateControl = new WeexFrameRateControl(this);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- mFrameRateControl = new WeexFrameRateControl(this);
- }
-
-
-
- @Override
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (mFrameRateControl != null) {
- mFrameRateControl.start();
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (mFrameRateControl != null) {
- mFrameRateControl.stop();
- }
- }
- @Override
- public void dispatchWindowVisibilityChanged(int visibility) {
- super.dispatchWindowVisibilityChanged(visibility);
- if (visibility == View.GONE) {
- if (mFrameRateControl != null) {
- mFrameRateControl.stop();
- }
- } else if (visibility == View.VISIBLE) {
- if (mFrameRateControl != null) {
- mFrameRateControl.start();
- }
- }
- }
-
- @Override
- public void OnVSync() {
- if (mSDKInstance != null && mSDKInstance.get() != null) {
- mSDKInstance.get().OnVSync();
- }
- }
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/Script.java b/android/sdk/src/main/java/com/taobao/weex/Script.java
deleted file mode 100644
index e18bb76..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/Script.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.text.TextUtils;
-
-public class Script {
- private String mContent;
- private byte[] mBinary;
-
- public Script(String content) {
- mContent = content;
- }
-
- public Script(byte[] binary) {
- mBinary = binary;
- }
-
- public String getContent() {
- return mContent;
- }
-
- public byte[] getBinary() {
- return mBinary;
- }
-
- public int length() {
- if (mContent != null) {
- return mContent.length();
- } else if (mBinary != null){
- return mBinary.length;
- }
- return 0;
- }
-
- public boolean isEmpty() {
- return TextUtils.isEmpty(mContent) && (mBinary == null || mBinary.length == 0);
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
deleted file mode 100644
index 9d3250d..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import static android.content.Context.MODE_PRIVATE;
-
-import android.annotation.SuppressLint;
-import android.app.Application;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.graphics.Typeface;
-import android.os.Environment;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import com.taobao.weex.common.WXConfig;
-import com.taobao.weex.utils.FontDO;
-import com.taobao.weex.utils.LogLevel;
-import com.taobao.weex.utils.TypefaceUtil;
-import com.taobao.weex.utils.WXFileUtils;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXSoInstallMgrSdk;
-import com.taobao.weex.utils.WXUtils;
-import com.taobao.weex.utils.WXViewUtils;
-import dalvik.system.PathClassLoader;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class WXEnvironment {
-
- public static final String OS = "android";
- public static String SYS_VERSION = android.os.Build.VERSION.RELEASE;
- static{
- if(SYS_VERSION != null && SYS_VERSION.toUpperCase(Locale.ROOT).equals("P")){
- SYS_VERSION = "9.0.0";
- }
- if(SYS_VERSION != null && SYS_VERSION.toUpperCase(Locale.ROOT).equals("Q")){
- SYS_VERSION = "10.0.0";
- }
- }
- public static final String SYS_MODEL = android.os.Build.MODEL;
- public static final String EAGLE = "eagle";
- public static final String ENVIRONMENT = "environment";
- public static final String WEEX_CURRENT_KEY = "wx_current_url";
- /*********************
- * Global config
- ***************************/
-
- public static String JS_LIB_SDK_VERSION = BuildConfig.buildJavascriptFrameworkVersion;
-
- public static String WXSDK_VERSION = BuildConfig.buildVersion;
- public static Application sApplication;
- public static final String DEV_Id = getDevId();
- @Deprecated
- public static int sDefaultWidth = 750;
- public volatile static boolean JsFrameworkInit = false;
-
- public static final String SETTING_EXCLUDE_X86SUPPORT = "env_exclude_x86";
-
- public static boolean SETTING_FORCE_VERTICAL_SCREEN = false;
-
- /**
- * auto adjust device width for when screen size change.
- * */
- public static boolean AUTO_ADJUST_ENV_DEVICE_WIDTH = true;
-
- public static boolean AUTO_UPDATE_APPLICATION_SCREEN_SIZE = true;
-
- public static volatile boolean sUseRunTimeApi = false;
-
- /**
- * Debug model
- */
- public static boolean sDebugMode = false;
- public static final boolean sForceEnableDevTool = true;
- public static String sDebugWsUrl = "";
- public static boolean sDebugServerConnectable = false;
- public static boolean sRemoteDebugMode = false;
- public static String sRemoteDebugProxyUrl = "";
- public static boolean sDebugNetworkEventReporterEnable = false;//debugtool network switch
- public static long sJSLibInitTime = 0;
-
- public static long sSDKInitStart = 0;// init start timestamp
- public static long sSDKInitInvokeTime = 0;//time cost to invoke init method
- public static long sSDKInitExecuteTime = 0;//time cost to execute init job
- /** from init to sdk-ready **/
- public static long sSDKInitTime =0;
-
- public static long sJSFMStartListenerTime=0;
-
- /**
- * component and modules ready
- * */
- public static long sComponentsAndModulesReadyTime = 0;
-
- public static boolean sInAliWeex = false;
-
- public static LogLevel sLogLevel = LogLevel.DEBUG;
- private static boolean isApkDebug = true;
- public static boolean isPerf = false;
- private static boolean sDebugFlagInit = false;
-
- private static boolean openDebugLog = true;
-
- private static String sGlobalFontFamily;
-
- public static final String CORE_SO_NAME = "weexcore";
- public static final String CORE_JSS_SO_NAME = "weexjss";
- public static final String CORE_JSB_SO_NAME = "weexjsb";
- public static final String CORE_JST_SO_NAME = "weexjst";
- public static final String CORE_JSC_SO_NAME = "JavaScriptCore";
- private static String CORE_JSS_SO_PATH = null;
-
- public static String CORE_JSS_RUNTIME_SO_PATH = null;
-
- private static String CORE_JSS_ICU_PATH = null;
-
- private static String CORE_JSC_SO_PATH = null;
-
- public static String CORE_JSB_SO_PATH = null;
-
- private static String COPY_SO_DES_DIR = null;
-
- private static String LIB_LD_PATH = null;
-
- private static Map<String, String> options = new ConcurrentHashMap<>();
- static {
- options.put(WXConfig.os, OS);
- options.put(WXConfig.osName, OS);
- }
-
-
- public static synchronized WXDefaultSettings getWXDefaultSettings() {
- if (mWXDefaultSettings == null && getApplication() != null) {
- mWXDefaultSettings = new WXDefaultSettings(getApplication());
- }
- return mWXDefaultSettings;
- }
-
- public static synchronized String getDefaultSettingValue(String key, String defaultValue) {
- WXDefaultSettings wxDefaultSettings = getWXDefaultSettings();
- if (wxDefaultSettings == null || TextUtils.isEmpty(key)) {
- return defaultValue;
- }
- return wxDefaultSettings.getValue(key, defaultValue);
- }
-
- public static synchronized void writeDefaultSettingsValue(String key, String value) {
- WXDefaultSettings wxDefaultSettings = getWXDefaultSettings();
- if (wxDefaultSettings == null
- || TextUtils.isEmpty(key)
- || TextUtils.isEmpty(value)) {
- return;
- }
- wxDefaultSettings.saveValue(key, value);
- }
-
- private static WXDefaultSettings mWXDefaultSettings;
-
- /**
- * dynamic
- */
- public static boolean sDynamicMode = false;
- public static String sDynamicUrl = "";
-
- /**
- * Fetch system information.
- * @return map contains system information.
- */
- public static Map<String, String> getConfig() {
- Map<String, String> configs = new HashMap<>();
- configs.put(WXConfig.os, OS);
- configs.put(WXConfig.appVersion, getAppVersionName());
- configs.put(WXConfig.cacheDir, getAppCacheFile());
- configs.put(WXConfig.devId, DEV_Id);
- configs.put(WXConfig.sysVersion, SYS_VERSION);
- configs.put(WXConfig.sysModel, SYS_MODEL);
- configs.put(WXConfig.weexVersion, String.valueOf(WXSDK_VERSION));
-
- try {
- configs.put(WXConfig.layoutDirection, isLayoutDirectionRTL() ? "rtl" : "ltr");
- } catch (Exception e) {
- configs.put(WXConfig.layoutDirection, "ltr");
- }
-
- try {
- if (isApkDebugable()) {
- addCustomOptions(WXConfig.debugMode, "true");
- }
- addCustomOptions(WXConfig.scale, Float.toString(sApplication.getResources().getDisplayMetrics().density));
- addCustomOptions(WXConfig.androidStatusBarHeight, Float.toString(WXViewUtils.getStatusBarHeight(sApplication)));
- }catch (NullPointerException e){
- //There is little chance of NullPointerException as sApplication may be null.
- WXLogUtils.e("WXEnvironment scale Exception: ", e);
- }
- configs.putAll(getCustomOptions());
- if(configs.get(WXConfig.appName)==null && sApplication!=null){
- configs.put(WXConfig.appName, sApplication.getPackageName());
- }
- return configs;
- }
-
- /**
- * Get the version of the current app.
- */
- public static String getAppVersionName() {
- String versionName = "";
- PackageManager manager;
- PackageInfo info = null;
- try {
- manager = sApplication.getPackageManager();
- info = manager.getPackageInfo(sApplication.getPackageName(), 0);
- versionName = info.versionName;
- } catch (Exception e) {
- WXLogUtils.e("WXEnvironment getAppVersionName Exception: ", e);
- }
- return versionName;
- }
-
- /**
- *
- * @return string cache file
- */
- private static String getAppCacheFile() {
- String cache = "";
- try {
- cache = sApplication.getApplicationContext().getCacheDir().getPath();
- } catch (Exception e) {
- WXLogUtils.e("WXEnvironment getAppCacheFile Exception: ", e);
- }
- return cache;
- }
-
-
- /**
- * Use {@link #addCustomOptions(String, String)} to add custom options.
- * Use {@link #getCustomOptions(String)} to get custom options
- * @return
- */
- @Deprecated
- public static Map<String, String> getCustomOptions() {
- return options;
- }
-
- public static void addCustomOptions(String key, String value) {
- options.put(key, value);
- }
-
- public static String getCustomOptions(String key){
- return options.get(key);
- }
-
-
- @SuppressLint("SdCardPath")
- public static String copySoDesDir() {
- try {
- if (TextUtils.isEmpty(COPY_SO_DES_DIR)) {
- if (sApplication == null) {
- WXLogUtils.e("sApplication is null, so copy path will be null");
- return null;
- }
-
- String dirName = "/cache/weex/libs";
- File desDir = null;
- String cachePath = WXEnvironment.getApplication().getApplicationContext().getCacheDir().getPath();
-
- if (TextUtils.isEmpty(cachePath)) {
- desDir = new File(cachePath, dirName);
- } else {
- String pkgName = sApplication.getPackageName();
- String toPath = "/data/data/" + pkgName + dirName;
- desDir = new File(toPath);
- }
-
- if (!desDir.exists()) {
- desDir.mkdirs();
- }
- COPY_SO_DES_DIR = desDir.getAbsolutePath();
- }
- } catch (Throwable e) {
- WXLogUtils.e(WXLogUtils.getStackTrace(e));
- }
- return COPY_SO_DES_DIR;
-
- }
-
- @Deprecated
- /**
- * Use {@link #isHardwareSupport()} if you want to see whether current hardware support Weex.
- */
- public static boolean isSupport() {
- boolean isInitialized = WXSDKEngine.isInitialized();
- if(!isInitialized){
- WXLogUtils.e("WXSDKEngine.isInitialized():" + isInitialized);
- }
- return isHardwareSupport() && isInitialized;
- }
-
- public static boolean isLayoutDirectionRTL() {
- // support RTL
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
- return sApplication.getApplicationContext().getResources().getBoolean(R.bool.weex_is_right_to_left);
- }
- return false;
- }
- /**
- * Tell whether Weex can run on current hardware.
- * @return true if weex can run on current hardware, otherwise false.
- * Weex has removed the restrictions on the tablet, please use {@link #isCPUSupport()}
- */
- @Deprecated
- public static boolean isHardwareSupport() {
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.d("isTableDevice:" + WXUtils.isTabletDevice());
- }
- return isCPUSupport();
- }
-
- /**
- * Determine whether Weex supports the current CPU architecture
- * @return true when support
- */
- public static boolean isCPUSupport(){
- boolean excludeX86 = "true".equals(getCustomOptions().get(SETTING_EXCLUDE_X86SUPPORT));
- boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86() && excludeX86;
- boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport() && !isX86AndExcluded;
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.d("WXEnvironment.sSupport:" + isCPUSupport
- + "isX86AndExclueded: "+ isX86AndExcluded);
- }
- return isCPUSupport;
- }
-
- public static boolean isApkDebugable() {
- return isApkDebugable(sApplication);
- }
-
- public static boolean isApkDebugable(Application application) {
- if (application == null) {
- return false;
- }
-
- if (isPerf) {
- return false;
- }
-
- if (sDebugFlagInit){
- return isApkDebug;
- }
- try {
- String debugModeConfig = getCustomOptions().get(WXConfig.debugMode);
- if (TextUtils.isEmpty(debugModeConfig)){
- ApplicationInfo info = application.getApplicationInfo();
- isApkDebug = (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
- }else {
- isApkDebug = Boolean.valueOf(debugModeConfig);
- }
- } catch (Exception e) {
- /**
- * Don't call WXLogUtils.e here,will cause stackoverflow
- */
- e.printStackTrace();
- isApkDebug = false;
- }
- sDebugFlagInit = true;
- return isApkDebug;
- }
-
- public static boolean isPerf() {
- return isPerf;
- }
-
- @SuppressLint("HardwareIds")
- private static String getDevId() {
- String ret = "";
- if(sApplication != null){
- try{
- ret = ((TelephonyManager) sApplication
- .getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
- }catch (SecurityException | NullPointerException e){
- WXLogUtils.e(WXLogUtils.getStackTrace(e));
- }
- }
- return ret;
- }
-
- public static Application getApplication() {
- return sApplication;
- }
-
- public void initMetrics() {
- if (sApplication == null) {
- return;
- }
- }
-
- public static String getDiskCacheDir(Context context) {
- if (context == null) {
- return null;
- }
- String cachePath = null;
- try {
- if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
- || !Environment.isExternalStorageRemovable()) {
- cachePath = context.getExternalCacheDir().getPath();
- } else {
- cachePath = context.getCacheDir().getPath();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return cachePath;
- }
-
- public static String getFilesDir(Context context) {
- if (context == null) {
- return "";
- }
- File filesDir = context.getFilesDir();
- String path = "";
- if (filesDir != null) {
- path = filesDir.getPath();
- } else {
- path = WXEnvironment.getApplication().getApplicationInfo().dataDir;
- path += File.separator;
- path += "files";
- }
-
- return path;
- }
-
- public static String getCrashFilePath(Context context) {
- if (context == null) {
- return "";
- }
-
- File dir = context.getDir("crash", Context.MODE_PRIVATE);
- if (dir == null)
- return "";
-
- String crashDir = dir.getAbsolutePath();
-
- return crashDir;
- }
-
- public static String getGlobalFontFamilyName() {
- return sGlobalFontFamily;
- }
-
- public static void setGlobalFontFamily(String fontFamilyName, Typeface typeface) {
- WXLogUtils.d("GlobalFontFamily", "Set global font family: " + fontFamilyName);
- sGlobalFontFamily = fontFamilyName;
- if (!TextUtils.isEmpty(fontFamilyName)) {
- if (typeface == null) {
- TypefaceUtil.removeFontDO(fontFamilyName);
- } else {
- FontDO nativeFontDO = new FontDO(fontFamilyName, typeface);
- TypefaceUtil.putFontDO(nativeFontDO);
- WXLogUtils.d("TypefaceUtil", "Add new font: " + fontFamilyName);
- }
- }
- }
-
- public static boolean isOpenDebugLog() {
- return openDebugLog;
- }
-
- public static void setOpenDebugLog(boolean openDebugLog) {
- WXEnvironment.openDebugLog = openDebugLog;
- }
-
- public static void setApkDebugable(boolean debugable){
- isApkDebug = debugable;
- if(!isApkDebug){
- openDebugLog = false;
- }
- }
-
- public static String getCacheDir() {
- final Application application = getApplication();
- if (application == null || application.getApplicationContext() == null)
- return null;
- return application.getApplicationContext().getCacheDir().getPath();
- }
-
- public static boolean extractSo() {
- File sourceFile = new File(getApplication().getApplicationContext().getApplicationInfo().sourceDir);
- final String soDesPath = copySoDesDir();
- if (sourceFile.exists() && !TextUtils.isEmpty(soDesPath)) {
- try {
- WXFileUtils.extractSo(sourceFile.getAbsolutePath(), soDesPath);
- } catch (IOException e) {
- WXLogUtils.e("extractSo error " + e.getMessage());
-// e.printStackTrace();
- return false;
- }
- return true;
- }
- return false;
- }
-
- private static String findIcuPath() {
- File file = new File("/proc/self/maps");
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(file));
- String tempString = null;
- while ((tempString = reader.readLine()) != null) {
- if (tempString.contains("icudt")) {
-
- int i = tempString.indexOf('/');
-
- String substring = tempString.substring(i);
- return substring.trim();
- }
- }
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e1) {
- }
- }
- }
-
- return null;
- }
-
-
- public static String findSoPath(String libName) {
- String soPath = ((PathClassLoader) (WXEnvironment.class.getClassLoader())).findLibrary(libName);
- if (!TextUtils.isEmpty(soPath)) {
- File soFile = new File(soPath);
- if (soFile.exists()) {
- WXLogUtils.e(libName + "'s Path is" + soPath);
- return soFile.getAbsolutePath();
- } else {
- WXLogUtils.e(libName + "'s Path is " + soPath + " but file does not exist");
- }
- }
-
- String realName = "lib" + libName + ".so";
- String cacheDir = getCacheDir();
- if (TextUtils.isEmpty(cacheDir)) {
- WXLogUtils.e("cache dir is null");
- return "";
- }
-
-
- if (cacheDir.indexOf("/cache") > 0) {
- soPath = new File(cacheDir.replace("/cache", "/lib"), realName).getAbsolutePath();
- }
-
-
- final File soFile = new File(soPath);
- if (soFile.exists()) {
- WXLogUtils.e(libName + "use lib so");
- return soPath;
- } else {
- //unzip from apk file
- final boolean success = extractSo();
- if (success) {
- return new File(getCacheDir(), realName).getAbsolutePath();
- }
- }
- return soPath;
- }
-
- public static String getLibJScRealPath() {
- if(TextUtils.isEmpty(CORE_JSC_SO_PATH)) {
- CORE_JSC_SO_PATH = findSoPath(CORE_JSC_SO_NAME);
- WXLogUtils.e("findLibJscRealPath " + CORE_JSC_SO_PATH);
- }
- return CORE_JSC_SO_PATH;
- }
-
- public static String getLibJssRealPath() {
- if (WXEnvironment.sUseRunTimeApi && !TextUtils.isEmpty(CORE_JSS_RUNTIME_SO_PATH)){
- WXLogUtils.d("test-> findLibJssRuntimeRealPath " + CORE_JSS_RUNTIME_SO_PATH);
- return CORE_JSS_RUNTIME_SO_PATH;
- }
-
- if(TextUtils.isEmpty(CORE_JSS_SO_PATH)) {
- CORE_JSS_SO_PATH = findSoPath(CORE_JSS_SO_NAME);
- WXLogUtils.d("test-> findLibJssRealPath " + CORE_JSS_SO_PATH);
- }
-
- return CORE_JSS_SO_PATH;
- }
-
- public static String getLibJssIcuPath() {
- if(TextUtils.isEmpty(CORE_JSS_ICU_PATH)){
- CORE_JSS_ICU_PATH = findIcuPath();
- }
-
- return CORE_JSS_ICU_PATH;
- }
-
- public static String getLibLdPath() {
- if (TextUtils.isEmpty(LIB_LD_PATH)) {
- ClassLoader classLoader = WXEnvironment.class.getClassLoader();
- try {
- Method getLdLibraryPath = classLoader.getClass().getMethod("getLdLibraryPath", new Class[0]);
- LIB_LD_PATH = (String) getLdLibraryPath.invoke(classLoader, new Object[0]);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- }
-
- if(TextUtils.isEmpty(LIB_LD_PATH)) {
- try {
- String property = System.getProperty("java.library.path");
- String libJScRealPath = getLibJScRealPath();
- if(!TextUtils.isEmpty(libJScRealPath)) {
- LIB_LD_PATH = new File(libJScRealPath).getParent() + ":" + property;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- WXLogUtils.d("getLibLdPath is " + LIB_LD_PATH);
- return LIB_LD_PATH;
- }
-
- public static class WXDefaultSettings {
- private String configName = "weex_default_settings";
- private SharedPreferences sharedPreferences = null;
- public WXDefaultSettings(Application application) {
- if(application != null) {
- sharedPreferences = application.getSharedPreferences(configName, MODE_PRIVATE);
- }
- }
-
- public synchronized String getValue(String key, String defaultValue) {
- if(sharedPreferences == null || TextUtils.isEmpty(key)) {
- WXLogUtils.i("get default settings " + key + " return default value :" + defaultValue);
- return defaultValue;
- }
-
- String result = sharedPreferences.getString(key, defaultValue);
- WXLogUtils.i("get default settings " + key + " : " + result);
- return result;
- }
-
- public synchronized void saveValue(String key, String value) {
- if (sharedPreferences == null
- || TextUtils.isEmpty(key)
- || TextUtils.isEmpty(value)) {
- return;
- }
- WXLogUtils.i("save default settings " + key + ":" + value);
- SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putString(key, value);
- editor.apply();
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXGlobalEventModule.java b/android/sdk/src/main/java/com/taobao/weex/WXGlobalEventModule.java
deleted file mode 100644
index b487ba2..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXGlobalEventModule.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import com.taobao.weex.annotation.JSMethod;
-import com.taobao.weex.common.WXModule;
-
-import java.util.Map;
-
-/**
- * Created by lixinke on 16/8/25.
- */
-public class WXGlobalEventModule extends WXModule {
-
-
- @JSMethod
- public void addEventListener(String eventName, String callback) {
- mWXSDKInstance.addEventListener(eventName,callback);
- }
-
- public void removeEventListener(String eventName, String callback) {
- mWXSDKInstance.removeEventListener(eventName,callback);
- }
-
- @JSMethod
- public void removeEventListener(String eventName){
- mWXSDKInstance.removeEventListener(eventName);
- }
-
-
- @Override
- public void addEventListener(String eventName, String callback, Map<String, Object> options) {
- super.addEventListener(eventName, callback, options);
- addEventListener(eventName,callback);
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXGlobalEventReceiver.java b/android/sdk/src/main/java/com/taobao/weex/WXGlobalEventReceiver.java
deleted file mode 100644
index 82e8363..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXGlobalEventReceiver.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import com.taobao.weex.utils.WXLogUtils;
-
-import java.util.HashMap;
-
-public class WXGlobalEventReceiver extends BroadcastReceiver {
-
- public static final String EVENT_NAME = "eventName";
- public static final String EVENT_PARAMS = "eventParams";
- public static final String EVENT_ACTION = "wx_global_action";
- public static final String EVENT_WX_INSTANCEID = "wx_instanceid";
-
- private WXSDKInstance mWXSDKInstance;
-
- public WXGlobalEventReceiver() {
- }
-
- public WXGlobalEventReceiver(WXSDKInstance instance) {
- mWXSDKInstance = instance;
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- String eventName = intent.getStringExtra(EVENT_NAME);
- String params = intent.getStringExtra(EVENT_PARAMS);
- HashMap<String, Object> maps = null;
- try {
- maps = com.alibaba.fastjson.JSON.parseObject(params, HashMap.class);
- mWXSDKInstance.fireGlobalEventCallback(eventName, maps);
- } catch (Exception e) {
- WXLogUtils.e("global-receive",e);
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXHttpListener.java b/android/sdk/src/main/java/com/taobao/weex/WXHttpListener.java
deleted file mode 100644
index 15d9cf2..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXHttpListener.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.net.Uri;
-import android.text.TextUtils;
-
-import com.taobao.weex.adapter.IWXHttpAdapter;
-import com.taobao.weex.adapter.IWXUserTrackAdapter;
-import com.taobao.weex.common.WXErrorCode;
-import com.taobao.weex.common.WXPerformance;
-import com.taobao.weex.common.WXRenderStrategy;
-import com.taobao.weex.common.WXResponse;
-import com.taobao.weex.performance.WXInstanceApm;
-import com.taobao.weex.tracing.WXTracing;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.tools.LogDetail;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * load bundle js listener
- */
-public class WXHttpListener implements IWXHttpAdapter.OnHttpListener {
-
- private String pageName;
- private Map<String, Object> options;
- private String jsonInitData;
- private WXRenderStrategy flag;
- private WXSDKInstance instance;
- private long startRequestTime;
- private int traceId;
- private WXPerformance mWXPerformance;
- private WXInstanceApm mApmForInstance;
- private IWXUserTrackAdapter mUserTrackAdapter;
- public boolean isPreDownLoadMode = false;
- private boolean isInstanceReady =false;
- private boolean isResponseHasWait = false;
- private WXResponse mResponse;
- private LogDetail mLogDetail;
-
- private String mBundleUrl;
-
- public WXHttpListener(WXSDKInstance instance) {
- if(instance != null) {
- mLogDetail = instance.mTimeCalculator.createLogDetail("downloadBundleJS");
- }
- this.instance = instance;
- this.traceId = WXTracing.nextId();
- this.mWXPerformance = instance.getWXPerformance();
- this.mApmForInstance = instance.getApmForInstance();
- this.mUserTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter();
- if (WXTracing.isAvailable()) {
- WXTracing.TraceEvent event = WXTracing.newEvent("downloadBundleJS", instance.getInstanceId(), -1);
- event.iid = instance.getInstanceId();
- event.tname = "Network";
- event.ph = "B";
- event.traceId = traceId;
- event.submit();
- }
- }
-
- public WXHttpListener(WXSDKInstance instance, String bundleUrl) {
- this(instance);
- this.startRequestTime = System.currentTimeMillis();
- this.mBundleUrl = bundleUrl;
- }
-
- public WXHttpListener(WXSDKInstance instance, String pageName, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag, long startRequestTime) {
- this(instance);
- this.pageName = pageName;
- this.options = options;
- this.jsonInitData = jsonInitData;
- this.flag = flag;
- this.startRequestTime = startRequestTime;
- this.mBundleUrl = instance.getBundleUrl();
- }
-
- public void setSDKInstance(WXSDKInstance instance) {
- this.instance = instance;
- }
-
- protected WXSDKInstance getInstance() {
- return instance;
- }
-
- @Override
- public void onHttpStart() {
- if (this.instance != null
- && this.instance.getWXStatisticsListener() != null) {
- this.instance.getWXStatisticsListener().onHttpStart();
- if(mLogDetail != null) {
- mLogDetail.taskStart();
- }
- }
- }
-
- @Override
- public void onHeadersReceived(int statusCode, Map<String,List<String>> headers) {
- if (this.instance != null
- && this.instance.getWXStatisticsListener() != null) {
- this.instance.getWXStatisticsListener().onHeadersReceived();
- this.instance.onHttpStart();
- }
- if(this.instance != null
- && this.instance.responseHeaders != null
- && headers != null){
- this.instance.responseHeaders.putAll(headers);
- }
- }
-
- @Override
- public void onHttpUploadProgress(int uploadProgress) {
-
- }
-
- @Override
- public void onHttpResponseProgress(int loadedLength) {
- instance.getApmForInstance().extInfo.put(WXInstanceApm.VALUE_BUNDLE_LOAD_LENGTH,loadedLength);
- }
-
- @Override
- public void onHttpFinish(WXResponse response) {
- if(mLogDetail != null) {
- mLogDetail.taskEnd();
- }
- if (this.instance != null
- && this.instance.getWXStatisticsListener() != null) {
- this.instance.getWXStatisticsListener().onHttpFinish();
- }
-
- if (WXTracing.isAvailable()) {
- WXTracing.TraceEvent event = WXTracing.newEvent("downloadBundleJS", instance.getInstanceId(), -1);
- event.traceId = traceId;
- event.tname = "Network";
- event.ph = "E";
- event.extParams = new HashMap<>();
- if (response != null && response.originalData != null) {
- event.extParams.put("BundleSize", response.originalData.length);
- }
- event.submit();
- }
-
- mWXPerformance.networkTime = System.currentTimeMillis() - startRequestTime;
- if(null!= response && response.extendParams!=null){
- mApmForInstance.updateRecordInfo(response.extendParams);
- Object actualNetworkTime=response.extendParams.get("actualNetworkTime");
- mWXPerformance.actualNetworkTime=actualNetworkTime instanceof Long?(long)actualNetworkTime:0;
-
- Object pureNetworkTime=response.extendParams.get("pureNetworkTime");
- mWXPerformance.pureNetworkTime=pureNetworkTime instanceof Long?(long)pureNetworkTime:0;
-
- Object connectionType=response.extendParams.get("connectionType");
- mWXPerformance.connectionType=connectionType instanceof String?(String)connectionType:"";
-
- Object packageSpendTime=response.extendParams.get("packageSpendTime");
- mWXPerformance.packageSpendTime=packageSpendTime instanceof Long ?(long)packageSpendTime:0;
-
- Object syncTaskTime=response.extendParams.get("syncTaskTime");
- mWXPerformance.syncTaskTime=syncTaskTime instanceof Long ?(long)syncTaskTime:0;
-
- Object requestType=response.extendParams.get("requestType");
- mWXPerformance.requestType=requestType instanceof String?(String)requestType:"none";
-
- Object cacheType = response.extendParams.get(WXPerformance.Dimension.cacheType.toString());
- if(cacheType instanceof String){
- mWXPerformance.cacheType = (String) cacheType;
- }
-
- Object zCacheInfo = response.extendParams.get("zCacheInfo");
- mWXPerformance.zCacheInfo = zCacheInfo instanceof String?(String)zCacheInfo:"";
-
- if(isNet(mWXPerformance.requestType) && mUserTrackAdapter!=null){
- WXPerformance performance=new WXPerformance(instance.getInstanceId());
- if(!TextUtils.isEmpty(mBundleUrl)){
- try {
- performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString();
- } catch (Exception e) {
- performance.args=pageName;
- }
- }
- if(!"200".equals(response.statusCode)){
- performance.errCode= WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode();
- performance.appendErrMsg(response.errorCode);
- performance.appendErrMsg("|");
- performance.appendErrMsg(response.errorMsg);
-
- }else if("200".equals(response.statusCode) && (response.originalData==null || response.originalData.length<=0)){
- performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode();
- performance.appendErrMsg(response.statusCode);
- performance.appendErrMsg("|template is null!");
- }else {
- performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode();
- }
-
- if (mUserTrackAdapter != null) {
- mUserTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.JS_DOWNLOAD, performance, null);
- }
- }
- }
-
- if (isPreDownLoadMode){
- if (isInstanceReady){
- WXLogUtils.d("test->", "DownLoad didHttpFinish on http" );
- didHttpFinish(response);
- }else {
- WXLogUtils.d("test->", "DownLoad end before activity created" );
- mResponse = response;
- isResponseHasWait = true;
- }
- }else {
- didHttpFinish(response);
- }
-
- }
-
- public void onInstanceReady(){
- if (!isPreDownLoadMode){
- return;
- }
- this.isInstanceReady = true;
- if (isResponseHasWait){
- WXLogUtils.d("test->", "preDownLoad didHttpFinish on ready" );
- this.didHttpFinish(mResponse);
- }
-
- }
-
- private void didHttpFinish(WXResponse response){
- String wxErrorCode = WXInstanceApm.VALUE_ERROR_CODE_DEFAULT;
- if (response!=null && response.originalData!=null && TextUtils.equals("200", response.statusCode)) {
- mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_END);
- onSuccess(response);
-
- // check content-type
- } else if (TextUtils.equals(WXErrorCode.WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR.getErrorCode(),
- response.statusCode)) {
- WXLogUtils.e("user intercept: WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR");
- wxErrorCode = WXErrorCode.WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR.getErrorCode();
- instance.onRenderError(wxErrorCode,
- "|response.errorMsg==" + response.errorMsg +
- "|instance bundleUrl = \n" + instance.getBundleUrl() +
- "|instance requestUrl = \n" + Uri.decode(WXSDKInstance.requestUrl)
- );
- onFail(response);
-
- // check content-length
- } else if (response!=null && response.originalData!=null && TextUtils.equals("-206", response.statusCode)) {
- WXLogUtils.e("user intercept: WX_DEGRAD_ERR_NETWORK_CHECK_CONTENT_LENGTH_FAILED");
- wxErrorCode = WXErrorCode.WX_DEGRAD_ERR_NETWORK_CHECK_CONTENT_LENGTH_FAILED.getErrorCode();
- instance.onRenderError(wxErrorCode ,
- WXErrorCode.WX_DEGRAD_ERR_NETWORK_CHECK_CONTENT_LENGTH_FAILED.getErrorCode() +
- "|response.errorMsg==" + response.errorMsg
- );
- onFail(response);
- }
- else {
- wxErrorCode = WXErrorCode.WX_DEGRAD_ERR_NETWORK_BUNDLE_DOWNLOAD_FAILED.getErrorCode();
- instance.onRenderError(wxErrorCode,
- response.errorMsg);
- onFail(response);
- }
- if (!WXInstanceApm.VALUE_ERROR_CODE_DEFAULT.equals(wxErrorCode)){
- mApmForInstance.addProperty(WXInstanceApm.KEY_PROPERTIES_ERROR_CODE,wxErrorCode);
- }
- }
-
- private boolean isNet(String requestType){
-
- return "network".equals(requestType) || "2g".equals(requestType) || "3g".equals(requestType)
- || "4g".equals(requestType) || "wifi".equals(requestType) || "other".equals(requestType)
- || "unknown".equals(requestType);
- }
-
- public void onSuccess(WXResponse response) {
- if (flag==WXRenderStrategy.DATA_RENDER_BINARY){
- instance.render(pageName, response.originalData, options, jsonInitData);
- }else {
- String template = new String(response.originalData);
- instance.render(pageName, template, options, jsonInitData, flag);
- }
- }
-
- public void onFail(WXResponse response) {
-
- }
-}
-
-
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
deleted file mode 100644
index d9ef522..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import static com.taobao.weex.WXEnvironment.CORE_SO_NAME;
-
-import android.app.Application;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.support.v4.content.LocalBroadcastManager;
-import android.text.TextUtils;
-import com.taobao.weex.adapter.IDrawableLoader;
-import com.taobao.weex.adapter.IWXHttpAdapter;
-import com.taobao.weex.adapter.IWXImgLoaderAdapter;
-import com.taobao.weex.adapter.IWXJSExceptionAdapter;
-import com.taobao.weex.adapter.IWXJsFileLoaderAdapter;
-import com.taobao.weex.adapter.IWXUserTrackAdapter;
-import com.taobao.weex.appfram.clipboard.WXClipboardModule;
-import com.taobao.weex.appfram.navigator.IActivityNavBarSetter;
-import com.taobao.weex.appfram.navigator.INavigator;
-import com.taobao.weex.appfram.navigator.WXNavigatorModule;
-import com.taobao.weex.appfram.pickers.WXPickersModule;
-import com.taobao.weex.appfram.storage.IWXStorageAdapter;
-import com.taobao.weex.appfram.storage.WXStorageModule;
-import com.taobao.weex.appfram.websocket.WebSocketModule;
-import com.taobao.weex.bridge.ModuleFactory;
-import com.taobao.weex.bridge.WXBridgeManager;
-import com.taobao.weex.bridge.WXModuleManager;
-import com.taobao.weex.bridge.WXServiceManager;
-import com.taobao.weex.common.Destroyable;
-import com.taobao.weex.common.TypeModuleFactory;
-import com.taobao.weex.common.WXErrorCode;
-import com.taobao.weex.common.WXException;
-import com.taobao.weex.common.WXInstanceWrap;
-import com.taobao.weex.common.WXModule;
-import com.taobao.weex.http.WXStreamModule;
-import com.taobao.weex.performance.WXStateRecord;
-import com.taobao.weex.ui.ExternalLoaderComponentHolder;
-import com.taobao.weex.ui.IExternalComponentGetter;
-import com.taobao.weex.ui.IExternalModuleGetter;
-import com.taobao.weex.ui.IFComponentHolder;
-import com.taobao.weex.ui.SimpleComponentHolder;
-import com.taobao.weex.ui.WXComponentRegistry;
-import com.taobao.weex.ui.animation.WXAnimationModule;
-import com.taobao.weex.ui.component.Textarea;
-import com.taobao.weex.ui.component.WXA;
-import com.taobao.weex.ui.component.WXBasicComponentType;
-import com.taobao.weex.ui.component.WXComponent;
-import com.taobao.weex.ui.component.WXDiv;
-import com.taobao.weex.ui.component.WXEmbed;
-import com.taobao.weex.ui.component.WXHeader;
-import com.taobao.weex.ui.component.WXImage;
-import com.taobao.weex.ui.component.WXIndicator;
-import com.taobao.weex.ui.component.WXInput;
-import com.taobao.weex.ui.component.WXLoading;
-import com.taobao.weex.ui.component.WXLoadingIndicator;
-import com.taobao.weex.ui.component.WXRefresh;
-import com.taobao.weex.ui.component.WXScroller;
-import com.taobao.weex.ui.component.WXSlider;
-import com.taobao.weex.ui.component.WXSliderNeighbor;
-import com.taobao.weex.ui.component.WXSwitch;
-import com.taobao.weex.ui.component.WXText;
-import com.taobao.weex.ui.component.WXVideo;
-import com.taobao.weex.ui.component.WXWeb;
-import com.taobao.weex.ui.component.list.HorizontalListComponent;
-import com.taobao.weex.ui.component.list.SimpleListComponent;
-import com.taobao.weex.ui.component.list.WXCell;
-import com.taobao.weex.ui.component.list.WXListComponent;
-import com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList;
-import com.taobao.weex.ui.component.richtext.WXRichText;
-import com.taobao.weex.ui.config.AutoScanConfigRegister;
-import com.taobao.weex.ui.module.WXDeviceInfoModule;
-import com.taobao.weex.ui.module.ConsoleLogModule;
-import com.taobao.weex.ui.module.WXLocaleModule;
-import com.taobao.weex.ui.module.WXMetaModule;
-import com.taobao.weex.ui.module.WXModalUIModule;
-import com.taobao.weex.ui.module.WXTimerModule;
-import com.taobao.weex.ui.module.WXWebViewModule;
-import com.taobao.weex.utils.LogLevel;
-import com.taobao.weex.utils.WXExceptionUtils;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXSoInstallMgrSdk;
-import com.taobao.weex.utils.batch.BatchOperationHelper;
-import com.taobao.weex.utils.cache.RegisterCache;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-public class WXSDKEngine implements Serializable {
-
- public static final String JS_FRAMEWORK_RELOAD="js_framework_reload";
- private static final String V8_SO_NAME = CORE_SO_NAME;
- private volatile static boolean mIsInit = false;
- private volatile static boolean mIsSoInit = false;
- private static final Object mLock = new Object();
- private static final String TAG = "WXSDKEngine";
-
- /**
- * Deprecated. Use {@link #initialize(Application, InitConfig)} instead.
- */
- @Deprecated
- public static void init(Application application) {
- init(application, null);
- }
-
- /**
- * Deprecated. Use {@link #initialize(Application, InitConfig)} instead.
- */
- @Deprecated
- public static void init(Application application, IWXUserTrackAdapter utAdapter) {
- init(application, utAdapter, null);
- }
-
- /**
- * Deprecated. Use {@link #initialize(Application, InitConfig)} instead.
- */
- @Deprecated
- public static void init(Application application, IWXUserTrackAdapter utAdapter, String framework) {
- initialize(application,
- new InitConfig.Builder()
- .setUtAdapter(utAdapter)
- .build()
- );
- }
-
-
- public static boolean isInitialized(){
- synchronized(mLock) {
-
- return mIsInit && WXEnvironment.JsFrameworkInit;
- }
- }
-
- public static boolean isSoInitialized(){
- synchronized(mLock) {
- return mIsSoInit;
- }
- }
-
- /**
- *
- * @param application
- * @param config initial configurations or null
- */
- public static void initialize(Application application,InitConfig config){
- synchronized (mLock) {
- if (mIsInit) {
- return;
- }
- long start = System.currentTimeMillis();
- WXEnvironment.sSDKInitStart = start;
- if(WXEnvironment.isApkDebugable(application)){
- WXEnvironment.sLogLevel = LogLevel.DEBUG;
- }else{
- WXEnvironment.sLogLevel = LogLevel.WARN;
- }
- doInitInternal(application,config);
- registerApplicationOptions(application);
- WXEnvironment.sSDKInitInvokeTime = System.currentTimeMillis()-start;
- WXLogUtils.renderPerformanceLog("SDKInitInvokeTime", WXEnvironment.sSDKInitInvokeTime);
- mIsInit = true;
- }
- }
-
- private static void registerApplicationOptions(final Application application) {
-
- if (application == null) {
- WXLogUtils.e(TAG, "RegisterApplicationOptions application is null");
- return;
- }
-
- Resources resources = application.getResources();
- registerCoreEnv("screen_width_pixels", String.valueOf(resources.getDisplayMetrics().widthPixels));
- registerCoreEnv("screen_height_pixels", String.valueOf(resources.getDisplayMetrics().heightPixels));
-
- int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
- if (resourceId > 0) {
- int statusBarHeight = resources.getDimensionPixelSize(resourceId);
- registerCoreEnv("status_bar_height", String.valueOf(statusBarHeight));
- }
- }
-
- private static void doInitInternal(final Application application,final InitConfig config){
- WXEnvironment.sApplication = application;
- if(application == null){
- WXLogUtils.e(TAG, " doInitInternal application is null");
- WXExceptionUtils.commitCriticalExceptionRT(null,
- WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT,
- "doInitInternal",
- WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "WXEnvironment sApplication is null",
- null);
- }
- WXEnvironment.JsFrameworkInit = false;
-
- WXBridgeManager.getInstance().postWithName(new Runnable() {
- @Override
- public void run() {
- long start = System.currentTimeMillis();
- WXSDKManager sm = WXSDKManager.getInstance();
- sm.onSDKEngineInitialize();
- if(config != null ) {
- sm.setInitConfig(config);
- }
- WXSoInstallMgrSdk.init(application,
- sm.getIWXSoLoaderAdapter(),
- sm.getWXStatisticsListener());
- final IWXUserTrackAdapter userTrackAdapter= config!=null?config.getUtAdapter():null;
- final int version = 1;
- mIsSoInit = WXSoInstallMgrSdk.initSo(V8_SO_NAME, version, userTrackAdapter);
- WXSoInstallMgrSdk.copyJssRuntimeSo();
- if(config!=null) {
- for (String libraryName : config.getNativeLibraryList()) {
- WXSoInstallMgrSdk.initSo(libraryName, version, userTrackAdapter);
- }
- }
- if (!mIsSoInit) {
- WXExceptionUtils.commitCriticalExceptionRT(null,
- WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT,
- "doInitInternal",
- WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "isSoInit false",
- null);
- return;
- }
- sm.initScriptsFramework(config!=null?config.getFramework():null);
-
- WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
- WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
- }
- },null,"doInitWeexSdkInternal");
- WXStateRecord.getInstance().startJSThreadWatchDog();
- register();
- }
-
- @Deprecated
- public static void init(Application application, String framework, IWXUserTrackAdapter utAdapter, IWXImgLoaderAdapter imgLoaderAdapter, IWXHttpAdapter httpAdapter) {
- initialize(application,
- new InitConfig.Builder()
- .setUtAdapter(utAdapter)
- .setHttpAdapter(httpAdapter)
- .setImgAdapter(imgLoaderAdapter)
- .build()
- );
- }
-
- public static void setJSExcetptionAdapter(IWXJSExceptionAdapter excetptionAdapter){
- WXSDKManager.getInstance().setIWXJSExceptionAdapter(excetptionAdapter);
- }
-
- private static void register() {
- BatchOperationHelper batchHelper = new BatchOperationHelper(WXBridgeManager.getInstance());
- try {
- registerComponent(
- new SimpleComponentHolder(
- WXText.class,
- new WXText.Creator()
- ),
- false,
- WXBasicComponentType.TEXT
- );
- registerComponent(
- new SimpleComponentHolder(
- WXDiv.class,
- new WXDiv.Ceator()
- ),
- false,
- WXBasicComponentType.CONTAINER,
- WXBasicComponentType.DIV,
- WXBasicComponentType.HEADER,
- WXBasicComponentType.FOOTER
- );
- registerComponent(
- new SimpleComponentHolder(
- WXImage.class,
- new WXImage.Creator()
- ),
- false,
- WXBasicComponentType.IMAGE,
- WXBasicComponentType.IMG
- );
- registerComponent(
- new SimpleComponentHolder(
- WXScroller.class,
- new WXScroller.Creator()
- ),
- false,
- WXBasicComponentType.SCROLLER
- );
- registerComponent(
- new SimpleComponentHolder(
- WXSlider.class,
- new WXSlider.Creator()
- ),
- true,
- WXBasicComponentType.SLIDER,
- WXBasicComponentType.CYCLE_SLIDER
- );
- registerComponent(
- new SimpleComponentHolder(
- WXSliderNeighbor.class,
- new WXSliderNeighbor.Creator()
- ),
- true,
- WXBasicComponentType.SLIDER_NEIGHBOR
- );
- registerComponent(
- new SimpleComponentHolder(
- WXCell.class,
- new WXCell.Creator()
- ),
- true,
- WXBasicComponentType.CELL);
- registerComponent(
- new SimpleComponentHolder(
- WXListComponent.class,
- new WXListComponent.Creator()
- ),
- true,
- WXBasicComponentType.LIST,
- WXBasicComponentType.VLIST,
- WXBasicComponentType.RECYCLER,
- WXBasicComponentType.WATERFALL);
-
- registerComponent(
- new SimpleComponentHolder(
- WXRichText.class,
- new WXRichText.Creator()
- ),
- false,
- WXBasicComponentType.RICHTEXT
- );
-
- String simpleList = "simplelist";
- registerComponent(SimpleListComponent.class,false,simpleList);
- registerComponent(WXRecyclerTemplateList.class, false,WXBasicComponentType.RECYCLE_LIST);
- registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST);
- registerComponent(WXBasicComponentType.CELL_SLOT, WXCell.class, true);
- registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true);
- registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false);
- registerComponent(WXBasicComponentType.INPUT, WXInput.class, false);
- registerComponent(WXBasicComponentType.TEXTAREA, Textarea.class,false);
- registerComponent(WXBasicComponentType.SWITCH, WXSwitch.class, false);
- registerComponent(WXBasicComponentType.A, WXA.class, false);
- registerComponent(WXBasicComponentType.EMBED, WXEmbed.class, true);
- registerComponent(WXBasicComponentType.WEB, WXWeb.class);
- registerComponent(WXBasicComponentType.REFRESH, WXRefresh.class);
- registerComponent(WXBasicComponentType.LOADING, WXLoading.class);
- registerComponent(WXBasicComponentType.LOADING_INDICATOR, WXLoadingIndicator.class);
- registerComponent(WXBasicComponentType.HEADER, WXHeader.class);
-
- registerModule("modal", WXModalUIModule.class);
- registerModule("instanceWrap", WXInstanceWrap.class);
- registerModule("animation", WXAnimationModule.class);
- registerModule("webview", WXWebViewModule.class);
- registerModule("navigator", WXNavigatorModule.class);
- registerModule("stream", WXStreamModule.class);
- registerModule("timer", WXTimerModule.class);
- registerModule("storage", WXStorageModule.class);
- registerModule("clipboard", WXClipboardModule.class);
- registerModule("globalEvent",WXGlobalEventModule.class);
- registerModule("picker", WXPickersModule.class);
- registerModule("meta", WXMetaModule.class);
- registerModule("webSocket", WebSocketModule.class);
- registerModule("locale", WXLocaleModule.class);
- registerModule("deviceInfo", WXDeviceInfoModule.class);
- registerModule("sdk-console-log", ConsoleLogModule.class);
- } catch (WXException e) {
- WXLogUtils.e("[WXSDKEngine] register:", e);
- }
-
- if(RegisterCache.getInstance().enableAutoScan()) {
- AutoScanConfigRegister.doScanConfig();
- }
-
- batchHelper.flush();
- }
-
- /**
- *
- * Register component. The registration is singleton in {@link WXSDKEngine} level
- * @param type name of component. Same as type field in the JS.
- * @param clazz the class of the {@link WXComponent} to be registered.
- * @param appendTree true for appendTree flag
- * @return true for registration success, false for otherwise.
- * @throws WXException Throws exception if type conflicts.
- */
- public static boolean registerComponent(String type, Class<? extends WXComponent> clazz, boolean appendTree) throws WXException {
- return registerComponent(clazz, appendTree,type);
- }
-
- public static boolean registerComponent(String type, IExternalComponentGetter componentGetter, boolean appendTree) throws WXException {
- return registerComponent(new ExternalLoaderComponentHolder(type,componentGetter), appendTree,type);
- }
-
- /**
- *
- * Register component. The registration is singleton in {@link WXSDKEngine} level
- * @param clazz the class of the {@link WXComponent} to be registered.
- * @param appendTree true for appendTree flag
- * @return true for registration success, false for otherwise.
- * @param names names(alias) of component. Same as type field in the JS.
- * @throws WXException Throws exception if type conflicts.
- */
- public static boolean registerComponent(Class<? extends WXComponent> clazz, boolean appendTree,String ... names) throws WXException {
- if(clazz == null){
- return false;
- }
- SimpleComponentHolder holder = new SimpleComponentHolder(clazz);
- return registerComponent(holder,appendTree,names);
- }
-
-
- public static boolean registerComponent(IFComponentHolder holder, boolean appendTree, String ... names) throws WXException {
- boolean result = true;
- try {
- for (String name : names) {
- Map<String, Object> componentInfo = new HashMap<>();
- if (appendTree) {
- componentInfo.put("append", "tree");
- }
- result = result && WXComponentRegistry.registerComponent(name, holder, componentInfo);
- }
- return result;
- } catch (Throwable e) {
- e.printStackTrace();
- return result;
- }
- }
-
- /**
- * Register module. This is a wrapper method for
- * {@link #registerModule(String, Class, boolean)}. The module register here only need to
- * be singleton in {@link WXSDKInstance} level.
- * @param moduleName module name
- * @param moduleClass module to be registered.
- * @return true for registration success, false for otherwise.
- * {@link WXModuleManager#registerModule(String, ModuleFactory, boolean)}
- */
- public static <T extends WXModule> boolean registerModule(String moduleName, Class<T> moduleClass,boolean global) throws WXException {
- return moduleClass != null && registerModule(moduleName, new TypeModuleFactory<>(moduleClass), global);
- }
-
- /**
- * Register module. This is a wrapper method for
- * {@link #registerModule(String, Class, boolean)}. The module register here only need to
- * be singleton in {@link WXSDKInstance} level.
- * @param moduleName module name
- * @param factory module factory to be registered. You can override {@link DestroyableModuleFactory#buildInstance()} to customize module creation.
- * @return true for registration success, false for otherwise.
- * {@link WXModuleManager#registerModule(String, ModuleFactory, boolean)}
- */
- public static <T extends WXModule> boolean registerModuleWithFactory(String moduleName, DestroyableModuleFactory factory, boolean global) throws WXException {
- return registerModule(moduleName, factory,global);
- }
-
-
- public static <T extends WXModule> boolean registerModuleWithFactory(String moduleName, IExternalModuleGetter factory, boolean global) throws WXException {
- return registerModule(moduleName, factory.getExternalModuleClass(moduleName,WXEnvironment.getApplication()),global);
- }
-
- public static <T extends WXModule> boolean registerModule(String moduleName, ModuleFactory factory, boolean global) throws WXException {
- return WXModuleManager.registerModule(moduleName, factory,global);
- }
-
- public static boolean registerModule(String moduleName, Class<? extends WXModule> moduleClass) throws WXException {
- return registerModule(moduleName, moduleClass,false);
- }
-
- public static boolean registerService(String name, String serviceScript, Map<String, Object> options) {
- return WXServiceManager.registerService(name, serviceScript, options);
- }
-
- public static boolean unRegisterService(String name) {
- return WXServiceManager.unRegisterService(name);
- }
-
- /**
- * module implement {@link Destroyable}
- */
- public static abstract class DestroyableModule extends WXModule implements Destroyable {}
-
- public static abstract class DestroyableModuleFactory<T extends DestroyableModule> extends TypeModuleFactory<T> {
- public DestroyableModuleFactory(Class<T> clz) {
- super(clz);
- }
- }
-
- public static void callback(String instanceId, String funcId, Map<String, Object> data) {
- WXSDKManager.getInstance().callback(instanceId, funcId, data);
- }
-
- /**
- * Model switch, only applicable for developer model
- * @param debug
- */
- public static void restartBridge(boolean debug) {
- WXEnvironment.sDebugMode = debug;
- WXSDKManager.getInstance().restartBridge();
- }
-
- public static boolean registerComponent(String type, Class<? extends WXComponent> clazz) throws WXException {
- return WXComponentRegistry.registerComponent(type, new SimpleComponentHolder(clazz),new HashMap<String, Object>());
- }
-
- public static boolean registerComponent(Map<String, Object> componentInfo, Class<? extends WXComponent> clazz) throws WXException {
- if(componentInfo == null){
- return false;
- }
- String type = (String)componentInfo.get("type");
- if(TextUtils.isEmpty(type)){
- return false;
- }
- return WXComponentRegistry.registerComponent(type,new SimpleComponentHolder(clazz), componentInfo);
- }
-
- public static void addCustomOptions(String key, String value) {
- WXEnvironment.addCustomOptions(key, value);
- }
-
- public static IWXUserTrackAdapter getIWXUserTrackAdapter() {
- return WXSDKManager.getInstance().getIWXUserTrackAdapter();
- }
-
- public static IWXImgLoaderAdapter getIWXImgLoaderAdapter() {
- return WXSDKManager.getInstance().getIWXImgLoaderAdapter();
- }
-
- public static IDrawableLoader getDrawableLoader() {
- return WXSDKManager.getInstance().getDrawableLoader();
- }
-
- public static IWXHttpAdapter getIWXHttpAdapter() {
- return WXSDKManager.getInstance().getIWXHttpAdapter();
- }
-
- public static IWXStorageAdapter getIWXStorageAdapter() {
- return WXSDKManager.getInstance().getIWXStorageAdapter();
- }
-
-
- public static IWXJsFileLoaderAdapter getIWXJsFileLoaderAdapter() {
- return WXSDKManager.getInstance().getIWXJsFileLoaderAdapter();
- }
-
- public static IActivityNavBarSetter getActivityNavBarSetter() {
- return WXSDKManager.getInstance().getActivityNavBarSetter();
- }
-
- public static INavigator getNavigator() {
- return WXSDKManager.getInstance().getNavigator();
- }
-
- public static void setNavigator(INavigator navigator) {
- WXSDKManager.getInstance().setNavigator(navigator);
- }
-
- public static void setActivityNavBarSetter(IActivityNavBarSetter activityNavBarSetter) {
- WXSDKManager.getInstance().setActivityNavBarSetter(activityNavBarSetter);
- }
-
- public static void reload(final Context context,String framework, boolean remoteDebug) {
- WXEnvironment.sRemoteDebugMode = remoteDebug;
- WXBridgeManager.getInstance().restart();
- WXBridgeManager.getInstance().initScriptsFramework(framework);
-
- WXServiceManager.reload();
- WXModuleManager.reload();
- WXComponentRegistry.reload();
- WXSDKManager.getInstance().postOnUiThread(new Runnable() {
- @Override
- public void run() {
- LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(JS_FRAMEWORK_RELOAD));
- }
- }, 0);
- }
- public static void reload(final Context context, boolean remoteDebug) {
- reload(context,null,remoteDebug);
- }
-
- public static void reload() {
- reload(WXEnvironment.getApplication(), WXEnvironment.sRemoteDebugMode);
- }
-
- public static void registerCoreEnv(String key, String value) {
- WXBridgeManager.getInstance().registerCoreEnv(key, value);
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
deleted file mode 100644
index b8beb51..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
+++ /dev/null
@@ -1,2400 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import static com.taobao.weex.common.WXErrorCode.WX_ERR_RELOAD_PAGE;
-import static com.taobao.weex.http.WXHttpUtil.KEY_USER_AGENT;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.net.Uri;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.RestrictTo;
-import android.support.annotation.RestrictTo.Scope;
-import android.support.annotation.WorkerThread;
-import android.support.v4.util.ArrayMap;
-import android.text.TextUtils;
-import android.view.Menu;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ScrollView;
-import com.alibaba.fastjson.JSONObject;
-import com.taobao.weex.adapter.IDrawableLoader;
-import com.taobao.weex.adapter.IWXConfigAdapter;
-import com.taobao.weex.adapter.IWXHttpAdapter;
-import com.taobao.weex.adapter.IWXImgLoaderAdapter;
-import com.taobao.weex.adapter.IWXJscProcessManager;
-import com.taobao.weex.adapter.IWXUserTrackAdapter;
-import com.taobao.weex.adapter.URIAdapter;
-import com.taobao.weex.appfram.websocket.IWebSocketAdapter;
-import com.taobao.weex.bridge.EventResult;
-import com.taobao.weex.bridge.NativeInvokeHelper;
-import com.taobao.weex.bridge.SimpleJSCallback;
-import com.taobao.weex.bridge.WXBridgeManager;
-import com.taobao.weex.bridge.WXModuleManager;
-import com.taobao.weex.bridge.WXParams;
-import com.taobao.weex.common.Constants;
-import com.taobao.weex.common.Destroyable;
-import com.taobao.weex.common.OnWXScrollListener;
-import com.taobao.weex.common.RenderTypes;
-import com.taobao.weex.common.WXConfig;
-import com.taobao.weex.common.WXErrorCode;
-import com.taobao.weex.common.WXModule;
-import com.taobao.weex.common.WXPerformance;
-import com.taobao.weex.common.WXRefreshData;
-import com.taobao.weex.common.WXRenderStrategy;
-import com.taobao.weex.common.WXRequest;
-import com.taobao.weex.dom.WXEvent;
-import com.taobao.weex.http.WXHttpUtil;
-import com.taobao.weex.instance.InstanceOnFireEventInterceptor;
-import com.taobao.weex.layout.ContentBoxMeasurement;
-import com.taobao.weex.performance.WXInstanceApm;
-import com.taobao.weex.performance.WXStateRecord;
-import com.taobao.weex.performance.WhiteScreenUtils;
-import com.taobao.weex.render.WXAbstractRenderContainer;
-import com.taobao.weex.tracing.WXTracing;
-import com.taobao.weex.ui.action.GraphicActionAddElement;
-import com.taobao.weex.ui.component.NestedContainer;
-import com.taobao.weex.ui.component.WXComponent;
-import com.taobao.weex.ui.component.WXEmbed;
-import com.taobao.weex.ui.flat.FlatGUIContext;
-import com.taobao.weex.ui.view.WXScrollView;
-import com.taobao.weex.utils.Trace;
-import com.taobao.weex.utils.WXDeviceUtils;
-import com.taobao.weex.utils.WXExceptionUtils;
-import com.taobao.weex.utils.WXFileUtils;
-import com.taobao.weex.utils.WXJsonUtils;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXReflectionUtils;
-import com.taobao.weex.utils.WXUtils;
-import com.taobao.weex.utils.WXViewUtils;
-import com.taobao.weex.utils.cache.RegisterCache;
-import com.taobao.weex.utils.tools.LogDetail;
-import com.taobao.weex.utils.tools.TimeCalculator;
-import java.io.Serializable;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * Each instance of WXSDKInstance represents an running weex instance.
- * It can be a pure weex view, or mixed with native view
- */
-public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChangeListener {
-
- private static final String SOURCE_TEMPLATE_BASE64_MD5 = "templateSourceBase64MD5";
-
- /**
- * Devtool protocol
- */
- public static String ACTION_DEBUG_INSTANCE_REFRESH = "DEBUG_INSTANCE_REFRESH";
- public static String ACTION_INSTANCE_RELOAD = "INSTANCE_RELOAD";
-
- //Performance
- public boolean mEnd = false;
- public boolean mHasCreateFinish = false;
- public static final String BUNDLE_URL = "bundleUrl";
- private IWXUserTrackAdapter mUserTrackAdapter;
- private IWXRenderListener mRenderListener;
- private IWXStatisticsListener mStatisticsListener;
- /** package **/ Context mContext;
- private final String mInstanceId;
- private WXAbstractRenderContainer mRenderContainer;
- private WXComponent mRootComp;
- private boolean mRendered;
- private WXRefreshData mLastRefreshData;
- private NestedInstanceInterceptor mNestedInstanceInterceptor;
- private String mBundleUrl = "";
- public static String requestUrl = "requestUrl";
- private boolean isDestroy=false;
- private boolean hasException = false;
- private boolean isRenderSuccess = false;
- private boolean createInstanceHeartBeat = false;
- private Map<String,Serializable> mUserTrackParams;
- private NativeInvokeHelper mNativeInvokeHelper;
- private boolean isCommit=false;
- private WXGlobalEventReceiver mGlobalEventReceiver=null;
- private boolean trackComponent;
- private boolean enableLayerType = true;
- private boolean mNeedValidate = false;
- private boolean mNeedReLoad = false;
- private boolean mUseScroller = false;
- private int mInstanceViewPortWidth = 750;
- private boolean enableFullScreenHeight = false;
- private WXInstanceApm mApmForInstance;
- private @NonNull
- FlatGUIContext mFlatGUIContext =new FlatGUIContext();
-
- private Map<String,String> mContainerInfo;
-
- public boolean isNewFsEnd = false;
- private List<JSONObject> componentsInfoExceedGPULimit = new LinkedList<>();
-
- /**
- * bundle type
- */
- public WXBridgeManager.BundType bundleType;
- public long mRenderStartNanos;
- public int mExecJSTraceId = WXTracing.nextId();
-
- private boolean isViewDisAppear = false;
-
- /**
- *for network tracker
- */
- public String mwxDims[] = new String [5];
- public long measureTimes[] = new long [5];
-
- public WeakReference<String> templateRef;
- public Map<String,List<String>> responseHeaders = new HashMap<>();
-
- /**
- * Render strategy.
- */
- private WXRenderStrategy mRenderStrategy = WXRenderStrategy.APPEND_ASYNC;
-
- private boolean mDisableSkipFrameworkInit = false;
-
- /**
- * Render start time
- */
- public long mRenderStartTime;
- /**
- * Refresh start time
- */
- private long mRefreshStartTime;
- private WXPerformance mWXPerformance;
- private ScrollView mScrollView;
- private WXScrollView.WXScrollViewListener mWXScrollViewListener;
-
- private List<OnWXScrollListener> mWXScrollListeners;
-
- private List<String> mLayerOverFlowListeners;
-
- private List<ActionBarHandler> mWXActionbarHandlers;
-
- private List<OnBackPressedHandler> mWXBackPressedHandlers;
-
- private WXSDKInstance mParentInstance;
-
- private String mRenderType = RenderTypes.RENDER_TYPE_NATIVE;
-
- public TimeCalculator mTimeCalculator;
- /**
- * Default Width And Viewport is 750,
- * when screen width change, we adjust viewport to adapter screen change
- * */
- private boolean mAutoAdjustDeviceWidth = WXEnvironment.AUTO_ADJUST_ENV_DEVICE_WIDTH;
-
- public List<JSONObject> getComponentsExceedGPULimit(){return componentsInfoExceedGPULimit;}
- @RestrictTo(Scope.LIBRARY)
- public void setComponentsInfoExceedGPULimit(JSONObject component){
- if(component!= null && !component.isEmpty()){
- componentsInfoExceedGPULimit.add(component);
- }
- }
-
- public List<String> getLayerOverFlowListeners() {
- return mLayerOverFlowListeners;
- }
-
- public void addLayerOverFlowListener(String ref) {
- if (mLayerOverFlowListeners == null)
- mLayerOverFlowListeners = new ArrayList<>();
- mLayerOverFlowListeners.add(ref);
- }
-
- public void removeLayerOverFlowListener(String ref) {
- if (mLayerOverFlowListeners != null)
- mLayerOverFlowListeners.remove(ref);
- }
-
- /**
- * whether we are in preRender mode
- * */
- private volatile boolean isPreRenderMode;
-
- private boolean mCurrentGround = false;
- private ComponentObserver mComponentObserver;
- private Map<String, GraphicActionAddElement> inactiveAddElementAction = new ArrayMap<>();
-
- private Map<Long, ContentBoxMeasurement> mContentBoxMeasurements = new ArrayMap<>();
-
- private List<InstanceOnFireEventInterceptor> mInstanceOnFireEventInterceptorList;
-
-
- /**
- * network handler
- */
- public interface ImageNetworkHandler {
- public String fetchLocal(String url);
- }
-
- public interface StreamNetworkHandler {
- public String fetchLocal(String url);
- }
-
- public interface CustomFontNetworkHandler {
- public String fetchLocal(String url);
- }
-
- private ImageNetworkHandler mImageNetworkHandler;
-
- private StreamNetworkHandler mStreamNetworkHandler;
-
- private CustomFontNetworkHandler mCustomFontNetworkHandler;
-
- public ImageNetworkHandler getImageNetworkHandler() {
- return mImageNetworkHandler;
- }
-
- public void setImageNetworkHandler(ImageNetworkHandler imageNetworkHandler) {
- this.mImageNetworkHandler = imageNetworkHandler;
- }
-
- public StreamNetworkHandler getStreamNetworkHandler() {
- return mStreamNetworkHandler;
- }
-
- public void setStreamNetworkHandler(StreamNetworkHandler streamNetworkHandler) {
- this.mStreamNetworkHandler = streamNetworkHandler;
- }
-
- public CustomFontNetworkHandler getCustomFontNetworkHandler() {
- return mCustomFontNetworkHandler;
- }
-
- public void setCustomFontNetworkHandler(CustomFontNetworkHandler customFontNetworkHandler) {
- this.mCustomFontNetworkHandler = customFontNetworkHandler;
- }
-
-
- /**
- * ActionBar Handler
- */
-
- public interface ActionBarHandler {
- boolean onSupportNavigateUp();
- }
-
- public interface OnBackPressedHandler {
- boolean onBackPressed();
- }
-
- /**
- * set make weexCore run in single process mode
- * @param flag true means weexCore run in single process mode or multi process mode
- */
- public void setUseSingleProcess(boolean flag) {
- WXBridgeManager.getInstance().setUseSingleProcess(flag);
- }
-
- /**
- * set open SandBox
- * @param flag
- */
- public void setUseSandBox(boolean flag) {
- WXBridgeManager.getInstance().setSandBoxContext(flag);
- }
-
- public PriorityQueue<WXEmbed> hiddenEmbeds;
-
- private int maxHiddenEmbedsNum = -1; //max hidden embed num, -1 standard for ulimit
-
- public int getMaxHiddenEmbedsNum() {
- return maxHiddenEmbedsNum;
- }
-
- public void setMaxHiddenEmbedsNum(int maxHiddenEmbedsNum) {
- this.maxHiddenEmbedsNum = maxHiddenEmbedsNum;
- }
-
- @WorkerThread
- @RestrictTo(Scope.LIBRARY)
- public void addInActiveAddElementAction(String ref, GraphicActionAddElement action){
- inactiveAddElementAction.put(ref, action);
- }
-
- @WorkerThread
- @RestrictTo(Scope.LIBRARY)
- public void removeInActiveAddElmentAction(String ref){
- inactiveAddElementAction.remove(ref);
- }
-
- @WorkerThread
- @RestrictTo(Scope.LIBRARY)
- public GraphicActionAddElement getInActiveAddElementAction(String ref){
- return inactiveAddElementAction.get(ref);
- }
-
- /**
- * If anchor is created manually(etc. define a layout xml resource ),
- * be aware do not add it to twice when {@link IWXRenderListener#onViewCreated(WXSDKInstance, View)}.
- * @param a
- */
- public void setRenderContainer(RenderContainer a){
- setWXAbstractRenderContainer(a);
- }
-
- public void setWXAbstractRenderContainer(WXAbstractRenderContainer a){
- if(a != null) {
- a.setSDKInstance(this);
- a.addOnLayoutChangeListener(this);
- }
-
- mRenderContainer = a;
- if (mRenderContainer != null && mRenderContainer.getLayoutParams() != null
- && mRenderContainer.getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT) {
- WXBridgeManager.getInstance().post(new Runnable() {
- @Override
- public void run() {
- WXBridgeManager.getInstance().setRenderContentWrapContentToCore(true, getInstanceId());
- }
- });
- } else {
- WXBridgeManager.getInstance().post(new Runnable() {
- @Override
- public void run() {
- WXBridgeManager.getInstance().setRenderContentWrapContentToCore(false, getInstanceId());
- }
- });
- }
- }
-
- private int mMaxDeepLayer;
-
- public boolean isTrackComponent() {
- return trackComponent;
- }
-
- public void setTrackComponent(boolean trackComponent) {
- this.trackComponent = trackComponent;
- }
-
- /**
- * Tell whether it is enabled to change the layerType
- * {@link android.view.View#setLayerType(int, Paint)}
- * @return True for enable to change the layerType of component, false otherwise. The default
- * is True
- */
- public boolean isLayerTypeEnabled() {
- return enableLayerType;
- }
-
- /**
- * Enable the ability of changing layerType. e.g. {@link android.view.View#setLayerType(int, Paint)}
- * Disable the ability of changing layerType will have tremendous <strong>performance
- * punishment</strong>.
- *
- * <strong>Do not</strong> set this to false unless you know exactly what you are doing.
- * @param enable True for enable to change the layerType of component, false otherwise. The default
- * is True
- */
- public void enableLayerType(boolean enable) {
- enableLayerType = enable;
- }
-
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- public @NonNull
- FlatGUIContext getFlatUIContext(){
- return mFlatGUIContext;
- }
-
- public boolean isNeedValidate() {
- return mNeedValidate;
- }
-
- public boolean isNeedReLoad() {
- return mNeedReLoad;
- }
-
- public void setNeedLoad(boolean load) {
- mNeedReLoad = load;
- }
-
- @RestrictTo(Scope.LIBRARY)
- public void setEnableFullScreenHeight(boolean fullScreenHeight){enableFullScreenHeight = fullScreenHeight;}
-
- @RestrictTo(Scope.LIBRARY)
- public boolean isFullScreenHeightEnabled(){return enableFullScreenHeight;}
-
- public boolean isUseScroller() {
- return mUseScroller;
- }
-
- public void setUseScroller(boolean use) {
- mUseScroller = use;
- }
-
- public void setInstanceViewPortWidth(int instanceViewPortWidth) {
- setInstanceViewPortWidth(instanceViewPortWidth,false);
-
- }
- public void setInstanceViewPortWidth(int instanceViewPortWidth,boolean fromMetaModule){
- this.mInstanceViewPortWidth = instanceViewPortWidth;
- this.mAutoAdjustDeviceWidth = false;
- if(!fromMetaModule){
- WXBridgeManager.getInstance().setViewPortWidth(getInstanceId(), mInstanceViewPortWidth);
- }
- }
- public void resetDeviceDisplayOfPage(){
- WXBridgeManager.getInstance().setDeviceDisplayOfPage(getInstanceId(), WXViewUtils.getScreenWidth(getContext()), WXViewUtils.getScreenHeight(getContext()));
- }
- public void setPageKeepRawCssStyles(){
- WXBridgeManager.getInstance().setPageArgument(getInstanceId(),"reserveCssStyles","true");
- }
- public void reloadPageLayout(){
- WXBridgeManager.getInstance().reloadPageLayout(getInstanceId());
- }
-
- public void setAutoAdjustDeviceWidth(boolean autoAdjustViewPort){
- this.mAutoAdjustDeviceWidth = autoAdjustViewPort;
- }
-
- public boolean isAutoAdjustDeviceWidth(){
- return mAutoAdjustDeviceWidth;
- }
-
- private void setDeviceDisplay(float deviceWith, float deviceHeight, float scale){
- WXBridgeManager.getInstance().setDeviceDisplay(getInstanceId(), deviceWith, deviceHeight, scale);
- }
-
-
-
- public int getInstanceViewPortWidth(){
- return mInstanceViewPortWidth;
- }
-
- public interface OnInstanceVisibleListener{
- void onAppear();
- void onDisappear();
- }
- private List<OnInstanceVisibleListener> mVisibleListeners = new ArrayList<>();
-
- public WXSDKInstance(Context context) {
- mInstanceId = WXSDKManager.getInstance().generateInstanceId();
- init(context);
- }
-
- //for preInit
- public WXSDKInstance(){
- mInstanceId = WXSDKManager.getInstance().generateInstanceId();
- mWXPerformance = new WXPerformance(mInstanceId);
- mApmForInstance = new WXInstanceApm(mInstanceId);
- WXSDKManager.getInstance().getAllInstanceMap().put(mInstanceId,this);
- mTimeCalculator = new TimeCalculator(this);
- }
-
-
- /**
- * For unittest only.
- */
- @RestrictTo(Scope.TESTS)
- WXSDKInstance(Context context,String id) {
- mInstanceId = id;
- init(context);
- }
-
- public WXComponent getRootComponent() {
- return mRootComp;
- }
-
- public void setNestedInstanceInterceptor(NestedInstanceInterceptor interceptor){
- mNestedInstanceInterceptor = interceptor;
- }
-
- public final WXSDKInstance createNestedInstance(NestedContainer container){
- WXSDKInstance sdkInstance = newNestedInstance();
- if(mNestedInstanceInterceptor != null){
- mNestedInstanceInterceptor.onCreateNestInstance(sdkInstance,container);
- }
- if(sdkInstance != null){
- sdkInstance.setComponentObserver(this.getComponentObserver());
- }
- return sdkInstance;
- }
-
- protected WXSDKInstance newNestedInstance() {
- return new WXSDKInstance(mContext);
- }
- public boolean isHasException() {
- return hasException;
- }
-
- public void setHasException(boolean hasException) {
- this.hasException = hasException;
- }
-
- public void createInstanceFuncHeartBeat() {
- WXLogUtils.d("createInstanceFuncHeartBeat: " + mInstanceId);
- this.createInstanceHeartBeat = true;
- getApmForInstance().onStage(WXInstanceApm.KEY_PAGE_STAGES_END_EXCUTE_BUNDLE);
- }
-
- public void addOnInstanceVisibleListener(OnInstanceVisibleListener l){
- mVisibleListeners.add(l);
- }
-
- public void removeOnInstanceVisibleListener(OnInstanceVisibleListener l){
- mVisibleListeners.remove(l);
- }
-
- public void init(Context context) {
- RegisterCache.getInstance().idle(true);
- mContext = context;
- mContainerInfo = new HashMap<>(4);
- mNativeInvokeHelper = new NativeInvokeHelper(mInstanceId);
-
- if (null == mWXPerformance){
- mWXPerformance = new WXPerformance(mInstanceId);
- }
- if (null == mApmForInstance){
- mApmForInstance = new WXInstanceApm(mInstanceId);
- }
-
- mWXPerformance.WXSDKVersion = WXEnvironment.WXSDK_VERSION;
- mWXPerformance.JSLibInitTime = WXEnvironment.sJSLibInitTime;
-
- mUserTrackAdapter=WXSDKManager.getInstance().getIWXUserTrackAdapter();
-
- WXSDKManager.getInstance().getAllInstanceMap().put(mInstanceId,this);
-
- mContainerInfo.put(WXInstanceApm.KEY_PAGE_PROPERTIES_CONTAINER_NAME, context instanceof Activity
- ? context.getClass().getSimpleName()
- :"unKnowContainer"
- );
- mContainerInfo.put(WXInstanceApm.KEY_PAGE_PROPERTIES_INSTANCE_TYPE,"page");
-
- // WXBridgeManager.getInstance().checkJsEngineMultiThread();
- mDisableSkipFrameworkInit = isDisableSkipFrameworkInDataRender();
-
- if(mTimeCalculator == null) {
- mTimeCalculator = new TimeCalculator(this);
- }
- }
-
- /**
- * Set a Observer for component.
- * This observer will be called in each component, should not doing
- * anything will impact render performance.
- *
- * @param observer
- */
- public void setComponentObserver(ComponentObserver observer){
- mComponentObserver = observer;
- }
-
- public ComponentObserver getComponentObserver(){
- return mComponentObserver;
- }
-
- public NativeInvokeHelper getNativeInvokeHelper() {
- return mNativeInvokeHelper;
- }
-
- @Deprecated
- public void setBizType(String bizType) {
- if (!TextUtils.isEmpty(bizType)) {
- mWXPerformance.bizType = bizType;
- }
- }
-
- public ScrollView getScrollView() {
- return mScrollView;
- }
-
- public void setRootScrollView(ScrollView scrollView) {
- mScrollView = scrollView;
- if (mWXScrollViewListener != null && mScrollView instanceof WXScrollView) {
- ((WXScrollView) mScrollView).addScrollViewListener(mWXScrollViewListener);
- }
- }
-
- @Deprecated
- public void registerScrollViewListener(WXScrollView.WXScrollViewListener scrollViewListener) {
- mWXScrollViewListener = scrollViewListener;
- }
-
- @Deprecated
- public WXScrollView.WXScrollViewListener getScrollViewListener() {
- return mWXScrollViewListener;
- }
-
- @Deprecated
- public void setIWXUserTrackAdapter(IWXUserTrackAdapter adapter) {
- }
-
- public void setContainerInfo(String key,String val){
- mContainerInfo.put(key,val);
- }
-
- public Map<String, String> getContainerInfo() {
- return mContainerInfo;
- }
-
- /**
- * Render template asynchronously, use {@link WXRenderStrategy#APPEND_ASYNC} as render strategy
- * @param template bundle js
- * @param options os iphone/android/ipad
- * weexversion Weex version(like 1.0.0)
- * appversion App version(like 1.0.0)
- * devid Device id(like Aqh9z8dRJNBhmS9drLG5BKCmXhecHUXIZoXOctKwFebH)
- * sysversion Device system version(like 5.4.4、7.0.4, should be used with os)
- * sysmodel Device model(like iOS:"MGA82J/A", android:"MI NOTE LTE")
- * Time UNIX timestamp, UTC+08:00
- * TTID(Optional)
- * MarkertId
- * Appname(Optional) tm,tb,qa
- * Bundleurl(Optional) template url
- * @param jsonInitData Initial data for rendering
- */
- public void render(String template, Map<String, Object> options, String jsonInitData) {
- render(template, options, jsonInitData, WXRenderStrategy.APPEND_ASYNC);
- }
-
- /**
- * Render template asynchronously
- * @param template bundle js
- * @param options os iphone/android/ipad
- * weexversion Weex version(like 1.0.0)
- * appversion App version(like 1.0.0)
- * devid Device id(like Aqh9z8dRJNBhmS9drLG5BKCmXhecHUXIZoXOctKwFebH)
- * sysversion Device system version(like 5.4.4、7.0.4, should be used with os)
- * sysmodel Device model(like iOS:"MGA82J/A", android:"MI NOTE LTE")
- * Time UNIX timestamp, UTC+08:00
- * TTID(Optional)
- * MarkertId
- * Appname(Optional) tm,tb,qa
- * Bundleurl(Optional) template url
- * @param jsonInitData Initial data for rendering
- * @param flag RenderStrategy {@link WXRenderStrategy}
- */
- @Deprecated
- public void render(String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag) {
- render(WXPerformance.DEFAULT, template, options, jsonInitData, flag);
- }
-
- /**
- * Render template asynchronously
- *
- * @param pageName, used for performance log.
- * @param template bundle js
- * @param options os iphone/android/ipad
- * weexversion Weex version(like 1.0.0)
- * appversion App version(like 1.0.0)
- * devid Device id(like Aqh9z8dRJNBhmS9drLG5BKCmXhecHUXIZoXOctKwFebH)
- * sysversion Device system version(like 5.4.4、7.0.4, should be used with os)
- * sysmodel Device model(like iOS:"MGA82J/A", android:"MI NOTE LTE")
- * Time UNIX timestamp, UTC+08:00
- * TTID(Optional)
- * MarkertId
- * Appname(Optional) tm,tb,qa
- * Bundleurl(Optional) template url
- * @param jsonInitData Initial data for rendering
- * @param flag RenderStrategy {@link WXRenderStrategy}
- */
- public void render(String pageName, String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag) {
- render(pageName, new Script(template), options, jsonInitData, flag);
- }
-
- public void render(String pageName, Script template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag) {
- mWXPerformance.beforeInstanceRender(mInstanceId);
-
- if(WXEnvironment.isApkDebugable() && WXPerformance.DEFAULT.equals(pageName)){
-
- if (getUIContext() != null) {
- new AlertDialog.Builder(getUIContext())
- .setTitle("Error: Missing pageName")
- .setMessage("We highly recommend you to set pageName. Call" +
- "\nWXSDKInstance#render(String pageName, String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag)\n" +
- "to fix it.")
- .show();
- }
-
- return;
- }
- renderInternal(pageName,template,options,jsonInitData,flag);
- }
-
- /**
- * Render binary template asynchronously in DATA_RENDER_BINARY strategy.
- */
- public void render(String pageName, byte[] template, Map<String, Object> options, String jsonInitData) {
- render(pageName, new Script(template), options, jsonInitData, WXRenderStrategy.DATA_RENDER_BINARY);
- }
-
- private void ensureRenderArchor(){
- if(mRenderContainer == null){
- if (getContext() != null) {
- setRenderContainer(new RenderContainer(getContext()));
- mRenderContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- mRenderContainer.setBackgroundColor(Color.TRANSPARENT);
- mRenderContainer.setSDKInstance(this);
- mRenderContainer.addOnLayoutChangeListener(this);
- }
- }
- }
-
- private void renderInternal(String pageName,
- String template,
- Map<String, Object> options,
- String jsonInitData,
- WXRenderStrategy flag) {
- if (mRendered || TextUtils.isEmpty(template)) {
- return;
- }
- renderInternal(pageName, new Script(template), options, jsonInitData, flag);
- }
-
- private boolean isPreInit = false;
- public boolean isPreInitMode(){
- return isPreInit;
- }
-
- private boolean isPreDownLoad =false;
- public boolean isPreDownLoad(){
- return isPreDownLoad;
- }
-
- public void onInstanceReady(){
- WXLogUtils.d("test->","onInstanceReady");
- mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_CONTAINER_READY);
- if (!isPreInit && !isPreDownLoad){
- return;
- }
- mApmForInstance.onInstanceReady(isPreDownLoad);
- if (isPreDownLoad){
- mHttpListener.onInstanceReady();
- }
- }
-
- public void preInit(String pageName,
- String script,
- Map<String, Object> options,
- String jsonInitData,
- WXRenderStrategy flag){
- isPreInit = true;
- mRenderStrategy = flag;
- Map<String, Object> renderOptions = options;
- if (renderOptions == null) {
- renderOptions = new HashMap<>();
- }
- //mApmForInstance.doInit();
- mApmForInstance.isReady = false;
- WXSDKManager.getInstance().createInstance(this, new Script(script), renderOptions, jsonInitData);
- }
-
- public void preDownLoad(String url,
- Map<String, Object> options,
- String jsonInitData,
- WXRenderStrategy flag){
- this.isPreDownLoad =true;
- mRenderStrategy = flag;
- mApmForInstance.isReady = false;
- renderByUrl(url,url,options,jsonInitData,flag);
- }
-
-
- private void renderInternal(String pageName,
- Script template,
- Map<String, Object> options,
- String jsonInitData,
- WXRenderStrategy flag){
- if (mRendered || template == null || template.isEmpty()) {
- return;
- }
-
- LogDetail logDetail = mTimeCalculator.createLogDetail("renderInternal");
- mRenderStrategy = flag;
-
- //some case ,from render(template),but not render (url)
- if (!mApmForInstance.hasInit()){
- mApmForInstance.doInit();
- }
- mApmForInstance.setPageName(pageName);
- mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_RENDER_ORGIGIN);
- mApmForInstance.doDelayCollectData();
-
- mWXPerformance.pageName = (TextUtils.isEmpty(pageName) ? "defaultBundleUrl":pageName);
- if (TextUtils.isEmpty(mBundleUrl)) {
- mBundleUrl = mWXPerformance.pageName;
- }
-
- if (WXTracing.isAvailable()) {
- WXTracing.TraceEvent traceEvent = WXTracing.newEvent("executeBundleJS", mInstanceId, -1);
- traceEvent.traceId = mExecJSTraceId;
- traceEvent.iid = mInstanceId;
- traceEvent.tname = "JSThread";
- traceEvent.ph = "B";
- traceEvent.submit();
- mRenderStartNanos = System.nanoTime();
- }
-
- ensureRenderArchor();
-
- Map<String, Object> renderOptions = options;
- if (renderOptions == null) {
- renderOptions = new HashMap<>();
- }
-
- if (WXEnvironment.sDynamicMode && !TextUtils.isEmpty(WXEnvironment.sDynamicUrl) && renderOptions.get("dynamicMode") == null) {
- renderOptions.put("dynamicMode", "true");
- renderByUrl(pageName, WXEnvironment.sDynamicUrl, renderOptions, jsonInitData, flag);
- return;
- }
-
- TimeCalculator timeCalculator = new TimeCalculator(this);
-
- mWXPerformance.JSTemplateSize = template.length() / 1024f;
- mApmForInstance.addStats(WXInstanceApm.KEY_PAGE_STATS_BUNDLE_SIZE,mWXPerformance.JSTemplateSize);
- mRenderStartTime = System.currentTimeMillis();
- WXSDKManager.getInstance().setCrashInfo(WXEnvironment.WEEX_CURRENT_KEY,pageName);
- if(mAutoAdjustDeviceWidth && WXDeviceUtils.isAutoResize(mContext)){
- if(WXEnvironment.AUTO_UPDATE_APPLICATION_SCREEN_SIZE) {
- WXViewUtils.updateApplicationScreen(mContext);
- }
- WXParams params = WXBridgeManager.getInstance().getInitParams();
- if(params != null && !TextUtils.equals(params.getDeviceWidth(), String.valueOf(WXViewUtils.getScreenWidth(mContext)))){
- params.setDeviceWidth(String.valueOf(WXViewUtils.getScreenWidth(mContext)));
- params.setDeviceHeight(String.valueOf(WXViewUtils.getScreenHeight(mContext)));
- float density = WXEnvironment.sApplication.getResources().getDisplayMetrics().density;
- WXEnvironment.addCustomOptions(WXConfig.scale, Float.toString(density));
- String statusBarHeight = null;
- if(WXViewUtils.getStatusBarHeight(mContext) > 0 ){
- statusBarHeight = String.valueOf(WXViewUtils.getStatusBarHeight(mContext));
- }
- WXBridgeManager.getInstance().updateInitDeviceParams(params.getDeviceWidth(),
- params.getDeviceHeight(),
- Float.toString(density), statusBarHeight);
- setDeviceDisplay(WXViewUtils.getScreenWidth(mContext),
- WXViewUtils.getScreenHeight(mContext),
- WXViewUtils.getScreenDensity(mContext));
- }
- }
- logDetail.taskStart();
- if (isPreInitMode()){
- getApmForInstance().onStage(WXInstanceApm.KEY_PAGE_STAGES_LOAD_BUNDLE_START);
- WXBridgeManager.getInstance().loadJsBundleInPreInitMode(getInstanceId(),template.getContent());
- } else {
- WXSDKManager.getInstance().createInstance(this, template, renderOptions, jsonInitData);
- }
- logDetail.taskEnd();
- mRendered = true;
-
- final IWXJscProcessManager wxJscProcessManager = WXSDKManager.getInstance().getWXJscProcessManager();
-
- if(wxJscProcessManager != null && wxJscProcessManager.shouldReboot()) {
- WXSDKManager.getInstance().postOnUiThread(new Runnable() {
- @Override
- public void run() {
- checkWhiteScreen();
- if(isDestroy || hasException || isRenderSuccess) {
- return;
- }
-
- // there is no need to reboot js engine if render by eagle
- if(isDataRender()) {
- return;
- }
-
- View containerView = getContainerView();
- if(containerView instanceof ViewGroup) {
- if(0 == ((ViewGroup) containerView).getChildCount()) {
- if(wxJscProcessManager.withException(WXSDKInstance.this)) {
- onJSException(String.valueOf(WX_ERR_RELOAD_PAGE),"jsc reboot","jsc reboot");
- }
- if(!createInstanceHeartBeat) {
- WXBridgeManager.getInstance().callReportCrashReloadPage(mInstanceId, null);
- WXLogUtils.e("callReportCrashReloadPage with jsc reboot");
- }
- }
- }
- }
- }, wxJscProcessManager.rebootTimeout());
- }
- }
-
-
- private void checkWhiteScreen(){
- if (isDestroy ||!WhiteScreenUtils.doWhiteScreenCheck()){
- return;
- }
-
- boolean isWS = WhiteScreenUtils.isWhiteScreen(this);
- if (!isWS){
- return;
- }
- WXErrorCode errorCode = WXErrorCode.WX_ERROR_WHITE_SCREEN;
- Map<String,String> args = new HashMap<>(1);
- String vieTreeMsg = WhiteScreenUtils.takeViewTreeSnapShot(this);
- args.put("viewTree",null == vieTreeMsg?"null viewTreeMsg":vieTreeMsg);
- args.put("weexCoreThreadStackTrace",WXBridgeManager.getInstance().getWeexCoreThreadStackTrace());
-
- for (Map.Entry<String,String> entry: WXStateRecord.getInstance().getStateInfo().entrySet()){
- args.put(entry.getKey(),entry.getValue());
- }
- WXExceptionUtils.commitCriticalExceptionRT(getInstanceId(),errorCode,"checkEmptyScreen",errorCode.getErrorMsg(),args);
- }
-
-
- public boolean skipFrameworkInit(){
- return isDataRender() && !mDisableSkipFrameworkInit;
- }
-
- private boolean isDataRender() {
- return getRenderStrategy() == WXRenderStrategy.DATA_RENDER_BINARY || getRenderStrategy() == WXRenderStrategy.DATA_RENDER;
- }
-
- private void renderByUrlInternal(String pageName,
- final String url,
- Map<String, Object> options,
- final String jsonInitData,
- WXRenderStrategy flag) {
-
-
- LogDetail logDetail = mTimeCalculator.createLogDetail("renderByUrlInternal");
- logDetail.taskStart();
- ensureRenderArchor();
- pageName = wrapPageName(pageName, url);
- mBundleUrl = url;
- mRenderStrategy = flag;
- if(WXSDKManager.getInstance().getValidateProcessor()!=null) {
- mNeedValidate = WXSDKManager.getInstance().getValidateProcessor().needValidate(mBundleUrl);
- }
-
- Map<String, Object> renderOptions = options;
- if (renderOptions == null) {
- renderOptions = new HashMap<>();
- }
- if (!renderOptions.containsKey(BUNDLE_URL)) {
- renderOptions.put(BUNDLE_URL, url);
- }
-
- getWXPerformance().pageName = pageName;
-
- mApmForInstance.doInit();
- mApmForInstance.setPageName(pageName);
-
- Uri uri = Uri.parse(url);
- if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
- mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
- String template = WXFileUtils.loadFileOrAsset(assembleFilePath(uri), mContext);
- mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_END);
- render(pageName,template , renderOptions, jsonInitData, flag);
- return;
- }
-
- boolean is_wlasm = false;
- if (uri != null && uri.getPath()!=null) {
- if(uri.getPath().endsWith(".wlasm")){
- is_wlasm = true;
- }
- }
- if (is_wlasm){
- flag = WXRenderStrategy.DATA_RENDER_BINARY;
- }
-
- IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();
-
- WXRequest wxRequest = new WXRequest();
- wxRequest.url = rewriteUri(Uri.parse(url),URIAdapter.BUNDLE).toString();
- if(wxRequest != null && !TextUtils.isEmpty(wxRequest.url)){
- requestUrl = wxRequest.url;
- }else {
- requestUrl = pageName;
- }
-
- if (wxRequest.paramMap == null) {
- wxRequest.paramMap = new HashMap<String, String>();
- }
- wxRequest.instanceId = getInstanceId();
- wxRequest.paramMap.put(KEY_USER_AGENT, WXHttpUtil.assembleUserAgent(mContext,WXEnvironment.getConfig()));
- wxRequest.paramMap.put("isBundleRequest","true");
- mHttpListener = new WXHttpListener(this, pageName, renderOptions, jsonInitData, flag, System.currentTimeMillis());
- mHttpListener.isPreDownLoadMode = isPreDownLoad;
- mHttpListener.setSDKInstance(this);
- mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
- adapter.sendRequest(wxRequest, (IWXHttpAdapter.OnHttpListener) mHttpListener);
- logDetail.taskEnd();
- }
-
- private WXHttpListener mHttpListener = null;
-
- /**
- * Use {@link #render(String, String, Map, String, WXRenderStrategy)} instead.
- * @param pageName
- * @param template
- * @param options
- * @param jsonInitData
- * @param width
- * @param height
- * @param flag
- */
- @Deprecated
- public void render(String pageName, String template, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag) {
- render(pageName,template,options,jsonInitData,flag);
- }
-
- /**
- * Render template asynchronously, use {@link WXRenderStrategy#APPEND_ASYNC} as render strategy
- * @param template bundle js
- */
- public void render(String template) {
- render(WXPerformance.DEFAULT, template, null, null, mRenderStrategy);
- }
-
- /**
- * Use {@link #render(String)} instead.
- * @param template
- * @param width
- * @param height
- */
- @Deprecated
- public void render(String template, int width, int height) {
- render(template);
- }
-
- /**
- * Use {@link #renderByUrl(String, String, Map, String, WXRenderStrategy)} instead.
- * @param pageName
- * @param url
- * @param options
- * @param jsonInitData
- * @param width
- * @param height
- * @param flag
- */
- @Deprecated
- public void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag){
- renderByUrl(pageName,url,options,jsonInitData,flag);
- }
-
- public void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final WXRenderStrategy flag) {
- renderByUrlInternal(pageName,url,options,jsonInitData,flag);
- }
-
- private String wrapPageName(String pageName, String url) {
- if(TextUtils.equals(pageName, WXPerformance.DEFAULT)){
- pageName = url;
- WXExceptionUtils.degradeUrl = pageName;
- try {
- Uri uri=Uri.parse(url);
- if(uri!=null){
- Uri.Builder builder=new Uri.Builder();
- builder.scheme(uri.getScheme());
- builder.authority(uri.getAuthority());
- builder.path(uri.getPath());
- pageName=builder.toString();
- }
- } catch (Exception e) {
- }
- }
- return pageName;
- }
-
- private String assembleFilePath(Uri uri) {
- if(uri!=null && uri.getPath()!=null){
- return uri.getPath().replaceFirst("/","");
- }
- return "";
- }
-
- public void reloadPage(boolean reloadThis) {
-
- WXSDKEngine.reload();
-
- if (reloadThis) {
- if (mContext != null) {
- Intent intent = new Intent();
- intent.setAction(ACTION_INSTANCE_RELOAD);
- intent.putExtra("url", mBundleUrl);
- mContext.sendBroadcast(intent);
- }
- // mRendered = false;
- // destroy();
- // renderInternal(mPackage, mTemplate, mOptions, mJsonInitData, mFlag);
- // refreshInstance("{}");
- } else {
- IWXConfigAdapter adapter = WXSDKManager.getInstance().getWxConfigAdapter();
- if (adapter != null) {
- boolean degrade = Boolean.parseBoolean(adapter
- .getConfig("android_weex_ext_config",
- "degrade_to_h5_if_not_reload",
- "true"));
- WXLogUtils.e("degrade : " + degrade);
- if(degrade) {
- onJSException(String.valueOf(WX_ERR_RELOAD_PAGE.getErrorCode()),"Do not reloadPage", "Do not reloadPage degradeToH5");
- WXLogUtils.e("Do not reloadPage degradeToH5");
- }
- }
- }
- }
-
- /**
- * Refresh instance asynchronously.
- * @param data the new data
- */
- public void refreshInstance(Map<String, Object> data) {
- if (data == null) {
- return;
- }
- refreshInstance(WXJsonUtils.fromObjectToJSONString(data));
- }
-
- /**
- * Refresh instance asynchronously.
- * @param jsonData the new data
- */
- public void refreshInstance(String jsonData) {
- if (jsonData == null) {
- return;
- }
- mRefreshStartTime = System.currentTimeMillis();
- //cancel last refresh message
- if (mLastRefreshData != null) {
- mLastRefreshData.isDirty = true;
- }
-
- mLastRefreshData = new WXRefreshData(jsonData, false);
-
- WXSDKManager.getInstance().refreshInstance(mInstanceId, mLastRefreshData);
- }
-
- public WXRenderStrategy getRenderStrategy() {
- return mRenderStrategy;
- }
-
- public Context getUIContext() {
- return mContext;
- }
-
- public String getInstanceId() {
- return mInstanceId;
- }
-
- public Context getContext() {
- return mContext;
- }
-
- public int getWeexHeight() {
- return mRenderContainer == null ? 0: mRenderContainer.getHeight();
- }
-
- public int getWeexWidth() {
- return mRenderContainer == null ? 0: mRenderContainer.getWidth();
- }
-
-
- public IWXImgLoaderAdapter getImgLoaderAdapter() {
- return WXSDKManager.getInstance().getIWXImgLoaderAdapter();
- }
-
- public IDrawableLoader getDrawableLoader() {
- return WXSDKManager.getInstance().getDrawableLoader();
- }
-
- public URIAdapter getURIAdapter(){
- return WXSDKManager.getInstance().getURIAdapter();
- }
-
- public Uri rewriteUri(Uri uri,String type){
- return getURIAdapter().rewrite(this,type,uri);
- }
-
- public IWXHttpAdapter getWXHttpAdapter() {
- return WXSDKManager.getInstance().getIWXHttpAdapter();
- }
-
- public IWXStatisticsListener getWXStatisticsListener() {
- return mStatisticsListener;
- }
-
- public @Nullable
- IWebSocketAdapter getWXWebSocketAdapter() {
- return WXSDKManager.getInstance().getIWXWebSocketAdapter();
- }
-
- @Deprecated
- public void reloadImages() {
- if (mScrollView == null) {
- return;
- }
- }
-
-
- public boolean isPreRenderMode() {
- return this.isPreRenderMode;
- }
-
- public void setPreRenderMode(final boolean isPreRenderMode) {
- WXSDKManager.getInstance().getWXRenderManager().postOnUiThread(new Runnable() {
- @Override
- public void run() {
- WXSDKInstance.this.isPreRenderMode = isPreRenderMode;
- }
- },0);
- }
-
- public void setContext(@NonNull Context context) {
- this.mContext = context;
- }
-
- /********************************
- * begin register listener
- ********************************************************/
- public void registerRenderListener(IWXRenderListener listener) {
- mRenderListener = listener;
- }
-
- @Deprecated
- public void registerActivityStateListener(IWXActivityStateListener listener) {
-
- }
-
- public void registerStatisticsListener(IWXStatisticsListener listener) {
- mStatisticsListener = listener;
- }
-
- /**set render start time*/
- public void setRenderStartTime(long renderStartTime) {
- this.mRenderStartTime = renderStartTime;
- }
-
- /********************************
- * end register listener
- ********************************************************/
-
-
- /********************************
- * begin hook Activity life cycle callback
- ********************************************************/
-
- @Override
- public void onActivityCreate() {
-
- // module listen Activity onActivityCreate
- WXModuleManager.onActivityCreate(getInstanceId());
-
- if(mRootComp != null) {
- mRootComp.onActivityCreate();
- }else{
- if (WXEnvironment.isApkDebugable()){
- WXLogUtils.w("Warning :Component tree has not build completely,onActivityCreate can not be call!");
- }
- }
-
- mGlobalEventReceiver=new WXGlobalEventReceiver(this);
- try {
- getContext().registerReceiver(mGlobalEventReceiver, new IntentFilter(WXGlobalEventReceiver.EVENT_ACTION));
- } catch (Throwable e) {
- // Huawei may throw a exception if register more than 500 BroadcastReceivers
- WXLogUtils.e(e.getMessage());
- mGlobalEventReceiver = null;
- }
-
- }
-
- @Override
- public void onActivityStart() {
-
- // module listen Activity onActivityCreate
- WXModuleManager.onActivityStart(getInstanceId());
- if(mRootComp != null) {
- mRootComp.onActivityStart();
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely,onActivityStart can not be call!");
-
- }
- }
-
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
-
- WXModuleManager.onCreateOptionsMenu(getInstanceId(),menu);
- if(mRootComp != null) {
- mRootComp.onCreateOptionsMenu(menu);
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely,onActivityStart can not be call!");
-
- }
- }
- return true;
- }
-
- @Override
- public void onActivityPause() {
- onViewDisappear();
- if(!isCommit){
- if(mUseScroller){
- mWXPerformance.useScroller=1;
- }
- mWXPerformance.maxDeepViewLayer=getMaxDeepLayer();
- mWXPerformance.wxDims = mwxDims;
- mWXPerformance.measureTimes = measureTimes;
- if (mUserTrackAdapter != null) {
- mUserTrackAdapter.commit(mContext, null, IWXUserTrackAdapter.LOAD, mWXPerformance, getUserTrackParams());
- }
- isCommit=true;
- }
- // module listen Activity onActivityPause
- WXModuleManager.onActivityPause(getInstanceId());
- if(mRootComp != null) {
- mRootComp.onActivityPause();
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely,onActivityPause can not be call!");
- }
- }
-
- if (!mCurrentGround) {
- WXLogUtils.i("Application to be in the backround");
- Intent intent = new Intent(WXGlobalEventReceiver.EVENT_ACTION);
- intent.putExtra(WXGlobalEventReceiver.EVENT_NAME, Constants.Event.PAUSE_EVENT);
- intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID, getInstanceId());
- /**
- * Fix NPE just like {@link #onActivityResume()}
- */
- if (null != mContext){
- mContext.sendBroadcast(intent);
- }else {
- try {
- WXEnvironment.getApplication().sendBroadcast(intent);
- } catch (Exception e){
- WXLogUtils.e("weex",e);
- }
- }
- this.mCurrentGround = true;
- }
-
- //component appear
- if((WXEnvironment.isApkDebugable() || WXEnvironment.isPerf()) && mApmForInstance != null){
- WXLogUtils.e("PerformanceData " + mApmForInstance.toPerfString());
- }
- }
-
-
- @Override
- public void onActivityResume() {
-
- // notify onActivityResume callback to module
- WXModuleManager.onActivityResume(getInstanceId());
-
- if(mRootComp != null) {
- mRootComp.onActivityResume();
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely, onActivityResume can not be call!");
- }
- }
-
- if (mCurrentGround) {
- WXLogUtils.i("Application to be in the foreground");
- Intent intent = new Intent(WXGlobalEventReceiver.EVENT_ACTION);
- intent.putExtra(WXGlobalEventReceiver.EVENT_NAME, Constants.Event.RESUME_EVENT);
- intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID, getInstanceId());
- //todo tmp solution for gray version
- if (null != mContext){
- mContext.sendBroadcast(intent);
- }else {
- WXEnvironment.getApplication().sendBroadcast(intent);
- }
- this.mCurrentGround = false;
- }
-
- onViewAppear();
- }
-
- @Override
- public void onActivityStop() {
-
- // notify onActivityResume callback to module
- WXModuleManager.onActivityStop(getInstanceId());
-
- if(mRootComp != null) {
- mRootComp.onActivityStop();
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely, onActivityStop can not be call!");
- }
- }
-
- }
-
- @Override
- public void onActivityDestroy() {
- WXModuleManager.onActivityDestroy(getInstanceId());
-
- if(mRootComp != null) {
- mRootComp.onActivityDestroy();
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely, onActivityDestroy can not be call!");
- }
- }
- this.mTimeCalculator.println();
- destroy();
- }
-
- @Override
- public boolean onActivityBack() {
-
- WXModuleManager.onActivityBack(getInstanceId());
-
- if(mRootComp != null) {
- return mRootComp.onActivityBack();
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely, onActivityBack can not be call!");
- }
- }
-
- return false;
- }
-
- public boolean onSupportNavigateUp() {
- if (mWXActionbarHandlers != null) {
- for (ActionBarHandler handler : mWXActionbarHandlers) {
- if (handler.onSupportNavigateUp()) {
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean onBackPressed() {
- if(mWXBackPressedHandlers != null) {
- for (OnBackPressedHandler handler : mWXBackPressedHandlers) {
- if(handler.onBackPressed()) {
- return true;
- }
- }
- }
-
- WXComponent comp = getRootComponent();
- if(comp != null) {
- WXEvent events= comp.getEvents();
- boolean hasNativeBackHook = events.contains(Constants.Event.NATIVE_BACK);
- if (hasNativeBackHook) {
- EventResult result = comp.fireEventWait(Constants.Event.NATIVE_BACK, null);
- if (WXUtils.getBoolean(result.getResult(), false)) {
- return true;
- }
- }
-
- boolean hasBackPressed = events.contains(Constants.Event.CLICKBACKITEM);
- if (hasBackPressed) {
- fireEvent(comp.getRef(), Constants.Event.CLICKBACKITEM,null, null);
- }
- return hasBackPressed;
- }
- return false;
- }
-
- public void onActivityResult(int requestCode, int resultCode, Intent data){
- WXModuleManager.onActivityResult(getInstanceId(),requestCode,resultCode,data);
-
- if(mRootComp != null) {
- mRootComp.onActivityResult(requestCode,resultCode,data);
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w("Warning :Component tree has not build completely, onActivityResult can not be call!");
- }
- }
- }
-
-
- public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
-
- WXModuleManager.onRequestPermissionsResult(getInstanceId(),requestCode,permissions,grantResults);
-
- if(mRootComp != null) {
- mRootComp.onRequestPermissionsResult(requestCode,permissions,grantResults);
- }else{
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.w(
- "Warning :Component tree has not build completely, onRequestPermissionsResult can not be call!");
- }
- }
- }
-
- /********************************
- * end hook Activity life cycle callback
- ********************************************************/
-
- public void onViewDisappear(){
- isViewDisAppear = false;
- mApmForInstance.onDisAppear();
- WXComponent comp = getRootComponent();
- if(comp != null) {
- fireEvent(comp.getRef(), Constants.Event.VIEWDISAPPEAR, null, null);
- //call disappear of nested instances
- for(OnInstanceVisibleListener instance:mVisibleListeners){
- instance.onDisappear();
- }
- }
- }
-
- public boolean isViewDisAppear(){
- return isViewDisAppear;
- }
-
- public void onViewAppear(){
- isViewDisAppear = true;
- mApmForInstance.onAppear();
- WXComponent comp = getRootComponent();
- if(comp != null) {
- fireEvent( comp.getRef(), Constants.Event.VIEWAPPEAR,null, null);
- for(OnInstanceVisibleListener instance:mVisibleListeners){
- instance.onAppear();
- }
- }
- }
-
-
- public void onCreateFinish() {
- if(mHasCreateFinish){
- return;
- }
- if (mContext != null) {
- onViewAppear();
- View wxView= mRenderContainer;
- if(mRenderListener != null) {
- mRenderListener.onViewCreated(WXSDKInstance.this, wxView);
- }
- if (mStatisticsListener != null) {
- mStatisticsListener.onFirstView();
- }
- }
- }
-
- /**
- * call back when update finish
- */
- public void onUpdateFinish() {
- if (WXEnvironment.isApkDebugable()){
- WXLogUtils.d("Instance onUpdateSuccess");
- }
- }
-
-
- public void runOnUiThread(Runnable action) {
- WXSDKManager.getInstance().postOnUiThread(action, 0);
- }
-
- public void onRenderSuccess(final int width, final int height) {
- isRenderSuccess = true;
- if (!isNewFsEnd){
- getApmForInstance().arriveNewFsRenderTime();
- }
-
- long time = System.currentTimeMillis() - mRenderStartTime;
- long[] renderFinishTime = WXBridgeManager.getInstance().getRenderFinishTime(getInstanceId());
-
- mWXPerformance.callBridgeTime = renderFinishTime[0];
- mWXPerformance.cssLayoutTime = renderFinishTime[1];
- mWXPerformance.parseJsonTime = renderFinishTime[2];
-
- mWXPerformance.totalTime = time;
- if(mWXPerformance.screenRenderTime<0.001){
- mWXPerformance.screenRenderTime = time;
- }
-
- if (mRenderListener != null && mContext != null) {
- mRenderListener.onRenderSuccess(WXSDKInstance.this, width, height);
- if (mUserTrackAdapter != null) {
- WXPerformance performance=new WXPerformance(mInstanceId);
- performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode();
- performance.args=getBundleUrl();
- mUserTrackAdapter.commit(mContext,null,IWXUserTrackAdapter.JS_BRIDGE,performance,getUserTrackParams());
- }
- if (WXEnvironment.isApkDebugable()){
- WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString());
- }
- }
- if(WXEnvironment.isPerf()){
- WXLogUtils.e("weex_perf",mWXPerformance.getPerfData());
- }
- }
-
- public void onRefreshSuccess(final int width, final int height) {
- if (mRenderListener != null && mContext != null) {
- mRenderListener.onRefreshSuccess(WXSDKInstance.this, width, height);
- }
- }
-
- public void onChangeElement(WXComponent component, boolean isOutOfScreen) {
-
- if (isDestroy() || null == mRenderContainer || mWXPerformance == null ){
- return;
- }
- if (null == component || component.isIgnoreInteraction){
- return;
- }
-
- if (mRenderContainer.hasConsumeEvent()) {
- return;
- }
-
- long lastElementChangeTime = System.currentTimeMillis();
-
- long lazyLoadTime;
-
- if (mHasCreateFinish){
- lazyLoadTime = lastElementChangeTime - mWXPerformance.renderTimeOrigin;
- if (lazyLoadTime > 8000) {
- //force record detail performance data
- return;
- }
- }
-
- if (component.mIsAddElementToTree) {
- getWXPerformance().localInteractionViewAddCount++;
- if (!isOutOfScreen)
- getWXPerformance().interactionViewAddLimitCount++;
- component.mIsAddElementToTree = false;
- }
-
- if (!isOutOfScreen) {
- mApmForInstance.arriveInteraction(component);
- }
- }
-
- public void onRenderError(final String errCode, final String msg) {
- WXStateRecord.getInstance().recordException(getInstanceId(),"onRenderError,"+errCode+","+msg);
- if (mRenderListener != null && mContext != null) {
- WXLogUtils.e("onRenderError "+errCode +","+msg);
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- if (mRenderListener != null && mContext != null) {
- mRenderListener.onException(WXSDKInstance.this, errCode, msg);
- }
- }
- });
- }
- }
-
- public void onJSException(final String errCode, final String function, final String exception) {
- WXStateRecord.getInstance().recordException(getInstanceId(),"onJSException,"+errCode+","+function+"|"+exception);
- hasException = true;
- if (mRenderListener != null && mContext != null) {
- WXLogUtils.e("onJSException "+errCode +","+exception);
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- if (mRenderListener != null && mContext != null) {
- StringBuilder builder = new StringBuilder();
- builder.append(function);
- builder.append(exception);
- mRenderListener.onException(WXSDKInstance.this, errCode, builder.toString());
- }
- }
- });
- }
- }
-
-
- @Override
- public final void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int
- oldTop, int oldRight, int oldBottom) {
- if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
- onLayoutChange(v);
- }
- }
-
- /**
- * Subclass should override this method to get notifications of layout change of GodView.
- * @param godView the godView.
- */
- public void onLayoutChange(View godView) {
-
- }
-
- private boolean mCreateInstance =true;
- public void firstScreenCreateInstanceTime(long time) {
- if(mCreateInstance) {
- mWXPerformance.firstScreenJSFExecuteTime = time -mRenderStartTime;
- mCreateInstance =false;
- }
- }
-
- public void callJsTime(final long time){
- if (!mEnd){
- mWXPerformance.fsCallJsTotalTime+=time;
- mWXPerformance.fsCallJsTotalNum++;
- }
- }
-
- public void onComponentCreate(WXComponent component,long createTime) {
- mWXPerformance.mActionAddElementCount++;
- mWXPerformance.mActionAddElementSumTime += createTime;
- if (!mEnd){
- mWXPerformance.fsComponentCreateTime+=createTime;
- mWXPerformance.fsComponentCount++;
- }
- mWXPerformance.componentCount++;
- mWXPerformance.componentCreateTime+=createTime;
- }
-
- public void callActionAddElementTime(long time) {
- mWXPerformance.mActionAddElementSumTime += time;
- }
-
- public void onOldFsRenderTimeLogic(){
- if (mEnd){
- return;
- }
- mEnd = true;
- if (mStatisticsListener != null && mContext != null) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (mStatisticsListener != null && mContext != null) {
- Trace.beginSection("onFirstScreen");
- mStatisticsListener.onFirstScreen();
- Trace.endSection();
- }
- }
- });
- }
- mApmForInstance.arriveFSRenderTime();
- mWXPerformance.fsRenderTime = System.currentTimeMillis();
- mWXPerformance.screenRenderTime = System.currentTimeMillis() - mRenderStartTime;
- }
-
- public WXSDKInstance getParentInstance() {
- return mParentInstance;
- }
-
- public void setParentInstance(WXSDKInstance mParentInstance) {
- this.mParentInstance = mParentInstance;
- }
-
- private void destroyView(View rootView) {
- try {
- if (rootView instanceof ViewGroup) {
- ViewGroup cViewGroup = ((ViewGroup) rootView);
- for (int index = 0; index < cViewGroup.getChildCount(); index++) {
- destroyView(cViewGroup.getChildAt(index));
- }
-
- cViewGroup.removeViews(0, ((ViewGroup) rootView).getChildCount());
- // Ensure that the viewgroup's status to be normal
- WXReflectionUtils.setValue(rootView, "mChildrenCount", 0);
-
- }
- if(rootView instanceof Destroyable){
- ((Destroyable)rootView).destroy();
- }
- } catch (Exception e) {
- WXLogUtils.e("WXSDKInstance destroyView Exception: ", e);
- }
- }
-
- public synchronized void destroy() {
- if(!isDestroy()) {
- if(mParentInstance != null){
- mParentInstance = null;
- }
- mApmForInstance.onEnd();
-
-
- if(mRendered) {
- WXSDKManager.getInstance().destroyInstance(mInstanceId);
- }
-
- try {
- if (mGlobalEventReceiver != null) {
- getContext().unregisterReceiver(mGlobalEventReceiver);
- mGlobalEventReceiver = null;
- }
- }catch (IllegalArgumentException e){
- WXLogUtils.w(WXLogUtils.getStackTrace(e));
- }
-
- if (mRootComp != null) {
- mRootComp.destroy();
- mRootComp = null;
- }
-
- if(mRenderContainer != null){
- destroyView(mRenderContainer);
- }
-
-
- if (mGlobalEvents != null) {
- mGlobalEvents.clear();
- }
-
- if (mComponentObserver != null) {
- mComponentObserver = null;
- }
-
- if (mLayerOverFlowListeners != null) {
- mLayerOverFlowListeners.clear();
- }
-
- getFlatUIContext().destroy();
- mFlatGUIContext = null;
- mInstanceOnFireEventInterceptorList = null;
- mWXScrollListeners = null;
- mWXActionbarHandlers = null;
- mWXBackPressedHandlers = null;
- mRenderContainer = null;
- mNestedInstanceInterceptor = null;
- mUserTrackAdapter = null;
- mScrollView = null;
- mContext = null;
- mRenderListener = null;
- isDestroy = true;
- mStatisticsListener = null;
- if(responseHeaders != null){
- responseHeaders.clear();
- }
- if(templateRef != null){
- templateRef = null;
- }
- if (null != mContentBoxMeasurements) {
- mContentBoxMeasurements.clear();
- }
- mWXPerformance.afterInstanceDestroy(mInstanceId);
-
- WXBridgeManager.getInstance().post(new Runnable() {
- @Override
- public void run() {
- WXBridgeManager.getInstance().onInstanceClose(getInstanceId());
- inactiveAddElementAction.clear();
- }
- });
-
- //when report error in @WXExceptionUtils
- // instance may had destroy and remove,
- // so we delay remove from allInstanceMap
- WXBridgeManager.getInstance().postDelay(new Runnable() {
- @Override
- public void run() {
- WXSDKManager.getInstance().getAllInstanceMap().remove(mInstanceId);
- }
- },1000);
- }
- }
-
- public boolean isDestroy(){
- return isDestroy;
- }
-
- /**
- * @return If you use render () the return value may be empty
- */
- public @Nullable String getBundleUrl() {
- return mBundleUrl;
- }
-
- public View getRootView() {
- if (mRootComp == null)
- return null;
- return mRootComp.getRealView();
- }
-
- public View getContainerView() {
- return mRenderContainer;
- }
-
- @Deprecated
- public void setBundleUrl(String url){
- mBundleUrl = url;
- if(WXSDKManager.getInstance().getValidateProcessor()!=null) {
- mNeedValidate = WXSDKManager.getInstance().getValidateProcessor().needValidate(mBundleUrl);
- }
- }
-
- public void onRootCreated(WXComponent root) {
- this.mRootComp = root;
- this.mRootComp.mDeepInComponentTree =1;
- mRenderContainer.addView(root.getHostView());
-
-
- setSize(mRenderContainer.getWidth(),mRenderContainer.getHeight());
- }
-
- /**
- * Move fixed view to container ,except it's already moved.
- * @param fixedChild
- */
- public void moveFixedView(View fixedChild){
- if(mRenderContainer != null) {
- ViewGroup parent;
- if((parent = (ViewGroup) fixedChild.getParent()) != null){
- if (parent != mRenderContainer) {
- parent.removeView(fixedChild);
- mRenderContainer.addView(fixedChild);
- }
- }else{
- mRenderContainer.addView(fixedChild);
- }
- }
- }
-
- public void removeFixedView(View fixedChild){
- if(mRenderContainer != null) {
- mRenderContainer.removeView(fixedChild);
- }
- }
-
- public int getRenderContainerPaddingLeft() {
- if(mRenderContainer != null) {
- return mRenderContainer.getPaddingLeft();
- }
- return 0;
- }
-
- public int getRenderContainerPaddingRight() {
- if(mRenderContainer != null) {
- return mRenderContainer.getPaddingRight();
- }
- return 0;
- }
-
- public int getRenderContainerPaddingTop() {
- if(mRenderContainer != null) {
- return mRenderContainer.getPaddingTop();
- }
- return 0;
- }
-
- public synchronized List<OnWXScrollListener> getWXScrollListeners() {
- return mWXScrollListeners;
- }
-
- public synchronized void registerOnWXScrollListener(OnWXScrollListener wxScrollListener) {
- if(mWXScrollListeners==null){
- mWXScrollListeners=new ArrayList<>();
- }
- mWXScrollListeners.add(wxScrollListener);
- }
-
- public synchronized void registerActionbarHandler(ActionBarHandler actionBarHandler) {
- if(actionBarHandler == null) {
- return;
- }
- if(mWXActionbarHandlers == null) {
- mWXActionbarHandlers = new ArrayList<>();
- }
-
- mWXActionbarHandlers.add(actionBarHandler);
- }
-
- public synchronized void unRegisterActionbarHandler(ActionBarHandler actionBarHandler) {
- if(mWXActionbarHandlers != null && actionBarHandler != null) {
- mWXActionbarHandlers.remove(actionBarHandler);
- }
- }
-
- public synchronized void registerBackPressedHandler(OnBackPressedHandler backPressedHandler) {
- if(backPressedHandler == null) {
- return;
- }
-
- if(mWXBackPressedHandlers == null) {
- mWXBackPressedHandlers = new ArrayList<>();
- }
-
- mWXBackPressedHandlers.add(backPressedHandler);
- }
-
- public synchronized void unRegisterBackPressedHandler(OnBackPressedHandler backPressedHandler) {
- if(mWXBackPressedHandlers != null && backPressedHandler != null) {
- mWXBackPressedHandlers.remove(backPressedHandler);
- }
- }
-
- static int sScreenHeight = -1;
- public void setSize(int width, int height) {
- if (width > 0 && height > 0 & !isDestroy && mRendered && mRenderContainer != null) {
- if (sScreenHeight < 0){
- sScreenHeight = WXViewUtils.getScreenHeight(getContext());
- }
- if (sScreenHeight>0){
- double screenRatio = (double)height/(double)sScreenHeight *100;
- if(screenRatio>100){
- screenRatio =100;
- }
- getApmForInstance().addStats(WXInstanceApm.KEY_PAGE_STATS_BODY_RATIO,screenRatio);
- }
- ViewGroup.LayoutParams layoutParams = mRenderContainer.getLayoutParams();
- if (layoutParams != null) {
- final float realWidth = width;
- final float realHeight = height;
- if (mRenderContainer.getWidth() != width || mRenderContainer.getHeight() != height) {
- layoutParams.width = width;
- layoutParams.height = height;
- mRenderContainer.setLayoutParams(layoutParams);
- }
-
- if (mRootComp != null && layoutParams != null) {
- final boolean isWidthWrapContent = layoutParams.width == ViewGroup.LayoutParams.WRAP_CONTENT;
- final boolean isHeightWrapContent = layoutParams.height == ViewGroup.LayoutParams.WRAP_CONTENT;
-
- WXBridgeManager.getInstance().post(new Runnable() {
- @Override
- public void run() {
- WXBridgeManager.getInstance().setDefaultRootSize(getInstanceId(), realWidth, realHeight, isWidthWrapContent,
- isHeightWrapContent);
- }
- });
- }
- }
- }
- }
-
- /*Global Event*/
- private HashMap<String, List<String>> mGlobalEvents = new HashMap<>();
-
- public void fireGlobalEventCallback(String eventName, Map<String,Object> params){
- List<String> callbacks=mGlobalEvents.get(eventName);
- if(callbacks!=null){
- for(String callback:callbacks){
- WXSDKManager.getInstance().callback(mInstanceId,callback,params,true);
- }
- }
- }
-
- /**
- * Fire event callback on a element.
- * @param elementRef
- * @param type
- * @param data
- * @param domChanges
- */
- public void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges, List<Object> eventArgs){
- fireEvent(elementRef, type, data, domChanges, eventArgs, null);
- }
-
- public void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges, List<Object> eventArgs, EventResult callback) {
- onInterceptInstanceEvent(getInstanceId(), elementRef, type, data, domChanges);
- if (null != mWXPerformance && mWXPerformance.fsCallEventTotalNum<Integer.MAX_VALUE){
- mWXPerformance.fsCallEventTotalNum++;
- }
- mApmForInstance.updateFSDiffStats(WXInstanceApm.KEY_PAGE_STATS_FS_CALL_EVENT_NUM,1);
- WXBridgeManager.getInstance().fireEventOnNode(getInstanceId(),elementRef,type,data,domChanges, eventArgs, callback);
- }
-
-
- /**
- * Fire event callback on a element.
- * @param elementRef
- * @param type
- * @param data
- * @param domChanges
- */
- public void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges){
- fireEvent(elementRef, type, data, domChanges, null);
- }
-
- public void fireEvent(String elementRef,final String type, final Map<String, Object> data){
- fireEvent(elementRef,type,data,null);
- }
-
- public void fireEvent(String ref, String type){
- fireEvent(ref,type,new HashMap<String, Object>());
- }
-
- protected void addEventListener(String eventName, String callback) {
- if (TextUtils.isEmpty(eventName) || TextUtils.isEmpty(callback)) {
- return;
- }
- List<String> callbacks = mGlobalEvents.get(eventName);
- if (callbacks == null) {
- callbacks = new ArrayList<>();
- mGlobalEvents.put(eventName, callbacks);
- }
- callbacks.add(callback);
- }
- protected void removeEventListener(String eventName, String callback) {
- if (TextUtils.isEmpty(eventName) || TextUtils.isEmpty(callback)) {
- return;
- }
- List<String> callbacks = mGlobalEvents.get(eventName);
- if (callbacks != null) {
- callbacks.remove(callback);
- }
- }
-
- protected void removeEventListener(String eventName) {
- if (TextUtils.isEmpty(eventName)) {
- return;
- }
- mGlobalEvents.remove(eventName);
- }
-
- /**
- * Notifies WEEX that this event has occurred
- * @param eventName WEEX register event
- * @param module Events occur in this Module
- * @param params The parameters to be notified to WEEX are required
- */
- public void fireModuleEvent(String eventName, WXModule module,Map<String, Object> params) {
- if (TextUtils.isEmpty(eventName) || module == null) {
- return;
- }
-
- Map<String, Object> event = new HashMap<>();
- event.put("type", eventName);
- event.put("module", module.getModuleName());
- event.put("data", params);
-
- List<String> callbacks = module.getEventCallbacks(eventName);
- if (callbacks != null) {
- for (String callback : callbacks) {
- SimpleJSCallback jsCallback = new SimpleJSCallback(mInstanceId, callback);
- if (module.isOnce(callback)) {
- jsCallback.invoke(event);
- } else {
- jsCallback.invokeAndKeepAlive(event);
- }
- }
- }
- }
-
- /**
- * Check whether the current module registered the event
- * @param eventName EventName register in weex
- * @param module Events occur in this Module
- * @return register->true
- */
- public boolean checkModuleEventRegistered(String eventName,WXModule module) {
- if (module != null) {
- List<String> events = module.getEventCallbacks(eventName);
- if (events != null && events.size() > 0) {
- return true;
- }
- }
- return false;
- }
-
- public WXPerformance getWXPerformance(){
- return mWXPerformance;
- }
-
- public WXInstanceApm getApmForInstance() {
- return mApmForInstance;
- }
-
- public Map<String, Serializable> getUserTrackParams() {
- return mUserTrackParams;
- }
-
- public void addUserTrackParameter(String key,Serializable value){
- if(this.mUserTrackParams == null){
- this.mUserTrackParams = new ConcurrentHashMap<>();
- }
- mUserTrackParams.put(key,value);
- }
-
- public void clearUserTrackParameters(){
- if(this.mUserTrackParams != null){
- this.mUserTrackParams.clear();
- }
- }
-
- public void removeUserTrackParameter(String key){
- if(this.mUserTrackParams != null){
- this.mUserTrackParams.remove(key);
- }
- }
-
- public int getMaxDeepLayer() {
- return mMaxDeepLayer;
- }
-
- public void setMaxDeepLayer(int maxDeepLayer) {
- mMaxDeepLayer = maxDeepLayer;
- mApmForInstance.updateMaxStats(WXInstanceApm.KEY_PAGE_STATS_MAX_DEEP_VIEW,maxDeepLayer);
- }
-
- public void setMaxDomDeep(int maxDomDeep){
- mApmForInstance.updateMaxStats(WXInstanceApm.KEY_PAGE_STATS_MAX_DEEP_DOM,maxDomDeep);
- if (null == mWXPerformance){
- return;
- }
- if (mWXPerformance.maxDeepVDomLayer <= maxDomDeep){
- mWXPerformance.maxDeepVDomLayer = maxDomDeep;
- }
- }
-
- public void onHttpStart(){
- if (!mEnd){
- mWXPerformance.fsRequestNum++;
- }
- }
-
- /**
- * return md5, and bytes length
- * */
- public String getTemplateInfo() {
- String template = getTemplate();
- if(template == null){
- return " template md5 null ,httpHeader:" + JSONObject.toJSONString(responseHeaders);
- }
- if(TextUtils.isEmpty(template)){
- return " template md5 length 0 ,httpHeader" + JSONObject.toJSONString(responseHeaders);
- }
- try {
- byte[] bts = template.getBytes("UTF-8");
- String sourceMD5 = WXFileUtils.md5(bts);
- String sourceBase64MD5 = WXFileUtils.base64Md5(bts);
- ArrayList<String> sourceMD5List = new ArrayList<>();
- ArrayList<String> sourceBase64MD5List = new ArrayList<>();
- sourceMD5List.add(sourceMD5);
- sourceBase64MD5List.add(sourceBase64MD5);
- responseHeaders.put("templateSourceMD5", sourceMD5List);
- responseHeaders.put(SOURCE_TEMPLATE_BASE64_MD5, sourceBase64MD5List);
- return " template md5 " + sourceMD5 + " length " + bts.length
- + " base64 md5 " + sourceBase64MD5
- + " response header " + JSONObject.toJSONString(responseHeaders);
- } catch (Exception e) {
- return "template md5 getBytes error";
- }
-
- }
-
- /**
- * check template header md5 match with header content-md5
- * */
- public boolean isContentMd5Match(){
- if(responseHeaders == null){
- return true;
- }
- List<String> contentMD5s = responseHeaders.get("Content-Md5");
- if(contentMD5s == null){
- contentMD5s = responseHeaders.get("content-md5");
- }
- if(contentMD5s == null || contentMD5s.size() <= 0){
- return true;
- }
- String md5 = contentMD5s.get(0);
-
- List<String> sourceBase64Md5 = responseHeaders.get(SOURCE_TEMPLATE_BASE64_MD5);
- if(sourceBase64Md5 == null){
- getTemplateInfo();
- sourceBase64Md5 = responseHeaders.get(SOURCE_TEMPLATE_BASE64_MD5);
- }
- if(sourceBase64Md5 == null || sourceBase64Md5.size() == 0){
- return true;
- }
- return md5.equals(sourceBase64Md5.get(0));
- }
-
- public String getTemplate() {
- if(templateRef == null){
- return null;
- }
- return templateRef.get();
- }
-
- public void setTemplate(String template) {
- this.templateRef = new WeakReference<String>(template);
- }
-
- public interface NestedInstanceInterceptor {
- void onCreateNestInstance(WXSDKInstance instance, NestedContainer container);
- }
-
- public void OnVSync() {
- boolean forceLayout = WXBridgeManager.getInstance().notifyLayout(getInstanceId());
- if(forceLayout) {
- WXBridgeManager.getInstance().post(new Runnable() {
- @Override
- public void run() {
- WXBridgeManager.getInstance().forceLayout(getInstanceId());
- }
- });
- }
- }
-
- public void addContentBoxMeasurement(long renderObjectPtr, ContentBoxMeasurement contentBoxMeasurement) {
- mContentBoxMeasurements.put(renderObjectPtr, contentBoxMeasurement);
- }
-
- public ContentBoxMeasurement getContentBoxMeasurement(long renderObjectPtr) {
- return mContentBoxMeasurements.get(renderObjectPtr);
- }
-
-
- private void onInterceptInstanceEvent(String instanceId, String elementRef, String type, Map<String, Object> data, Map<String, Object> domChanges) {
- if(this.mInstanceOnFireEventInterceptorList == null){
- return;
- }
- for(InstanceOnFireEventInterceptor instanceOnFireEventInterceptor : this.mInstanceOnFireEventInterceptorList){
- instanceOnFireEventInterceptor.onInterceptFireEvent(instanceId, elementRef, type, data, domChanges);
- }
- }
-
- public List<InstanceOnFireEventInterceptor> getInstanceOnFireEventInterceptorList(){
- if(this.mInstanceOnFireEventInterceptorList == null){
- this.mInstanceOnFireEventInterceptorList = new ArrayList<>();
- }
- return mInstanceOnFireEventInterceptorList;
- }
-
-
- public void addInstanceOnFireEventInterceptor(InstanceOnFireEventInterceptor instanceOnFireEventInterceptor) {
- if(instanceOnFireEventInterceptor == null){
- return;
- }
- if(!getInstanceOnFireEventInterceptorList().contains(instanceOnFireEventInterceptor)){
- getInstanceOnFireEventInterceptorList().add(instanceOnFireEventInterceptor);
- }
- }
-
- public String getRenderType() {
- return mRenderType;
- }
-
- public void setRenderType(String renderType) {
- this.mRenderType = renderType;
- }
-
- private static boolean isDisableSkipFrameworkInDataRender() {
- IWXConfigAdapter adapter = WXSDKManager.getInstance().getWxConfigAdapter();
- if (adapter == null) {
- return false;
- }
- String result = adapter.getConfig("wxeagle", "disable_skip_framework_init", "false");
- return "true".equals(result);
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java
deleted file mode 100644
index c6c49d9..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-import android.os.Looper;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-
-import com.taobao.weex.adapter.ClassLoaderAdapter;
-import com.taobao.weex.adapter.DefaultUriAdapter;
-import com.taobao.weex.adapter.DefaultWXHttpAdapter;
-import com.taobao.weex.adapter.IWXConfigAdapter;
-import com.taobao.weex.adapter.ICrashInfoReporter;
-import com.taobao.weex.adapter.IDrawableLoader;
-import com.taobao.weex.adapter.IWXJscProcessManager;
-import com.taobao.weex.adapter.ITracingAdapter;
-import com.taobao.weex.adapter.IWXAccessibilityRoleAdapter;
-import com.taobao.weex.adapter.IWXHttpAdapter;
-import com.taobao.weex.adapter.IWXImgLoaderAdapter;
-import com.taobao.weex.adapter.IWXJSExceptionAdapter;
-import com.taobao.weex.adapter.IWXJsFileLoaderAdapter;
-import com.taobao.weex.adapter.IWXSoLoaderAdapter;
-import com.taobao.weex.adapter.IWXUserTrackAdapter;
-import com.taobao.weex.adapter.URIAdapter;
-import com.taobao.weex.appfram.navigator.IActivityNavBarSetter;
-import com.taobao.weex.appfram.navigator.INavigator;
-import com.taobao.weex.appfram.storage.DefaultWXStorage;
-import com.taobao.weex.appfram.storage.IWXStorageAdapter;
-import com.taobao.weex.appfram.websocket.IWebSocketAdapter;
-import com.taobao.weex.appfram.websocket.IWebSocketAdapterFactory;
-import com.taobao.weex.bridge.WXBridgeManager;
-import com.taobao.weex.bridge.WXModuleManager;
-import com.taobao.weex.bridge.WXValidateProcessor;
-import com.taobao.weex.common.WXRefreshData;
-import com.taobao.weex.common.WXRuntimeException;
-import com.taobao.weex.common.WXThread;
-import com.taobao.weex.common.WXWorkThreadManager;
-import com.taobao.weex.font.FontAdapter;
-import com.taobao.weex.performance.IApmGenerator;
-import com.taobao.weex.performance.IWXAnalyzer;
-import com.taobao.weex.ui.WXRenderManager;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXUtils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Manger class for weex context.
- */
-public class WXSDKManager {
-
- private static volatile WXSDKManager sManager;
- private static AtomicInteger sInstanceId = new AtomicInteger(0);
- private final WXWorkThreadManager mWXWorkThreadManager;
- private WXBridgeManager mBridgeManager;
- /** package **/ WXRenderManager mWXRenderManager;
-
- private IWXUserTrackAdapter mIWXUserTrackAdapter;
- private IWXImgLoaderAdapter mIWXImgLoaderAdapter;
- private IWXSoLoaderAdapter mIWXSoLoaderAdapter;
- private IDrawableLoader mDrawableLoader;
- private IWXHttpAdapter mIWXHttpAdapter;
- private IActivityNavBarSetter mActivityNavBarSetter;
- private IWXAccessibilityRoleAdapter mRoleAdapter;
- private List<IWXAnalyzer> mWXAnalyzerList;
- private IApmGenerator mApmGenerater;
- private IWXJsFileLoaderAdapter mWXJsFileLoaderAdapter;
-
- private ICrashInfoReporter mCrashInfo;
-
- private IWXJSExceptionAdapter mIWXJSExceptionAdapter;
-
- private IWXConfigAdapter mConfigAdapter;
- private IWXStorageAdapter mIWXStorageAdapter;
- private IWXStatisticsListener mStatisticsListener;
- private URIAdapter mURIAdapter;
- private ClassLoaderAdapter mClassLoaderAdapter;
- private IWebSocketAdapterFactory mIWebSocketAdapterFactory;
- private ITracingAdapter mTracingAdapter;
- private WXValidateProcessor mWXValidateProcessor;
- private IWXJscProcessManager mWXJscProcessManager;
- // Tell weexv8 to initialize v8, default is true.
- private boolean mNeedInitV8 = true;
-
- //add when instance create,rm when instance destroy, not like WXRenderManager
- private Map<String,WXSDKInstance> mAllInstanceMap;
-
- private List<InstanceLifeCycleCallbacks> mLifeCycleCallbacks;
-
- private static final int DEFAULT_VIEWPORT_WIDTH = 750;
-
- private WXSDKManager() {
- this(new WXRenderManager());
- }
-
- private WXSDKManager(WXRenderManager renderManager) {
- mWXRenderManager = renderManager;
- mBridgeManager = WXBridgeManager.getInstance();
- mWXWorkThreadManager = new WXWorkThreadManager();
- mWXAnalyzerList = new CopyOnWriteArrayList<>();
- mAllInstanceMap = new HashMap<>();
- }
-
- /**
- * Used in junit test
- */
- static void initInstance(WXRenderManager renderManager){
- sManager = new WXSDKManager(renderManager);
- }
-
- public void registerStatisticsListener(IWXStatisticsListener listener) {
- mStatisticsListener = listener;
- }
-
- public IWXStatisticsListener getWXStatisticsListener() {
- return mStatisticsListener;
- }
-
- public void onSDKEngineInitialize() {
- if (mStatisticsListener != null) {
- mStatisticsListener.onSDKEngineInitialize();
- }
- }
-
- public void setNeedInitV8(boolean need) {
- mNeedInitV8 = need;
- }
-
- public boolean needInitV8() {
- return mNeedInitV8;
- }
-
- public void takeJSHeapSnapshot(String path) {
- File file = new File(path);
- if (!file.exists()) {
- if (!file.mkdir()) {
- return;
- }
- }
-
- String name = String.valueOf(sInstanceId.get());
- String filename = path;
-
- if (!path.endsWith(File.separator)) {
- filename += File.separator;
- }
- filename += name;
- filename += ".heapsnapshot";
-
- mBridgeManager.takeJSHeapSnapshot(filename);
- }
-
- public static WXSDKManager getInstance() {
- if (sManager == null) {
- synchronized (WXSDKManager.class) {
- if(sManager == null) {
- sManager = new WXSDKManager();
- }
- }
- }
- return sManager;
- }
-
- public static int getInstanceViewPortWidth(String instanceId){
- WXSDKInstance instance = getInstance().getSDKInstance(instanceId);
- if (instance == null) {
- return DEFAULT_VIEWPORT_WIDTH;
- }
- return instance.getInstanceViewPortWidth();
- }
-
- static void setInstance(WXSDKManager manager){
- sManager = manager;
- }
-
- public IActivityNavBarSetter getActivityNavBarSetter() {
- return mActivityNavBarSetter;
- }
-
- public void setActivityNavBarSetter(IActivityNavBarSetter mActivityNavBarSetter) {
- this.mActivityNavBarSetter = mActivityNavBarSetter;
- }
-
- public void restartBridge() {
- mBridgeManager.restart();
- }
-
- public WXBridgeManager getWXBridgeManager() {
- return mBridgeManager;
- }
-
- public WXRenderManager getWXRenderManager() {
- return mWXRenderManager;
- }
- public IWXJscProcessManager getWXJscProcessManager() {
- return mWXJscProcessManager;
- }
- public WXWorkThreadManager getWXWorkThreadManager() {
- return mWXWorkThreadManager;
- }
-
- public void setWxConfigAdapter(IWXConfigAdapter mConfigAdapter) {
- this.mConfigAdapter = mConfigAdapter;
- }
-
- public IWXConfigAdapter getWxConfigAdapter() {
- return mConfigAdapter;
- }
-
- public @Nullable WXSDKInstance getSDKInstance(String instanceId) {
- return instanceId == null? null : mWXRenderManager.getWXSDKInstance(instanceId);
- }
-
- public void postOnUiThread(Runnable runnable, long delayMillis) {
- mWXRenderManager.postOnUiThread(WXThread.secure(runnable), delayMillis);
- }
- public Map<String, WXSDKInstance> getAllInstanceMap() {
- return mAllInstanceMap;
- }
-
- public void destroy() {
- if (mWXWorkThreadManager != null) {
- mWXWorkThreadManager.destroy();
- }
- mAllInstanceMap.clear();
- }
-
- @Deprecated
- public void callback(String instanceId, String funcId, Map<String, Object> data) {
- mBridgeManager.callback(instanceId, funcId, data);
- }
-
- @Deprecated
- public void callback(String instanceId, String funcId, Map<String, Object> data,boolean keepAlive) {
- mBridgeManager.callback(instanceId, funcId, data,keepAlive);
- }
-
- public void initScriptsFramework(String framework) {
- mBridgeManager.initScriptsFramework(framework);
- }
-
- public void registerComponents(List<Map<String, Object>> components) {
- mBridgeManager.registerComponents(components);
- }
-
- public void registerModules(Map<String, Object> modules) {
- mBridgeManager.registerModules(modules);
- }
-
- /**
- * Do not direct invoke this method in Components, use {@link WXSDKInstance#fireEvent(String, String, Map, Map)} instead.
- */
- @Deprecated
- public void fireEvent(final String instanceId, String ref, String type) {
- fireEvent(instanceId, ref, type, new HashMap<String, Object>());
- }
-
- /**
- * FireEvent back to JS
- * Do not direct invoke this method in Components, use {@link WXSDKInstance#fireEvent(String, String, Map, Map)} instead.
- */
- @Deprecated
- public void fireEvent(final String instanceId, String ref, String type, Map<String, Object> params){
- fireEvent(instanceId,ref,type,params,null);
- }
-
- /**
- * Do not direct invoke this method in Components, use {@link WXSDKInstance#fireEvent(String, String, Map, Map)} instead.
- **/
- @Deprecated
- public void fireEvent(final String instanceId, String ref, String type, Map<String, Object> params,Map<String,Object> domChanges) {
- if (WXEnvironment.isApkDebugable() && Looper.getMainLooper().getThread().getId() != Thread.currentThread().getId()) {
- throw new WXRuntimeException("[WXSDKManager] fireEvent error");
- }
- mBridgeManager.fireEventOnNode(instanceId, ref, type, params,domChanges);
- }
-
- void createInstance(WXSDKInstance instance, Script code, Map<String, Object> options, String jsonInitData) {
- mWXRenderManager.registerInstance(instance);
- mBridgeManager.createInstance(instance.getInstanceId(), code, options, jsonInitData);
- if (mLifeCycleCallbacks != null) {
- for (InstanceLifeCycleCallbacks callbacks : mLifeCycleCallbacks) {
- callbacks.onInstanceCreated(instance.getInstanceId());
- }
- }
- }
-
- void refreshInstance(String instanceId, WXRefreshData jsonData) {
- mBridgeManager.refreshInstance(instanceId, jsonData);
- }
-
- void destroyInstance(String instanceId) {
- setCrashInfo(WXEnvironment.WEEX_CURRENT_KEY,"");
- if (TextUtils.isEmpty(instanceId)) {
- return;
- }
- if (!WXUtils.isUiThread()) {
- throw new WXRuntimeException("[WXSDKManager] destroyInstance error");
- }
- if (mLifeCycleCallbacks != null) {
- for (InstanceLifeCycleCallbacks callbacks : mLifeCycleCallbacks) {
- callbacks.onInstanceDestroyed(instanceId);
- }
- }
- mWXRenderManager.removeRenderStatement(instanceId);
- mBridgeManager.destroyInstance(instanceId);
- WXModuleManager.destroyInstanceModules(instanceId);
- }
-
- String generateInstanceId() {
- return String.valueOf(sInstanceId.incrementAndGet());
- }
-
- public IWXUserTrackAdapter getIWXUserTrackAdapter() {
- return mIWXUserTrackAdapter;
- }
-
- public IWXImgLoaderAdapter getIWXImgLoaderAdapter() {
- return mIWXImgLoaderAdapter;
- }
-
- public IWXJsFileLoaderAdapter getIWXJsFileLoaderAdapter() {
- return mWXJsFileLoaderAdapter;
- }
-
- public IDrawableLoader getDrawableLoader() {
- return mDrawableLoader;
- }
-
- public IWXJSExceptionAdapter getIWXJSExceptionAdapter() {
- return mIWXJSExceptionAdapter;
- }
-
- public void setIWXJSExceptionAdapter(IWXJSExceptionAdapter IWXJSExceptionAdapter) {
- mIWXJSExceptionAdapter = IWXJSExceptionAdapter;
- }
-
- public @NonNull IWXHttpAdapter getIWXHttpAdapter() {
- if (mIWXHttpAdapter == null) {
- mIWXHttpAdapter = new DefaultWXHttpAdapter();
- }
- return mIWXHttpAdapter;
- }
-
- public IApmGenerator getApmGenerater() {
- return mApmGenerater;
- }
-
- public @NonNull URIAdapter getURIAdapter() {
- if(mURIAdapter == null){
- mURIAdapter = new DefaultUriAdapter();
- }
- return mURIAdapter;
- }
-
- public ClassLoaderAdapter getClassLoaderAdapter() {
- if(mClassLoaderAdapter == null){
- mClassLoaderAdapter = new ClassLoaderAdapter();
- }
- return mClassLoaderAdapter;
- }
-
- public IWXSoLoaderAdapter getIWXSoLoaderAdapter() {
- return mIWXSoLoaderAdapter;
- }
-
- public List<IWXAnalyzer> getWXAnalyzerList(){
- return mWXAnalyzerList;
- }
-
- public void addWXAnalyzer(IWXAnalyzer analyzer){
- if (!mWXAnalyzerList.contains(analyzer)) {
- mWXAnalyzerList.add(analyzer);
- }
- }
-
- public void rmWXAnalyzer(IWXAnalyzer analyzer){
- mWXAnalyzerList.remove(analyzer);
- }
-
- void setInitConfig(InitConfig config){
- this.mIWXHttpAdapter = config.getHttpAdapter();
- this.mIWXImgLoaderAdapter = config.getImgAdapter();
- this.mDrawableLoader = config.getDrawableLoader();
- this.mIWXStorageAdapter = config.getStorageAdapter();
- this.mIWXUserTrackAdapter = config.getUtAdapter();
- this.mURIAdapter = config.getURIAdapter();
- this.mIWebSocketAdapterFactory = config.getWebSocketAdapterFactory();
- this.mIWXJSExceptionAdapter = config.getJSExceptionAdapter();
- this.mIWXSoLoaderAdapter = config.getIWXSoLoaderAdapter();
- this.mClassLoaderAdapter = config.getClassLoaderAdapter();
- this.mApmGenerater = config.getApmGenerater();
- this.mWXJsFileLoaderAdapter = config.getJsFileLoaderAdapter();
- this.mWXJscProcessManager = config.getJscProcessManager();
- }
-
- public IWXStorageAdapter getIWXStorageAdapter(){
- if(mIWXStorageAdapter == null){
- if(WXEnvironment.sApplication != null){
- mIWXStorageAdapter = new DefaultWXStorage(WXEnvironment.sApplication);
- }else{
- WXLogUtils.e("WXStorageModule", "No Application context found,you should call WXSDKEngine#initialize() method in your application");
- }
- }
- return mIWXStorageAdapter;
- }
-
- /**
- * Weex embedders can use <code>notifyTrimMemory</code> to reduce
- * memory at a proper time.
- *
- * It's not a good idea to reduce memory at any time, because
- * memory trimming is a expense operation, and V8 needs to do
- * a full GC and all the inline caches get to be cleared.
- *
- * The embedder needs to make some scheduling strategies to
- * ensure that the embedded application is just on an idle time.
- * If the application use the same js bundle to render pages,
- * it's not a good idea to trim memory every time of exiting
- * pages.
- */
- public void notifyTrimMemory() {
- mBridgeManager.notifyTrimMemory();
- }
-
- /**
- * Weex embedders can use <code>notifySerializeCodeCache</code> to
- * serialize code caches if the jsfm has the alility to compile 'new Function'
- * against js bundles on the weex native side.
- *
- * It's a good time to serialize a code cache after exiting a weex page.
- * Then, the next time of entering the same weex page, V8 would compile
- * 'new Function' against the code cache deseriazed from the js bundle.
- */
- public void notifySerializeCodeCache() {
- mBridgeManager.notifySerializeCodeCache();
- }
-
- public @Nullable
- IWebSocketAdapter getIWXWebSocketAdapter() {
- if (mIWebSocketAdapterFactory != null) {
- return mIWebSocketAdapterFactory.createWebSocketAdapter();
- }
- return null;
- }
-
- public void registerValidateProcessor(WXValidateProcessor processor){
- this.mWXValidateProcessor = processor;
- }
-
- public WXValidateProcessor getValidateProcessor(){
- return mWXValidateProcessor;
- }
-
-
- public void setCrashInfoReporter(ICrashInfoReporter mCrashInfo) {
- this.mCrashInfo = mCrashInfo;
- }
-
- public void setCrashInfo(String key, String value) {
- if(mCrashInfo!=null){
- mCrashInfo.addCrashInfo(key,value);
- }
- }
-
- public void setTracingAdapter(ITracingAdapter adapter) {
- this.mTracingAdapter = adapter;
- }
-
- public ITracingAdapter getTracingAdapter() {
- return mTracingAdapter;
- }
-
- public void registerInstanceLifeCycleCallbacks(InstanceLifeCycleCallbacks callbacks) {
- if (mLifeCycleCallbacks == null) {
- mLifeCycleCallbacks = new ArrayList<>();
- }
- mLifeCycleCallbacks.add(callbacks);
- }
-
- public void setAccessibilityRoleAdapter(IWXAccessibilityRoleAdapter adapter) {
- this.mRoleAdapter = adapter;
- }
-
- public IWXAccessibilityRoleAdapter getAccessibilityRoleAdapter() {
- return mRoleAdapter;
- }
-
- public interface InstanceLifeCycleCallbacks {
- void onInstanceDestroyed(String instanceId);
- void onInstanceCreated(String instanceId);
- }
-
- private INavigator mNavigator;
-
- public INavigator getNavigator() {
- return mNavigator;
- }
-
- public void setNavigator(INavigator mNavigator) {
- this.mNavigator = mNavigator;
- }
-
-
- private FontAdapter mFontAdapter;
-
- public FontAdapter getFontAdapter(){
- if(mFontAdapter == null){
- synchronized (this){
- if(mFontAdapter == null){
- mFontAdapter = new FontAdapter();
- }
- }
- }
- return mFontAdapter;
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java b/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java
deleted file mode 100644
index eef4d5c..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex;
-
-/**
- * Created by shiwentao on 2017/8/24.
- */
-
-import android.annotation.SuppressLint;
-import android.os.Build;
-import android.util.Log;
-import android.view.Choreographer;
-import com.taobao.weex.common.WXErrorCode;
-import java.lang.ref.WeakReference;
-
-public class WeexFrameRateControl {
- private static final long VSYNC_FRAME = 1000 / 60;
- private WeakReference<VSyncListener> mListener;
- private final Choreographer mChoreographer;
- private final Choreographer.FrameCallback mVSyncFrameCallback;
- private final Runnable runnable;
-
- public interface VSyncListener {
- void OnVSync();
- }
-
- public WeexFrameRateControl(VSyncListener listener) {
- mListener = new WeakReference<>(listener);
- if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
- mChoreographer = Choreographer.getInstance();
- mVSyncFrameCallback = new Choreographer.FrameCallback() {
- @SuppressLint("NewApi")
- @Override
- public void doFrame(long frameTimeNanos) {
- VSyncListener vSyncListener;
- if (mListener != null && (vSyncListener=mListener.get()) != null) {
- try {
- vSyncListener.OnVSync();
- mChoreographer.postFrameCallback(mVSyncFrameCallback);
- }catch (UnsatisfiedLinkError e){
- if(vSyncListener instanceof WXSDKInstance){
- ((WXSDKInstance) vSyncListener).onRenderError(
- WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(),
- Log.getStackTraceString(e));
- }
- }
- }
- }
- };
- runnable = null;
- } else {
- // For API 15 or lower
- runnable = new Runnable() {
- @Override
- public void run() {
- VSyncListener vSyncListener;
- if (mListener != null && (vSyncListener = mListener.get()) != null) {
- try {
- vSyncListener.OnVSync();
- WXSDKManager.getInstance().getWXRenderManager().postOnUiThread(runnable, VSYNC_FRAME);
- }catch (UnsatisfiedLinkError e){
- if(vSyncListener instanceof WXSDKInstance){
- ((WXSDKInstance) vSyncListener).onRenderError(
- WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(),
- Log.getStackTraceString(e));
- }
- }
- }
- }
- };
- mChoreographer = null;
- mVSyncFrameCallback = null;
- }
- }
-
- @SuppressLint("NewApi")
- public void start() {
- if (mChoreographer != null) {
- mChoreographer.postFrameCallback(mVSyncFrameCallback);
- }
- else if(runnable!=null){
- WXSDKManager.getInstance().getWXRenderManager().postOnUiThread(runnable, VSYNC_FRAME);
- }
- }
-
- @SuppressLint("NewApi")
- public void stop() {
- if (mChoreographer != null) {
- mChoreographer.removeFrameCallback(mVSyncFrameCallback);
- }else if(runnable!=null){
- WXSDKManager.getInstance().getWXRenderManager().removeTask(runnable);
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/ClassLoaderAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/ClassLoaderAdapter.java
deleted file mode 100644
index 7d6a854..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/ClassLoaderAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import android.content.Context;
-
-import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.common.WXModule;
-import com.taobao.weex.ui.component.WXComponent;
-
-/**
- * Created by furture on 2018/2/7.
- * class loader adapter for load auto config class.
- */
-public class ClassLoaderAdapter {
-
- /**
- * context is module class
- * */
- public Class<? extends WXModule> getModuleClass(String name, String className, Context context){
- try {
- return (Class<? extends WXModule>) context.getClassLoader().loadClass(className);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * context is instance context
- */
- public Class<? extends WXComponent> getComponentClass(String name, String className, WXSDKInstance instance) {
- try {
- return (Class<? extends WXComponent>) instance.getContext().getClassLoader().loadClass(className);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
\ No newline at end of file
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/DefaultUriAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/DefaultUriAdapter.java
deleted file mode 100644
index de77e87..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/DefaultUriAdapter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import android.net.Uri;
-import android.support.annotation.NonNull;
-import android.text.TextUtils;
-
-import com.taobao.weex.WXSDKInstance;
-
-import java.util.List;
-
-
-/**
- * Default Uri adapter. Provide basic capability to handle relative path, local file path etc.
- * Created by sospartan on 21/11/2016.
- */
-public class DefaultUriAdapter implements URIAdapter {
-
-
- @NonNull
- @Override
- public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
- return rewrite(instance.getBundleUrl(), type, uri);
- }
-
- @NonNull
- @Override
- public Uri rewrite(String bundleURL, String type, Uri uri) {
- if (TextUtils.isEmpty(bundleURL)) {
- return uri;
- }
-
- Uri base = Uri.parse(bundleURL);
- Uri.Builder resultBuilder = uri.buildUpon();
-
- if (uri.isRelative()) {
- //When uri is empty, means use the base url instead. Web broswer behave this way.
- if(uri.getEncodedPath().length() == 0){
- if(URIAdapter.IMAGE.equals(type)){
- if(TextUtils.isEmpty(uri.toString())){
- return uri;
- }
- }
- return base;
- } else {
- resultBuilder = buildRelativeURI(resultBuilder, base, uri);
- return resultBuilder.build();
- }
- }
- return uri;
- }
-
- private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri uri) {
- if (uri.getAuthority() != null) {
- return resultBuilder.scheme(base.getScheme());
- } else {
- resultBuilder
- .encodedAuthority(base.getEncodedAuthority())
- .scheme(base.getScheme())
- .path(null);
-
- if (uri.getPath().startsWith("/")) {
- //relative to root
- resultBuilder.appendEncodedPath(uri.getEncodedPath().substring(1));
- } else {
- List<String> segments = base.getPathSegments();
- //ignore last segment if not end with /
- int ignoreLast = 1;
- if (base.getPath().endsWith("/")) {
- ignoreLast = 0;
- }
- for (int i = 0, len = segments.size() - ignoreLast; i < len; i++) {
- resultBuilder.appendEncodedPath(segments.get(i));
- }
- resultBuilder.appendEncodedPath(uri.getEncodedPath());
- }
- return resultBuilder;
- }
- }
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/DefaultWXHttpAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/DefaultWXHttpAdapter.java
deleted file mode 100644
index 2d26765..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/DefaultWXHttpAdapter.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-
-import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.WXSDKManager;
-import com.taobao.weex.common.WXRequest;
-import com.taobao.weex.common.WXResponse;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-
-public class DefaultWXHttpAdapter implements IWXHttpAdapter {
-
- private static final IEventReporterDelegate DEFAULT_DELEGATE = new NOPEventReportDelegate();
- private ExecutorService mExecutorService;
-
- private void execute(Runnable runnable){
- if(mExecutorService==null){
- mExecutorService = Executors.newFixedThreadPool(3);
- }
- mExecutorService.execute(runnable);
- }
-
- @Override
- public void sendRequest(final WXRequest request, final OnHttpListener listener) {
- if (listener != null) {
- listener.onHttpStart();
- }
- execute(new Runnable() {
- @Override
- public void run() {
- WXSDKInstance instance = WXSDKManager.getInstance().getAllInstanceMap().get(request.instanceId);
- if (null != instance && !instance.isDestroy()){
- instance.getApmForInstance().actionNetRequest();
- }
-
- boolean isNetRequestSucceed = true;
-
- WXResponse response = new WXResponse();
- IEventReporterDelegate reporter = getEventReporterDelegate();
- try {
- HttpURLConnection connection = openConnection(request, listener);
- reporter.preConnect(connection, request.body);
- Map<String,List<String>> headers = connection.getHeaderFields();
- int responseCode = connection.getResponseCode();
- if(listener != null){
- listener.onHeadersReceived(responseCode,headers);
- }
- reporter.postConnect();
-
- response.statusCode = String.valueOf(responseCode);
- if (responseCode >= 200 && responseCode<=299) {
- InputStream rawStream = connection.getInputStream();
- rawStream = reporter.interpretResponseStream(rawStream);
- response.originalData = readInputStreamAsBytes(rawStream, listener);
- } else {
- response.errorMsg = readInputStream(connection.getErrorStream(), listener);
- isNetRequestSucceed = false;
- }
- if (listener != null) {
- listener.onHttpFinish(response);
- }
- } catch (IOException|IllegalArgumentException e) {
- isNetRequestSucceed = false;
- e.printStackTrace();
- response.statusCode = "-1";
- response.errorCode="-1";
- response.errorMsg=e.getMessage();
- if(listener!=null){
- listener.onHttpFinish(response);
- }
- if (e instanceof IOException) {
- try {
- reporter.httpExchangeFailed((IOException) e);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- }
- if (null != instance && !instance.isDestroy()){
- instance.getApmForInstance().actionNetResult(isNetRequestSucceed,null);
- }
- }
- });
- }
-
-
- /**
- * Opens an {@link HttpURLConnection} with parameters.
- *
- * @param request
- * @param listener
- * @return an open connection
- * @throws IOException
- */
- private HttpURLConnection openConnection(WXRequest request, OnHttpListener listener) throws IOException {
- URL url = new URL(request.url);
- HttpURLConnection connection = createConnection(url);
- connection.setConnectTimeout(request.timeoutMs);
- connection.setReadTimeout(request.timeoutMs);
- connection.setUseCaches(false);
- connection.setDoInput(true);
-
- if (request.paramMap != null) {
- Set<String> keySets = request.paramMap.keySet();
- for (String key : keySets) {
- connection.addRequestProperty(key, request.paramMap.get(key));
- }
- }
-
- if ("POST".equals(request.method) || "PUT".equals(request.method) || "PATCH".equals(request.method)) {
- connection.setRequestMethod(request.method);
- if (request.body != null) {
- if (listener != null) {
- listener.onHttpUploadProgress(0);
- }
- connection.setDoOutput(true);
- DataOutputStream out = new DataOutputStream(connection.getOutputStream());
- //TODO big stream will cause OOM; Progress callback is meaningless
- out.write(request.body.getBytes());
- out.close();
- if (listener != null) {
- listener.onHttpUploadProgress(100);
- }
- }
- } else if (!TextUtils.isEmpty(request.method)) {
- connection.setRequestMethod(request.method);
- } else {
- connection.setRequestMethod("GET");
- }
-
- return connection;
- }
-
- private byte[] readInputStreamAsBytes(InputStream inputStream,OnHttpListener listener) throws IOException{
- if(inputStream == null){
- return null;
- }
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-
- int nRead;
- int readCount = 0;
- byte[] data = new byte[2048];
-
- while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
- buffer.write(data, 0, nRead);
- readCount += nRead;
- if (listener != null) {
- listener.onHttpResponseProgress(readCount);
- }
- }
-
- buffer.flush();
-
- return buffer.toByteArray();
- }
-
- private String readInputStream(InputStream inputStream, OnHttpListener listener) throws IOException {
- if(inputStream == null){
- return null;
- }
- StringBuilder builder = new StringBuilder();
- BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- char[] data = new char[2048];
- int len;
- while ((len = localBufferedReader.read(data)) != -1) {
- builder.append(data, 0, len);
- if (listener != null) {
- listener.onHttpResponseProgress(builder.length());
- }
- }
- localBufferedReader.close();
- return builder.toString();
- }
-
- /**
- * Create an {@link HttpURLConnection} for the specified {@code url}.
- */
- protected HttpURLConnection createConnection(URL url) throws IOException {
- return (HttpURLConnection) url.openConnection();
- }
-
- public @NonNull IEventReporterDelegate getEventReporterDelegate() {
- return DEFAULT_DELEGATE;
- }
-
- public interface IEventReporterDelegate {
- void preConnect(HttpURLConnection connection, @Nullable String body);
- void postConnect();
- InputStream interpretResponseStream(@Nullable InputStream inputStream);
- void httpExchangeFailed(IOException e);
- }
-
- private static class NOPEventReportDelegate implements IEventReporterDelegate {
- @Override
- public void preConnect(HttpURLConnection connection, @Nullable String body) {
- //do nothing
- }
-
- @Override
- public void postConnect() {
- //do nothing
- }
-
- @Override
- public InputStream interpretResponseStream(@Nullable InputStream inputStream) {
- return inputStream;
- }
-
- @Override
- public void httpExchangeFailed(IOException e) {
- //do nothing
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/DrawableStrategy.java b/android/sdk/src/main/java/com/taobao/weex/adapter/DrawableStrategy.java
deleted file mode 100644
index c6daa5a..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/DrawableStrategy.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.taobao.weex.adapter;
-
-
-public class DrawableStrategy {
-
- public int width;
- public int height;
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/ICrashInfoReporter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/ICrashInfoReporter.java
deleted file mode 100644
index 54c15cc..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/ICrashInfoReporter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-/**
- * Created by zhengshihan on 2017/5/23.
- */
-
-public interface ICrashInfoReporter {
- void addCrashInfo(String key ,String value);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IDrawableLoader.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IDrawableLoader.java
deleted file mode 100644
index 080d3b5..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IDrawableLoader.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.taobao.weex.adapter;
-
-import android.graphics.drawable.Drawable;
-import android.support.annotation.Nullable;
-
-public interface IDrawableLoader {
-
- interface DrawableTarget {
- void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
- }
-
- interface StaticTarget extends DrawableTarget{
- void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
- }
-
- interface AnimatedTarget extends DrawableTarget{
- void setAnimatedDrawable(@Nullable Drawable drawable);
- }
-
- void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
-}
-
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/ITracingAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/ITracingAdapter.java
deleted file mode 100644
index 4acb23d..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/ITracingAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import com.taobao.weex.tracing.WXTracing;
-
-/**
- * Created by moxun on 2017/7/6.
- */
-
-public interface ITracingAdapter {
- void enable();
- void disable();
- void submitTracingEvent(WXTracing.TraceEvent event);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXAccessibilityRoleAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXAccessibilityRoleAdapter.java
deleted file mode 100644
index 46ca77f..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXAccessibilityRoleAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-/**
- * Created by moxun on 2017/11/13.
- */
-
-public interface IWXAccessibilityRoleAdapter {
- String getRole(String key);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java
deleted file mode 100644
index 9eee5b0..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-/**
- * @author zhongcang
- * @date 2019/3/20
- */
-public interface IWXConfigAdapter {
- String getConfig(String nameSpace,String key,String defaultValue);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXHttpAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXHttpAdapter.java
deleted file mode 100644
index 3d6ea1f..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXHttpAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-
-import com.taobao.weex.common.WXRequest;
-import com.taobao.weex.common.WXResponse;
-
-import java.util.List;
-import java.util.Map;
-
-public interface IWXHttpAdapter {
-
- /**
- * http request method
- *
- * @param request weex assemble request
- * @param listener http response notify
- */
- void sendRequest(WXRequest request, OnHttpListener listener);
-
- interface OnHttpListener {
-
- /**
- * start request
- */
- void onHttpStart();
-
- /**
- * headers received
- */
- void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
-
- /**
- * post progress
- * @param uploadProgress
- */
- void onHttpUploadProgress(int uploadProgress);
-
- /**
- * response loaded length (bytes), full length should read from headers (content-length)
- * @param loadedLength
- */
- void onHttpResponseProgress(int loadedLength);
-
- /**
- * http response finish
- * @param response
- */
- void onHttpFinish(WXResponse response);
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXImgLoaderAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXImgLoaderAdapter.java
deleted file mode 100644
index 4b03ba8..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXImgLoaderAdapter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import android.widget.ImageView;
-
-import com.taobao.weex.common.WXImageStrategy;
-import com.taobao.weex.dom.WXImageQuality;
-
-/**
- * Interface for ImageLoader. This interface works as an adapter for various image library.
- */
-public interface IWXImgLoaderAdapter {
-
- void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJSExceptionAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJSExceptionAdapter.java
deleted file mode 100644
index 12ea4d8..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJSExceptionAdapter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import com.taobao.weex.common.WXJSExceptionInfo;
-
-public interface IWXJSExceptionAdapter {
-
- /**
- * report js exception
- *
- * @param exception {@link WXJSExceptionInfo}
- */
-
- void onJSException(WXJSExceptionInfo exception);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJsFileLoaderAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJsFileLoaderAdapter.java
deleted file mode 100644
index 37bbf7f..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJsFileLoaderAdapter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-public interface IWXJsFileLoaderAdapter {
- String loadRaxApi();
- String loadJsFramework();
- String loadJsFrameworkForSandBox();
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJscProcessManager.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJscProcessManager.java
deleted file mode 100644
index 4c8d22a..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXJscProcessManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import com.taobao.weex.WXSDKInstance;
-
-public interface IWXJscProcessManager {
- boolean enableBackupThread();
- boolean enableBackUpThreadCache();
- boolean shouldReboot();
- long rebootTimeout();
- boolean withException(WXSDKInstance instance);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXSoLoaderAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXSoLoaderAdapter.java
deleted file mode 100644
index fb9614a..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXSoLoaderAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-/**
- * Interface for loading library.
- */
-public interface IWXSoLoaderAdapter {
- /**
- * A method <code>doLoadLibrary</code> that
- * helps embedders to load a shared library with a short name.
- * <p>
- *
- * Embedders would have a chance to take charge of library loading,
- * they could load libraries with different class loaders,
- * or load libraries from specified library pathes.
- *
- * @param shortName the name of the library
- */
- void doLoadLibrary(String shortName);
-
- /**
- * A method <code>doLoad</code> that
- * helps embedders to load a shared library.
- * <p>
- *
- * Embedders would have a chance to take charge of library loading,
- * they could load libraries with different class loaders,
- * or load libraries from specified library pathes.
- *
- * @param name the file to load.
- */
- void doLoad(String name);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXUserTrackAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXUserTrackAdapter.java
deleted file mode 100644
index 915399e..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXUserTrackAdapter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import android.content.Context;
-
-import com.taobao.weex.common.WXPerformance;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * Interface for commit log info. This interface works as an adapter for various log library.
- */
-public interface IWXUserTrackAdapter {
-
- String MODULE_NAME = "weex";
-
- //Performance
- String LOAD = "load";
-
- //Alarm
- String JS_FRAMEWORK = "jsFramework";
- String JS_DOWNLOAD = "jsDownload";
- String DOM_MODULE = "domModule";
- String JS_BRIDGE = "jsBridge";
- String STREAM_MODULE = "streamModule";
- String INVOKE_MODULE = "invokeModule";
- String INIT_FRAMEWORK = "initFramework";
- String COUNTER = "counter";
-
- /**
- * monitor keys
- */
- String MONITOR_ERROR_CODE = "errCode";
- String MONITOR_ARG = "arg";
- String MONITOR_ERROR_MSG = "errMsg";
-
- void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/URIAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/URIAdapter.java
deleted file mode 100644
index cdac2fd..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/adapter/URIAdapter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.adapter;
-
-import android.net.Uri;
-import android.support.annotation.NonNull;
-
-import com.taobao.weex.WXSDKInstance;
-
-/**
- * Created by sospartan on 15/11/2016.
- */
-
-public interface URIAdapter {
-
- /**
- * Stream request url.
- */
- String REQUEST = "request";
-
- /**
- * URI for image src.
- */
- String IMAGE = "image";
-
- /**
- * Font file URI for text @font-face .
- */
- String FONT = "font";
-
- /**
- * Video URI.
- */
- String VIDEO = "video";
-
- /**
- * URI for a 'href' attribute.
- */
- String LINK = "link";
-
- /**
- * Bundle URI for Weex instance.
- */
- String BUNDLE = "bundle";
-
- /**
- * Web page src
- */
- String WEB = "web";
-
- /**
- * Unknown URIs.
- */
- String OTHERS = "others";
-
- /**
- *
- * @param type URI type, see {@link #IMAGE}/{@link #LINK}/{@link #FONT}/{@link #BUNDLE}/{@link #VIDEO}/{@link #OTHERS}
- * @param uri
- * @return
- */
- @NonNull Uri rewrite(WXSDKInstance instance, String type, Uri uri);
- @NonNull Uri rewrite(String bundleURL, String type, Uri uri);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/annotation/Component.java b/android/sdk/src/main/java/com/taobao/weex/annotation/Component.java
deleted file mode 100644
index 3f3414c..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/annotation/Component.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Created by sospartan on 6/12/16.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface Component {
- boolean lazyload() default true;
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/annotation/JSMethod.java b/android/sdk/src/main/java/com/taobao/weex/annotation/JSMethod.java
deleted file mode 100644
index 443dc37..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/annotation/JSMethod.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Created by sospartan on 19/10/2016.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-@Target(ElementType.METHOD)
-public @interface JSMethod {
- boolean uiThread() default true;
-
- String alias() default NOT_SET;
-
- String NOT_SET = "_";
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/clipboard/IWXClipboard.java b/android/sdk/src/main/java/com/taobao/weex/appfram/clipboard/IWXClipboard.java
deleted file mode 100644
index ccccd31..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/clipboard/IWXClipboard.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.clipboard;
-
-import android.support.annotation.Nullable;
-
-import com.taobao.weex.bridge.JSCallback;
-
-/**
- * Created by yiyuan.zhangyy(xingjiu) <br/>
- */
-interface IWXClipboard {
- public void setString(String text);
- public void getString(@Nullable JSCallback callback);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/clipboard/WXClipboardModule.java b/android/sdk/src/main/java/com/taobao/weex/appfram/clipboard/WXClipboardModule.java
deleted file mode 100644
index 7ded68a..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/clipboard/WXClipboardModule.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.clipboard;
-
-import android.content.ClipData;
-import android.content.ClipboardManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.AssetFileDescriptor;
-import android.net.Uri;
-import android.support.annotation.Nullable;
-
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.annotation.JSMethod;
-import com.taobao.weex.common.WXModule;
-import com.taobao.weex.utils.WXLogUtils;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class WXClipboardModule extends WXModule implements IWXClipboard {
-
- private final String CLIP_KEY = "WEEX_CLIP_KEY_MAIN";
-
- private static final String RESULT = "result";
- private static final String DATA = "data";
-
- private static final String RESULT_OK = "success";
- private static final String RESULT_FAILED = "failed";
-
- @Override
- @JSMethod
- public void setString(String text) {
- if(null == text) {
- return;
- }
-
- Context context = mWXSDKInstance.getContext();
- ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText(CLIP_KEY, text);
- clipboard.setPrimaryClip(clip);
- }
-
- @Override
- @JSMethod
- public void getString(@Nullable JSCallback callback) {
- Context context = mWXSDKInstance.getContext();
- ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
-
- Map<String, Object> map = new HashMap<>(2);
- ClipData clip = clipboard.getPrimaryClip();
- if (clip != null && clip.getItemCount() > 0) {
- ClipData.Item item = clip.getItemAt(0);
- CharSequence text = coerceToText(context, item);
-
- map.put(RESULT, text != null ? RESULT_OK : RESULT_FAILED);
- map.put(DATA, text != null ? text : "");
- } else {
- map.put(RESULT, RESULT_FAILED);
- map.put(DATA, "");
- }
-
- if (null != callback) {
- callback.invoke(map);
- }
- }
-
- @Nullable
- private CharSequence coerceToText(Context context, ClipData.Item item) {
- // Condition 1. just a simple text
- CharSequence text = item.getText();
- if (text != null) {
- return text;
- }
-
- // Condition 2. a URI value
- Uri uri = item.getUri();
- if (uri != null) {
- InputStreamReader reader = null;
- FileInputStream stream = null;
- try {
- AssetFileDescriptor assetFileDescriptor = context.getContentResolver().openTypedAssetFileDescriptor(uri, "text/*", null);
- stream = assetFileDescriptor.createInputStream();
- reader = new InputStreamReader(stream, "UTF-8");
-
- StringBuilder builder = new StringBuilder(128);
- char[] buffer = new char[8192];
- int len;
- while ((len = reader.read(buffer)) > 0) {
- builder.append(buffer, 0, len);
- }
- return builder.toString();
-
- } catch (FileNotFoundException e) {
- // ignore.
- } catch (IOException e) {
- WXLogUtils.w("ClippedData Failure loading text.", e);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // ignore
- }
- }
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- return uri.toString();
- }
-
- // Condition 3. an intent.
- Intent intent = item.getIntent();
- if (intent != null) {
- return intent.toUri(Intent.URI_INTENT_SCHEME);
- }
-
- // else case
- return null;
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/IActivityNavBarSetter.java b/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/IActivityNavBarSetter.java
deleted file mode 100644
index 321991d..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/IActivityNavBarSetter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.navigator;
-
-/**
- * Define the NavBarSetter api of the Activity
- */
-public interface IActivityNavBarSetter {
-
- boolean push(String param);
-
- boolean pop(String param);
-
- boolean setNavBarRightItem(String param);
-
- boolean clearNavBarRightItem(String param);
-
- boolean setNavBarLeftItem(String param);
-
- boolean clearNavBarLeftItem(String param);
-
- boolean setNavBarMoreItem(String param);
-
- boolean clearNavBarMoreItem(String param);
-
- boolean setNavBarTitle(String param);
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/INavigator.java b/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/INavigator.java
deleted file mode 100644
index 65c7193..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/INavigator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.navigator;
-import android.app.Activity;
-
-/**
- * Created by zhengshihan on 2018/8/9.
- */
-
-public interface INavigator {
-
- boolean push(Activity activity,String param);
-
- boolean pop(Activity activity,String param);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/WXNavigatorModule.java b/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/WXNavigatorModule.java
deleted file mode 100644
index 69c253b..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/navigator/WXNavigatorModule.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.navigator;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.support.v7.app.AppCompatActivity;
-import android.text.TextUtils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONException;
-import com.alibaba.fastjson.JSONObject;
-import com.taobao.weex.WXSDKEngine;
-import com.taobao.weex.annotation.JSMethod;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.bridge.WXBridgeManager;
-import com.taobao.weex.common.Constants;
-import com.taobao.weex.common.WXModule;
-import com.taobao.weex.utils.WXLogUtils;
-
-
-public class WXNavigatorModule extends WXModule {
-
- public static final String MSG_SUCCESS = "WX_SUCCESS";
- public static final String MSG_FAILED = "WX_FAILED";
- public static final String MSG_PARAM_ERR = "WX_PARAM_ERR";
-
- public static final String CALLBACK_RESULT = "result";
- public static final String CALLBACK_MESSAGE = "message";
-
- private final static String INSTANCE_ID = "instanceId";
- private final static String TAG = "Navigator";
- private final static String WEEX = "com.taobao.android.intent.category.WEEX";
- private final static String URL = "url";
-
- @JSMethod(uiThread = true)
- public void open(JSONObject options, JSCallback success, JSCallback failure) {
- if (options != null) {
- String url = options.getString(Constants.Value.URL);
- JSCallback callback = success;
- JSONObject result = new JSONObject();
- if (!TextUtils.isEmpty(url)) {
- Uri rawUri = Uri.parse(url);
- String scheme = rawUri.getScheme();
- if (TextUtils.isEmpty(scheme) || Constants.Scheme.HTTP.equalsIgnoreCase(scheme) || Constants.Scheme.HTTPS.equalsIgnoreCase(scheme)) {
- this.push(options.toJSONString(), success);
- } else {
- try {
- Intent intent = new Intent(Intent.ACTION_VIEW, rawUri);
- mWXSDKInstance.getContext().startActivity(intent);
- result.put(CALLBACK_RESULT, MSG_SUCCESS);
- } catch (Throwable e) {
- e.printStackTrace();
- result.put(CALLBACK_RESULT, MSG_FAILED);
- result.put(CALLBACK_MESSAGE, "Open page failed.");
- callback = failure;
- }
- }
- } else {
- result.put(CALLBACK_RESULT, MSG_PARAM_ERR);
- result.put(CALLBACK_MESSAGE, "The URL parameter is empty.");
- callback = failure;
- }
-
- if(callback != null){
- callback.invoke(result);
- }
- }
- }
-
- @JSMethod(uiThread = true)
- public void close(JSONObject options, JSCallback success, JSCallback failure) {
- JSONObject result = new JSONObject();
- JSCallback callback = null;
- if (mWXSDKInstance.getContext() instanceof Activity) {
- callback = success;
- ((Activity) mWXSDKInstance.getContext()).finish();
- } else {
- result.put(CALLBACK_RESULT, MSG_FAILED);
- result.put(CALLBACK_MESSAGE, "Close page failed.");
- callback = failure;
- }
- if (callback != null) {
- callback.invoke(result);
- }
- }
-
- @JSMethod(uiThread = true)
- public void push(String param, JSCallback callback) {
-
- if (!TextUtils.isEmpty(param)) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
-
- if (mWXSDKInstance.getContext() instanceof Activity){
- Activity activity = (Activity)mWXSDKInstance.getContext();
-
- if (WXSDKEngine.getNavigator()!= null
- && WXSDKEngine.getNavigator().push(activity,param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
-
- try {
- JSONObject jsonObject = JSON.parseObject(param);
- String url = jsonObject.getString(URL);
- if (!TextUtils.isEmpty(url)) {
- Uri rawUri = Uri.parse(url);
- String scheme = rawUri.getScheme();
- Uri.Builder builder = rawUri.buildUpon();
- if (TextUtils.isEmpty(scheme)) {
- builder.scheme(Constants.Scheme.HTTP);
- }
- Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
- intent.addCategory(WEEX);
- intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
- mWXSDKInstance.getContext().startActivity(intent);
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- }
- } catch (Exception e) {
- WXLogUtils.eTag(TAG, e);
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
- } else if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod(uiThread = true)
- public void pop(String param, JSCallback callback) {
-
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().pop(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
-
- if (mWXSDKInstance.getContext() instanceof Activity) {
- Activity activity = (Activity) mWXSDKInstance.getContext();
- if (WXSDKEngine.getNavigator() != null) {
- if (WXSDKEngine.getNavigator().pop(activity, param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
-
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- ((Activity) mWXSDKInstance.getContext()).finish();
- }
- }
-
- @JSMethod(uiThread = true)
- public void setNavBarRightItem(String param, JSCallback callback) {
- if (!TextUtils.isEmpty(param)) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().setNavBarRightItem(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
- }
-
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod(uiThread = true)
- public void clearNavBarRightItem(String param, JSCallback callback) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().clearNavBarRightItem(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod(uiThread = true)
- public void setNavBarLeftItem(String param, JSCallback callback) {
- if (!TextUtils.isEmpty(param)) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().setNavBarLeftItem(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
- }
-
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
-
- }
-
- @JSMethod(uiThread = true)
- public void clearNavBarLeftItem(String param, JSCallback callback) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().clearNavBarLeftItem(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
-
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod(uiThread = true)
- public void setNavBarMoreItem(String param, JSCallback callback) {
- if (!TextUtils.isEmpty(param)) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().setNavBarMoreItem(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
- }
-
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod(uiThread = true)
- public void clearNavBarMoreItem(String param, JSCallback callback) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().clearNavBarMoreItem(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
-
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod(uiThread = true)
- public void setNavBarTitle(String param, JSCallback callback) {
- if (!TextUtils.isEmpty(param)) {
- if (WXSDKEngine.getActivityNavBarSetter() != null) {
- if (WXSDKEngine.getActivityNavBarSetter().setNavBarTitle(param)) {
- if (callback != null) {
- callback.invoke(MSG_SUCCESS);
- }
- return;
- }
- }
- }
- if (callback != null) {
- callback.invoke(MSG_FAILED);
- }
- }
-
- @JSMethod
- public void setNavBarHidden(String param, final String callback) {
- String message = MSG_FAILED;
- try {
- JSONObject jsObj = JSON.parseObject(param);
- int visibility = jsObj.getInteger(Constants.Name.NAV_BAR_VISIBILITY);
- boolean success = changeVisibilityOfActionBar(mWXSDKInstance.getContext(), visibility);
- if (success) {
- message = MSG_SUCCESS;
- }
- } catch (JSONException e) {
- WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e));
- }
- WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callback, message);
- }
-
- private boolean changeVisibilityOfActionBar(Context context, int visibility) {
- boolean result = false;
- boolean hasAppCompatActivity = false;
- try {
- Class.forName("android.support.v7.app.AppCompatActivity");
- hasAppCompatActivity = true;
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- if (hasAppCompatActivity && mWXSDKInstance.getContext() instanceof AppCompatActivity) {
- android.support.v7.app.ActionBar actionbar = ((AppCompatActivity) mWXSDKInstance.getContext()).getSupportActionBar();
- if (actionbar != null) {
- switch (visibility) {
- case Constants.Value.NAV_BAR_HIDDEN:
- actionbar.hide();
- result = true;
- break;
- case Constants.Value.NAV_BAR_SHOWN:
- actionbar.show();
- result = true;
- break;
- }
- }
- } else if (mWXSDKInstance.getContext() instanceof Activity) {
- android.app.ActionBar actionbar = ((Activity) mWXSDKInstance.getContext()).getActionBar();
- if (actionbar != null) {
- switch (visibility) {
- case Constants.Value.NAV_BAR_HIDDEN:
- actionbar.hide();
- result = true;
- break;
- case Constants.Value.NAV_BAR_SHOWN:
- actionbar.show();
- result = true;
- break;
- }
- }
- }
- return result;
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/pickers/DatePickerImpl.java b/android/sdk/src/main/java/com/taobao/weex/appfram/pickers/DatePickerImpl.java
deleted file mode 100644
index 7aca328..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/pickers/DatePickerImpl.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.pickers;
-
-import android.app.AlertDialog;
-import android.app.DatePickerDialog;
-import android.app.TimePickerDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-import android.widget.Button;
-import android.widget.DatePicker;
-import android.widget.TimePicker;
-
-import com.taobao.weex.common.WXThread;
-import com.taobao.weex.utils.WXLogUtils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Created by moxun on 16/11/23.
- */
-
-public class DatePickerImpl {
-
- private static final int DEFAULT_START_YEAR = 1900;
- private static final int DEFAULT_END_YEAR = 2100;
-
- private static SimpleDateFormat timeFormatter;
- private static SimpleDateFormat dateFormatter;
-
- public static void pickDate(@NonNull Context context, String value, String max, String min, @NonNull final OnPickListener listener, @Nullable Map<String, Object> extras) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parseDate(value));
- final DatePickerDialog dialog = new DatePickerDialog(
- context,
- new DatePickerDialog.OnDateSetListener() {
- @Override
- public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- int realMonth = monthOfYear + 1;
- String realMonthString = realMonth < 10 ? "0" + realMonth : String.valueOf(realMonth);
- String realDayString = dayOfMonth < 10 ? "0" + dayOfMonth : String.valueOf(dayOfMonth);
- String result = year + "-" + realMonthString + "-" + realDayString;
- listener.onPick(true, result);
- }
- },
- calendar.get(Calendar.YEAR),
- calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH)
- );
-
- final DatePicker datePicker = dialog.getDatePicker();
-
- final Calendar defaultMinDate = Calendar.getInstance(Locale.getDefault());
- final Calendar defaultMaxDate = Calendar.getInstance(Locale.getDefault());
-
- defaultMinDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1);
- defaultMaxDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31);
-
- if (!TextUtils.isEmpty(min)) {
- long minDate = parseDate(min).getTime();
- if (datePicker.getMaxDate() >= minDate) {
- datePicker.setMinDate(parseDate(min).getTime());
- } else {
- datePicker.setMinDate(defaultMinDate.getTimeInMillis());
- datePicker.setMaxDate(defaultMaxDate.getTimeInMillis());
- }
- }
- if (!TextUtils.isEmpty(max)) {
- long maxDate = parseDate(max).getTime();
- if (datePicker.getMinDate() <= maxDate) {
- datePicker.setMaxDate(parseDate(max).getTime());
- } else {
- datePicker.setMinDate(defaultMinDate.getTimeInMillis());
- datePicker.setMaxDate(defaultMaxDate.getTimeInMillis());
- }
- }
-
- dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- listener.onPick(false, null);
- }
- });
-
- setButtonText(dialog, DialogInterface.BUTTON_NEGATIVE, String.valueOf(extras != null ? extras.get("cancelTitle") : null));
- setButtonText(dialog, DialogInterface.BUTTON_POSITIVE, String.valueOf(extras != null ? extras.get("confirmTitle") : null));
-
- dialog.show();
- }
-
- public static void pickTime(@NonNull Context context, String value, @NonNull final OnPickListener listener, @Nullable Map<String, Object> extras) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parseTime(value));
- TimePickerDialog dialog = new TimePickerDialog(
- context,
- new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
- String h = hourOfDay < 10 ? "0" + hourOfDay : String.valueOf(hourOfDay);
- String m = minute < 10 ? "0" + minute : String.valueOf(minute);
- String result = h + ":" + m;
- listener.onPick(true, result);
- }
- },
- calendar.get(Calendar.HOUR_OF_DAY),
- calendar.get(Calendar.MINUTE),
- false
- );
-
- dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- listener.onPick(false, null);
- }
- });
-
- setButtonText(dialog, DialogInterface.BUTTON_NEGATIVE, String.valueOf(extras != null ? extras.get("cancelTitle") : null));
- setButtonText(dialog, DialogInterface.BUTTON_POSITIVE, String.valueOf(extras != null ? extras.get("confirmTitle") : null));
-
- dialog.show();
- }
-
- public interface OnPickListener {
- void onPick(boolean set, @Nullable String result);
- }
-
- private static Date parseDate(String s) {
- if (dateFormatter == null) {
- dateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
- }
-
- try {
- return dateFormatter.parse(s);
- } catch (ParseException e) {
- //don't worry
- WXLogUtils.w("[DatePickerImpl] " + e.toString());
- }
- return new Date();
- }
-
- private static Date parseTime(String s) {
- if (timeFormatter == null) {
- timeFormatter = new SimpleDateFormat("HH:mm", Locale.getDefault());
- }
-
- try {
- return timeFormatter.parse(s);
- } catch (ParseException e) {
- //don't worry
- WXLogUtils.w("[DatePickerImpl] " + e.toString());
- }
- return new Date();
- }
-
- private static void setButtonText(final AlertDialog dialog, final int which, final CharSequence text) {
- if (TextUtils.isEmpty(text) || "null".equals(text)) {
- return;
- }
- try {
- dialog.getWindow().getDecorView().post(WXThread.secure(new Runnable() {
- @Override
- public void run() {
- Button button = dialog.getButton(which);
- if (button != null) {
- button.setAllCaps(false);
- button.setText(text);
- }
- }
- }));
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/pickers/WXPickersModule.java b/android/sdk/src/main/java/com/taobao/weex/appfram/pickers/WXPickersModule.java
deleted file mode 100644
index ef46f8f..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/pickers/WXPickersModule.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.pickers;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.graphics.Color;
-import android.os.Build;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AlertDialog;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.Checkable;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.taobao.weex.annotation.JSMethod;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.common.WXModule;
-import com.taobao.weex.common.WXThread;
-import com.taobao.weex.utils.WXResourceUtils;
-import com.taobao.weex.utils.WXViewUtils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by moxun on 16/10/27.
- */
-
-public class WXPickersModule extends WXModule {
-
- private static final String SUCCESS = "success";
- private static final String CANCEL = "cancel";
- private static final String ERROR = "error";
-
- private static final String RESULT = "result";
- private static final String DATA = "data";
-
- private static final String KEY_VALUE = "value";
- private static final String KEY_INDEX = "index";
- private static final String KEY_TITLE = "title";
- private static final String KEY_MAX = "max";
- private static final String KEY_MIN = "min";
- private static final String KEY_ITEMS = "items";
-
- private static final String KEY_TITLE_COLOR = "titleColor";
- private static final String KEY_CANCEL_TITLE_COLOR = "cancelTitleColor";
- private static final String KEY_CONFIRM_TITLE = "confirmTitle";
- private static final String KEY_CANCEL_TITLE = "cancelTitle";
- private static final String KEY_CONFIRM_TITLE_COLOR = "confirmTitleColor";
- private static final String KEY_TITLE_BACKGROUND_COLOR = "titleBackgroundColor";
- private static final String KEY_TEXT_COLOR = "textColor";
- private static final String KEY_SELECTION_COLOR = "selectionColor";
-
- private int selected;
-
- @JSMethod
- public void pick(Map<String, Object> options, JSCallback callback) {
- List<String> items = safeConvert(getOption(options, KEY_ITEMS, new ArrayList<String>()));
- try {
- performSinglePick(items, options, callback);
- } catch (Throwable throwable) {
- throwable.printStackTrace();
- }
- }
-
- @JSMethod
- public void pickDate(Map<String, Object> options, JSCallback callback) {
- performPickDate(options, callback);
- }
-
- @JSMethod
- public void pickTime(Map<String, Object> options, JSCallback callback) {
- performPickTime(options, callback);
- }
-
- private List<String> safeConvert(List src) {
- List<String> result = new ArrayList<>(src.size());
- for (Object obj : src) {
- result.add(String.valueOf(obj));
- }
- return result;
- }
-
- private <T> T getOption(Map<String, Object> options, String key, T defValue) {
- Object value = options.get(key);
- if (value == null) {
- return defValue;
- } else {
- try {
- return (T) value;
- } catch (Exception e) {
- e.printStackTrace();
- return defValue;
- }
- }
- }
-
- private int getColor(Map<String, Object> options, String key, int defValue) {
- Object value = getOption(options, key, null);
- if (value == null) {
- return defValue;
- }
- return WXResourceUtils.getColor(value.toString(), defValue);
- }
-
- private void performPickTime(Map<String, Object> options, final JSCallback callback) {
- String value = getOption(options, KEY_VALUE, "");
- DatePickerImpl.pickTime(
- mWXSDKInstance.getContext(),
- value,
- new DatePickerImpl.OnPickListener() {
- @Override
- public void onPick(boolean set, @Nullable String result) {
- if (set) {
- Map<String, Object> ret = new HashMap<>(2);
- ret.put(RESULT, SUCCESS);
- ret.put(DATA, result);
- callback.invoke(ret);
- } else {
- Map<String, Object> ret = new HashMap<>(2);
- ret.put(RESULT, CANCEL);
- ret.put(DATA, null);
- callback.invoke(ret);
- }
- }
- },
- options);
- }
-
- private void performPickDate(Map<String, Object> options, final JSCallback callback) {
- String value = getOption(options, KEY_VALUE, "");
- String max = getOption(options, KEY_MAX, "");
- String min = getOption(options, KEY_MIN, "");
- DatePickerImpl.pickDate(
- mWXSDKInstance.getContext(),
- value,
- max,
- min,
- new DatePickerImpl.OnPickListener() {
- @Override
- public void onPick(boolean set, @Nullable String result) {
- if (set) {
- Map<String, Object> ret = new HashMap<>(2);
- ret.put(RESULT, SUCCESS);
- ret.put(DATA, result);
- callback.invoke(ret);
- } else {
- Map<String, Object> ret = new HashMap<>(2);
- ret.put(RESULT, CANCEL);
- ret.put(DATA, null);
- callback.invoke(ret);
- }
- }
- },
- options);
-
- }
-
- private void performSinglePick(final List<String> items, final Map<String, Object> options, final JSCallback callback) {
- selected = getOption(options, KEY_INDEX, 0);
- final int textColor = getColor(options, KEY_TEXT_COLOR, Color.TRANSPARENT);
- final int selectionColor = getColor(options, KEY_SELECTION_COLOR, Color.TRANSPARENT);
- final ArrayAdapter adapter = new ArrayAdapter<String>(
- mWXSDKInstance.getContext(),
- android.R.layout.simple_list_item_single_choice,
- items) {
- @NonNull
- @Override
- public View getView(int position, View convertView, @Nullable ViewGroup parent) {
- View itemView = super.getView(position, convertView, parent);
-
- if (itemView != null && itemView instanceof Checkable) {
- boolean needSelected = position == selected;
- ((Checkable) itemView).setChecked(needSelected);
-
- if (needSelected) {
- itemView.setBackgroundColor(selectionColor);
- } else {
- itemView.setBackgroundColor(Color.TRANSPARENT);
- }
- }
-
- if (itemView instanceof TextView && textColor != Color.TRANSPARENT) {
- ((TextView) itemView).setTextColor(textColor);
- }
-
- return itemView;
- }
- };
- final AlertDialog dialog = new AlertDialog.Builder(mWXSDKInstance.getContext())
- .setAdapter(adapter, null)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- //which == -1
- Map<String, Object> ret = new HashMap<>(2);
- ret.put(RESULT, SUCCESS);
- ret.put(DATA, selected);
- callback.invoke(ret);
- }
- })
- .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- //which == -2
- Map<String, Object> ret = new HashMap<>(2);
- ret.put(RESULT, CANCEL);
- ret.put(DATA, -1);
- callback.invoke(ret);
- }
- })
- .setCustomTitle(makeTitleView(mWXSDKInstance.getContext(), options))
- .create();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- //pre create the content view on dialog.
- //if not , the content view will not be created until dialog.show() called
- dialog.create();
- }
-
- final ListView listView = dialog.getListView();
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- selected = position;
- adapter.notifyDataSetChanged();
- }
- });
-
- dialog.getWindow().getDecorView().post(WXThread.secure(new Runnable() {
- @Override
- public void run() {
- Button confirm = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
- Button cancel = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
-
- if (confirm != null) {
- String confirmTitle = getOption(options, KEY_CONFIRM_TITLE, null);
- int confirmColor = getColor(options, KEY_CONFIRM_TITLE_COLOR, Color.TRANSPARENT);
-
- if (confirmTitle != null) {
- confirm.setText(confirmTitle);
- confirm.setAllCaps(false);
- }
-
- if (confirmColor != Color.TRANSPARENT) {
- confirm.setTextColor(confirmColor);
- confirm.setAllCaps(false);
- }
- }
-
- if (cancel != null) {
- String cancelTitle = getOption(options, KEY_CANCEL_TITLE, null);
- int cancelColor = getColor(options, KEY_CANCEL_TITLE_COLOR, Color.TRANSPARENT);
-
- if (cancelTitle != null) {
- cancel.setText(cancelTitle);
- }
-
- if (cancelColor != Color.TRANSPARENT) {
- cancel.setTextColor(cancelColor);
- }
- }
- }
- }));
-
- dialog.show();
- }
-
- private TextView makeTitleView(Context context, Map<String, Object> options) {
- String text = getOption(options, KEY_TITLE, null);
- if (text == null) {
- return null;
- }
- TextView textView = new TextView(context);
- textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
- int padding = WXViewUtils.dip2px(12);
- textView.setPadding(padding, padding, padding, padding);
- textView.getPaint().setFakeBoldText(true);
- textView.setBackgroundColor(getColor(options, KEY_TITLE_BACKGROUND_COLOR, Color.TRANSPARENT));
- textView.setTextColor(getColor(options, KEY_TITLE_COLOR, Color.BLACK));
- textView.setText(text);
- return textView;
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/DefaultWXStorage.java b/android/sdk/src/main/java/com/taobao/weex/appfram/storage/DefaultWXStorage.java
deleted file mode 100644
index 9bcc75e..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/DefaultWXStorage.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.storage;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteFullException;
-import android.database.sqlite.SQLiteStatement;
-import android.support.annotation.Nullable;
-
-import com.taobao.weex.common.WXThread;
-import com.taobao.weex.utils.WXLogUtils;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class DefaultWXStorage implements IWXStorageAdapter {
-
- private WXSQLiteOpenHelper mDatabaseSupplier;
-
- private ExecutorService mExecutorService;
-
- private void execute(@Nullable final Runnable runnable) {
- if (mExecutorService == null) {
- mExecutorService = Executors.newSingleThreadExecutor();
- }
-
- if(runnable != null && !mExecutorService.isShutdown() && !mExecutorService.isTerminated()) {
- mExecutorService.execute(WXThread.secure(runnable));
- }
- }
-
- public DefaultWXStorage(Context context) {
- this.mDatabaseSupplier = new WXSQLiteOpenHelper(context);
- }
-
-
- @Override
- public void setItem(final String key, final String value, final OnResultReceivedListener listener) {
- execute(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> data = StorageResultHandler.setItemResult(performSetItem(key, value, false, true));
- if (listener == null) {
- return;
- }
- listener.onReceived(data);
- }
- });
- }
-
- @Override
- public void getItem(final String key, final OnResultReceivedListener listener) {
- execute(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> data = StorageResultHandler.getItemResult(performGetItem(key));
- if (listener == null) {
- return;
- }
- listener.onReceived(data);
- }
- });
- }
-
- @Override
- public void removeItem(final String key, final OnResultReceivedListener listener) {
- execute(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> data = StorageResultHandler.removeItemResult(performRemoveItem(key));
- if (listener == null) {
- return;
- }
- listener.onReceived(data);
- }
- });
- }
-
- @Override
- public void length(final OnResultReceivedListener listener) {
- execute(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> data = StorageResultHandler.getLengthResult(performGetLength());
- if (listener == null) {
- return;
- }
- listener.onReceived(data);
- }
- });
- }
-
- @Override
- public void getAllKeys(final OnResultReceivedListener listener) {
- execute(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> data = StorageResultHandler.getAllkeysResult(performGetAllKeys());
- if (listener == null) {
- return;
- }
- listener.onReceived(data);
- }
- });
- }
-
- @Override
- public void setItemPersistent(final String key, final String value, final OnResultReceivedListener listener) {
- execute(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> data = StorageResultHandler.setItemResult(performSetItem(key, value, true, true));
- if (listener == null) {
- return;
- }
- listener.onReceived(data);
- }
- });
- }
-
- @Override
- public void close() {
- final ExecutorService needCloseService = mExecutorService;
- execute(new Runnable() {
- @Override
- public void run() {
- try {
- mDatabaseSupplier.closeDatabase();
- if (needCloseService != null) {
- needCloseService.shutdown();
- }
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, e.getMessage());
- }
- }
- });
- mExecutorService = null;
- }
-
- private boolean performSetItem(String key, String value, boolean isPersistent, boolean allowRetryWhenFull) {
- SQLiteDatabase database = mDatabaseSupplier.getDatabase();
- if (database == null) {
- return false;
- }
-
- WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "set k-v to storage(key:" + key + ",value:" + value + ",isPersistent:" + isPersistent + ",allowRetry:" + allowRetryWhenFull + ")");
- String sql = "INSERT OR REPLACE INTO " + WXSQLiteOpenHelper.TABLE_STORAGE + " VALUES (?,?,?,?);";
- SQLiteStatement statement = null;
- String timeStamp = WXSQLiteOpenHelper.sDateFormatter.format(new Date());
- try {
- statement = database.compileStatement(sql);
- statement.clearBindings();
- statement.bindString(1, key);
- statement.bindString(2, value);
- statement.bindString(3, timeStamp);
- statement.bindLong(4, isPersistent ? 1 : 0);
- statement.execute();
- return true;
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute setItem :" + e.getMessage());
- if (e instanceof SQLiteFullException) {
- if (allowRetryWhenFull && trimToSize()) {
- //try again
- //setItem/setItemPersistent method only allow try once when occurred a sqliteFullException.
- WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "retry set k-v to storage(key:" + key + ",value:" + value + ")");
- return performSetItem(key, value, isPersistent, false);
- }
- }
-
- return false;
- } finally {
- if(statement != null) {
- statement.close();
- }
- }
- }
-
- /**
- * remove 10% of total record(at most) ordered by timestamp.
- * */
- private boolean trimToSize() {
- SQLiteDatabase database = mDatabaseSupplier.getDatabase();
- if (database == null) {
- return false;
- }
-
- List<String> toEvict = new ArrayList<>();
- int num = 0;
-
- Cursor c = database.query(WXSQLiteOpenHelper.TABLE_STORAGE, new String[]{WXSQLiteOpenHelper.COLUMN_KEY, WXSQLiteOpenHelper.COLUMN_PERSISTENT}, null, null, null, null, WXSQLiteOpenHelper.COLUMN_TIMESTAMP + " ASC");
- try {
- int evictSize = c.getCount() / 10;
- while (c.moveToNext()) {
- String key = c.getString(c.getColumnIndex(WXSQLiteOpenHelper.COLUMN_KEY));
- boolean persistent = c.getInt(c.getColumnIndex(WXSQLiteOpenHelper.COLUMN_PERSISTENT)) == 1;
- if (!persistent && key != null) {
- num++;
- toEvict.add(key);
- if (num == evictSize) {
- break;
- }
- }
- }
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute trimToSize:" + e.getMessage());
- } finally {
- c.close();
- }
-
- if (num <= 0) {
- return false;
- }
-
- for (String key : toEvict) {
- performRemoveItem(key);
- }
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "remove " + num + " items by lru");
- return true;
- }
-
- private String performGetItem(String key) {
- SQLiteDatabase database = mDatabaseSupplier.getDatabase();
- if (database == null) {
- return null;
- }
-
- Cursor c = database.query(WXSQLiteOpenHelper.TABLE_STORAGE,
- new String[]{WXSQLiteOpenHelper.COLUMN_VALUE},
- WXSQLiteOpenHelper.COLUMN_KEY + "=?",
- new String[]{key},
- null, null, null);
- try {
- if (c.moveToNext()) {
- ContentValues values = new ContentValues();
- //update timestamp
- values.put(WXSQLiteOpenHelper.COLUMN_TIMESTAMP, WXSQLiteOpenHelper.sDateFormatter.format(new Date()));
- int updateResult = mDatabaseSupplier.getDatabase().update(WXSQLiteOpenHelper.TABLE_STORAGE, values, WXSQLiteOpenHelper.COLUMN_KEY + "= ?", new String[]{key});
-
- WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "update timestamp " + (updateResult == 1 ? "success" : "failed") + " for operation [getItem(key = " + key + ")]");
- return c.getString(c.getColumnIndex(WXSQLiteOpenHelper.COLUMN_VALUE));
- } else {
- return null;
- }
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getItem:" + e.getMessage());
- return null;
- } finally {
- c.close();
- }
- }
-
- private boolean performRemoveItem(String key) {
- SQLiteDatabase database = mDatabaseSupplier.getDatabase();
- if (database == null) {
- return false;
- }
-
- int count = 0;
- try {
- count = database.delete(WXSQLiteOpenHelper.TABLE_STORAGE,
- WXSQLiteOpenHelper.COLUMN_KEY + "=?",
- new String[]{key});
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute removeItem:" + e.getMessage());
- return false;
- }
- return count == 1;
- }
-
- private long performGetLength() {
- SQLiteDatabase database = mDatabaseSupplier.getDatabase();
- if (database == null) {
- return 0;
- }
-
- String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE;
- SQLiteStatement statement = null;
- try {
- statement = database.compileStatement(sql);
- return statement.simpleQueryForLong();
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage());
- return 0;
- } finally {
- if(statement != null) {
- statement.close();
- }
- }
- }
-
- private List<String> performGetAllKeys() {
- SQLiteDatabase database = mDatabaseSupplier.getDatabase();
- if (database == null) {
- return null;
- }
-
- List<String> result = new ArrayList<>();
- Cursor c = database.query(WXSQLiteOpenHelper.TABLE_STORAGE, new String[]{WXSQLiteOpenHelper.COLUMN_KEY}, null, null, null, null, null);
- try {
- while (c.moveToNext()) {
- result.add(c.getString(c.getColumnIndex(WXSQLiteOpenHelper.COLUMN_KEY)));
- }
- return result;
- } catch (Exception e) {
- WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getAllKeys:" + e.getMessage());
- return result;
- } finally {
- c.close();
- }
- }
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/IWXStorage.java b/android/sdk/src/main/java/com/taobao/weex/appfram/storage/IWXStorage.java
deleted file mode 100644
index c869d53..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/IWXStorage.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.storage;
-
-import android.support.annotation.Nullable;
-
-import com.taobao.weex.bridge.JSCallback;
-
-interface IWXStorage {
- public void setItem(String key, String value,@Nullable JSCallback callback);
- public void getItem(String key,@Nullable JSCallback callback);
- public void removeItem(String key,@Nullable JSCallback callback);
- public void length(@Nullable JSCallback callback);
- public void getAllKeys(@Nullable JSCallback callback);
- public void setItemPersistent(String key, String value, @Nullable JSCallback callback);
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/IWXStorageAdapter.java b/android/sdk/src/main/java/com/taobao/weex/appfram/storage/IWXStorageAdapter.java
deleted file mode 100644
index c04512c..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/IWXStorageAdapter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.storage;
-
-import java.util.Map;
-
-/**
- * interface for {@link WXStorageModule} class.
- * this interface works as an adapter for different storage strategy.
- * the default is use {@link android.database.sqlite.SQLiteDatabase} to store k-v pairs.
- * You can call {@link com.taobao.weex.InitConfig.Builder#setStorageAdapter(IWXStorageAdapter)} to inject your own
- * storage implementation.
- * */
-public interface IWXStorageAdapter {
- void setItem(String key, String value,OnResultReceivedListener listener);
-
- void getItem(String key,OnResultReceivedListener listener);
-
- void removeItem(String key,OnResultReceivedListener listener);
-
- void length(OnResultReceivedListener listener);
-
- void getAllKeys(OnResultReceivedListener listener);
-
- void setItemPersistent(String key, String value, OnResultReceivedListener listener);
-
- void close();
-
- /**
- * the callback of storage operation.
- * */
- interface OnResultReceivedListener {
- void onReceived(Map<String,Object> data);
- }
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/StorageResultHandler.java b/android/sdk/src/main/java/com/taobao/weex/appfram/storage/StorageResultHandler.java
deleted file mode 100644
index f8be207..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/StorageResultHandler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.storage;
-
-import android.support.annotation.Nullable;
-
-import com.taobao.weex.bridge.JSCallback;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class StorageResultHandler {
-
- private StorageResultHandler() {
- }
-
- private static final String RESULT = "result";
- private static final String DATA = "data";
-
-
- private static final String UNDEFINED = "undefined";
- private static final String RESULT_FAILED_NO_HANDLER = "no_handler";
- private static final String RESULT_FAILED_INVALID_PARAM = "invalid_param";
-
-
- private static final String RESULT_OK = "success";
- private static final String RESULT_FAILED = "failed";
-
-
- public static Map<String, Object> getItemResult(String result) {
- Map<String, Object> map = new HashMap<>(4);
- map.put(RESULT, result != null ? RESULT_OK : RESULT_FAILED);
- map.put(DATA, result != null ? result : UNDEFINED);
- return map;
- }
-
- public static Map<String, Object> setItemResult(boolean result) {
- Map<String, Object> map = new HashMap<>(4);
- map.put(RESULT, result ? RESULT_OK : RESULT_FAILED);
- map.put(DATA, UNDEFINED);
- return map;
- }
-
-
- public static Map<String, Object> removeItemResult(boolean result) {
- Map<String, Object> map = new HashMap<>(4);
- map.put(RESULT, result ? RESULT_OK : RESULT_FAILED);
- map.put(DATA, UNDEFINED);
- return map;
- }
-
- public static Map<String, Object> getLengthResult(long result) {
- Map<String, Object> map = new HashMap<>(4);
- map.put(RESULT, RESULT_OK);
- map.put(DATA, result);
- return map;
- }
-
- public static Map<String, Object> getAllkeysResult(List<String> result) {
- if (result == null) {
- result = new ArrayList<>(1);
- }
- Map<String, Object> map = new HashMap<>(4);
- map.put(RESULT, RESULT_OK);
- map.put(DATA, result);
- return map;
- }
-
-
- private static void handleResult(@Nullable JSCallback callback, String result, Object data) {
- if (callback == null) {
- return;
- }
- Map<String, Object> retVal = new HashMap<>(4);
- retVal.put(RESULT, result);
- retVal.put(DATA, data);
- callback.invoke(retVal);
- }
-
- public static void handleNoHandlerError(@Nullable JSCallback callback) {
- handleResult(callback, RESULT_FAILED, RESULT_FAILED_NO_HANDLER);
- }
-
- public static void handleInvalidParam(@Nullable JSCallback callback) {
- handleResult(callback, RESULT_FAILED, RESULT_FAILED_INVALID_PARAM);
- }
-
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/WXSQLiteOpenHelper.java b/android/sdk/src/main/java/com/taobao/weex/appfram/storage/WXSQLiteOpenHelper.java
deleted file mode 100644
index 4477030..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/WXSQLiteOpenHelper.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.storage;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteException;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import com.taobao.weex.utils.WXLogUtils;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-public class WXSQLiteOpenHelper extends SQLiteOpenHelper {
-
- private static final String DATABASE_NAME = "WXStorage";
- private static final int DATABASE_VERSION = 2;
- static final String TAG_STORAGE = "weex_storage";
-
- private long mMaximumDatabaseSize = 5 * 10 * 1024 * 1024L;//50mb
- static SimpleDateFormat sDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
- private Context mContext;
- private SQLiteDatabase mDb;
-
-
- static final String TABLE_STORAGE = "default_wx_storage";
- static final String COLUMN_KEY = "key";
- static final String COLUMN_VALUE = "value";
- static final String COLUMN_TIMESTAMP = "timestamp";
- static final String COLUMN_PERSISTENT = "persistent";
-
- private static final int SLEEP_TIME_MS = 30;
-
- private static final String STATEMENT_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_STORAGE + " ("
- + COLUMN_KEY
- + " TEXT PRIMARY KEY,"
- + COLUMN_VALUE
- + " TEXT NOT NULL,"
- + COLUMN_TIMESTAMP
- + " TEXT NOT NULL,"
- + COLUMN_PERSISTENT
- + " INTEGER DEFAULT 0"
- + ")";
-
-
- public WXSQLiteOpenHelper(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- this.mContext = context;
- }
-
- /**
- * retrieve sqlite database
- *
- * @return a {@link SQLiteDatabase} instance or null if retrieve fails.
- * */
- public @Nullable SQLiteDatabase getDatabase() {
- ensureDatabase();
- return mDb;
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(STATEMENT_CREATE_TABLE);
- }
-
-
- /**
- * version 1:
- *
- * ----------------
- * | key | value |
- * ---------------
- *
- * version 2:
- *
- * ----------------------------------------
- * | key | value | timestamp | persistent |
- * ----------------------------------------
- **/
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- if (oldVersion != newVersion) {
- if(newVersion == 2 && oldVersion == 1){
- WXLogUtils.d(TAG_STORAGE,"storage is updating from version "+oldVersion+" to version "+newVersion);
- boolean updateResult = true;
- try {
- long start = System.currentTimeMillis();
-
- db.beginTransaction();
- // update table structure
- String SQL_ADD_COLUMN_TIMESTAMP = "ALTER TABLE "+TABLE_STORAGE+" ADD COLUMN "+COLUMN_TIMESTAMP+" TEXT;";
- WXLogUtils.d(TAG_STORAGE,"exec sql : "+ SQL_ADD_COLUMN_TIMESTAMP);
- db.execSQL(SQL_ADD_COLUMN_TIMESTAMP);
-
- String SQL_ADD_COLUMN_PERSISTENT = "ALTER TABLE "+TABLE_STORAGE+" ADD COLUMN "+COLUMN_PERSISTENT+" INTEGER;";
- WXLogUtils.d(TAG_STORAGE,"exec sql : "+ SQL_ADD_COLUMN_PERSISTENT);
- db.execSQL(SQL_ADD_COLUMN_PERSISTENT);
-
- // update timestamp & persistent
- String SQL_UPDATE_TABLE = "UPDATE "+TABLE_STORAGE+" SET "+ COLUMN_TIMESTAMP+" = '"+sDateFormatter.format(new Date())+"' , "+ COLUMN_PERSISTENT +" = 0";
- WXLogUtils.d(TAG_STORAGE,"exec sql : "+ SQL_UPDATE_TABLE);
- db.execSQL(SQL_UPDATE_TABLE);
-
- db.setTransactionSuccessful();
- long time = System.currentTimeMillis() - start;
- WXLogUtils.d(TAG_STORAGE,"storage updated success ("+time+"ms)");
- }catch (Exception e){
- WXLogUtils.d(TAG_STORAGE,"storage updated failed from version "+oldVersion+" to version "+newVersion+","+e.getMessage());
- updateResult = false;
- }finally {
- db.endTransaction();
- }
- //rollback
- if(!updateResult){
- WXLogUtils.d(TAG_STORAGE,"storage is rollback,all data will be removed");
- deleteDB();
- onCreate(db);
- }
- }else{
- deleteDB();
- onCreate(db);
- }
- }
- }
-
-
-
- synchronized void ensureDatabase() {
- if (mDb != null && mDb.isOpen()) {
- return;
- }
-
- try {
- // Sometimes retrieving the database fails. We do 2 retries: first without database deletion
- // and then with deletion.
- for (int tries = 0; tries < 2; tries++) {
- try {
- if (tries > 0) {
- //delete db and recreate
- deleteDB();
- }
- mDb = getWritableDatabase();
- break;
- } catch (SQLiteException e) {
- e.printStackTrace();
- }
- // Wait before retrying.
- try {
- Thread.sleep(SLEEP_TIME_MS);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- }
- }
- if(mDb == null){
- return;
- }
-
- createTableIfNotExists(mDb);
-
- mDb.setMaximumSize(mMaximumDatabaseSize);
- } catch (Throwable e) {
- mDb = null;
- WXLogUtils.d(TAG_STORAGE,"ensureDatabase failed, throwable = " + e.getMessage());
- }
-
- }
-
- public synchronized void setMaximumSize(long size) {
- mMaximumDatabaseSize = size;
- if (mDb != null) {
- mDb.setMaximumSize(mMaximumDatabaseSize);
- }
- }
-
- private boolean deleteDB() {
- closeDatabase();
- return mContext.deleteDatabase(DATABASE_NAME);
- }
-
- public synchronized void closeDatabase() {
- if (mDb != null && mDb.isOpen()) {
- mDb.close();
- mDb = null;
- }
- }
-
- private void createTableIfNotExists(@NonNull SQLiteDatabase db) {
- Cursor cursor = null;
- try {
- cursor = db.rawQuery("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name = '"+TABLE_STORAGE+"'", null);
- if(cursor != null && cursor.getCount() > 0) {
- return;
- }
- db.execSQL(STATEMENT_CREATE_TABLE);
- }catch (Exception e){
- e.printStackTrace();
- }finally {
- if(cursor != null){
- cursor.close();
- }
- }
- }
-
-
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/WXStorageModule.java b/android/sdk/src/main/java/com/taobao/weex/appfram/storage/WXStorageModule.java
deleted file mode 100644
index b6d9534..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/storage/WXStorageModule.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.storage;
-
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-
-import com.taobao.weex.WXSDKEngine;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.annotation.JSMethod;
-
-import java.util.Map;
-
-public class WXStorageModule extends WXSDKEngine.DestroyableModule implements IWXStorage {
-
- IWXStorageAdapter mStorageAdapter;
-
- private IWXStorageAdapter ability() {
- if (mStorageAdapter != null) {
- return mStorageAdapter;
- }
- mStorageAdapter = WXSDKEngine.getIWXStorageAdapter();
- return mStorageAdapter;
- }
-
-
- @Override
- @JSMethod(uiThread = false)
- public void setItem(String key, String value, @Nullable final JSCallback callback) {
- if (TextUtils.isEmpty(key) || value == null) {
- StorageResultHandler.handleInvalidParam(callback);
- return;
- }
-
- IWXStorageAdapter adapter = ability();
- if (adapter == null) {
- StorageResultHandler.handleNoHandlerError(callback);
- return;
- }
- adapter.setItem(key, value, new IWXStorageAdapter.OnResultReceivedListener() {
- @Override
- public void onReceived(Map<String, Object> data) {
- if(callback != null){
- callback.invoke(data);
- }
- }
- });
-
-
- }
-
- @Override
- @JSMethod(uiThread = false)
- public void getItem(String key, @Nullable final JSCallback callback) {
- if (TextUtils.isEmpty(key)) {
- StorageResultHandler.handleInvalidParam(callback);
- return;
- }
-
- IWXStorageAdapter adapter = ability();
- if (adapter == null) {
- StorageResultHandler.handleNoHandlerError(callback);
- return;
- }
- adapter.getItem(key, new IWXStorageAdapter.OnResultReceivedListener() {
- @Override
- public void onReceived(Map<String, Object> data) {
- if(callback != null){
- callback.invoke(data);
- }
- }
- });
- }
-
- @Override
- @JSMethod(uiThread = false)
- public void removeItem(String key, @Nullable final JSCallback callback) {
- if (TextUtils.isEmpty(key)) {
- StorageResultHandler.handleInvalidParam(callback);
- return;
- }
-
- IWXStorageAdapter adapter = ability();
- if (adapter == null) {
- StorageResultHandler.handleNoHandlerError(callback);
- return;
- }
- adapter.removeItem(key, new IWXStorageAdapter.OnResultReceivedListener() {
- @Override
- public void onReceived(Map<String, Object> data) {
- if(callback != null){
- callback.invoke(data);
- }
- }
- });
- }
-
- @Override
- @JSMethod(uiThread = false)
- public void length(@Nullable final JSCallback callback) {
- IWXStorageAdapter adapter = ability();
- if (adapter == null) {
- StorageResultHandler.handleNoHandlerError(callback);
- return;
- }
- adapter.length(new IWXStorageAdapter.OnResultReceivedListener() {
- @Override
- public void onReceived(Map<String, Object> data) {
- if(callback != null){
- callback.invoke(data);
- }
- }
- });
- }
-
- @Override
- @JSMethod(uiThread = false)
- public void getAllKeys(@Nullable final JSCallback callback) {
- IWXStorageAdapter adapter = ability();
- if (adapter == null) {
- StorageResultHandler.handleNoHandlerError(callback);
- return;
- }
- adapter.getAllKeys(new IWXStorageAdapter.OnResultReceivedListener() {
- @Override
- public void onReceived(Map<String, Object> data) {
- if(callback != null){
- callback.invoke(data);
- }
- }
- });
- }
-
- @Override
- @JSMethod(uiThread = false)
- public void setItemPersistent(String key, String value, @Nullable final JSCallback callback) {
- if (TextUtils.isEmpty(key) || value == null) {
- StorageResultHandler.handleInvalidParam(callback);
- return;
- }
-
- IWXStorageAdapter adapter = ability();
- if (adapter == null) {
- StorageResultHandler.handleNoHandlerError(callback);
- return;
- }
- adapter.setItemPersistent(key, value, new IWXStorageAdapter.OnResultReceivedListener() {
- @Override
- public void onReceived(Map<String, Object> data) {
- if(callback != null){
- callback.invoke(data);
- }
- }
- });
- }
-
- @Override
- public void destroy() {
- IWXStorageAdapter adapter = ability();
- if (adapter != null) {
- adapter.close();
- }
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapter.java b/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapter.java
deleted file mode 100644
index aebd1b8..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.websocket;
-
-import android.support.annotation.Nullable;
-
-/**
- * Created by moxun on 16/12/27.
- */
-
-public interface IWebSocketAdapter {
-
- String HEADER_SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol";
-
- void connect(String url, @Nullable String protocol, EventListener listener);
-
- void send(String data);
-
- void close(int code, String reason);
-
- void destroy();
-
- interface EventListener {
- void onOpen();
-
- void onMessage(String data);
-
- void onClose(int code, String reason, boolean wasClean);
-
- void onError(String msg);
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapterFactory.java b/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapterFactory.java
deleted file mode 100644
index e2e21dd..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapterFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.websocket;
-
-/**
- * Created by moxun on 16/12/28.
- */
-
-public interface IWebSocketAdapterFactory {
- IWebSocketAdapter createWebSocketAdapter();
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/WebSocketCloseCodes.java b/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/WebSocketCloseCodes.java
deleted file mode 100644
index 6251399..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/WebSocketCloseCodes.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.websocket;
-
-/**
- * Created by moxun on 17/1/3.
- * @link {https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
- */
-
-public enum WebSocketCloseCodes {
- CLOSE_NORMAL(1000),
- CLOSE_GOING_AWAY(1001),
- CLOSE_PROTOCOL_ERROR(1002),
- CLOSE_UNSUPPORTED(1003),
- CLOSE_NO_STATUS(1005),
- CLOSE_ABNORMAL(1006),
- UNSUPPORTED_DATA(1007),
- POLICY_VIOLATION(1008),
- CLOSE_TOO_LARGE(1009),
- MISSING_EXTENSION(1010),
- INTERNAL_ERROR(1011),
- SERVICE_RESTART(1012),
- TRY_AGAIN_LATER(1013),
- TLS_HANDSHAKE(1015);
-
- private int code;
-
- WebSocketCloseCodes(int code) {
- this.code = code;
- }
-
- public int getCode() {
- return code;
- }
-}
diff --git a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/WebSocketModule.java b/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/WebSocketModule.java
deleted file mode 100644
index f05f560..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/appfram/websocket/WebSocketModule.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.taobao.weex.appfram.websocket;
-
-import android.os.Looper;
-
-import com.taobao.weex.WXSDKEngine;
-import com.taobao.weex.annotation.JSMethod;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.bridge.WXBridgeManager;
-import com.taobao.weex.utils.WXLogUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by moxun on 16/12/27.
- */
-
-public class WebSocketModule extends WXSDKEngine.DestroyableModule {
-
- private static final String TAG = "WebSocketModule";
- private static final String KEY_DATA = "data";
- private static final String KEY_CODE = "code";
- private static final String KEY_REASON = "reason";
- private static final String KEY_WAS_CLEAN = "wasClean";
-
- private IWebSocketAdapter webSocketAdapter;
- private WebSocketEventListener eventListener;
-
- public WebSocketModule() {
- WXLogUtils.e(TAG, "create new instance");
- }
-
- @JSMethod(uiThread = false)
- public void WebSocket(String url, String protocol) {
- if (webSocketAdapter != null) {
- WXLogUtils.w(TAG, "close");
- webSocketAdapter.close(WebSocketCloseCodes.CLOSE_GOING_AWAY.getCode(), WebSocketCloseCodes.CLOSE_GOING_AWAY.name());
- }
- webSocketAdapter = mWXSDKInstance.getWXWebSocketAdapter();
- if (!reportErrorIfNoAdapter()) {
- eventListener = new WebSocketEventListener();
- webSocketAdapter.connect(url, protocol, eventListener);
- }
- }
-
- @JSMethod(uiThread = false)
- public void send(String data) {
- if (!reportErrorIfNoAdapter()) {
- webSocketAdapter.send(data);
- }
- }
-
- @JSMethod(uiThread = false)
- public void close(String code, String reason) {
- if (!reportErrorIfNoAdapter()) {
- int codeNumber = WebSocketCloseCodes.CLOSE_NORMAL.getCode();
- if (code != null) {
- try {
- codeNumber = Integer.parseInt(code);
- } catch (NumberFormatException e) {
- //ignore
- }
- }
- webSocketAdapter.close(codeNumber, reason);
- }
- }
-
- @JSMethod(uiThread = false)
- public void onopen(JSCallback callback) {
- if (eventListener != null) {
- eventListener.onOpen = callback;
- }
- }
-
- @JSMethod(uiThread = false)
- public void onmessage(JSCallback callback) {
- if (eventListener != null) {
- eventListener.onMessage = callback;
- }
- }
-
- @JSMethod(uiThread = false)
- public void onclose(JSCallback callback) {
- if (eventListener != null) {
- eventListener.onClose = callback;
- }
- }
-
- @JSMethod(uiThread = false)
- public void onerror(JSCallback callback) {
- if (eventListener != null) {
- eventListener.onError = callback;
- }
- }
-
- @Override
- public void destroy() {
- Runnable destroyTask = new Runnable() {
- @Override
- public void run() {
- WXLogUtils.w(TAG, "close session with instance id " + mWXSDKInstance.getInstanceId());
- if (webSocketAdapter != null) {
- webSocketAdapter.destroy();
- }
- webSocketAdapter = null;
- eventListener = null;
- }
- };
-
- if (Looper.myLooper() == Looper.getMainLooper()) {
- WXBridgeManager.getInstance().post(destroyTask);
- } else {
- destroyTask.run();
- }
- }
-
- private boolean reportErrorIfNoAdapter() {
- if (webSocketAdapter == null) {
- if (eventListener != null) {
- eventListener.onError("No implementation found for IWebSocketAdapter");
- }
- WXLogUtils.e(TAG, "No implementation found for IWebSocketAdapter");
- return true;
- }
- return false;
- }
-
- private class WebSocketEventListener implements IWebSocketAdapter.EventListener {
- private JSCallback onOpen;
... 147304 lines suppressed ...