├── _config.yml ├── .gitattributes ├── XulDemo ├── assets │ ├── gif │ │ ├── 1.gif │ │ ├── 10.gif │ │ ├── 11.gif │ │ ├── 12.gif │ │ ├── 13.gif │ │ ├── 14.gif │ │ ├── 15.gif │ │ ├── 16.gif │ │ ├── 17.gif │ │ ├── 18.gif │ │ ├── 19.gif │ │ ├── 2.gif │ │ ├── 20.gif │ │ ├── 21.gif │ │ ├── 3.gif │ │ ├── 30.gif │ │ ├── 4.gif │ │ ├── 5.gif │ │ ├── 6.gif │ │ ├── 7.gif │ │ ├── 8.gif │ │ ├── 9.gif │ │ └── gun.gif │ ├── films │ │ ├── 14.jpg │ │ └── 15.jpg │ ├── png │ │ ├── dongman.png │ │ ├── about_logo.png │ │ └── selector_slider_mask.png │ ├── fonts │ │ └── scyahei.ttf │ ├── star │ │ ├── star-a1.png │ │ ├── star-a2.png │ │ └── star-a3.png │ ├── animation │ │ ├── icon.ani.zip │ │ └── float.ani.zip │ ├── detail_page_a │ │ ├── bkg.jpg │ │ ├── poster.png │ │ └── full_screen_mask.png │ ├── indicator │ │ ├── up-arrow.png │ │ ├── down-arrow.png │ │ ├── left-arrow.png │ │ ├── right-arrow.png │ │ └── indicator-focused.png │ ├── jpg │ │ └── store_entrance.jpg │ ├── nine-patch │ │ ├── mask.9.png │ │ └── combo-edit-active.9.png │ ├── common │ │ ├── mirror-mask.9.png │ │ └── icon-btn-focus.9.png │ ├── poster │ │ ├── poster_bkg.9.png │ │ ├── poster_icon_large.png │ │ └── poster_icon_small.png │ ├── provinces │ │ ├── cities_data_0.xml │ │ ├── cities_data_2.xml │ │ ├── cities_data_3.xml │ │ ├── cities_data_1.xml │ │ └── provinces_data.xml │ ├── xul_massive_ltr_demo.xml │ └── xul_max_min_width_height_demo.xml ├── libs │ ├── x86 │ │ ├── libstarcor_xul.so │ │ └── libstarcor_xul-v8.so │ └── armeabi │ │ ├── libstarcor_xul.so │ │ └── libstarcor_xul-v8.so ├── res │ ├── drawable-hdpi │ │ ├── hexagon.png │ │ ├── ic_launcher.png │ │ └── parallelogram.png │ ├── values │ │ └── strings.xml │ └── layout │ │ └── main.xml ├── src │ └── com │ │ └── starcor │ │ └── xuldemo │ │ ├── XulDemoEnv.java │ │ ├── activities │ │ ├── CommonPageActivity.java │ │ └── MainActivity.java │ │ ├── behavior │ │ ├── XABCustomViewDemo.java │ │ ├── XABBindingDemo.java │ │ ├── XABMassiveDemo.java │ │ ├── XABSelectorSliderDemo.java │ │ └── XulActivityBehavior.java │ │ └── utils │ │ └── log │ │ └── LogFilter.java └── AndroidManifest.xml ├── xul ├── doc │ └── XML UI Language.docx ├── ext_so │ ├── x86 │ │ ├── libstarcor_xul.so │ │ └── libstarcor_xul-v8.so │ └── armeabi │ │ ├── libstarcor_xul.so │ │ └── libstarcor_xul-v8.so ├── src │ └── com │ │ ├── starcor │ │ └── xul │ │ │ ├── XulDataNode.aidl │ │ │ ├── Script │ │ │ ├── IScriptableObject.java │ │ │ ├── IScriptFinalize.java │ │ │ ├── IScriptMap.java │ │ │ ├── IScriptRunnable.java │ │ │ ├── IScriptableClass.java │ │ │ ├── IScript.java │ │ │ ├── V8 │ │ │ │ ├── V8MethodCallback.java │ │ │ │ ├── V8Script.java │ │ │ │ └── V8ScriptFunction.java │ │ │ ├── IScriptContext.java │ │ │ ├── XulScriptableObject.java │ │ │ ├── IScriptArray.java │ │ │ ├── IScriptArguments.java │ │ │ ├── XulScriptableClass.java │ │ │ ├── XulScriptFactory.java │ │ │ └── XulScriptFinalizeCollector.java │ │ │ ├── PropMap │ │ │ ├── IXulPropIterator.java │ │ │ └── IXulPropChain.java │ │ │ ├── Render │ │ │ ├── Drawer │ │ │ │ ├── IXulAnimation.java │ │ │ │ ├── XulDrawer.java │ │ │ │ ├── XulBitmapDrawer.java │ │ │ │ └── XulAnimationDrawer.java │ │ │ ├── Transform │ │ │ │ ├── Algorithm │ │ │ │ │ ├── LinearTransform.java │ │ │ │ │ ├── PowTransform.java │ │ │ │ │ ├── ITransformAlgorithm.java │ │ │ │ │ ├── SinTransform.java │ │ │ │ │ ├── BouncingBackTransform.java │ │ │ │ │ ├── BouncingTransform.java │ │ │ │ │ ├── ShakingTransform.java │ │ │ │ │ ├── BasicTransformAlgorithmImpl.java │ │ │ │ │ └── ConstantTransform.java │ │ │ │ └── ITransformer.java │ │ │ ├── XulItemRender.java │ │ │ ├── Components │ │ │ │ └── BaseScrollBar.java │ │ │ ├── Effect │ │ │ │ ├── FlipAnimation.java │ │ │ │ ├── CompositeAnimation.java │ │ │ │ └── QuiverAnimation.java │ │ │ ├── XulAreaRender.java │ │ │ └── Text │ │ │ │ └── XulTextRenderer.java │ │ │ ├── Events │ │ │ ├── XulActionEvent.java │ │ │ └── XulStateChangeEvent.java │ │ │ ├── Utils │ │ │ ├── XulRenderDrawableItem.java │ │ │ ├── XulSimpleStack.java │ │ │ ├── XulAreaChildrenCollectorAllFocusable.java │ │ │ ├── XulIntArray.java │ │ │ ├── XulAreaChildrenVisibleChangeNotifier.java │ │ │ ├── XulAreaChildrenRender.java │ │ │ └── XulAreaChildrenCollectorByClass.java │ │ │ ├── XulElement.java │ │ │ ├── ScriptWrappr │ │ │ ├── XulItemScriptableObject.java │ │ │ ├── Annotation │ │ │ │ ├── ScriptGetter.java │ │ │ │ ├── ScriptMethod.java │ │ │ │ └── ScriptSetter.java │ │ │ └── XulLayerScriptableObject.java │ │ │ ├── Graphics │ │ │ ├── IXulDrawable.java │ │ │ ├── XulAndroidDrawable.java │ │ │ ├── XulBitmapDrawable.java │ │ │ ├── XulCommonDrawable.java │ │ │ └── XulDrawable.java │ │ │ ├── Factory │ │ │ ├── XulParserData.java │ │ │ ├── XulParserCachedTag.java │ │ │ └── XulParserDataStoreSupported.java │ │ │ ├── IXulExternalView.java │ │ │ ├── Wrapper │ │ │ ├── XulLabelItemWrapper.java │ │ │ ├── XulLayerAreaWrapper.java │ │ │ ├── XulViewWrapper.java │ │ │ ├── XulGroupAreaWrapper.java │ │ │ └── XulImageItemWrapper.java │ │ │ ├── XulQueryableData.java │ │ │ ├── XulPendingInputStream.java │ │ │ ├── Prop │ │ │ └── XulProp.java │ │ │ └── XulSuspendTaskCollector.java │ │ └── caverock │ │ └── androidsvg │ │ ├── LibConfig.java │ │ ├── SVGParseException.java │ │ └── SVGExternalFileResolver.java ├── AndroidManifest.xml ├── project.properties ├── ant.properties └── proguard-project.txt ├── XulApp ├── src │ └── com │ │ └── starcor │ │ └── xulapp │ │ ├── model │ │ ├── XulClauseInfo.aidl │ │ ├── XulDataException.java │ │ ├── XulDataServiceImpl.java │ │ ├── XulPendingDataCallback.java │ │ ├── XulDataOperation.java │ │ ├── IXulRemoteDataCallback.aidl │ │ ├── utils │ │ │ ├── XulPullCollectionException.java │ │ │ └── XulHttpDataOperation.java │ │ ├── IXulRemoteDataOperation.aidl │ │ ├── IXulRemoteDataService.aidl │ │ ├── XulDataCallback.java │ │ ├── XulPullDataCollection.java │ │ ├── XulDataProvider.java │ │ └── XulStickyDataCallback.java │ │ ├── utils │ │ ├── XulCancelable.java │ │ ├── XulExecutable.java │ │ ├── CancellableRunnable.java │ │ ├── SystemUiHiderBase.java │ │ ├── XulBitmapUtil.java │ │ └── XulTime.java │ │ ├── plugin │ │ └── XulPlugin.java │ │ ├── message │ │ ├── seqmessage │ │ │ ├── XulSeqMessageHandler.java │ │ │ ├── XulSeqMsgDataWrapper.java │ │ │ ├── XulSeqMsgData.java │ │ │ └── XulSeqMsgDataDispatcher.java │ │ ├── matchpolicy │ │ │ ├── XulMatchPolicy.java │ │ │ ├── XulStrictMatchPolicy.java │ │ │ └── XulDefaultMatchPolicy.java │ │ ├── XulThreadMode.java │ │ ├── handler │ │ │ ├── XulMessageHandler.java │ │ │ ├── XulDefaultMessageHandler.java │ │ │ ├── XulUiThreadMessageHandler.java │ │ │ └── XulAsyncMessageHandler.java │ │ ├── XulSubscriber.java │ │ └── XulCommonMsgData.java │ │ ├── behavior │ │ ├── XulAppBehavior.java │ │ ├── XulBehavior.java │ │ ├── utils │ │ │ ├── IBehaviorOperation.java │ │ │ └── IBehaviorContact.java │ │ ├── XulLogicBehavior.java │ │ └── XulBehaviorManager.java │ │ ├── service │ │ ├── XulService.java │ │ ├── XulServiceManager.java │ │ └── XulServiceHost.java │ │ ├── debug │ │ ├── IXulDebugCommandHandler.java │ │ └── IXulDebuggableObject.java │ │ ├── cache │ │ ├── cachedomain │ │ │ ├── XulMemoryCacheDomain.java │ │ │ ├── XulFileCacheDomain.java │ │ │ └── XulPropertyCacheDomain.java │ │ ├── cacherecycle │ │ │ ├── XulNoRecycleStrategy.java │ │ │ ├── XulRecycleStrategy.java │ │ │ ├── XulRecentlyUnusedStrategy.java │ │ │ ├── XulExpireStrategy.java │ │ │ └── XulCacheRecycle.java │ │ ├── cacheimplement │ │ │ └── XulMemoryCache.java │ │ └── XulCacheModel.java │ │ ├── http │ │ ├── XulHttpResponse.java │ │ ├── XulHttpFilter.java │ │ └── XulHttpStatisticFilter.java │ │ └── XulPresenter.java ├── AndroidManifest.xml ├── project.properties ├── ant.properties └── proguard-project.txt ├── README.md └── .gitignore /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /XulDemo/assets/gif/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/1.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/10.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/11.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/12.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/13.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/14.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/15.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/16.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/17.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/18.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/19.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/2.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/20.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/21.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/3.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/30.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/4.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/5.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/6.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/7.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/8.gif -------------------------------------------------------------------------------- /XulDemo/assets/gif/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/9.gif -------------------------------------------------------------------------------- /XulDemo/assets/films/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/films/14.jpg -------------------------------------------------------------------------------- /XulDemo/assets/films/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/films/15.jpg -------------------------------------------------------------------------------- /XulDemo/assets/gif/gun.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/gif/gun.gif -------------------------------------------------------------------------------- /XulDemo/assets/png/dongman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/png/dongman.png -------------------------------------------------------------------------------- /xul/doc/XML UI Language.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/xul/doc/XML UI Language.docx -------------------------------------------------------------------------------- /XulDemo/assets/fonts/scyahei.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/fonts/scyahei.ttf -------------------------------------------------------------------------------- /XulDemo/assets/star/star-a1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/star/star-a1.png -------------------------------------------------------------------------------- /XulDemo/assets/star/star-a2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/star/star-a2.png -------------------------------------------------------------------------------- /XulDemo/assets/star/star-a3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/star/star-a3.png -------------------------------------------------------------------------------- /xul/ext_so/x86/libstarcor_xul.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/xul/ext_so/x86/libstarcor_xul.so -------------------------------------------------------------------------------- /XulDemo/assets/png/about_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/png/about_logo.png -------------------------------------------------------------------------------- /XulDemo/libs/x86/libstarcor_xul.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/libs/x86/libstarcor_xul.so -------------------------------------------------------------------------------- /xul/ext_so/x86/libstarcor_xul-v8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/xul/ext_so/x86/libstarcor_xul-v8.so -------------------------------------------------------------------------------- /XulDemo/assets/animation/icon.ani.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/animation/icon.ani.zip -------------------------------------------------------------------------------- /XulDemo/assets/detail_page_a/bkg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/detail_page_a/bkg.jpg -------------------------------------------------------------------------------- /XulDemo/assets/indicator/up-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/indicator/up-arrow.png -------------------------------------------------------------------------------- /XulDemo/assets/jpg/store_entrance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/jpg/store_entrance.jpg -------------------------------------------------------------------------------- /XulDemo/assets/nine-patch/mask.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/nine-patch/mask.9.png -------------------------------------------------------------------------------- /XulDemo/libs/x86/libstarcor_xul-v8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/libs/x86/libstarcor_xul-v8.so -------------------------------------------------------------------------------- /XulDemo/res/drawable-hdpi/hexagon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/res/drawable-hdpi/hexagon.png -------------------------------------------------------------------------------- /xul/ext_so/armeabi/libstarcor_xul.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/xul/ext_so/armeabi/libstarcor_xul.so -------------------------------------------------------------------------------- /XulDemo/assets/animation/float.ani.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/animation/float.ani.zip -------------------------------------------------------------------------------- /XulDemo/assets/common/mirror-mask.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/common/mirror-mask.9.png -------------------------------------------------------------------------------- /XulDemo/assets/detail_page_a/poster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/detail_page_a/poster.png -------------------------------------------------------------------------------- /XulDemo/assets/indicator/down-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/indicator/down-arrow.png -------------------------------------------------------------------------------- /XulDemo/assets/indicator/left-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/indicator/left-arrow.png -------------------------------------------------------------------------------- /XulDemo/assets/indicator/right-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/indicator/right-arrow.png -------------------------------------------------------------------------------- /XulDemo/assets/poster/poster_bkg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/poster/poster_bkg.9.png -------------------------------------------------------------------------------- /XulDemo/libs/armeabi/libstarcor_xul.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/libs/armeabi/libstarcor_xul.so -------------------------------------------------------------------------------- /xul/ext_so/armeabi/libstarcor_xul-v8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/xul/ext_so/armeabi/libstarcor_xul-v8.so -------------------------------------------------------------------------------- /XulDemo/assets/common/icon-btn-focus.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/common/icon-btn-focus.9.png -------------------------------------------------------------------------------- /XulDemo/libs/armeabi/libstarcor_xul-v8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/libs/armeabi/libstarcor_xul-v8.so -------------------------------------------------------------------------------- /XulDemo/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /XulDemo/assets/png/selector_slider_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/png/selector_slider_mask.png -------------------------------------------------------------------------------- /XulDemo/assets/poster/poster_icon_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/poster/poster_icon_large.png -------------------------------------------------------------------------------- /XulDemo/assets/poster/poster_icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/poster/poster_icon_small.png -------------------------------------------------------------------------------- /XulDemo/res/drawable-hdpi/parallelogram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/res/drawable-hdpi/parallelogram.png -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/XulDataNode.aidl: -------------------------------------------------------------------------------- 1 | package com.starcor.xul; 2 | 3 | /** 4 | * Created by hy on 2014/7/7. 5 | */ 6 | parcelable XulDataNode; 7 | -------------------------------------------------------------------------------- /XulDemo/assets/indicator/indicator-focused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/indicator/indicator-focused.png -------------------------------------------------------------------------------- /XulDemo/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | XulDemo 4 | 5 | -------------------------------------------------------------------------------- /XulDemo/assets/detail_page_a/full_screen_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/detail_page_a/full_screen_mask.png -------------------------------------------------------------------------------- /XulDemo/assets/nine-patch/combo-edit-active.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/starcor-company/starcor.xul/HEAD/XulDemo/assets/nine-patch/combo-edit-active.9.png -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulClauseInfo.aidl: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2016/11/15. 5 | */ 6 | parcelable XulClauseInfo; -------------------------------------------------------------------------------- /XulDemo/assets/provinces/cities_data_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/utils/XulCancelable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.utils; 2 | 3 | /** 4 | * Created by hy on 2016/9/19. 5 | */ 6 | public interface XulCancelable { 7 | void cancel(); 8 | } 9 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/plugin/XulPlugin.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.plugin; 2 | 3 | /** 4 | * Created by hy on 2016/5/12. 5 | */ 6 | public abstract class XulPlugin { 7 | public abstract String getName(); 8 | } 9 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptableObject.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by hy on 2014/6/25. 5 | */ 6 | public interface IScriptableObject { 7 | XulScriptableObject getObjectValue(); 8 | } 9 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/PropMap/IXulPropIterator.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.PropMap; 2 | 3 | import com.starcor.xul.Prop.XulProp; 4 | 5 | public interface IXulPropIterator { 6 | void onProp(T prop, int state); 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # starcor.xul 2 | 3 | 20181127
4 |
  • 1.xulApp freamwork has support lottie, please add lottie's jar in your project.

  • 5 |

        more details:https://github.com/airbnb/lottie-android

    6 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptFinalize.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by skycnlr on 2018/6/6. 5 | */ 6 | public interface IScriptFinalize { 7 | void doFinalize(); 8 | void markGC(); 9 | } 10 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptMap.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by hy on 2014/6/26. 5 | */ 6 | public interface IScriptMap { 7 | Object mapGet(String name); 8 | void mapPut(String name, Object val); 9 | } 10 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptRunnable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by hy on 2014/6/25. 5 | */ 6 | public interface IScriptRunnable { 7 | Object run(IScriptContext ctx, IScriptableObject ctxObj, Object[] params); 8 | } 9 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/PropMap/IXulPropChain.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.PropMap; 2 | 3 | /** 4 | * Created by hy on 2014/5/5. 5 | */ 6 | interface IXulPropChain { 7 | T getVal(int key, int state); 8 | T getValEx(int key, int state, int state2); 9 | } 10 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptableClass.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by hy on 2014/6/25. 5 | */ 6 | public interface IScriptableClass { 7 | String getClassName(); 8 | String[] getProperties(); 9 | String[] getMethods(); 10 | } 11 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Drawer/IXulAnimation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Drawer; 2 | 3 | /** 4 | * Created by hy on 2014/11/12. 5 | */ 6 | public interface IXulAnimation { 7 | // 返回false表示动画已经结束,不用理处理更新动作 8 | boolean updateAnimation(long timestamp); 9 | } 10 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/seqmessage/XulSeqMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.seqmessage; 2 | 3 | /** 4 | * Created by ZFB on 2015/12/8 0008. 5 | */ 6 | public interface XulSeqMessageHandler { 7 | 8 | void handleSeqMessage(XulSeqMsgData seqMsg); 9 | } 10 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/utils/XulExecutable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.utils; 2 | 3 | import com.starcor.xulapp.model.XulDataService; 4 | 5 | /** 6 | * Created by hy on 2015/9/25. 7 | */ 8 | public interface XulExecutable { 9 | boolean exec(XulDataService.Clause clause); 10 | } 11 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulDataException.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2015/9/25. 5 | */ 6 | public class XulDataException extends Exception { 7 | public XulDataException(String detailMessage) { 8 | super(detailMessage); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/behavior/XulAppBehavior.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.behavior; 2 | 3 | /** 4 | * Created by hy on 2015/9/7. 5 | */ 6 | public class XulAppBehavior implements XulBehavior { 7 | @Override 8 | public int getBehaviorType() { 9 | return BEHAVIOR_TYPE_APP; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /xul/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulDataServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | import com.starcor.xulapp.service.XulService; 4 | 5 | /** 6 | * Created by hy on 2015/9/7. 7 | */ 8 | public class XulDataServiceImpl extends XulService { 9 | public static void register() { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/service/XulService.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.service; 2 | 3 | import android.content.Intent; 4 | import android.os.IBinder; 5 | 6 | /** 7 | * Created by hy on 2015/9/7. 8 | */ 9 | public class XulService { 10 | public IBinder onBind(Intent intent) { 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/matchpolicy/XulMatchPolicy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.matchpolicy; 2 | 3 | 4 | import com.starcor.xulapp.message.XulMessage; 5 | 6 | import java.util.List; 7 | 8 | public interface XulMatchPolicy { 9 | 10 | List findMatchMessageTypes(XulMessage message); 11 | } 12 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/service/XulServiceManager.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.service; 2 | 3 | /** 4 | * Created by hy on 2015/9/7. 5 | */ 6 | public class XulServiceManager { 7 | 8 | public static void initServiceManager() { 9 | 10 | } 11 | 12 | public static void shutdownServiceManager() { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/behavior/XulBehavior.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.behavior; 2 | 3 | /** 4 | * Created by hy on 2015/9/7. 5 | */ 6 | public interface XulBehavior { 7 | int BEHAVIOR_TYPE_UI = 0x0001; 8 | int BEHAVIOR_TYPE_APP = 0x0002; 9 | int BEHAVIOR_TYPE_LOGIC = 0x0002; 10 | 11 | int getBehaviorType(); 12 | } 13 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScript.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by hy on 2014/6/25. 5 | */ 6 | public interface IScript { 7 | String getScriptType(); 8 | Object run(IScriptContext ctx, IScriptableObject ctxObj); 9 | Object run(IScriptContext ctx, IScriptableObject ctxObj, Object[] args); 10 | } 11 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulPendingDataCallback.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2015/9/25. 5 | */ 6 | class XulPendingDataCallback extends XulDataCallback { 7 | 8 | public boolean scheduleExec(XulDataOperation operation, XulDataCallback dataCallback) { 9 | return false; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Events/XulActionEvent.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Events; 2 | 3 | import com.starcor.xul.XulView; 4 | 5 | /** 6 | * Created by hy on 2014/5/31. 7 | */ 8 | public class XulActionEvent { 9 | public String action; 10 | public XulView eventSource; 11 | public XulView notifySource; 12 | public boolean noPopup; 13 | } 14 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/XulThreadMode.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message; 2 | 3 | /** 4 | * 消息发布的线程模式枚举 5 | */ 6 | public enum XulThreadMode { 7 | /** 8 | * 在UI线程执行 9 | */ 10 | MAIN, 11 | /** 12 | * 在发布线程执行 13 | */ 14 | POST, 15 | /** 16 | * 在一个子线程中执行 17 | */ 18 | ASYNC 19 | } 20 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulDataOperation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2015/9/25. 5 | */ 6 | public class XulDataOperation { 7 | public boolean exec(XulDataCallback callback) throws XulDataException { 8 | return false; 9 | } 10 | 11 | public boolean cancel() { 12 | return false; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulRenderDrawableItem.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | import com.starcor.xul.Graphics.XulDrawable; 4 | import com.starcor.xul.XulWorker; 5 | 6 | /** 7 | * Created by hy on 2014/5/13. 8 | */ 9 | public class XulRenderDrawableItem extends XulWorker.DrawableItem { 10 | public void onImageReady(XulDrawable bmp) {} 11 | } 12 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/XulElement.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul; 2 | 3 | /** 4 | * Created by hy on 2015/6/8. 5 | */ 6 | public abstract class XulElement { 7 | public static final int VIEW_TYPE = 1; 8 | public static final int TEMPLATE_TYPE = 2; 9 | 10 | public final int elementType; 11 | 12 | public XulElement(int t) { 13 | this.elementType = t; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /XulDemo/assets/provinces/cities_data_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /XulDemo/assets/provinces/cities_data_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/ScriptWrappr/XulItemScriptableObject.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.ScriptWrappr; 2 | 3 | import com.starcor.xul.XulItem; 4 | 5 | /** 6 | * Created by hy on 2014/6/25. 7 | */ 8 | public class XulItemScriptableObject extends XulViewScriptableObject { 9 | 10 | public XulItemScriptableObject(XulItem item) { 11 | super(item); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/service/XulServiceHost.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.service; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | 7 | /** 8 | * Created by hy on 2015/8/24. 9 | */ 10 | public class XulServiceHost extends Service { 11 | @Override 12 | public IBinder onBind(Intent intent) { 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Graphics/IXulDrawable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Graphics; 2 | 3 | import android.graphics.Rect; 4 | import android.graphics.RectF; 5 | 6 | /** 7 | * Created by hy on 2014/6/4. 8 | */ 9 | public interface IXulDrawable { 10 | boolean draw(XulDC dc, Rect updateRc, int xBase, int yBase); 11 | boolean draw(XulDC dc, RectF updateRc, float xBase, float yBase); 12 | } 13 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Factory/XulParserData.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Factory; 2 | 3 | /** 4 | * Created by hy on 2015/4/28. 5 | */ 6 | public abstract class XulParserData { 7 | public static final int ITEM_TAG_BEGIN = 0; 8 | public static final int ITEM_TEXT = 1; 9 | public static final int ITEM_TAG_END = 2; 10 | 11 | public abstract void buildItem(XulFactory.ItemBuilder pageBuilder); 12 | } 13 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/handler/XulMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.handler; 2 | 3 | 4 | import com.starcor.xulapp.message.XulSubscription; 5 | 6 | /** 7 | * 消息处理接口 8 | */ 9 | public interface XulMessageHandler { 10 | 11 | /** 12 | * 处理消息 13 | * 14 | * @param subscription 订阅对象 15 | */ 16 | void handleMessage(XulSubscription subscription); 17 | } 18 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/debug/IXulDebugCommandHandler.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.debug; 2 | 3 | import com.starcor.xulapp.http.XulHttpServer; 4 | 5 | /** 6 | * Created by hy on 2015/12/3. 7 | */ 8 | public interface IXulDebugCommandHandler { 9 | XulHttpServer.XulHttpServerResponse execCommand(String url, XulHttpServer.XulHttpServerHandler serverHandler, XulHttpServer.XulHttpServerRequest request); 10 | } 11 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cachedomain/XulMemoryCacheDomain.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cachedomain; 2 | 3 | import com.starcor.xulapp.cache.cacheimplement.XulMemoryCache; 4 | 5 | /** 6 | * Created by ZFB on 2015/9/29. 7 | */ 8 | public class XulMemoryCacheDomain extends XulMemoryCache { 9 | 10 | public XulMemoryCacheDomain(long maxSize, int maxCount) { 11 | super(maxSize, maxCount); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/http/XulHttpResponse.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.http; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by hy on 2015/11/6. 9 | */ 10 | public class XulHttpResponse { 11 | public int code; 12 | public String message; 13 | public InputStream data; 14 | public Map> headers; 15 | public XulHttpRequest request; 16 | } 17 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/http/XulHttpFilter.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.http; 2 | 3 | /** 4 | * Created by hy on 2015/11/6. 5 | */ 6 | public abstract class XulHttpFilter { 7 | 8 | public abstract String name(); 9 | 10 | public int doRequest(XulHttpStack.XulHttpCtx ctx, XulHttpRequest request) { 11 | return 0; 12 | } 13 | 14 | public int handleResponse(XulHttpStack.XulHttpCtx ctx, XulHttpResponse response) { 15 | return 0; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /XulApp/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cachedomain/XulFileCacheDomain.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cachedomain; 2 | 3 | import com.starcor.xulapp.cache.cacheimplement.XulFileCache; 4 | 5 | import java.io.File; 6 | 7 | /** 8 | * Created by ZFB on 2015/9/29. 9 | */ 10 | public class XulFileCacheDomain extends XulFileCache { 11 | 12 | public XulFileCacheDomain(File cacheDir, long maxSize, int maxCount) { 13 | super(cacheDir, maxSize, maxCount); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cacherecycle/XulNoRecycleStrategy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cacherecycle; 2 | 3 | import com.starcor.xulapp.cache.XulCacheModel; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | * Created by ZFB on 2015/10/23. 9 | */ 10 | class XulNoRecycleStrategy implements XulRecycleStrategy { 11 | 12 | @Override 13 | public XulCacheModel findRecycledCache(Collection caches) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/ScriptWrappr/Annotation/ScriptGetter.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.ScriptWrappr.Annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by hy on 2014/6/26. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.METHOD) 13 | public @interface ScriptGetter { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/ScriptWrappr/Annotation/ScriptMethod.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.ScriptWrappr.Annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by hy on 2014/6/26. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.METHOD) 13 | public @interface ScriptMethod { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/ScriptWrappr/Annotation/ScriptSetter.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.ScriptWrappr.Annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by hy on 2014/6/26. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.METHOD) 13 | public @interface ScriptSetter { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/behavior/utils/IBehaviorOperation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.behavior.utils; 2 | 3 | import android.graphics.Rect; 4 | 5 | /** 6 | * Created by skycnlr on 2018/9/6. 7 | */ 8 | public interface IBehaviorOperation { 9 | boolean close(); 10 | boolean show(); 11 | boolean hide(); 12 | boolean changeBounds(Rect rect) ; 13 | boolean enableKeyEvent(boolean enable); 14 | boolean setBackgroundColor(int color); 15 | Rect getBounds() ; 16 | } 17 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/V8/V8MethodCallback.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script.V8; 2 | 3 | /** 4 | * Created by hy on 2015/6/18. 5 | */ 6 | public abstract class V8MethodCallback { 7 | public boolean invoke(V8ScriptObject thisObject, V8Arguments args) { 8 | return false; 9 | } 10 | 11 | public boolean set(V8ScriptObject thisObject, V8Arguments args) { 12 | return false; 13 | } 14 | 15 | public boolean get(V8ScriptObject thisObject, V8Arguments args) { 16 | return false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/IXulRemoteDataCallback.aidl: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2016/11/15. 5 | */ 6 | 7 | import com.starcor.xul.XulDataNode; 8 | import com.starcor.xulapp.model.IXulRemoteDataOperation; 9 | 10 | interface IXulRemoteDataCallback { 11 | void setError(int error); 12 | void setErrorEx(int error, in String msg); 13 | void onResult(IXulRemoteDataOperation op, int code, in XulDataNode data); 14 | void onError(IXulRemoteDataOperation op, int code); 15 | } 16 | -------------------------------------------------------------------------------- /XulDemo/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cacherecycle/XulRecycleStrategy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cacherecycle; 2 | 3 | import com.starcor.xulapp.cache.XulCacheModel; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | * Created by ZFB on 2015/10/23. 9 | */ 10 | interface XulRecycleStrategy { 11 | 12 | /** 13 | * 根据特定的回收算法返回一个可回收的数据对象 14 | * 15 | * @param caches 缓存数据集合 16 | * @return 可回收对象,若未找到,则返回null 17 | */ 18 | XulCacheModel findRecycledCache(Collection caches); 19 | } 20 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/utils/CancellableRunnable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.utils; 2 | 3 | /** 4 | * Created by hy on 2016/1/26. 5 | */ 6 | public abstract class CancellableRunnable implements Runnable, XulCancelable { 7 | private volatile boolean _isCancelled = false; 8 | 9 | @Override 10 | public void cancel() { 11 | _isCancelled = true; 12 | } 13 | 14 | @Override 15 | public void run() { 16 | if (_isCancelled) { 17 | return; 18 | } 19 | doRun(); 20 | } 21 | 22 | protected abstract void doRun(); 23 | } 24 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/XulDemoEnv.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo; 2 | 3 | /** 4 | * Created by ZFB on 2015/7/12 0012. 5 | */ 6 | public class XulDemoEnv { 7 | 8 | public static final boolean DEBUGGABLE = true; 9 | 10 | public static final String XUL_VIEW_DEMO_FILE = "xul_view_demo.xml"; 11 | public static final String XUL_PAGE_DEMO_FILE = "xul_page_demo.xml"; 12 | public static final String XUL_ANIM_DEMO_FILE = "xul_animation_demo.xml"; 13 | public static final String XUL_FOCUS_DEMO_FILE = "xul_focus_demo.xml"; 14 | } 15 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/utils/XulPullCollectionException.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model.utils; 2 | 3 | /** 4 | * Created by hy on 2015/11/17. 5 | */ 6 | public class XulPullCollectionException extends Exception { 7 | int _code; 8 | public XulPullCollectionException(int code, String detailMessage) { 9 | super(detailMessage); 10 | _code = code; 11 | } 12 | 13 | public XulPullCollectionException(String detailMessage) { 14 | this(-1, detailMessage); 15 | } 16 | 17 | public int getCode() { 18 | return _code; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/behavior/utils/IBehaviorContact.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.behavior.utils; 2 | 3 | import android.content.Intent; 4 | import com.starcor.xulapp.behavior.XulUiBehavior; 5 | 6 | /** 7 | * Created by skycnlr on 2018/8/23. 8 | */ 9 | public interface IBehaviorContact { 10 | 11 | boolean xulOpenBehavior(Intent o) ; 12 | 13 | boolean xulCloseBehavior(String id) ; 14 | 15 | IBehaviorOperation getXulBehaviorOperation(XulUiBehavior behavior); 16 | 17 | IBehaviorOperation getXulBehaviorOperation(String id); 18 | } 19 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/IXulRemoteDataOperation.aidl: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | import com.starcor.xulapp.model.IXulRemoteDataCallback; 4 | 5 | /** 6 | * Created by hy on 2016/11/15. 7 | */ 8 | 9 | interface IXulRemoteDataOperation { 10 | boolean exec(IXulRemoteDataCallback callback); 11 | boolean cancel(); 12 | boolean pull(IXulRemoteDataCallback callback); 13 | boolean reset(); 14 | boolean resetEx(int pageIdx); 15 | int currentPage(); 16 | int pageSize(); 17 | boolean isFinished(); 18 | boolean isPullOperation(); 19 | } 20 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/IXulRemoteDataService.aidl: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2016/11/15. 5 | */ 6 | 7 | import com.starcor.xulapp.model.IXulRemoteDataCallback; 8 | import com.starcor.xulapp.model.IXulRemoteDataOperation; 9 | import com.starcor.xulapp.model.XulClauseInfo; 10 | 11 | interface IXulRemoteDataService { 12 | IXulRemoteDataService makeClone(); 13 | void cancelClause(); 14 | IXulRemoteDataOperation invokeRemoteService(in XulClauseInfo clauseInfo, in IXulRemoteDataCallback callback); 15 | } 16 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulDataCallback.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | import com.starcor.xul.XulDataNode; 4 | 5 | /** 6 | * Created by hy on 2015/9/25. 7 | */ 8 | public class XulDataCallback { 9 | 10 | public static XulDataCallback DUMMY_CALLBACK = new XulDataCallback(); 11 | 12 | public void onResult(XulDataService.Clause clause, int code, XulDataNode data) { 13 | } 14 | 15 | public void onError(XulDataService.Clause clause, int code) { 16 | } 17 | 18 | public Object getUserData() { 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/handler/XulDefaultMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.handler; 2 | 3 | 4 | import com.starcor.xulapp.message.XulSubscription; 5 | 6 | /** 7 | * 消息在哪个线程post,消息的接收就在哪个线程 8 | */ 9 | public class XulDefaultMessageHandler implements XulMessageHandler { 10 | 11 | /** 12 | * handle the message 13 | */ 14 | @Override 15 | public void handleMessage(XulSubscription subscription) { 16 | if (subscription != null) { 17 | subscription.handleMessage(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/matchpolicy/XulStrictMatchPolicy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.matchpolicy; 2 | 3 | 4 | import com.starcor.xulapp.message.XulMessage; 5 | 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | 9 | 10 | public class XulStrictMatchPolicy implements XulMatchPolicy { 11 | 12 | @Override 13 | public List findMatchMessageTypes(XulMessage message) { 14 | List result = new LinkedList(); 15 | result.add(message); 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/LinearTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class LinearTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "linear"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float percent = time / duration; 15 | if (percent >= 1.0f) { 16 | return -1000; 17 | } 18 | return percent; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/IXulExternalView.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul; 2 | 3 | import android.graphics.Rect; 4 | import android.view.KeyEvent; 5 | 6 | /** 7 | * Created by hy on 2014/5/27. 8 | */ 9 | public interface IXulExternalView { 10 | void extMoveTo(int x, int y, int width, int height); 11 | void extMoveTo(Rect rect); 12 | boolean extOnKeyEvent(KeyEvent event); 13 | void extOnFocus(); 14 | void extOnBlur(); 15 | void extShow(); 16 | void extHide(); 17 | void extDestroy(); 18 | String getAttr(String key, String defVal); 19 | boolean setAttr(String key, String val); 20 | void extSyncData(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Events/XulStateChangeEvent.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Events; 2 | 3 | import com.starcor.xul.XulView; 4 | 5 | /** 6 | * Created by hy on 2014/5/31. 7 | */ 8 | public class XulStateChangeEvent { 9 | public String event; 10 | public int oldState; 11 | public int state; 12 | public XulView eventSource; // 发生事件的view 13 | public XulView alteredEventSource; // 事件处理链变更后的目标view 14 | public XulView notifySource; // 本次通知的发送者view 15 | public boolean adjustFocusView = true; 16 | 17 | public XulView getEventSource() { 18 | return alteredEventSource == null ? eventSource : alteredEventSource; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/PowTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class PowTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "pow"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float percent = time / duration; 15 | if (percent >= 1.0f) { 16 | return -1000; 17 | } 18 | double factor = params[0] * 2.0; 19 | return (float) Math.pow(percent, factor); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Wrapper/XulLabelItemWrapper.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Wrapper; 2 | 3 | import com.starcor.xul.Render.XulLabelRender; 4 | import com.starcor.xul.XulView; 5 | 6 | /** 7 | * Created by hy on 2014/6/3. 8 | */ 9 | public class XulLabelItemWrapper extends XulViewWrapper { 10 | public static XulLabelItemWrapper fromXulView(XulView view) { 11 | if (view == null) { 12 | return null; 13 | } 14 | if (!(view.getRender() instanceof XulLabelRender)) { 15 | return null; 16 | } 17 | return new XulLabelItemWrapper(view); 18 | } 19 | 20 | XulLabelItemWrapper(XulView view) { 21 | super(view); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/ITransformAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public interface ITransformAlgorithm { 7 | class UpdateResult { 8 | public long newBegin; 9 | public float newSrc; 10 | public float newDest; 11 | } 12 | String name(); 13 | 14 | // returns -1 if terminated 15 | float transform(float[] params, float time, float duration, float fromVal, float toVal); 16 | UpdateResult update(float[] params, long begin, long duration, long progress, float curVal, float srcVal, float oldDestVal, float newDestVal); 17 | } 18 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulPullDataCollection.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2015/9/25. 5 | */ 6 | public class XulPullDataCollection extends XulDataOperation { 7 | 8 | public boolean pull(XulDataCallback dataCallback) { 9 | return false; 10 | } 11 | 12 | public boolean reset() { 13 | return false; 14 | } 15 | 16 | public boolean reset(int pageIdx) { 17 | return false; 18 | } 19 | 20 | public int currentPage() { 21 | return -1; 22 | } 23 | 24 | public int pageSize() { 25 | return 0; 26 | } 27 | 28 | public boolean isFinished() { 29 | return false; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /XulDemo/assets/provinces/cities_data_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /xul/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | android.library=true 14 | # Project target. 15 | target=android-15 16 | -------------------------------------------------------------------------------- /XulApp/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | android.library=true 14 | # Project target. 15 | target=android-21 16 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/ITransformer.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform; 2 | 3 | import com.starcor.xul.Render.Transform.Algorithm.ITransformAlgorithm; 4 | 5 | /** 6 | * Created by hy on 2015/5/26. 7 | */ 8 | public interface ITransformer { 9 | boolean switchAlgorithm(String algorithm); 10 | boolean switchParams(float[] params); 11 | float transform(float time, float duration, float fromVal, float toVal); 12 | // return new begin time 13 | ITransformAlgorithm.UpdateResult updateAnimation(long begin, long duration, long progress, float curVal, float srcVal, float oldDestVal, float newDestVal); 14 | 15 | boolean isEnd(); 16 | } 17 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/ScriptWrappr/XulLayerScriptableObject.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.ScriptWrappr; 2 | 3 | import com.starcor.xul.Wrapper.XulLayerAreaWrapper; 4 | import com.starcor.xul.XulArea; 5 | 6 | /** 7 | * Created by hy on 2014/6/27. 8 | */ 9 | public class XulLayerScriptableObject extends XulAreaScriptableObject { 10 | XulLayerAreaWrapper _wrapper; 11 | 12 | public XulLayerScriptableObject(XulArea item) { 13 | super(item); 14 | } 15 | 16 | private boolean _initWrapper() { 17 | if (_wrapper != null) { 18 | return true; 19 | } 20 | _wrapper = XulLayerAreaWrapper.fromXulView(_xulItem); 21 | return _wrapper != null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Wrapper/XulLayerAreaWrapper.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Wrapper; 2 | 3 | import com.starcor.xul.Render.XulLayerRender; 4 | import com.starcor.xul.XulArea; 5 | import com.starcor.xul.XulView; 6 | 7 | /** 8 | * Created by hy on 2014/6/3. 9 | */ 10 | public class XulLayerAreaWrapper extends XulViewWrapper { 11 | public static XulLayerAreaWrapper fromXulView(XulView view) { 12 | if (view == null) { 13 | return null; 14 | } 15 | if (!(view.getRender() instanceof XulLayerRender)) { 16 | return null; 17 | } 18 | return new XulLayerAreaWrapper((XulArea) view); 19 | } 20 | 21 | XulLayerAreaWrapper(XulArea view) { 22 | super(view); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/XulSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 消息接收函数的注解类,运用在函数上 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.METHOD) 13 | public @interface XulSubscriber { 14 | 15 | /** 16 | * 消息的tag,类似于BroadcastReceiver中的Action,消息的标识符 17 | */ 18 | int tag() default XulMessage.DEFAULT_TAG; 19 | 20 | /** 21 | * 消息执行的线程,默认为主线程 22 | */ 23 | XulThreadMode mode() default XulThreadMode.MAIN; 24 | } 25 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/behavior/XulLogicBehavior.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.behavior; 2 | 3 | /** 4 | * Created by hy on 2015/9/15. 5 | */ 6 | public class XulLogicBehavior implements XulBehavior { 7 | 8 | @Override 9 | public int getBehaviorType() { 10 | return XulBehavior.BEHAVIOR_TYPE_LOGIC; 11 | } 12 | 13 | public boolean exec(String command, String[] params) { 14 | return false; 15 | } 16 | 17 | // public boolean queryData( query_params, dataCallback ) {} 18 | // public boolean queryDataAsync( query_params, dataCallback ) {} 19 | // public PullDataCollection pullData( query_params ) {} 20 | 21 | public boolean registerEventListener() { 22 | return false; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/SinTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class SinTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "sin"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float percent = time / duration; 15 | if (percent >= 1.0f) { 16 | return -1000; 17 | } 18 | double slope = params[0]; 19 | double x = Math.pow(percent, 2.0 / slope); 20 | double PI = Math.PI; 21 | 22 | double y = (Math.sin((x - 0.5) * PI) + 1) / 2; 23 | return (float) y; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/debug/IXulDebuggableObject.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.debug; 2 | 3 | import com.starcor.xulapp.http.XulHttpServer; 4 | 5 | import org.xmlpull.v1.XmlSerializer; 6 | 7 | /** 8 | * Created by hy on 2015/12/3. 9 | */ 10 | public interface IXulDebuggableObject { 11 | String name(); 12 | 13 | boolean isValid(); 14 | 15 | boolean runInMainThread(); 16 | 17 | boolean buildBriefInfo(XulHttpServer.XulHttpServerRequest request, XmlSerializer infoWriter); 18 | 19 | boolean buildDetailInfo(XulHttpServer.XulHttpServerRequest request, XmlSerializer infoWriter); 20 | 21 | XulHttpServer.XulHttpServerResponse execCommand(String command, XulHttpServer.XulHttpServerRequest request, XulHttpServer.XulHttpServerHandler serverHandler); 22 | } 23 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/activities/CommonPageActivity.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.activities; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | /** 7 | * Created by ZFB on 2015/8/6 0006. 8 | */ 9 | public class CommonPageActivity extends XulDemoBaseActivity { 10 | 11 | @Override 12 | public void onCreate(Bundle savedInstanceState) { 13 | Intent intent = getIntent(); 14 | if (intent != null) { 15 | mPageId = intent.getStringExtra(EXTRA_XUL_PAGE_ID); 16 | mXulFileName = intent.getStringExtra(EXTRA_XUL_FILE_NAME); 17 | mXulPageBehavior = intent.getStringExtra(EXTRA_XUL_PAGE_BEHAVIOR); 18 | } 19 | super.onCreate(savedInstanceState); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xul/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/ 38 | 39 | # Keystore files 40 | *.jks 41 | 42 | # External native build folder generated in Android Studio 2.2 and later 43 | .externalNativeBuild 44 | .vs/ 45 | 46 | XulAppDemo/ 47 | -------------------------------------------------------------------------------- /XulApp/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | /** 4 | * Created by hy on 2015/9/25. 5 | */ 6 | public class XulDataProvider { 7 | 8 | final XulDataOperation dispatchClause(XulDataServiceContext ctx, XulClauseInfo clauseInfo) throws XulDataException { 9 | if ((clauseInfo.verb & XulDataService.XVERB_MODE_PULL) == XulDataService.XVERB_MODE_PULL) { 10 | return this.execPullClause(ctx, clauseInfo); 11 | } 12 | return this.execClause(ctx, clauseInfo); 13 | } 14 | 15 | public XulDataOperation execClause(XulDataServiceContext ctx, XulClauseInfo clauseInfo) throws XulDataException { 16 | return null; 17 | } 18 | 19 | public XulDataOperation execPullClause(XulDataServiceContext ctx, XulClauseInfo clauseInfo) throws XulDataException { 20 | return null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/seqmessage/XulSeqMsgDataWrapper.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.seqmessage; 2 | 3 | import com.starcor.xulapp.message.XulMessage; 4 | 5 | import java.util.concurrent.atomic.AtomicInteger; 6 | 7 | /** 8 | * Created by ZFB on 2015/12/8 0008. 9 | */ 10 | public class XulSeqMsgDataWrapper { 11 | 12 | private final int _messageId; 13 | private final AtomicInteger _seqId = new AtomicInteger(); 14 | 15 | public XulSeqMsgDataWrapper() { 16 | _messageId = XulMessage.obtainMessageId(); 17 | _seqId.set(0); 18 | } 19 | 20 | public XulSeqMsgData wrap() { 21 | return wrap(new Object()); 22 | } 23 | 24 | public XulSeqMsgData wrap(Object data) { 25 | return new XulSeqMsgData(_messageId, _seqId.getAndIncrement(), data); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulSimpleStack.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | /** 4 | * Created by hy on 2015/6/12. 5 | */ 6 | 7 | public class XulSimpleStack { 8 | Object[] _stack; 9 | int _maximumSize; 10 | int _num; 11 | 12 | public XulSimpleStack(int size) { 13 | this._stack = new Object[size]; 14 | _maximumSize = size; 15 | _num = 0; 16 | } 17 | 18 | public void push(T obj) { 19 | if (_num >= _maximumSize) { 20 | _maximumSize += 128; 21 | Object[] newStack = new Object[_maximumSize]; 22 | System.arraycopy(_stack, 0, newStack, 0, _num); 23 | _stack = newStack; 24 | } 25 | 26 | _stack[_num] = obj; 27 | ++_num; 28 | } 29 | 30 | public T pop() { 31 | if (_num <= 0) { 32 | return null; 33 | } 34 | --_num; 35 | Object obj = _stack[_num]; 36 | _stack[_num] = null; 37 | return (T) obj; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /xul/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /XulApp/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/BouncingBackTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class BouncingBackTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "bouncing-back"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float percent = time / duration; 15 | if (percent >= 1.0f) { 16 | return -1000; 17 | } 18 | double slope = params[0]; 19 | double d2 = params[1]; 20 | double strength = params[2]; 21 | double x = Math.pow(percent, 2.0 / slope); 22 | double PI = Math.PI; 23 | 24 | double y = (Math.sin((x - 0.5) * PI) + 1) / 2; 25 | y += Math.sin(Math.pow(percent, 10 / d2) * PI) * strength * 0.5; 26 | return (float) y; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cacherecycle/XulRecentlyUnusedStrategy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cacherecycle; 2 | 3 | import com.starcor.xulapp.cache.XulCacheModel; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | * Created by ZFB on 2015/10/23. 9 | */ 10 | class XulRecentlyUnusedStrategy implements XulRecycleStrategy { 11 | 12 | @Override 13 | public XulCacheModel findRecycledCache(Collection caches) { 14 | XulCacheModel oldestData = null; 15 | for (XulCacheModel cacheData : caches) { 16 | if (oldestData == null) { 17 | oldestData = cacheData; 18 | } else { 19 | if (cacheData.getLastAccessTime() < oldestData.getLastAccessTime()) { 20 | oldestData = cacheData; 21 | } 22 | } 23 | } 24 | 25 | return oldestData; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/XulItemRender.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render; 2 | 3 | import com.starcor.xul.Prop.XulFocus; 4 | import com.starcor.xul.XulItem; 5 | import com.starcor.xul.XulRenderContext; 6 | import com.starcor.xul.XulView; 7 | 8 | /** 9 | * Created by hy on 2014/5/13. 10 | */ 11 | public class XulItemRender extends XulViewRender { 12 | public static void register() { 13 | XulRenderFactory.registerBuilder("item", "*", new XulRenderFactory.RenderBuilder() { 14 | @Override 15 | protected XulViewRender createRender(XulRenderContext ctx, XulView view) { 16 | assert view instanceof XulItem; 17 | return new XulItemRender(ctx, view); 18 | } 19 | }); 20 | } 21 | 22 | public XulItemRender(XulRenderContext ctx, XulView view) { 23 | super(ctx, view); 24 | } 25 | 26 | @Override 27 | public int getDefaultFocusMode() { 28 | return XulFocus.MODE_FOCUSABLE; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/seqmessage/XulSeqMsgData.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.seqmessage; 2 | 3 | /** 4 | * Created by ZFB on 2015/12/8 0008. 5 | */ 6 | public class XulSeqMsgData { 7 | 8 | /** 9 | * 默认的序列id 10 | */ 11 | public static final int DEFAULT_SEQ_ID = 0; 12 | 13 | private int _msgId = 0; 14 | 15 | private int _seqId = 0; 16 | 17 | private Object _data = null; 18 | 19 | public XulSeqMsgData(int msgId, int seqId, Object data) { 20 | _msgId = msgId; 21 | _seqId = seqId; 22 | _data = data; 23 | } 24 | 25 | public int getMsgId() { 26 | return _msgId; 27 | } 28 | 29 | public int getSeqId() { 30 | return _seqId; 31 | } 32 | 33 | public Object getData() { 34 | return _data; 35 | } 36 | 37 | public void setData(Object _data) { 38 | this._data = _data; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /xul/src/com/caverock/androidsvg/LibConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Paul LeBeau, Cave Rock Software Ltd. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.caverock.androidsvg; 18 | 19 | /** 20 | * Configure debugging on or off. 21 | * 22 | * @hide 23 | */ 24 | public class LibConfig 25 | { 26 | public static final boolean DEBUG = false; 27 | } 28 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cacherecycle/XulExpireStrategy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cacherecycle; 2 | 3 | import com.starcor.xulapp.cache.XulCacheDomain; 4 | import com.starcor.xulapp.cache.XulCacheModel; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * Created by ZFB on 2015/10/23. 10 | */ 11 | class XulExpireStrategy implements XulRecycleStrategy { 12 | 13 | private final XulCacheDomain _cacheDomain; 14 | 15 | public XulExpireStrategy(XulCacheDomain domain) { 16 | _cacheDomain = domain; 17 | } 18 | 19 | @Override 20 | public XulCacheModel findRecycledCache(Collection caches) { 21 | XulCacheModel cacheModel = null; 22 | for (XulCacheModel cache : caches) { 23 | if (cache != null && _cacheDomain.isExpired(cache)) { 24 | break; 25 | } 26 | } 27 | 28 | return cacheModel; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptContext.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | import java.io.InputStream; 4 | 5 | /** 6 | * Created by hy on 2014/6/25. 7 | */ 8 | public interface IScriptContext { 9 | void init(); 10 | String getScriptType(); 11 | IScript compileFunction(String funcBodyText, String sourceName, int sourceLine); 12 | IScript compileFunction(InputStream funcBodyText, String sourceName, int sourceLine); 13 | IScript compileScript(String scriptText, String sourceName, int sourceLine); 14 | IScript compileScript(InputStream scriptText, String sourceName, int sourceLine); 15 | IScript getFunction(Object scriptableObject, String funcName); 16 | IScriptableObject createScriptObject(XulScriptableObject obj); 17 | IScriptMap createScriptMap(); 18 | IScriptArray createScriptArray(); 19 | void destroy(); 20 | boolean addIndexedString(String str, int id); 21 | boolean delIndexedString(String str); 22 | } 23 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/XulScriptableObject.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | /** 4 | * Created by hy on 2014/6/25. 5 | */ 6 | public abstract class XulScriptableObject { 7 | public abstract IScriptableClass getScriptClass(); 8 | public abstract Object getUnwrappedObject(); 9 | public abstract Object getProperty(IScriptContext ctx, String name); 10 | public abstract Object getProperty(IScriptContext ctx, int idx); 11 | public abstract Object putProperty(IScriptContext ctx, String name, Object newVal); 12 | public abstract Object putProperty(IScriptContext ctx, int idx, Object newVal); 13 | public abstract XulScriptMethodInvoker createMethodInvoker(String name); 14 | public abstract XulScriptMethodInvoker createMethodInvoker(int idx); 15 | public static abstract class XulScriptMethodInvoker { 16 | public abstract boolean invoke(XulScriptableObject thisObj, IScriptContext ctx, IScriptArguments args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptArray.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | import com.starcor.xul.Utils.XulArrayList; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | * Created by hy on 2015/6/21. 9 | */ 10 | public interface IScriptArray { 11 | void add(int val); 12 | 13 | void add(long val); 14 | 15 | void add(String val); 16 | 17 | void add(float val); 18 | 19 | void add(double val); 20 | 21 | void add(boolean val); 22 | 23 | void add(IScriptableObject val); 24 | 25 | void add(IScriptArray val); 26 | 27 | int getInteger(int idx); 28 | 29 | long getLong(int idx); 30 | 31 | float getFloat(int idx); 32 | 33 | double getDouble(int idx); 34 | 35 | String getString(int idx); 36 | 37 | int getStringId(int idx); 38 | 39 | boolean getBoolean(int idx); 40 | 41 | void addAll(Collection val); 42 | 43 | void addAll(XulArrayList val); 44 | 45 | void addAll(Object[] val); 46 | 47 | int size(); 48 | } 49 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/BouncingTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class BouncingTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "bouncing"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float percent = time / duration; 15 | if (percent >= 1.0f) { 16 | return -1000; 17 | } 18 | double growSpeed = params[0]; 19 | double frequency = params[1]; 20 | double slope = params[2]; 21 | double bounceStrength = params[3]; 22 | 23 | double x = Math.pow(percent, 2.5 / slope); 24 | double PI = Math.PI; 25 | double y = Math.pow(x, 0.15 + 0.1 * growSpeed) + 0.3 * bounceStrength * Math.pow(x, 0.4) * Math.sin(8 * PI * Math.pow(x * frequency, 1.6)) / Math.tan(x * PI / 2); 26 | return (float) y; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/ShakingTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class ShakingTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "shaking"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float percent = time / duration; 15 | if (percent >= 1.0f) { 16 | return -1000; 17 | } 18 | double frequency = params[0]; 19 | double offset = params[1]; 20 | double delta = params[2]; 21 | double strength = params[3]; 22 | double grow = params[4]; 23 | 24 | double PI = Math.PI; 25 | double x = percent; 26 | double g = 1 * grow + (1 - grow) * (Math.cos(x * 2 * PI + PI) + 1) / 2; 27 | double y = (Math.cos(x * frequency * 4 * PI + offset * PI) + delta) / 2 * strength * g; 28 | return (float) y; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulAreaChildrenCollectorAllFocusable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | import com.starcor.xul.XulArea; 4 | import com.starcor.xul.XulItem; 5 | import com.starcor.xul.XulView; 6 | 7 | public class XulAreaChildrenCollectorAllFocusable extends XulArea.XulAreaIterator { 8 | XulArrayList _result = new XulArrayList(); 9 | 10 | public void begin() { 11 | _result.clear(); 12 | } 13 | 14 | public XulArrayList end() { 15 | return _result; 16 | } 17 | 18 | public void clear() { 19 | _result.clear(); 20 | } 21 | 22 | private void doCollect(XulView view) { 23 | if ( view.isEnabled() && view.isVisible() && view.focusable() ) { 24 | _result.add(view); 25 | } 26 | } 27 | 28 | @Override 29 | public boolean onXulArea(int pos, XulArea area) { 30 | doCollect(area); 31 | area.eachChild(this); 32 | return true; 33 | } 34 | 35 | @Override 36 | public boolean onXulItem(int pos, XulItem item) { 37 | doCollect(item); 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/XulPresenter.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.view.KeyEvent; 6 | import android.view.MotionEvent; 7 | import android.widget.FrameLayout; 8 | 9 | import com.starcor.xul.XulRenderContext; 10 | 11 | /** 12 | * Created by hy on 2015/12/28. 13 | */ 14 | public interface XulPresenter { 15 | 16 | Context xulGetContext(); 17 | 18 | String xulGetIntentPageId(); 19 | 20 | String xulGetCurPageId(); 21 | 22 | String xulGetIntentLayoutFile(); 23 | 24 | String xulGetCurLayoutFile(); 25 | 26 | String xulGetCurBehaviorName(); 27 | 28 | XulRenderContext xulGetRenderContext(); 29 | 30 | FrameLayout xulGetRenderContextView(); 31 | 32 | void xulLoadLayoutFile(String layoutFile); 33 | 34 | boolean xulDefaultDispatchKeyEvent(KeyEvent event); 35 | 36 | boolean xulDefaultDispatchTouchEvent(MotionEvent event); 37 | 38 | Bundle xulGetBehaviorParams(); 39 | 40 | void xulDestroy(); 41 | 42 | boolean xulIsAlive(); 43 | } 44 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/IScriptArguments.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | import com.starcor.xul.Utils.XulArrayList; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | * Created by hy on 2015/6/19. 9 | */ 10 | public interface IScriptArguments { 11 | void setResult(int val); 12 | 13 | void setResult(long val); 14 | 15 | void setResult(String val); 16 | 17 | void setResult(float val); 18 | 19 | void setResult(double val); 20 | 21 | void setResult(boolean val); 22 | 23 | void setResult(Collection objects); 24 | 25 | void setResult(XulArrayList objects); 26 | 27 | void setResult(Object[] objects); 28 | 29 | void setResult(IScriptableObject val); 30 | 31 | void setResult(IScriptArray val); 32 | 33 | int getInteger(int idx); 34 | 35 | long getLong(int idx); 36 | 37 | float getFloat(int idx); 38 | 39 | double getDouble(int idx); 40 | 41 | String getString(int idx); 42 | 43 | int getStringId(int idx); 44 | 45 | boolean getBoolean(int idx); 46 | 47 | IScriptableObject getScriptableObject(int idx); 48 | 49 | int size(); 50 | } 51 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Wrapper/XulViewWrapper.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Wrapper; 2 | 3 | import com.starcor.xul.Render.XulViewRender; 4 | import com.starcor.xul.XulArea; 5 | import com.starcor.xul.XulLayout; 6 | import com.starcor.xul.XulView; 7 | 8 | /** 9 | * Created by hy on 2015/12/23. 10 | */ 11 | public class XulViewWrapper { 12 | XulView _view; 13 | 14 | XulViewWrapper(XulView view) { 15 | _view = view; 16 | } 17 | 18 | public static XulViewWrapper fromXulView(XulView view) { 19 | return new XulViewWrapper(view); 20 | } 21 | 22 | public XulView getAsView() { 23 | return _view; 24 | } 25 | 26 | public XulArea getAsArea() { 27 | if (_view instanceof XulArea) { 28 | return (XulArea) _view; 29 | } 30 | return null; 31 | } 32 | 33 | public void requestFocus() { 34 | XulLayout rootLayout = _view.getRootLayout(); 35 | if (rootLayout == null) { 36 | return; 37 | } 38 | rootLayout.requestFocus(_view); 39 | } 40 | 41 | public boolean blinkClass(String... clsName) { 42 | XulViewRender render = _view.getRender(); 43 | if (render == null) { 44 | return false; 45 | } 46 | return render.blinkClass(clsName); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/XulCommonMsgData.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message; 2 | 3 | /** 4 | * Created by ZFB on 2015/10/14. 5 | * 6 | * 通用消息数据,可自行拓展 7 | */ 8 | public class XulCommonMsgData { 9 | 10 | private boolean _boolValue = false; 11 | 12 | private int _intValue1 = 0; 13 | 14 | private int _intValue2 = 0; 15 | 16 | private String _stringValue = ""; 17 | 18 | 19 | public boolean getBoolValue() { 20 | return _boolValue; 21 | } 22 | 23 | public void setBoolValue(boolean boolValue) { 24 | _boolValue = boolValue; 25 | } 26 | 27 | public int getIntValue1() { 28 | return _intValue1; 29 | } 30 | 31 | public void setIntValue1(int intValue1) { 32 | _intValue1 = intValue1; 33 | } 34 | 35 | public int getIntValue2() { 36 | return _intValue2; 37 | } 38 | 39 | public void setIntValue2(int intValue2) { 40 | _intValue2 = intValue2; 41 | } 42 | 43 | public String getStringValue() { 44 | return _stringValue; 45 | } 46 | 47 | public void setStringValue(String stringValue) { 48 | _stringValue = stringValue; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xul/src/com/caverock/androidsvg/SVGParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Paul LeBeau, Cave Rock Software Ltd. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.caverock.androidsvg; 18 | 19 | /** 20 | * Thrown by the parser if a problem is found in the SVG file. 21 | */ 22 | 23 | public class SVGParseException extends Exception 24 | { 25 | public SVGParseException(String msg) 26 | { 27 | super(msg); 28 | } 29 | 30 | public SVGParseException(String msg, Throwable cause) 31 | { 32 | super(msg, cause); 33 | } 34 | 35 | public SVGParseException(Throwable cause) 36 | { 37 | super(cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/behavior/XABCustomViewDemo.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.behavior; 2 | 3 | import android.widget.RelativeLayout; 4 | 5 | import com.starcor.xul.IXulExternalView; 6 | import com.starcor.xul.XulView; 7 | import com.starcor.xuldemo.widget.XulExt_ExternalEditBox; 8 | 9 | /** 10 | * Created by hy on 2015/8/7. 11 | */ 12 | public class XABCustomViewDemo extends XulActivityBehavior { 13 | 14 | public static void register() { 15 | XulActivityBehavior.registerBehavior("behavior_custom_view_demo", new IBehaviorFactory() { 16 | @Override 17 | public XulActivityBehavior create() { 18 | return new XABCustomViewDemo(); 19 | } 20 | }); 21 | } 22 | 23 | @Override 24 | public IXulExternalView createExternalView(String cls, int x, int y, int width, int height, 25 | XulView view) { 26 | if ("EditBox".equals(cls)) { 27 | XulExt_ExternalEditBox editBox = new XulExt_ExternalEditBox(mXulActivity, view); 28 | ((RelativeLayout) mLayout).addView(editBox, width, height); 29 | return editBox; 30 | } 31 | 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/XulScriptableClass.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | import com.starcor.xul.Utils.XulCachedHashMap; 4 | 5 | /** 6 | * Created by hy on 2014/6/25. 7 | */ 8 | public class XulScriptableClass implements IScriptableClass { 9 | private final String[] _clsMethods; 10 | private final String[] _clsProps; 11 | String _clsName; 12 | 13 | @Override 14 | public String getClassName() { 15 | return _clsName; 16 | } 17 | 18 | @Override 19 | public String[] getProperties() { 20 | return _clsProps; 21 | } 22 | 23 | @Override 24 | public String[] getMethods() { 25 | return _clsMethods; 26 | } 27 | 28 | static XulCachedHashMap classCache = new XulCachedHashMap(); 29 | 30 | private XulScriptableClass(String name, String[] props, String[] methods) { 31 | _clsName = name; 32 | _clsProps = props; 33 | _clsMethods = methods; 34 | } 35 | 36 | static public IScriptableClass createScriptableClass(String name, String[] props, String[] methods) { 37 | XulScriptableClass cls = classCache.get(name); 38 | if (cls == null) { 39 | cls = new XulScriptableClass(name, props, methods); 40 | classCache.put(name, cls); 41 | } 42 | return cls; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/BasicTransformAlgorithmImpl.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/6/30. 5 | */ 6 | public abstract class BasicTransformAlgorithmImpl implements ITransformAlgorithm { 7 | @Override 8 | public UpdateResult update(float[] params, long begin, long duration, long progress, float curVal, float srcVal, float oldDestVal, float newDestVal) { 9 | return commonUpdateAnimation(begin, duration, progress, curVal, srcVal, oldDestVal, newDestVal); 10 | } 11 | 12 | public static UpdateResult updateResult = new UpdateResult(); 13 | 14 | public static UpdateResult commonUpdateAnimation(long begin, long duration, long progress, float curVal, float srcVal, float oldDestVal, float newDestVal) { 15 | boolean isSameDirection = (oldDestVal - curVal) * (newDestVal - curVal) >= 0; 16 | updateResult.newDest = newDestVal; 17 | updateResult.newSrc = curVal; 18 | if (isSameDirection) { 19 | updateResult.newBegin = begin + progress; 20 | } else { 21 | updateResult.newBegin = begin + 2 * progress - duration; 22 | } 23 | return updateResult; 24 | } 25 | 26 | @Override 27 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 28 | return 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/XulScriptFactory.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | import android.text.TextUtils; 4 | import com.starcor.xul.Utils.XulCachedHashMap; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by hy on 2014/6/25. 10 | */ 11 | public class XulScriptFactory { 12 | public interface IScriptFactory { 13 | List getSupportScriptTypes(); 14 | IScriptContext createContext(); 15 | } 16 | 17 | private static XulCachedHashMap _factories = new XulCachedHashMap(); 18 | 19 | public static boolean registerFactory(IScriptFactory factory) { 20 | List supportScriptTypes = factory.getSupportScriptTypes(); 21 | if (supportScriptTypes == null) { 22 | return false; 23 | } 24 | 25 | for (int i = 0; i < supportScriptTypes.size(); i++) { 26 | String scriptType = supportScriptTypes.get(i); 27 | _factories.put(scriptType, factory); 28 | } 29 | return true; 30 | } 31 | 32 | public static IScriptContext createScriptContext(String type) { 33 | if (TextUtils.isEmpty(type)) { 34 | return null; 35 | } 36 | IScriptFactory scriptFactory = _factories.get(type); 37 | if (scriptFactory == null) { 38 | return null; 39 | } 40 | 41 | IScriptContext context = scriptFactory.createContext(); 42 | return context; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Graphics/XulAndroidDrawable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Graphics; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | import android.graphics.Rect; 6 | import android.graphics.RectF; 7 | import android.graphics.drawable.Drawable; 8 | 9 | /** 10 | * Created by hy on 2014/7/10. 11 | */ 12 | class XulAndroidDrawable extends XulDrawable { 13 | private final Drawable drawable; 14 | 15 | public XulAndroidDrawable(Drawable drawable) { 16 | this.drawable = drawable; 17 | } 18 | 19 | @Override 20 | public boolean draw(Canvas canvas, Rect rc, Rect dst, Paint paint) { 21 | drawable.setBounds(dst); 22 | drawable.draw(canvas); 23 | return true; 24 | } 25 | 26 | @Override 27 | public boolean draw(Canvas canvas, Rect rc, RectF dst, Paint paint) { 28 | drawable.setBounds((int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom); 29 | drawable.draw(canvas); 30 | return false; 31 | } 32 | 33 | @Override 34 | public int getHeight() { 35 | int height = drawable.getIntrinsicHeight(); 36 | if (height <= 0) { 37 | height = drawable.getMinimumHeight(); 38 | } 39 | return height; 40 | } 41 | 42 | @Override 43 | public int getWidth() { 44 | int width = drawable.getIntrinsicWidth(); 45 | if (width <= 0) { 46 | width = drawable.getMinimumWidth(); 47 | } 48 | return width; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Graphics/XulBitmapDrawable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Graphics; 2 | 3 | import android.graphics.*; 4 | 5 | /** 6 | * Created by hy on 2014/6/20. 7 | */ 8 | public class XulBitmapDrawable extends XulDrawable { 9 | Bitmap _bmp; 10 | 11 | @Override 12 | public boolean draw(Canvas canvas, Rect rc, Rect dst, Paint paint) { 13 | Bitmap bmp = _bmp; 14 | if (bmp == null) { 15 | return false; 16 | } 17 | canvas.drawBitmap(bmp, rc, dst, paint); 18 | return true; 19 | } 20 | 21 | @Override 22 | public boolean draw(Canvas canvas, Rect rc, RectF dst, Paint paint) { 23 | Bitmap bmp = _bmp; 24 | if (bmp == null) { 25 | return false; 26 | } 27 | canvas.drawBitmap(bmp, rc, dst, paint); 28 | return true; 29 | } 30 | 31 | @Override 32 | public int getHeight() { 33 | Bitmap bmp = _bmp; 34 | if (bmp == null) { 35 | return 0; 36 | } 37 | return bmp.getHeight(); 38 | } 39 | 40 | @Override 41 | public int getWidth() { 42 | Bitmap bmp = _bmp; 43 | if (bmp == null) { 44 | return 0; 45 | } 46 | return bmp.getWidth(); 47 | } 48 | 49 | @Override 50 | public XulDrawable makeClone() { 51 | return XulDrawable.fromBitmap(BitmapTools.createBitmap(_bmp), _url, _url); 52 | } 53 | 54 | public static Bitmap detachBitmap(XulBitmapDrawable bmp) { 55 | Bitmap b = bmp._bmp; 56 | bmp._bmp = null; 57 | return b; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Drawer/XulDrawer.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Drawer; 2 | 3 | import android.graphics.Paint; 4 | import android.graphics.Rect; 5 | import android.graphics.RectF; 6 | 7 | import com.starcor.xul.Graphics.XulAnimationDrawable; 8 | import com.starcor.xul.Graphics.XulDC; 9 | import com.starcor.xul.Graphics.XulDrawable; 10 | import com.starcor.xul.Graphics.XulGIFAnimationDrawable; 11 | import com.starcor.xul.XulRenderContext; 12 | import com.starcor.xul.XulView; 13 | 14 | /** 15 | * Created by hy on 2014/6/21. 16 | */ 17 | public abstract class XulDrawer { 18 | 19 | static public XulDrawer create(XulDrawable drawable, XulView owner, XulRenderContext render) { 20 | if (drawable instanceof XulAnimationDrawable 21 | || drawable instanceof XulGIFAnimationDrawable) { 22 | return XulAnimationDrawer.create(drawable, owner, render); 23 | } 24 | return XulBitmapDrawer.create(drawable, owner, render); 25 | } 26 | 27 | public void reset() { 28 | } 29 | 30 | public abstract void draw(XulDC dc, XulDrawable drawable, Rect src, Rect dst, Paint paint); 31 | 32 | public abstract void draw(XulDC dc, XulDrawable drawable, Rect src, RectF dst, Paint paint); 33 | 34 | public abstract void draw(XulDC dc, XulDrawable drawable, Rect dst, Paint paint); 35 | 36 | public abstract void draw(XulDC dc, XulDrawable drawable, RectF dst, Paint paint); 37 | } 38 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Drawer/XulBitmapDrawer.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Drawer; 2 | 3 | import android.graphics.Paint; 4 | import android.graphics.Rect; 5 | import android.graphics.RectF; 6 | import com.starcor.xul.Graphics.XulDC; 7 | import com.starcor.xul.Graphics.XulDrawable; 8 | import com.starcor.xul.XulRenderContext; 9 | import com.starcor.xul.XulView; 10 | 11 | /** 12 | * Created by hy on 2014/6/21. 13 | */ 14 | public class XulBitmapDrawer extends XulDrawer { 15 | 16 | static XulBitmapDrawer _instance = new XulBitmapDrawer(); 17 | 18 | private XulBitmapDrawer() { 19 | 20 | } 21 | 22 | static public XulBitmapDrawer create(XulDrawable drawable, XulView owner, XulRenderContext render) { 23 | return _instance; 24 | } 25 | 26 | @Override 27 | public void draw(XulDC dc, XulDrawable drawable, Rect src, Rect dst, Paint paint) { 28 | dc.drawBitmap(drawable, src, dst, paint); 29 | } 30 | 31 | @Override 32 | public void draw(XulDC dc, XulDrawable drawable, Rect src, RectF dst, Paint paint) { 33 | dc.drawBitmap(drawable, src, dst, paint); 34 | } 35 | 36 | @Override 37 | public void draw(XulDC dc, XulDrawable drawable, Rect dst, Paint paint) { 38 | dc.drawBitmap(drawable, dst, paint); 39 | } 40 | 41 | @Override 42 | public void draw(XulDC dc, XulDrawable drawable, RectF dst, Paint paint) { 43 | dc.drawBitmap(drawable, dst, paint); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/activities/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.activities; 2 | 3 | import android.content.Intent; 4 | import android.text.TextUtils; 5 | import com.starcor.xul.XulView; 6 | import com.starcor.xuldemo.utils.log.LogUtil; 7 | 8 | /** 9 | * 10 | */ 11 | public class MainActivity extends XulDemoBaseActivity { 12 | 13 | private static final String PAGE_MAIN = "page_main"; 14 | 15 | public MainActivity() { 16 | super(); 17 | mPageId = PAGE_MAIN; 18 | } 19 | 20 | @Override 21 | public void onDoAction(XulView view, String action, String type, String command, 22 | Object userdata) { 23 | if ("click".equals(action)) { 24 | String pageId = command; 25 | if (TextUtils.isEmpty(pageId)) { 26 | LogUtil.e("XUL demo page id is null!"); 27 | return; 28 | } 29 | String pageBehavior = view.getAttrString("behavior"); 30 | String pageLayout = view.getAttrString("layout"); 31 | 32 | Intent intent = new Intent(this, CommonPageActivity.class); 33 | intent.putExtra(XulDemoBaseActivity.EXTRA_XUL_PAGE_ID, pageId); 34 | intent.putExtra(XulDemoBaseActivity.EXTRA_XUL_PAGE_BEHAVIOR, pageBehavior); 35 | intent.putExtra(XulDemoBaseActivity.EXTRA_XUL_FILE_NAME, pageLayout); 36 | startActivity(intent); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/behavior/XulBehaviorManager.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.behavior; 2 | 3 | import com.starcor.xulapp.XulPresenter; 4 | 5 | import java.util.HashMap; 6 | 7 | /** 8 | * Created by hy on 2015/8/31. 9 | */ 10 | public class XulBehaviorManager { 11 | 12 | private static HashMap _behaviorFactories = new HashMap(256); 13 | 14 | public static synchronized void registerBehavior(String behaviorName, IBehaviorFactory factory) { 15 | _behaviorFactories.put(behaviorName, factory); 16 | } 17 | 18 | public static void shutdownBehaviorManager() { 19 | 20 | } 21 | 22 | public static void initBehaviorManager() { 23 | 24 | } 25 | 26 | public interface IBehaviorFactory { 27 | XulUiBehavior createBehavior(XulPresenter xulPresenter); 28 | 29 | Class getBehaviorClass(); 30 | } 31 | 32 | public static synchronized XulUiBehavior obtainBehavior(String behaviorName, XulPresenter xulPresenter) { 33 | final IBehaviorFactory behaviorFactory = _behaviorFactories.get(behaviorName); 34 | if (behaviorFactory == null) { 35 | return null; 36 | } 37 | return behaviorFactory.createBehavior(xulPresenter); 38 | } 39 | 40 | public static Class obtainBehaviorClass(String behaviorName) { 41 | final IBehaviorFactory behaviorFactory = _behaviorFactories.get(behaviorName); 42 | if (behaviorFactory == null) { 43 | return null; 44 | } 45 | return behaviorFactory.getBehaviorClass(); 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /XulDemo/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Factory/XulParserCachedTag.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Factory; 2 | 3 | import com.starcor.xul.Utils.XulCachedHashMap; 4 | import com.starcor.xul.XulUtils; 5 | 6 | /** 7 | * Created by hy on 2015/4/28. 8 | */ 9 | public class XulParserCachedTag extends XulFactory.Attributes { 10 | String _name; 11 | XulCachedHashMap _attrs = null; 12 | int _length = 0; 13 | 14 | @Override 15 | public String getValue(String name) { 16 | if (_attrs == null) { 17 | return null; 18 | } 19 | return _attrs.get(name); 20 | } 21 | 22 | @Override 23 | public String getValue(int i) { 24 | return null; 25 | } 26 | 27 | @Override 28 | public int getLength() { 29 | return _length; 30 | } 31 | 32 | @Override 33 | public String getName(int i) { 34 | return null; 35 | } 36 | 37 | public XulParserCachedTag(String tag_name, XulFactory.Attributes attrs) { 38 | _name = XulUtils.getCachedString(tag_name); 39 | if (attrs == null) { 40 | return; 41 | } 42 | int attrsLength = attrs.getLength(); 43 | _length = attrsLength; 44 | if (attrsLength == 0) { 45 | return; 46 | } 47 | _attrs = new XulCachedHashMap(); 48 | 49 | for (int i = 0; i < attrsLength; i++) { 50 | String name = XulUtils.getCachedString(attrs.getName(i)); 51 | String value = XulUtils.getCachedString(attrs.getValue(i)); 52 | _attrs.put(name, value); 53 | } 54 | } 55 | 56 | public String getTagName() { 57 | return _name; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Components/BaseScrollBar.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Components; 2 | 3 | import android.graphics.Rect; 4 | import android.graphics.RectF; 5 | 6 | import com.starcor.xul.Graphics.IXulDrawable; 7 | import com.starcor.xul.Graphics.XulDC; 8 | 9 | /** 10 | * Created by hy on 2015/1/8. 11 | */ 12 | public abstract class BaseScrollBar implements IXulDrawable { 13 | 14 | public BaseScrollBar(ScrollBarHelper helper) { 15 | this._helper = helper; 16 | } 17 | 18 | public abstract BaseScrollBar update(String desc, String[] descFields); 19 | 20 | public abstract void reset(); 21 | 22 | public abstract boolean draw(XulDC dc, Rect rc, int xBase, int yBase); 23 | 24 | public abstract boolean draw(XulDC dc, RectF updateRc, float xBase, float yBase); 25 | 26 | public void recycle() { 27 | } 28 | 29 | public boolean isVertical() { 30 | return _helper.isVertical(); 31 | } 32 | 33 | public int getScrollPos() { 34 | return _helper.getScrollPos(); 35 | } 36 | 37 | public int getContentWidth() { 38 | return _helper.getContentWidth(); 39 | } 40 | 41 | public int getContentHeight() { 42 | return _helper.getContentHeight(); 43 | } 44 | 45 | private final ScrollBarHelper _helper; 46 | 47 | public static abstract class ScrollBarHelper { 48 | public abstract boolean isVertical(); 49 | 50 | public abstract int getScrollPos(); 51 | 52 | public abstract int getContentWidth(); 53 | 54 | public abstract int getContentHeight(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Graphics/XulCommonDrawable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Graphics; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | import android.graphics.Rect; 6 | import android.graphics.RectF; 7 | import android.graphics.drawable.Drawable; 8 | import com.starcor.xul.XulUtils; 9 | 10 | /** 11 | * Created by hy on 2014/6/20. 12 | */ 13 | public class XulCommonDrawable extends XulDrawable { 14 | Drawable _drawable; 15 | 16 | @Override 17 | public boolean draw(Canvas canvas, Rect rc, Rect dst, Paint paint) { 18 | Drawable drawable = _drawable; 19 | if (drawable == null) { 20 | return false; 21 | } 22 | drawable.setBounds(dst); 23 | drawable.draw(canvas); 24 | return true; 25 | } 26 | 27 | @Override 28 | public boolean draw(Canvas canvas, Rect rc, RectF dst, Paint paint) { 29 | Drawable drawable = _drawable; 30 | if (drawable == null) { 31 | return false; 32 | } 33 | drawable.setBounds(XulUtils.roundToInt(dst.left), XulUtils.roundToInt(dst.top), XulUtils.roundToInt(dst.right), XulUtils.roundToInt(dst.bottom)); 34 | drawable.draw(canvas); 35 | return true; 36 | } 37 | 38 | @Override 39 | public int getHeight() { 40 | Drawable drawable = _drawable; 41 | if (drawable == null) { 42 | return 0; 43 | } 44 | return drawable.getMinimumHeight(); 45 | } 46 | 47 | @Override 48 | public int getWidth() { 49 | Drawable drawable = _drawable; 50 | if (drawable == null) { 51 | return 0; 52 | } 53 | return drawable.getMinimumWidth(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/http/XulHttpStatisticFilter.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.http; 2 | 3 | import com.starcor.xulapp.utils.XulLog; 4 | 5 | /** 6 | * Created by hy on 2015/11/23. 7 | */ 8 | public class XulHttpStatisticFilter extends XulHttpFilter { 9 | private static final String TAG = XulHttpStatisticFilter.class.getSimpleName(); 10 | 11 | @Override 12 | public String name() { 13 | return "HTTP Statistic"; 14 | } 15 | 16 | @Override 17 | public int handleResponse(XulHttpStack.XulHttpCtx ctx, XulHttpResponse response) { 18 | long t0 = ctx.getRequestTime(); 19 | XulHttpRequest initialRequest = ctx.getInitialRequest(); 20 | StringBuilder logBuilder = new StringBuilder(); 21 | logBuilder.append(String.format("----- %s -----\n", initialRequest.path)); 22 | while (ctx.getNextCtx() != null) { 23 | XulHttpFilter filter = ctx.getFilter(); 24 | ctx = ctx.getNextCtx(); 25 | if (filter == this) { 26 | continue; 27 | } 28 | String name = filter.name(); 29 | long t1 = ctx.getRequestTime(); 30 | logBuilder.append(String.format("REQU : %.3f - %s\n", (t1 - t0) / 1000.0, name)); 31 | t0 = t1; 32 | } 33 | 34 | while (ctx.getPrevCtx() != null) { 35 | XulHttpFilter filter = ctx.getFilter(); 36 | ctx = ctx.getPrevCtx(); 37 | String name = filter.name(); 38 | long t1 = ctx.getResponseTime(); 39 | logBuilder.append(String.format("RESP : %.3f - %s\n", (t1 - t0) / 1000.0, name)); 40 | t0 = t1; 41 | } 42 | 43 | XulLog.d(TAG, logBuilder.toString()); 44 | return 0; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/matchpolicy/XulDefaultMatchPolicy.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.matchpolicy; 2 | 3 | 4 | import com.starcor.xulapp.message.XulMessage; 5 | 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | 9 | public class XulDefaultMatchPolicy implements XulMatchPolicy { 10 | 11 | @Override 12 | public List findMatchMessageTypes(XulMessage message) { 13 | Class messageClass = message.getParamClass(); 14 | List result = new LinkedList(); 15 | while (messageClass != null) { 16 | XulMessage newMessage = new XulMessage(message); 17 | newMessage.setParamClass(messageClass); 18 | result.add(newMessage); 19 | addInterfaces(result, newMessage); 20 | messageClass = messageClass.getSuperclass(); 21 | } 22 | 23 | return result; 24 | } 25 | 26 | 27 | /** 28 | * 获取该消息的所有接口类型 29 | */ 30 | private void addInterfaces(List messages, XulMessage message) { 31 | Class[] interfacesClasses = message.getParamClass().getInterfaces(); 32 | for (Class interfaceClass : interfacesClasses) { 33 | if (!messages.contains(interfaceClass)) { 34 | XulMessage newMessage = new XulMessage(message); 35 | newMessage.setParamClass(interfaceClass); 36 | messages.add(newMessage); 37 | addInterfaces(messages, newMessage); 38 | } 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Effect/FlipAnimation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Effect; 2 | 3 | import android.graphics.Camera; 4 | import android.graphics.Matrix; 5 | import com.starcor.xul.Graphics.XulDC; 6 | import com.starcor.xul.Render.Drawer.IXulAnimation; 7 | import com.starcor.xul.Render.XulViewRender; 8 | 9 | /** 10 | * Created by hy on 2015/1/26. 11 | */ 12 | public class FlipAnimation implements IXulAnimation { 13 | 14 | Camera _camera = new Camera(); 15 | Matrix _matrix = new Matrix(); 16 | 17 | protected XulViewRender _render; 18 | 19 | float _angle = 0; 20 | 21 | public FlipAnimation(XulViewRender render) { 22 | this._render = render; 23 | _render.addAnimation(this); 24 | } 25 | 26 | @Override 27 | public boolean updateAnimation(long timestamp) { 28 | if (_render == null) { 29 | return false; 30 | } 31 | _angle += 3; 32 | _angle %= 360.0; 33 | _render.markDirtyView(); 34 | return true; 35 | } 36 | 37 | public void setAngle(float angle) { 38 | _angle = angle; 39 | } 40 | 41 | public float getAngle() { 42 | return _angle; 43 | } 44 | 45 | public void preDraw(XulDC dc, float x, float y, float cx, float cy) { 46 | dc.save(); 47 | _camera.save(); 48 | _camera.rotateY(_angle); 49 | _camera.getMatrix(_matrix); 50 | _matrix.preTranslate(-x - cx / 2.0f, -y - cy / 2.0f); 51 | _matrix.postTranslate(+x + cx / 2.0f, y + cy / 2.0f); 52 | dc.setMatrix(_matrix); 53 | } 54 | 55 | public void postDraw(XulDC dc, float x, float y, float cx, float cy) { 56 | _camera.restore(); 57 | dc.restore(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulIntArray.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by hy on 2015/6/12. 7 | */ 8 | 9 | public class XulIntArray { 10 | int[] _buf; 11 | int _maximumSize; 12 | int _num; 13 | 14 | public XulIntArray(int size) { 15 | this._buf = new int[size]; 16 | _maximumSize = size; 17 | _num = 0; 18 | } 19 | 20 | public void push(int val) { 21 | add(val); 22 | } 23 | 24 | public void add(int val) { 25 | if (_num >= _maximumSize) { 26 | _enlargeBuf(128); 27 | } 28 | 29 | _buf[_num] = val; 30 | ++_num; 31 | } 32 | 33 | private void _enlargeBuf(int delta) { 34 | _maximumSize += delta; 35 | int[] newStack = new int[_maximumSize]; 36 | System.arraycopy(_buf, 0, newStack, 0, _num); 37 | _buf = newStack; 38 | } 39 | 40 | public int get(int idx) { 41 | if (idx >= _num) { 42 | return -1; 43 | } 44 | return _buf[idx]; 45 | } 46 | 47 | public int size() { 48 | return _num; 49 | } 50 | 51 | public void clear() { 52 | if (_num == 0) { 53 | return; 54 | } 55 | Arrays.fill(_buf, 0, _num, -1); 56 | _num = 0; 57 | } 58 | 59 | public int pop() { 60 | if (_num <= 0) { 61 | return -1; 62 | } 63 | --_num; 64 | int obj = _buf[_num]; 65 | _buf[_num] = -1; 66 | return obj; 67 | } 68 | 69 | public void addAll(XulIntArray baseSeq) { 70 | if (_num + baseSeq._num >= _maximumSize) { 71 | _enlargeBuf(((_num + baseSeq._num) - _maximumSize + 31) & ~0x1F); 72 | } 73 | System.arraycopy(baseSeq._buf, 0, _buf, _num, baseSeq._num); 74 | _num += baseSeq._num; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/seqmessage/XulSeqMsgDataDispatcher.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.seqmessage; 2 | 3 | import com.starcor.xulapp.message.XulMessageCenter; 4 | import com.starcor.xulapp.message.XulSubscriber; 5 | 6 | import java.util.concurrent.ConcurrentHashMap; 7 | import java.util.concurrent.ConcurrentMap; 8 | 9 | /** 10 | * Created by ZFB on 2015/12/8 0008. 11 | */ 12 | public abstract class XulSeqMsgDataDispatcher { 13 | 14 | public XulSeqMsgDataDispatcher(XulMessageCenter msgCenter) { 15 | msgCenter.register(this); 16 | } 17 | 18 | public XulSeqMsgDataDispatcher() { 19 | this(XulMessageCenter.getDefault()); 20 | } 21 | 22 | private ConcurrentMap _handlers = 23 | new ConcurrentHashMap(); 24 | 25 | @XulSubscriber 26 | public void onXulSeqMsgData(XulSeqMsgData seqMsgData) { 27 | if (seqMsgData.getSeqId() == XulSeqMsgData.DEFAULT_SEQ_ID) { 28 | onNewMessageSeq(seqMsgData); 29 | } 30 | dispatch(seqMsgData); 31 | } 32 | 33 | public void registerSeqHandler(XulSeqMsgData seqMsgData, XulSeqMessageHandler handler) { 34 | _handlers.put(seqMsgData.getMsgId(), handler); 35 | } 36 | 37 | public void dispatch(XulSeqMsgData seqMsgData) { 38 | final XulSeqMessageHandler handler = _handlers.get(seqMsgData.getMsgId()); 39 | if (handler != null) { 40 | handler.handleSeqMessage(seqMsgData); 41 | } 42 | } 43 | 44 | public abstract void onNewMessageSeq(XulSeqMsgData msg); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/handler/XulUiThreadMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.handler; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | import com.starcor.xulapp.message.XulMessage; 7 | import com.starcor.xulapp.message.XulSubscription; 8 | 9 | 10 | /** 11 | * 消息处理在UI线程,通过Handler将消息处理post到UI线程的消息队列 12 | */ 13 | public class XulUiThreadMessageHandler implements XulMessageHandler { 14 | 15 | /** 16 | * default handler 17 | */ 18 | private XulDefaultMessageHandler _messageHandler = new XulDefaultMessageHandler(); 19 | 20 | /** 21 | * ui handler 22 | */ 23 | private Handler _uiHandler = new Handler(Looper.getMainLooper()); 24 | 25 | /** 26 | * 将订阅的函数执行在主线程中 27 | */ 28 | @Override 29 | public void handleMessage(final XulSubscription subscription) { 30 | XulMessage xulMessage = subscription.getXulMessage(); 31 | if (xulMessage == null) { 32 | return; 33 | } 34 | 35 | _uiHandler.postDelayed(new Runnable() { 36 | 37 | @Override 38 | public void run() { 39 | if (subscription.isInvalid()) { 40 | // subscriber has dead or message has been canceled. 41 | return; 42 | } 43 | 44 | XulMessage xulMessage = subscription.getXulMessage(); 45 | 46 | if (xulMessage == null) { 47 | return; 48 | } 49 | 50 | int repeat = xulMessage.getRepeat(); 51 | if (repeat <= 0) { 52 | // 不需要执行 53 | return; 54 | } 55 | 56 | _messageHandler.handleMessage(subscription); 57 | if (--repeat > 0) { 58 | xulMessage.setRepeat(repeat); 59 | _uiHandler.postDelayed(this, xulMessage.getInterval()); 60 | } 61 | } 62 | }, xulMessage.getDelay()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/XulQueryableData.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul; 2 | 3 | import com.starcor.xul.Prop.XulBinding; 4 | import com.starcor.xul.Utils.XulBindingSelector; 5 | 6 | import java.io.InputStream; 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by hy on 2014/8/19. 11 | */ 12 | public class XulQueryableData { 13 | ArrayList _dataSet = new ArrayList(); 14 | 15 | public XulQueryableData(InputStream stream) { 16 | try { 17 | XulDataNode build = XulDataNode.build(stream); 18 | if (build != null) { 19 | _dataSet.add(build); 20 | } 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | 26 | public XulQueryableData(ArrayList dataSet) { 27 | for (int i = 0; i < dataSet.size(); i++) { 28 | XulDataNode node = dataSet.get(i); 29 | _dataSet.add(node); 30 | } 31 | } 32 | 33 | public XulQueryableData(XulDataNode node) { 34 | _dataSet.add(node); 35 | } 36 | 37 | ArrayList query(String selector) { 38 | return XulBindingSelector.selectData(new XulBindingSelector.IXulDataSelectContext() { 39 | @Override 40 | public boolean isEmpty() { 41 | return false; 42 | } 43 | 44 | @Override 45 | public XulBinding getDefaultBinding() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public XulBinding getBindingById(String id) { 51 | return null; 52 | } 53 | }, selector, _dataSet); 54 | } 55 | 56 | public String queryString(String selector) { 57 | ArrayList result = query(selector); 58 | if (result == null || result.isEmpty()) { 59 | return null; 60 | } 61 | XulDataNode xulDataNode = result.get(0); 62 | return xulDataNode.getValue(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /XulDemo/assets/provinces/provinces_data.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | cities_data_0.xml 5 | 6 | 7 | cities_data_1.xml 8 | 9 | 10 | cities_data_2.xml 11 | 12 | 13 | cities_data_3.xml 14 | 15 | 16 | cities_data_1.xml 17 | 18 | 19 | cities_data_2.xml 20 | 21 | 22 | cities_data_3.xml 23 | 24 | 25 | cities_data_1.xml 26 | 27 | 28 | cities_data_2.xml 29 | 30 | 31 | cities_data_3.xml 32 | 33 | 34 | cities_data_1.xml 35 | 36 | 37 | cities_data_2.xml 38 | 39 | 40 | cities_data_3.xml 41 | 42 | 43 | cities_data_1.xml 44 | 45 | 46 | cities_data_2.xml 47 | 48 | 49 | cities_data_3.xml 50 | 51 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/behavior/XABBindingDemo.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.behavior; 2 | 3 | import com.starcor.xul.XulView; 4 | import com.starcor.xuldemo.utils.log.LogUtil; 5 | 6 | /** 7 | * Created by hy on 2015/8/7. 8 | */ 9 | public class XABBindingDemo extends XulActivityBehavior { 10 | 11 | public static void register() { 12 | XulActivityBehavior.registerBehavior("behavior_binding_demo", new IBehaviorFactory() { 13 | @Override 14 | public XulActivityBehavior create() { 15 | return new XABBindingDemo(); 16 | } 17 | }); 18 | } 19 | 20 | @Override 21 | public void onDoAction(XulView view, String action, String type, String command, 22 | Object userdata) { 23 | final String TAG_BINDING_EVENT = "BindingEvent"; 24 | LogUtil.i(TAG_BINDING_EVENT, action + " " + type + " " + command); 25 | 26 | if ("load".equals(action)) { 27 | 28 | } else if ("ready".equals(action)) { 29 | 30 | } else if ("bindingFinished".equals(action)) { 31 | 32 | } else if ("bindingUpdated".equals(action)) { 33 | 34 | } else if ("incrementalBindingUpdate".equals(action)) { 35 | LogUtil.e( 36 | "Should not print this log! incrementalBindingUpdate has been handled by js!"); 37 | } else if ("incrementalBindingFinished".equals(action)) { 38 | LogUtil.e( 39 | "Should not print this log! incrementalBindingFinished has been handled by js!"); 40 | } else if ("bindingReady".equals(action)) { 41 | 42 | } else if ("bindingError".equals(action)) { 43 | 44 | } else if ("click".equals(action)) { 45 | // 刷新网络绑定源 46 | mXulRenderContext.getPage().refreshBinding("network_source"); 47 | } else { 48 | LogUtil.e("Should not print this log! No other event!"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulAreaChildrenVisibleChangeNotifier.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | import android.util.Pair; 4 | import com.starcor.xul.Render.XulViewRender; 5 | import com.starcor.xul.XulArea; 6 | import com.starcor.xul.XulItem; 7 | import com.starcor.xul.XulView; 8 | 9 | import java.util.ArrayList; 10 | 11 | /** 12 | * Created by hy on 2014/5/23. 13 | */ 14 | public class XulAreaChildrenVisibleChangeNotifier extends XulArea.XulAreaIterator { 15 | ArrayList> notifyStack = new ArrayList>(); 16 | 17 | boolean _isVisible = false; 18 | XulArea _eventSource = null; 19 | 20 | private void notifyItem(XulView view) { 21 | if (!view.isVisible()) { 22 | return; 23 | } 24 | XulViewRender render = view.getRender(); 25 | if (render != null) { 26 | render.onVisibilityChanged(_isVisible, _eventSource); 27 | } 28 | } 29 | 30 | @Override 31 | public boolean onXulArea(int pos, XulArea area) { 32 | notifyItem(area); 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean onXulItem(int pos, XulItem item) { 38 | notifyItem(item); 39 | return true; 40 | } 41 | 42 | public void begin(boolean isVisible, XulArea eventSource) { 43 | if (_eventSource != null) { 44 | notifyStack.add(Pair.create(_eventSource, _isVisible)); 45 | } 46 | _isVisible = isVisible; 47 | _eventSource = eventSource; 48 | } 49 | public void end() { 50 | if (notifyStack.isEmpty()) { 51 | _eventSource = null; 52 | return; 53 | } 54 | Pair oldState = notifyStack.remove(notifyStack.size() - 1); 55 | _isVisible = oldState.second; 56 | _eventSource = oldState.first; 57 | } 58 | 59 | 60 | private static XulAreaChildrenVisibleChangeNotifier g_notifier; 61 | public static XulAreaChildrenVisibleChangeNotifier getNotifier() { 62 | if (g_notifier == null) { 63 | g_notifier = new XulAreaChildrenVisibleChangeNotifier(); 64 | } 65 | return g_notifier; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/utils/SystemUiHiderBase.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.utils; 2 | 3 | import android.app.Activity; 4 | import android.view.View; 5 | import android.view.WindowManager; 6 | 7 | /** 8 | * A base implementation of {@link SystemUiHider}. Uses APIs available in all 9 | * API levels to show and hide the status bar. 10 | */ 11 | public class SystemUiHiderBase extends SystemUiHider { 12 | /** 13 | * Whether or not the system UI is currently visible. This is a cached value 14 | * from calls to {@link #hide()} and {@link #show()}. 15 | */ 16 | private boolean mVisible = true; 17 | 18 | /** 19 | * Constructor not intended to be called by clients. Use 20 | * {@link SystemUiHider#getInstance} to obtain an instance. 21 | */ 22 | protected SystemUiHiderBase(Activity activity, View anchorView, int flags) { 23 | super(activity, anchorView, flags); 24 | } 25 | 26 | @Override 27 | public void setup() { 28 | if ((mFlags & FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES) == 0) { 29 | mActivity.getWindow().setFlags( 30 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 31 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, 32 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 33 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); 34 | } 35 | } 36 | 37 | @Override 38 | public boolean isVisible() { 39 | return mVisible; 40 | } 41 | 42 | @Override 43 | public void hide() { 44 | if ((mFlags & FLAG_FULLSCREEN) != 0) { 45 | mActivity.getWindow().setFlags( 46 | WindowManager.LayoutParams.FLAG_FULLSCREEN, 47 | WindowManager.LayoutParams.FLAG_FULLSCREEN); 48 | } 49 | mOnVisibilityChangeListener.onVisibilityChange(false); 50 | mVisible = false; 51 | } 52 | 53 | @Override 54 | public void show() { 55 | if ((mFlags & FLAG_FULLSCREEN) != 0) { 56 | mActivity.getWindow().setFlags( 57 | 0, 58 | WindowManager.LayoutParams.FLAG_FULLSCREEN); 59 | } 60 | mOnVisibilityChangeListener.onVisibilityChange(true); 61 | mVisible = true; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulAreaChildrenRender.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Rect; 5 | import android.graphics.RectF; 6 | import android.util.Log; 7 | 8 | import com.starcor.xul.Graphics.XulDC; 9 | import com.starcor.xul.Render.XulViewRender; 10 | import com.starcor.xul.XulArea; 11 | import com.starcor.xul.XulView; 12 | 13 | /** 14 | * Created by hy on 2014/5/23. 15 | */ 16 | public class XulAreaChildrenRender extends XulArea.XulViewIterator { 17 | private static final String TAG = XulAreaChildrenRender.class.getSimpleName(); 18 | XulDC dc; 19 | Canvas canvas; 20 | Rect rect; 21 | int xBase; 22 | int yBase; 23 | 24 | private void drawItem(XulView view) { 25 | XulViewRender render = view.getRender(); 26 | if (render == null) { 27 | return; 28 | } 29 | if (!render.isVisible()) { 30 | render.setDrawingSkipped(true); 31 | return; 32 | } 33 | if (render.getDrawingRect() == null) { 34 | Log.w(TAG, "invalid drawing state!!"); 35 | render.setUpdateLayout(); 36 | render.setDrawingSkipped(true); 37 | return; 38 | } 39 | RectF updateRc = render.getUpdateRect(); 40 | updateRc.left += xBase; 41 | updateRc.top += yBase; 42 | updateRc.right += xBase; 43 | updateRc.bottom += yBase; 44 | if (canvas.quickReject(updateRc.left, updateRc.top, updateRc.right, updateRc.bottom, Canvas.EdgeType.AA)) { 45 | render.setDrawingSkipped(true); 46 | return; 47 | } 48 | render.setDrawingSkipped(false); 49 | if (render.needPostDraw()) { 50 | dc.postDraw(view, rect, xBase, yBase, render.getZIndex()); 51 | } else { 52 | view.draw(dc, rect, xBase, yBase); 53 | } 54 | } 55 | 56 | @Override 57 | public boolean onXulView(int pos, XulView view) { 58 | drawItem(view); 59 | return true; 60 | } 61 | 62 | public void init(XulDC dc, Rect rect, int xBase, int yBase) { 63 | this.dc = dc; 64 | this.canvas = dc.getCanvas(); 65 | this.rect = rect; 66 | this.xBase = xBase; 67 | this.yBase = yBase; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /XulDemo/assets/xul_massive_ltr_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1 7 | 8 | 9 | 2 10 | 11 | 12 | 3 13 | 14 | 15 | 4 16 | 17 | 18 | 5 19 | 20 | 21 | 6 22 | 23 | 24 | 7 25 | 26 | 27 | 8 28 | 29 | 30 | 9 31 | 32 | 33 | 10 34 | 35 | 36 | 11 37 | 38 | 39 | 12 40 | 41 | 42 | 43 | 44 | 45 | grid-fixed 46 | reverse-horizontal 47 | 60 | 61 | 62 | 63 | 68 | 71 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Utils/XulAreaChildrenCollectorByClass.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Utils; 2 | 3 | import com.starcor.xul.XulArea; 4 | import com.starcor.xul.XulItem; 5 | import com.starcor.xul.XulView; 6 | 7 | import java.util.ArrayList; 8 | 9 | public class XulAreaChildrenCollectorByClass extends XulArea.XulAreaIterator { 10 | XulArrayList _result = new XulArrayList(); 11 | ArrayList _classSet = new ArrayList(); 12 | boolean _isAny = true; 13 | 14 | public void begin(String clsName) { 15 | begin(true, clsName); 16 | } 17 | 18 | public void begin(String... clsNames) { 19 | begin(true, clsNames); 20 | } 21 | 22 | public void begin(boolean isAny, String... clsNames) { 23 | _classSet.clear(); 24 | _isAny = isAny; 25 | int length = clsNames.length; 26 | for (int i = 0; i < length; i++) { 27 | String clsName = clsNames[i]; 28 | _classSet.add(clsName); 29 | } 30 | _result.clear(); 31 | } 32 | 33 | public XulArrayList end() { 34 | return _result; 35 | } 36 | 37 | public void clear() { 38 | _result.clear(); 39 | } 40 | 41 | private boolean testAny(XulView view) { 42 | for (int i = 0; i < _classSet.size(); i++) { 43 | String clsName = _classSet.get(i); 44 | if (view.hasClass(clsName)) { 45 | return true; 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | private boolean testAll(XulView view) { 52 | for (int i = 0; i < _classSet.size(); i++) { 53 | String clsName = _classSet.get(i); 54 | if (!view.hasClass(clsName)) { 55 | return false; 56 | } 57 | } 58 | return true; 59 | } 60 | 61 | private void doCollect(XulView view) { 62 | if (_isAny) { 63 | if (testAny(view)) { 64 | _result.add(view); 65 | } 66 | 67 | } else { 68 | if (testAll(view)) { 69 | _result.add(view); 70 | } 71 | } 72 | } 73 | 74 | @Override 75 | public boolean onXulArea(int pos, XulArea area) { 76 | doCollect(area); 77 | area.eachChild(this); 78 | return true; 79 | } 80 | 81 | @Override 82 | public boolean onXulItem(int pos, XulItem item) { 83 | doCollect(item); 84 | return true; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/V8/V8Script.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script.V8; 2 | 3 | import android.util.Log; 4 | import com.starcor.xul.Script.IScript; 5 | import com.starcor.xul.Script.IScriptContext; 6 | import com.starcor.xul.Script.IScriptFinalize; 7 | import com.starcor.xul.Script.IScriptableObject; 8 | import com.starcor.xul.Script.XulScriptFinalizeCollector; 9 | import com.starcor.xul.XulManager; 10 | 11 | /** 12 | * Created by hy on 2015/6/17. 13 | */ 14 | public class V8Script implements IScript,IScriptFinalize { 15 | public static final String TAG = V8Script.class.getSimpleName(); 16 | V8ScriptContext _ctx; 17 | long _nativeId; 18 | 19 | @Override 20 | protected void finalize() throws Throwable { 21 | if (XulManager.DEBUG_V8_ENGINE) { 22 | Log.d(TAG, String.format("finalize ctx:%x, id:%x", _ctx._nativeId, _nativeId)); 23 | } 24 | markGC(); 25 | super.finalize(); 26 | } 27 | 28 | V8Script(V8ScriptContext ctx, long nativeScriptId) { 29 | this._ctx = ctx; 30 | this._nativeId = nativeScriptId; 31 | } 32 | 33 | public static V8Script wrapNativeScript(V8ScriptContext ctx, long scriptId) { 34 | return new V8Script(ctx, scriptId); 35 | } 36 | 37 | public void run() { 38 | V8Engine.v8RunScript(_ctx._nativeId, _nativeId); 39 | } 40 | 41 | @Override 42 | public String getScriptType() { 43 | return V8ScriptContext.DEFAULT_SCRIPT_TYPE; 44 | } 45 | 46 | @Override 47 | public Object run(IScriptContext ctx, IScriptableObject ctxObj) { 48 | this.run(); 49 | return null; 50 | } 51 | 52 | @Override 53 | public Object run(IScriptContext ctx, IScriptableObject ctxObj, Object[] args) { 54 | this.run(); 55 | return null; 56 | } 57 | 58 | @Override 59 | public void doFinalize() { 60 | if (XulManager.DEBUG_V8_ENGINE) { 61 | Log.d(TAG, String.format("doFinalize ctx:%x, id:%x", _ctx._nativeId, _nativeId)); 62 | } 63 | V8Engine.v8DestroyScript(_ctx._nativeId, _nativeId); 64 | } 65 | 66 | @Override 67 | public void markGC() { 68 | if (XulManager.DEBUG_V8_ENGINE) { 69 | Log.d(TAG, String.format("markGC ctx:%x, id:%x", _ctx._nativeId, _nativeId)); 70 | } 71 | XulScriptFinalizeCollector.register(this); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Effect/CompositeAnimation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Effect; 2 | 3 | import com.starcor.xul.Render.Drawer.IXulAnimation; 4 | import com.starcor.xul.Render.XulViewRender; 5 | import com.starcor.xul.Utils.XulSimpleArray; 6 | import com.starcor.xul.XulView; 7 | 8 | import java.lang.ref.WeakReference; 9 | 10 | /** 11 | * Created by hy on 2015/7/29. 12 | */ 13 | public class CompositeAnimation implements IXulAnimation { 14 | 15 | public interface BasicAnimation { 16 | void start(long timestamp); 17 | boolean isRunning(); 18 | boolean updateAnimation(long timestamp, CompositeAnimation ownerAnimation); 19 | } 20 | 21 | public static class SimpleAnimation implements BasicAnimation { 22 | protected WeakReference _view; 23 | protected WeakReference _render; 24 | 25 | protected long _duration; 26 | private long _beginTime; 27 | private BasicAnimation _nextAnimation; 28 | private boolean _isRunning = false; 29 | 30 | public SimpleAnimation(XulView view) { 31 | _view = view.getWeakReference(); 32 | _render = new WeakReference(view.getRender()); 33 | } 34 | 35 | @Override 36 | public void start(long timestamp) { 37 | 38 | } 39 | 40 | @Override 41 | public boolean isRunning() { 42 | return _isRunning; 43 | } 44 | 45 | @Override 46 | public boolean updateAnimation(long timestamp, CompositeAnimation ownerAnimation) { 47 | return false; 48 | } 49 | } 50 | 51 | public static class BasicAnimationArray extends XulSimpleArray implements BasicAnimation { 52 | private boolean _isRunning = false; 53 | 54 | @Override 55 | protected BasicAnimation[] allocArrayBuf(int size) { 56 | return new BasicAnimation[size]; 57 | } 58 | 59 | @Override 60 | public void start(long timestamp) { 61 | 62 | } 63 | 64 | @Override 65 | public boolean isRunning() { 66 | return _isRunning; 67 | } 68 | 69 | @Override 70 | public boolean updateAnimation(long timestamp, CompositeAnimation ownerAnimation) { 71 | return false; 72 | } 73 | } 74 | 75 | BasicAnimationArray _animations; 76 | @Override 77 | public boolean updateAnimation(long timestamp) { 78 | return false; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/XulAreaRender.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render; 2 | 3 | import android.graphics.Rect; 4 | import com.starcor.xul.Graphics.XulDC; 5 | import com.starcor.xul.Prop.XulFocus; 6 | import com.starcor.xul.Utils.XulAreaChildrenRender; 7 | import com.starcor.xul.Utils.XulLayoutHelper; 8 | import com.starcor.xul.*; 9 | 10 | /** 11 | * Created by hy on 2014/5/12. 12 | */ 13 | public class XulAreaRender extends XulViewContainerBaseRender { 14 | public static void register() { 15 | XulRenderFactory.registerBuilder("area", "*", new XulRenderFactory.RenderBuilder() { 16 | @Override 17 | protected XulViewRender createRender(XulRenderContext ctx, XulView view) { 18 | assert view instanceof XulArea; 19 | return new XulAreaRender(ctx, (XulArea) view); 20 | } 21 | }); 22 | } 23 | 24 | @Override 25 | public boolean hitTest(int event, float x, float y) { 26 | return super.hitTest(XulManager.HIT_EVENT_DUMMY, x, y); 27 | } 28 | 29 | protected XulAreaChildrenRender _childrenRender = createChildrenRender(); 30 | 31 | protected XulAreaChildrenRender createChildrenRender() { 32 | return new XulAreaChildrenRender(); 33 | } 34 | 35 | public XulAreaRender(XulRenderContext ctx, XulArea area) { 36 | super(ctx, area); 37 | } 38 | 39 | @Override 40 | public void draw(XulDC dc, Rect rect, int xBase, int yBase) { 41 | if (_isInvisible()) { 42 | return; 43 | } 44 | super.draw(dc, rect, xBase, yBase); 45 | _childrenRender.init(dc, rect, xBase, yBase); 46 | _area.eachView(_childrenRender); 47 | } 48 | 49 | @Override 50 | public int getDefaultFocusMode() { 51 | return XulFocus.MODE_NOFOCUS|XulFocus.MODE_NEARBY|XulFocus.MODE_PRIORITY; 52 | } 53 | 54 | protected class LayoutContainer extends XulViewContainerBaseRender.LayoutContainer { 55 | @Override 56 | public Rect getMargin() { 57 | if (_margin == null) { 58 | if (_area.getType() == XulTemplate.TEMPLATE_CONTAINER) { 59 | if (_area.getChildNum() == 1) { 60 | XulView child = _area.getChild(0); 61 | if (child != null) { 62 | return child.getRender().getLayoutElement().getMargin(); 63 | } 64 | } 65 | } 66 | return super.getMargin(); 67 | } 68 | return _margin; 69 | } 70 | } 71 | 72 | @Override 73 | protected XulLayoutHelper.ILayoutElement createElement() { 74 | return new LayoutContainer(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/XulStickyDataCallback.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model; 2 | 3 | import com.starcor.xul.XulDataNode; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Created by hy on 2015/10/8. 9 | */ 10 | public class XulStickyDataCallback extends XulDataCallback { 11 | static class TargetCallback { 12 | XulDataServiceContext ctx; 13 | XulDataService.Clause clause; 14 | XulDataCallback callback; 15 | 16 | public TargetCallback(XulDataServiceContext ctx, XulDataService.Clause clause, XulDataCallback callback) { 17 | this.ctx = ctx; 18 | this.clause = clause; 19 | this.callback = callback; 20 | } 21 | } 22 | 23 | ArrayList _cbs; 24 | int _state = 0; // 0 for uninitialized, 1 for success, others for failed 25 | int _code; 26 | String _msg; 27 | XulDataNode _data; 28 | 29 | @Override 30 | public void onResult(XulDataService.Clause clause, int code, XulDataNode data) { 31 | handlePendingCallbacks(1, clause, data); 32 | } 33 | 34 | @Override 35 | public void onError(XulDataService.Clause clause, int code) { 36 | handlePendingCallbacks(2, clause, null); 37 | } 38 | 39 | private void handlePendingCallbacks(int state, XulDataService.Clause clause, XulDataNode data) { 40 | if (_state != 0) { 41 | return; 42 | } 43 | _state = state; 44 | _code = clause.getError(); 45 | _msg = clause.getMessage(); 46 | _data = data; 47 | if (_cbs == null) { 48 | return; 49 | } 50 | for (TargetCallback cb : _cbs) { 51 | addCallback(cb.ctx, cb.clause, cb.callback); 52 | } 53 | _cbs.clear(); 54 | } 55 | 56 | /** 57 | * add pending result callback 58 | * if the sticky callback has been already triggered, the newly added callback will be invoked synchronously 59 | * @param ctx 60 | * @param clause 61 | * @param callback 62 | * @return the number of pending callbacks 63 | */ 64 | public int addCallback(XulDataServiceContext ctx, XulDataService.Clause clause, XulDataCallback callback) { 65 | if (_state == 0) { 66 | if (_cbs == null) { 67 | _cbs = new ArrayList(); 68 | } 69 | _cbs.add(new TargetCallback(ctx, clause, callback)); 70 | return _cbs.size(); 71 | } 72 | clause.setError(_code, _msg); 73 | if (_state == 1) { 74 | ctx.deliverResult(callback, clause, _data); 75 | } else { 76 | ctx.deliverError(callback, clause); 77 | } 78 | return 0; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/XulPendingInputStream.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * Created by hy on 2014/5/28. 8 | */ 9 | public class XulPendingInputStream extends InputStream { 10 | volatile InputStream _baseStream = null; 11 | volatile boolean _isCancelled = false; 12 | 13 | public boolean checkPending() { 14 | if (_baseStream == null && !_isCancelled) { 15 | synchronized (this) { 16 | try { 17 | this.wait(10 * 1000); 18 | } catch (InterruptedException e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | return _baseStream == null; 23 | } 24 | return false; 25 | } 26 | 27 | public void cancel() { 28 | _isCancelled = true; 29 | _baseStream = null; 30 | synchronized (this) { 31 | this.notifyAll(); 32 | } 33 | } 34 | 35 | public void setBaseStream(InputStream stream) { 36 | _isCancelled = false; 37 | _baseStream = stream; 38 | synchronized (this) { 39 | this.notifyAll(); 40 | } 41 | } 42 | 43 | public void reload() { 44 | _isCancelled = false; 45 | _baseStream = null; 46 | synchronized (this) { 47 | this.notifyAll(); 48 | } 49 | } 50 | 51 | public boolean isReady() { 52 | return _baseStream != null; 53 | } 54 | 55 | @Override 56 | public int available() throws IOException { 57 | return _baseStream.available(); 58 | } 59 | 60 | @Override 61 | public void close() throws IOException { 62 | _baseStream.close(); 63 | } 64 | 65 | @Override 66 | public void mark(int readlimit) { 67 | _baseStream.mark(readlimit); 68 | } 69 | 70 | @Override 71 | public boolean markSupported() { 72 | return _baseStream.markSupported(); 73 | } 74 | 75 | @Override 76 | public int read() throws IOException { 77 | return _baseStream.read(); 78 | } 79 | 80 | @Override 81 | public int read(byte[] buffer) throws IOException { 82 | return _baseStream.read(buffer); 83 | } 84 | 85 | @Override 86 | public int read(byte[] buffer, int offset, int length) throws IOException { 87 | return _baseStream.read(buffer, offset, length); 88 | } 89 | 90 | @Override 91 | public synchronized void reset() throws IOException { 92 | _baseStream.reset(); 93 | } 94 | 95 | @Override 96 | public long skip(long byteCount) throws IOException { 97 | return _baseStream.skip(byteCount); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/utils/XulBitmapUtil.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.graphics.Canvas; 6 | import android.graphics.PixelFormat; 7 | import android.graphics.drawable.BitmapDrawable; 8 | import android.graphics.drawable.Drawable; 9 | 10 | import java.io.ByteArrayOutputStream; 11 | 12 | /** 13 | * 缓存辅助工具类 14 | * 15 | * Created by ZFB on 2015/9/21. 16 | */ 17 | public class XulBitmapUtil { 18 | 19 | /** 20 | * Bitmap 转 byte[] 21 | */ 22 | public static byte[] bitmap2Bytes(Bitmap bm) { 23 | if (bm == null) { 24 | return null; 25 | } 26 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 27 | bm.compress(Bitmap.CompressFormat.PNG, 100, baos); 28 | return baos.toByteArray(); 29 | } 30 | 31 | /** 32 | * byte[] 转 Bitmap 33 | */ 34 | public static Bitmap bytes2Bitmap(byte[] b) { 35 | if (b.length == 0) { 36 | return null; 37 | } 38 | return BitmapFactory.decodeByteArray(b, 0, b.length); 39 | } 40 | 41 | /** 42 | * Drawable 转 Bitmap 43 | */ 44 | public static Bitmap drawable2Bitmap(Drawable drawable) { 45 | if (drawable == null) { 46 | return null; 47 | } 48 | // 取 drawable 的长宽 49 | int w = drawable.getIntrinsicWidth(); 50 | int h = drawable.getIntrinsicHeight(); 51 | // 取 drawable 的颜色格式 52 | Bitmap.Config config = 53 | drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 54 | : Bitmap.Config.RGB_565; 55 | // 建立对应 bitmap 56 | Bitmap bitmap = Bitmap.createBitmap(w, h, config); 57 | // 建立对应 bitmap 的画布 58 | Canvas canvas = new Canvas(bitmap); 59 | drawable.setBounds(0, 0, w, h); 60 | // 把 drawable 内容画到画布中 61 | drawable.draw(canvas); 62 | return bitmap; 63 | } 64 | 65 | /** 66 | * Bitmap 转 Drawable 67 | */ 68 | @SuppressWarnings("deprecation") 69 | public static Drawable bitmap2Drawable(Bitmap bm) { 70 | if (bm == null) { 71 | return null; 72 | } 73 | BitmapDrawable bd = new BitmapDrawable(bm); 74 | bd.setTargetDensity(bm.getDensity()); 75 | return new BitmapDrawable(bm); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cacheimplement/XulMemoryCache.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cacheimplement; 2 | 3 | 4 | import android.graphics.Bitmap; 5 | import android.graphics.drawable.Drawable; 6 | 7 | import com.starcor.xulapp.cache.XulCacheModel; 8 | 9 | import org.json.JSONArray; 10 | import org.json.JSONObject; 11 | 12 | import java.io.ByteArrayInputStream; 13 | import java.io.InputStream; 14 | 15 | /** 16 | * Created by ZFB on 2015/9/21. 17 | */ 18 | public class XulMemoryCache extends XulCacheImpl { 19 | 20 | public XulMemoryCache(long maxSize, int maxCount) { 21 | super(maxSize, maxCount); 22 | } 23 | 24 | @Override 25 | public InputStream getAsStream(XulCacheModel cacheModel) { 26 | Object data = cacheModel.getData(); 27 | if (data instanceof InputStream) { 28 | return (InputStream) data; 29 | } 30 | if (data instanceof byte[]) { 31 | return new ByteArrayInputStream(getAsBinary(cacheModel)); 32 | } 33 | return null; 34 | } 35 | 36 | @Override 37 | public String getAsString(XulCacheModel cacheModel) { 38 | Object data = cacheModel.getData(); 39 | if (data instanceof String) { 40 | return (String) data; 41 | } 42 | return String.valueOf(data); 43 | } 44 | 45 | @Override 46 | public JSONObject getAsJSONObject(XulCacheModel cacheModel) { 47 | Object data = cacheModel.getData(); 48 | if (data instanceof JSONObject) { 49 | return (JSONObject) data; 50 | } 51 | return null; 52 | } 53 | 54 | @Override 55 | public JSONArray getAsJSONArray(XulCacheModel cacheModel) { 56 | Object data = cacheModel.getData(); 57 | if (data instanceof JSONArray) { 58 | return (JSONArray) data; 59 | } 60 | return null; 61 | } 62 | 63 | @Override 64 | public byte[] getAsBinary(XulCacheModel cacheModel) { 65 | Object data = cacheModel.getData(); 66 | if (data instanceof byte[]) { 67 | return (byte[]) data; 68 | } 69 | return null; 70 | } 71 | 72 | @Override 73 | public Object getAsObject(XulCacheModel cacheModel) { 74 | return cacheModel.getData(); 75 | } 76 | 77 | @Override 78 | public Bitmap getAsBitmap(XulCacheModel cacheModel) { 79 | Object data = cacheModel.getData(); 80 | if (data instanceof Bitmap) { 81 | return (Bitmap) data; 82 | } 83 | return null; 84 | } 85 | 86 | @Override 87 | public Drawable getAsDrawable(XulCacheModel cacheModel) { 88 | Object data = cacheModel.getData(); 89 | if (data instanceof Drawable) { 90 | return (Drawable) data; 91 | } 92 | return null; 93 | } 94 | 95 | @Override 96 | public void close() { 97 | clear(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Prop/XulProp.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Prop; 2 | 3 | import android.text.TextUtils; 4 | import com.starcor.xul.XulUtils; 5 | 6 | /** 7 | * Created by hy on 2014/5/4. 8 | */ 9 | public class XulProp { 10 | boolean _referent = true; 11 | int _nameId = -1; 12 | Object _value; 13 | String _binding; 14 | String _desc; 15 | boolean _pending = true; 16 | int _priority = 0; 17 | private XulBinding _bindingSource; 18 | 19 | XulProp() { 20 | } 21 | 22 | XulProp(XulProp orgProp) { 23 | this._nameId = orgProp._nameId; 24 | this._value = orgProp._value; 25 | this._binding = orgProp._binding; 26 | this._desc = orgProp._desc; 27 | this._pending = orgProp._pending; 28 | this._priority = orgProp._priority; 29 | this._bindingSource = orgProp._bindingSource; 30 | this._referent = false; 31 | } 32 | 33 | public boolean isReferent() { 34 | return _referent; 35 | } 36 | 37 | public int getPriority() { 38 | return _priority; 39 | } 40 | 41 | // 属性数据是否为动态绑定模式 42 | public boolean isBinding() { 43 | return !TextUtils.isEmpty(_binding); 44 | } 45 | 46 | // 数据是否等待绑定 47 | public boolean isBindingPending() { 48 | if (_bindingSource != null) { 49 | return _bindingSource.isUpdated(); 50 | } 51 | return isBinding() && _pending; 52 | } 53 | 54 | // 设置数据已绑定 55 | public void setBindingReady() { 56 | _pending = false; 57 | } 58 | 59 | public String getBinding() { 60 | return _binding; 61 | } 62 | 63 | public String getName() { 64 | return XulPropNameCache.id2Name(_nameId); 65 | } 66 | 67 | public int getNameId() { 68 | return _nameId; 69 | } 70 | 71 | public String getStringValue() { 72 | return _value == null ? XulUtils.STR_EMPTY : String.valueOf(_value); 73 | } 74 | 75 | public Object getValue() { 76 | return _value; 77 | } 78 | 79 | public void setValue(Object value) { 80 | if (value instanceof String) { 81 | _value = XulUtils.getCachedString((String) value); 82 | } else { 83 | _value = value; 84 | } 85 | } 86 | 87 | public XulProp makeClone() { 88 | return this; 89 | } 90 | 91 | public void setBinding(String binding) { 92 | this._binding = XulUtils.getCachedString(binding); 93 | } 94 | 95 | public void setPriority(int priority) { 96 | this._priority = priority; 97 | } 98 | 99 | public void setBindingSource(XulBinding bindingSource) { 100 | this._bindingSource = bindingSource; 101 | if (this._bindingSource == null) { 102 | _pending = true; 103 | } 104 | } 105 | 106 | public XulBinding getBindingSource() { 107 | return _bindingSource; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Text/XulTextRenderer.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Text; 2 | 3 | import android.graphics.Paint; 4 | 5 | import com.starcor.xul.Graphics.XulDC; 6 | import com.starcor.xul.XulWorker; 7 | 8 | /** 9 | * Created by hy on 2015/12/11. 10 | */ 11 | public abstract class XulTextRenderer { 12 | public abstract void drawText(XulDC dc, float xBase, float yBase, float clientViewWidth, float clientViewHeight); 13 | 14 | public abstract void stopAnimation(); 15 | 16 | public abstract Paint getTextPaint(); 17 | 18 | public abstract boolean isMultiline(); 19 | 20 | public abstract boolean isAutoWrap(); 21 | 22 | public abstract boolean isDrawingEllipsis(); 23 | 24 | public abstract float getHeight(); 25 | 26 | public abstract float getLineHeight(); 27 | 28 | public abstract float getWidth(); 29 | 30 | public abstract boolean isEmpty(); 31 | 32 | public abstract XulTextEditor edit(); 33 | 34 | public abstract XulWorker.DrawableItem collectPendingImageItem(); 35 | 36 | public abstract String getText(); 37 | 38 | public abstract class XulTextEditor { 39 | public abstract XulTextEditor setText(String newText); 40 | 41 | public abstract XulTextEditor setSuperResample(float superResample); 42 | 43 | public abstract XulTextEditor fontScaleX(float fontScaleX); 44 | 45 | public abstract XulTextEditor setFontStrikeThrough(boolean fontStrikeThrough); 46 | 47 | public abstract XulTextEditor setFontFace(String fontFace); 48 | 49 | public abstract XulTextEditor setLineHeightScalar(float lineHeightScalar); 50 | 51 | public abstract XulTextEditor setUnderline(boolean underline); 52 | 53 | public abstract XulTextEditor setItalic(boolean italic); 54 | 55 | public abstract XulTextEditor setFixHalfChar(boolean fixHalfChar); 56 | 57 | public abstract XulTextEditor setFontSize(float fontSize); 58 | 59 | public abstract XulTextEditor setStartIndent(float startIndent); 60 | 61 | public abstract XulTextEditor setEndIndent(float endIndent); 62 | 63 | public abstract XulTextEditor setFontColor(int color); 64 | 65 | public abstract XulTextEditor setFontWeight(float weight); 66 | 67 | public abstract XulTextEditor setFontShadow(float xOff, float yOff, float size, int color); 68 | 69 | public abstract XulTextEditor setFontAlignment(float xAlign, float yAlign); 70 | 71 | public abstract XulTextEditor setMultiline(boolean multiline); 72 | 73 | public abstract XulTextEditor setAutoWrap(boolean autoWrap); 74 | 75 | public abstract XulTextEditor setDrawEllipsis(boolean drawEllipsis); 76 | 77 | public abstract void finish(boolean recalAutoWrap); 78 | 79 | public abstract boolean defMultiline(); 80 | 81 | public abstract boolean defAutoWrap(); 82 | 83 | public abstract boolean defDrawEllipsis(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/utils/log/LogFilter.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.utils.log; 2 | 3 | import android.text.TextUtils; 4 | 5 | import java.security.InvalidParameterException; 6 | 7 | /** 8 | * Decide which log will be written to the file. 9 | * 10 | * @author zhangfeibiao 11 | */ 12 | public abstract class LogFilter { 13 | 14 | /** 15 | * if true, filter the log. 16 | */ 17 | public abstract boolean filter(LogUtil.LEVEL level, String tag, String msg); 18 | 19 | public static class TagFilter extends LogFilter { 20 | 21 | private String mTag = null; 22 | 23 | /** 24 | * set the tag which will not be filtered. 25 | * 26 | * if the tag is null or empty, then nothing will be filtered.. 27 | */ 28 | public TagFilter(String tag) { 29 | this.mTag = tag; 30 | } 31 | 32 | @Override 33 | public boolean filter(LogUtil.LEVEL level, String tag, String msg) { 34 | if (TextUtils.isEmpty(this.mTag)) { 35 | return false; 36 | } 37 | 38 | if (this.mTag.equals(tag)) { 39 | return false; 40 | } 41 | 42 | return true; 43 | } 44 | 45 | } 46 | 47 | public static class LevelFilter extends LogFilter { 48 | 49 | private LogUtil.LEVEL mLevel = null; 50 | 51 | /** 52 | * set the Level.Any log with the level below it will be filtered. 53 | * 54 | * @param level the minimum level which will not be filtered. 55 | */ 56 | public LevelFilter(LogUtil.LEVEL level) { 57 | if (level == null) { 58 | throw new InvalidParameterException("level is null or not valid."); 59 | } 60 | 61 | this.mLevel = level; 62 | } 63 | 64 | @Override 65 | public boolean filter(LogUtil.LEVEL level, String tag, String msg) { 66 | return level.getLevel() < this.mLevel.getLevel(); 67 | } 68 | } 69 | 70 | public static class ContentFilter extends LogFilter { 71 | 72 | private String mMsg = null; 73 | 74 | public ContentFilter(String msg) { 75 | this.mMsg = msg; 76 | } 77 | 78 | @Override 79 | public boolean filter(LogUtil.LEVEL level, String tag, String msg) { 80 | if (level == null || TextUtils.isEmpty(tag) || TextUtils.isEmpty(msg)) { 81 | return true; 82 | } 83 | 84 | if (TextUtils.isEmpty(this.mMsg)) { 85 | return false; 86 | } 87 | 88 | if (tag.contains(this.mMsg) || msg.contains(this.mMsg)) { 89 | return false; 90 | } 91 | 92 | return true; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Drawer/XulAnimationDrawer.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Drawer; 2 | 3 | import android.graphics.Paint; 4 | import android.graphics.Rect; 5 | import android.graphics.RectF; 6 | import com.starcor.xul.Graphics.XulAnimationDrawable; 7 | import com.starcor.xul.Graphics.XulDC; 8 | import com.starcor.xul.Graphics.XulDrawable; 9 | import com.starcor.xul.XulRenderContext; 10 | import com.starcor.xul.XulView; 11 | 12 | /** 13 | * Created by hy on 2014/6/21. 14 | */ 15 | public class XulAnimationDrawer extends XulDrawer implements IXulAnimation { 16 | XulRenderContext _renderCtx; 17 | XulView _ownerView; 18 | XulAnimationDrawable _drawable; 19 | XulAnimationDrawable.AnimationDrawingContext _aniCtx; 20 | boolean _terminated = true; 21 | 22 | public static XulAnimationDrawer create(XulDrawable drawable, XulView owner, XulRenderContext render) { 23 | if (owner == null || drawable == null) { 24 | return null; 25 | } 26 | XulAnimationDrawer drawer = new XulAnimationDrawer(); 27 | drawer._renderCtx = render; 28 | drawer._ownerView = owner; 29 | drawer._drawable = (XulAnimationDrawable) drawable; 30 | drawer._aniCtx = drawer._drawable.createDrawingCtx(); 31 | return drawer; 32 | } 33 | 34 | @Override 35 | public void reset() { 36 | _terminated = true; 37 | } 38 | 39 | @Override 40 | public void draw(XulDC dc, XulDrawable drawable, Rect src, Rect dst, Paint paint) { 41 | if (_terminated) { 42 | _terminated = false; 43 | _aniCtx.reset(); 44 | _renderCtx.addAnimation(this); 45 | } 46 | _drawable.drawAnimation(_aniCtx, dc, dst, paint); 47 | } 48 | 49 | @Override 50 | public void draw(XulDC dc, XulDrawable drawable, Rect src, RectF dst, Paint paint) { 51 | if (_terminated) { 52 | _terminated = false; 53 | _aniCtx.reset(); 54 | _renderCtx.addAnimation(this); 55 | } 56 | _drawable.drawAnimation(_aniCtx, dc, dst, paint); 57 | } 58 | 59 | @Override 60 | public void draw(XulDC dc, XulDrawable drawable, Rect dst, Paint paint) { 61 | if (_terminated) { 62 | _terminated = false; 63 | _aniCtx.reset(); 64 | _renderCtx.addAnimation(this); 65 | } 66 | _drawable.drawAnimation(_aniCtx, dc, dst, paint); 67 | } 68 | 69 | @Override 70 | public void draw(XulDC dc, XulDrawable drawable, RectF dst, Paint paint) { 71 | if (_terminated) { 72 | _terminated = false; 73 | _aniCtx.reset(); 74 | _renderCtx.addAnimation(this); 75 | } 76 | _drawable.drawAnimation(_aniCtx, dc, dst, paint); 77 | } 78 | 79 | @Override 80 | public boolean updateAnimation(long timestamp) { 81 | if (_terminated) { 82 | return false; 83 | } 84 | boolean animationFinished = _aniCtx.isAnimationFinished(); 85 | if (_aniCtx.updateAnimation(timestamp)) { 86 | // 动画已经更新 87 | _ownerView.markDirtyView(); 88 | } 89 | return !animationFinished; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/XulCacheModel.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache; 2 | 3 | import android.text.TextUtils; 4 | 5 | import java.io.File; 6 | 7 | /** 8 | * Created by ZFB on 2015/9/25. 9 | */ 10 | public class XulCacheModel { 11 | private XulCacheDomain _owner; 12 | 13 | /** 14 | * 缓存数据键值 15 | */ 16 | private String _key; 17 | 18 | /** 19 | * 缓存数据 20 | */ 21 | private Object _data; 22 | 23 | /** 24 | * 缓存数据最后访问时间 25 | */ 26 | private long _lastAccessTime; 27 | 28 | public XulCacheModel() { 29 | _lastAccessTime = System.currentTimeMillis(); 30 | } 31 | 32 | public XulCacheModel(String key, Object data) { 33 | this(key, data, System.currentTimeMillis()); 34 | } 35 | 36 | public XulCacheModel(String key, Object data, long lastAccessTime) { 37 | _key = key; 38 | _data = data; 39 | _lastAccessTime = lastAccessTime; 40 | } 41 | 42 | public XulCacheModel(XulCacheModel other) { 43 | _key = other._key; 44 | _data = other._data; 45 | _lastAccessTime = other._lastAccessTime; 46 | } 47 | 48 | /** 49 | * 判断cache数据是否有效 50 | */ 51 | public static boolean isValid(XulCacheModel cacheData) { 52 | return (cacheData != null) && !TextUtils.isEmpty(cacheData.getKey()) 53 | && (cacheData.getData() != null); 54 | } 55 | 56 | /** 57 | * 以byte为单位返回缓存数据大小 58 | */ 59 | public long size() { 60 | // 根据缓存数据实际类型计算其大小 61 | if (_data instanceof String) { 62 | return ((String) _data).getBytes().length; 63 | } else if (_data instanceof byte[]) { 64 | return ((byte[]) _data).length; 65 | } else if (_data instanceof File) { 66 | return ((File) _data).length(); 67 | } else { 68 | // 无法计算或,默认返回0 69 | return 0; 70 | } 71 | } 72 | 73 | public String getKey() { 74 | return _key; 75 | } 76 | 77 | public void setKey(String key) { 78 | _key = key; 79 | } 80 | 81 | public Object getData() { 82 | return _data; 83 | } 84 | 85 | public void setData(Object data) { 86 | _data = data; 87 | } 88 | 89 | public long getLastAccessTime() { 90 | return _lastAccessTime; 91 | } 92 | 93 | public void setLastAccessTime(long lastAccessTime) { 94 | _lastAccessTime = lastAccessTime; 95 | } 96 | 97 | public void updateLastAccessTime() { 98 | long currentTime = System.currentTimeMillis(); 99 | if (_lastAccessTime >= currentTime) { 100 | return; 101 | } 102 | _lastAccessTime = currentTime; 103 | } 104 | 105 | public void setOwner(XulCacheDomain owner) { 106 | _owner = owner; 107 | } 108 | 109 | public XulCacheDomain getOwner() { 110 | return _owner; 111 | } 112 | 113 | @Override 114 | public int hashCode() { 115 | return _key.hashCode(); 116 | } 117 | 118 | @Override 119 | public boolean equals(Object o) { 120 | return _key.equals(((XulCacheModel) o)._key); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cachedomain/XulPropertyCacheDomain.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cachedomain; 2 | 3 | import com.starcor.xulapp.cache.XulCacheModel; 4 | import com.starcor.xulapp.message.XulMessageCenter; 5 | import com.starcor.xulapp.message.XulSubscriber; 6 | import com.starcor.xulapp.message.XulThreadMode; 7 | 8 | import java.io.File; 9 | import java.util.concurrent.atomic.AtomicBoolean; 10 | 11 | /** 12 | * Created by ZFB on 2015/10/21. 13 | */ 14 | public class XulPropertyCacheDomain extends XulWriteBackCacheDomain { 15 | 16 | private static final int INTERVAL_TO_SAVE_DATA = 200; 17 | private static final int MSG_TAG_SAVE_DATA_TO_FILE = 0x0001; 18 | 19 | private final AtomicBoolean _isUpdated = new AtomicBoolean(false); 20 | private final XulMessageCenter _propertyMsgCenter; 21 | 22 | public XulPropertyCacheDomain(long maxSize, int maxCount, 23 | File cacheDir, long maxFileSize, int maxFileCount) { 24 | super(maxSize, maxCount, cacheDir, maxFileSize, maxFileCount); 25 | 26 | _propertyMsgCenter = new XulMessageCenter(TAG); 27 | _propertyMsgCenter.register(this); 28 | _propertyMsgCenter.post(MSG_TAG_SAVE_DATA_TO_FILE, null, 29 | INTERVAL_TO_SAVE_DATA, Integer.MAX_VALUE, INTERVAL_TO_SAVE_DATA); 30 | } 31 | 32 | 33 | @XulSubscriber(tag = MSG_TAG_SAVE_DATA_TO_FILE, mode = XulThreadMode.ASYNC) 34 | public void onSaveTime(Object data) { 35 | if (_isUpdated.getAndSet(false)) { 36 | // 更新过数据,需要写入文件缓存 37 | for (XulCacheModel cache : _memoryCache.getAllCaches()) { 38 | if (null ==_fileCache.getCache(cache.getKey(), false)) { 39 | _fileCache.putCache(cache); 40 | } 41 | } 42 | } 43 | } 44 | 45 | @Override 46 | public void close() { 47 | super.close(); 48 | _propertyMsgCenter.unregister(this); 49 | } 50 | 51 | @Override 52 | protected boolean putCache(XulCacheModel cacheData) { 53 | boolean isUpdated = super.putCache(cacheData); 54 | if (isUpdated) { 55 | _isUpdated.set(true); 56 | } 57 | return isUpdated; 58 | } 59 | 60 | @Override 61 | protected XulCacheModel removeCache(String md5Key) { 62 | XulCacheModel cache = super.removeCache(md5Key); 63 | if (cache != null) { 64 | _isUpdated.set(true); 65 | } 66 | return cache; 67 | } 68 | 69 | @Override 70 | protected XulCacheModel removeNextCache() { 71 | XulCacheModel cache = super.removeNextCache(); 72 | if (cache != null) { 73 | _isUpdated.set(true); 74 | } 75 | return cache; 76 | } 77 | 78 | public boolean getIsUpdated() { 79 | return _isUpdated.get(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/cache/cacherecycle/XulCacheRecycle.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.cache.cacherecycle; 2 | 3 | import com.starcor.xulapp.cache.XulCacheDomain; 4 | import com.starcor.xulapp.cache.XulCacheModel; 5 | 6 | import java.util.Collection; 7 | import java.util.concurrent.ConcurrentLinkedQueue; 8 | import java.util.concurrent.ConcurrentMap; 9 | 10 | /** 11 | * Created by ZFB on 2015/9/28. 12 | */ 13 | public class XulCacheRecycle { 14 | 15 | // 回收策略枚举 16 | public static final int STRATEGY_NO_RECYCLE = 0x0001; 17 | public static final int STRATEGY_EXPIRED = 0x0002; 18 | public static final int STRATEGY_RECENTLY_UNUSED = 0x0003; 19 | 20 | private XulCacheDomain _cacheDomain; 21 | private ConcurrentLinkedQueue _strategies; 22 | 23 | public XulCacheRecycle(XulCacheDomain cacheDomain) { 24 | _cacheDomain = cacheDomain; 25 | _strategies = new ConcurrentLinkedQueue(); 26 | } 27 | 28 | /** 29 | * 添加回收策略 回收时会按照添加策略的先后顺序依次回收,直到找到下一个回收对象 30 | */ 31 | public void addRecycleStrategy(int recycleStrategy) { 32 | XulRecycleStrategy newStrategy = getRecycleStrategy(recycleStrategy); 33 | if (newStrategy != null && !_strategies.contains(newStrategy)) { 34 | _strategies.add(newStrategy); 35 | } 36 | } 37 | 38 | private XulRecycleStrategy getRecycleStrategy(int recycleStrategyFlag) { 39 | XulRecycleStrategy strategy = null; 40 | switch (recycleStrategyFlag) { 41 | case STRATEGY_EXPIRED: 42 | strategy = new XulExpireStrategy(_cacheDomain); 43 | break; 44 | case STRATEGY_RECENTLY_UNUSED: 45 | strategy = new XulRecentlyUnusedStrategy(); 46 | break; 47 | case STRATEGY_NO_RECYCLE: 48 | strategy = new XulNoRecycleStrategy(); 49 | break; 50 | default: 51 | strategy = null; 52 | break; 53 | } 54 | return strategy; 55 | } 56 | 57 | public void removeRecycleStrategy(int recycleStrategy) { 58 | _strategies.remove(getRecycleStrategy(recycleStrategy)); 59 | } 60 | 61 | public void clear() { 62 | _strategies.clear(); 63 | } 64 | 65 | public boolean containsRecycleStrategy(int recycleStrategy) { 66 | return _strategies.contains(getRecycleStrategy(recycleStrategy)); 67 | } 68 | 69 | public XulCacheModel recycle(ConcurrentMap caches) { 70 | XulCacheModel cache = null; 71 | for (XulRecycleStrategy strategy : _strategies) { 72 | cache = strategy.findRecycledCache(caches.values()); 73 | if (cache != null) { 74 | caches.remove(cache.getKey()); 75 | break; 76 | } 77 | } 78 | 79 | return cache; 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Effect/QuiverAnimation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Effect; 2 | 3 | import android.util.Log; 4 | import com.starcor.xul.Render.Drawer.IXulAnimation; 5 | import com.starcor.xul.Render.Transform.ITransformer; 6 | import com.starcor.xul.Render.Transform.TransformerFactory; 7 | import com.starcor.xul.Render.XulViewRender; 8 | import com.starcor.xul.XulManager; 9 | 10 | /** 11 | * Created by hy on 2015/6/2. 12 | */ 13 | public abstract class QuiverAnimation implements IXulAnimation { 14 | public final static String DEFAULT_MODE = "pow"; 15 | public final static float[] DEFAULT_PARAMS = new float[]{0.15f, 0f, 0f, 0f, 0f, 0f}; 16 | private final XulViewRender _render; 17 | ITransformer _transformer; 18 | long _duration = 120; 19 | long _begin; 20 | float _xStrength; 21 | float _yStrength; 22 | int _repeat = 1; 23 | float _repeatStrength = 1; 24 | 25 | public QuiverAnimation(XulViewRender render, float xStrength, float yStrength, int repeat, float repeatStrength) { 26 | this._render = render; 27 | this._xStrength = xStrength; 28 | this._yStrength = yStrength; 29 | this._repeat = Math.max(repeat, 1); 30 | this._repeatStrength = Math.max(repeatStrength, 0.01f); 31 | _begin = _render.animationTimestamp(); 32 | _transformer = TransformerFactory.createTransformer(DEFAULT_MODE, DEFAULT_PARAMS); 33 | } 34 | 35 | public void switchMode(String mode, float[] params) { 36 | _transformer.switchAlgorithm(mode); 37 | _transformer.switchParams(params); 38 | } 39 | 40 | public void updateDuration(int duration) { 41 | _duration = duration; 42 | } 43 | 44 | @Override 45 | public boolean updateAnimation(long timestamp) { 46 | long l = timestamp - _begin; 47 | long duration = _duration / _repeat; 48 | float percent = (float) (l) / duration; 49 | float pval; 50 | float roundScalar = percent / _repeat; 51 | percent = (float) (4.0f * (percent - Math.floor(percent))); 52 | if (percent <= 1.0f) { 53 | // phase 1 54 | pval = _transformer.transform(percent * duration, duration, 0, 0); 55 | } else if (percent <= 2.0f) { 56 | pval = _transformer.transform((2.0f - percent) * duration, duration, 0, 0); 57 | } else if (percent <= 3.0f) { 58 | pval = -_transformer.transform((percent - 2.0f) * duration, duration, 0, 0); 59 | } else { 60 | pval = -_transformer.transform((4.0f - percent) * duration, duration, 0, 0); 61 | } 62 | pval = pval * (1.0f + roundScalar * (_repeatStrength - 1.0f)); 63 | if (XulManager.DEBUG) { 64 | Log.d("quiver", String.format("percent:%.3f, pval:%.3f, roundScalar:%.3f, repeatStrength:%.3f\n", percent, pval, roundScalar, _repeatStrength)); 65 | } 66 | 67 | boolean ret = doQuiver(timestamp - _begin, _xStrength * pval, _yStrength * pval); 68 | if (!ret) { 69 | _render.onAnimationFinished(true); 70 | } 71 | return ret; 72 | } 73 | 74 | public abstract boolean doQuiver(long duration, float xDelta, float yDelta); 75 | } 76 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/behavior/XABMassiveDemo.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.behavior; 2 | 3 | import android.widget.Toast; 4 | 5 | import com.starcor.xul.Wrapper.XulMassiveAreaWrapper; 6 | import com.starcor.xul.XulDataNode; 7 | import com.starcor.xul.XulUtils; 8 | import com.starcor.xul.XulView; 9 | 10 | /** 11 | * Created by hy on 2015/8/7. 12 | */ 13 | public class XABMassiveDemo extends XulActivityBehavior { 14 | 15 | public static void register() { 16 | XulActivityBehavior.registerBehavior("behavior_massive_demo", new IBehaviorFactory() { 17 | @Override 18 | public XulActivityBehavior create() { 19 | return new XABMassiveDemo(); 20 | } 21 | }); 22 | } 23 | 24 | @Override 25 | public void onDoAction(XulView view, String action, String type, String command, Object userdata) { 26 | if ("add-items".equals(action)) { 27 | XulView itemById = mXulRenderContext.getPage().findItemById("massive-area"); 28 | XulMassiveAreaWrapper xulMassiveAreaWrapper = XulMassiveAreaWrapper.fromXulView(itemById); 29 | int baseId = xulMassiveAreaWrapper.itemNum(); 30 | int num = XulUtils.tryParseInt(command, 0); 31 | for (int i = 0; i < num; i++) { 32 | XulDataNode dataNode = XulDataNode.obtainDataNode("item"); 33 | dataNode.setValue(String.valueOf(baseId + i + 1)); 34 | xulMassiveAreaWrapper.addItem(dataNode); 35 | } 36 | xulMassiveAreaWrapper.syncContentView(); 37 | } else if ("clean-items".equals(action)) { 38 | XulView itemById = mXulRenderContext.getPage().findItemById("massive-area"); 39 | XulMassiveAreaWrapper xulMassiveAreaWrapper = XulMassiveAreaWrapper.fromXulView(itemById); 40 | xulMassiveAreaWrapper.clear(); 41 | } else if ("update-items".equals(action)) { 42 | XulDataNode dataNode = XulDataNode.obtainDataNode("item"); 43 | dataNode.setValue("new value"); 44 | XulView itemById = mXulRenderContext.getPage().findItemById("massive-area"); 45 | XulMassiveAreaWrapper xulMassiveAreaWrapper = XulMassiveAreaWrapper.fromXulView(itemById); 46 | xulMassiveAreaWrapper.updateItems(2, dataNode,dataNode,dataNode,dataNode); 47 | } else if ("make-child-visible".equals(action)) { 48 | XulView itemById = mXulRenderContext.getPage().findItemById("massive-area"); 49 | final XulMassiveAreaWrapper xulMassiveAreaWrapper = XulMassiveAreaWrapper.fromXulView(itemById); 50 | 51 | final int targetItem = (int) (Math.random()*xulMassiveAreaWrapper.itemNum()); 52 | 53 | Toast.makeText(mXulActivity, "Make child visible" + targetItem, Toast.LENGTH_SHORT).show(); 54 | 55 | xulMassiveAreaWrapper.makeChildVisible(itemById.findParentByType("slider"), targetItem, 0.5f, Float.NaN, true, new Runnable() { 56 | @Override 57 | public void run() { 58 | XulView itemView = xulMassiveAreaWrapper.getItemView(targetItem); 59 | if (itemView != null) { 60 | mXulRenderContext.getLayout().requestFocus(itemView); 61 | } 62 | } 63 | }); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/XulScriptFinalizeCollector.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Created by skycnlr on 2018/6/6. 7 | */ 8 | public class XulScriptFinalizeCollector { 9 | private static volatile ArrayList _addObjects = new ArrayList(); 10 | private static volatile ArrayList _clearObjects = new ArrayList(); 11 | private static Object _lock = new Object(); 12 | 13 | private static volatile Thread _collectThread; 14 | 15 | static { 16 | _collectThread = new Thread() { 17 | @Override 18 | public void run() { 19 | while (_collectThread != null) { 20 | try { 21 | doFinalize(); 22 | } catch (Exception e) { 23 | e.printStackTrace(); 24 | } 25 | 26 | try { 27 | Thread.sleep(100); 28 | } catch (InterruptedException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | } 33 | }; 34 | _collectThread.setName("XulScriptFinalizeCollector Thread"); 35 | _collectThread.setPriority(Thread.MIN_PRIORITY); 36 | _collectThread.start(); 37 | } 38 | 39 | public static void register(Object o) { 40 | if (o == null) { 41 | return; 42 | } 43 | if (!(o instanceof IScriptFinalize)) { 44 | return; 45 | } 46 | synchronized (_lock) { 47 | _addObjects.add(o); 48 | } 49 | } 50 | 51 | public static void stop() { 52 | if (_collectThread != null) { 53 | try { 54 | _collectThread.interrupt(); 55 | _collectThread = null; 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | } 61 | 62 | @Override 63 | protected void finalize() throws Throwable { 64 | stop(); 65 | super.finalize(); 66 | } 67 | 68 | private static void doFinalize() { 69 | synchronized (_lock) { 70 | ArrayList tmp = _clearObjects; 71 | _clearObjects = _addObjects; 72 | _addObjects = tmp; 73 | } 74 | int count = _clearObjects.size(); 75 | if (count <= 0) { 76 | return; 77 | } 78 | int idx = count - 1; 79 | for (; idx > -1; idx--) { 80 | Object o = _clearObjects.get(idx); 81 | if (o == null) { 82 | continue; 83 | } 84 | try { 85 | if (o instanceof IScriptFinalize) { 86 | ((IScriptFinalize) o).doFinalize(); 87 | } 88 | } catch (Exception e) { 89 | 90 | } finally { 91 | _clearObjects.remove(idx); 92 | } 93 | } 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/message/handler/XulAsyncMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.message.handler; 2 | 3 | import com.starcor.xulapp.message.XulMessage; 4 | import com.starcor.xulapp.message.XulSubscription; 5 | import com.starcor.xulapp.utils.XulLog; 6 | 7 | import java.util.concurrent.Executors; 8 | import java.util.concurrent.ScheduledExecutorService; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | 12 | /** 13 | * 消息的异步处理,将消息的处理函数执行在子线程中 14 | */ 15 | public class XulAsyncMessageHandler implements XulMessageHandler { 16 | 17 | /** 18 | * 消息分发线程 19 | */ 20 | private final ScheduledExecutorService _dispatcherService = 21 | Executors.newSingleThreadScheduledExecutor(); 22 | 23 | /** 24 | * 消息处理器 25 | */ 26 | private XulMessageHandler _messageHandler = new XulDefaultMessageHandler(); 27 | 28 | /** 29 | * 对象锁 30 | */ 31 | private Object _waitLock = new Object(); 32 | 33 | /** 34 | * 将订阅的函数执行在异步线程中 35 | */ 36 | @Override 37 | public void handleMessage(final XulSubscription subscription) { 38 | XulMessage xulMessage = subscription.getXulMessage(); 39 | if (xulMessage == null) { 40 | return; 41 | } 42 | 43 | _dispatcherService.schedule(new Runnable() { 44 | @Override 45 | public void run() { 46 | if (subscription.isInvalid()) { 47 | // subscriber has dead or message has been canceled. 48 | return; 49 | } 50 | 51 | XulMessage xulMessage = subscription.getXulMessage(); 52 | 53 | if (xulMessage == null) { 54 | return; 55 | } 56 | 57 | int repeat = xulMessage.getRepeat(); 58 | if (repeat <= 0) { 59 | // 不需要执行 60 | return; 61 | } 62 | 63 | _messageHandler.handleMessage(subscription); 64 | if (--repeat > 0) { 65 | xulMessage.setRepeat(repeat); 66 | _dispatcherService.schedule( 67 | this, xulMessage.getInterval(), TimeUnit.MILLISECONDS); 68 | } else { 69 | if (xulMessage.getIsSyncMessage()) { 70 | // 消息处理结束,释放对象锁 71 | synchronized (_waitLock) { 72 | _waitLock.notify(); 73 | } 74 | } 75 | } 76 | } 77 | }, xulMessage.getDelay(), TimeUnit.MILLISECONDS); 78 | 79 | if (xulMessage.getIsSyncMessage()) { 80 | waitHandleFinished(); 81 | } 82 | } 83 | 84 | private void waitHandleFinished() { 85 | synchronized (_waitLock) { 86 | try { 87 | _waitLock.wait(); 88 | } catch (InterruptedException e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/utils/XulTime.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.utils; 2 | 3 | import com.starcor.xul.XulUtils; 4 | 5 | import java.util.SimpleTimeZone; 6 | import java.util.TimeZone; 7 | 8 | /** 9 | * Created by hy on 2015/12/18. 10 | */ 11 | public class XulTime { 12 | private static final String TAG = XulTime.class.getSimpleName(); 13 | private static long _xulTimeDelta = System.currentTimeMillis() - XulUtils.timestamp(); 14 | private static long _meanDifference = 0; 15 | private static int _tzOffset = 0; 16 | private static TimeZone _tzObject = null; 17 | 18 | public static final long ONE_HOUR_SEC = 60 * 60; 19 | public static final long ONE_HOUR_MS = ONE_HOUR_SEC * 1000; 20 | public static final long ONE_DAY_SEC = ONE_HOUR_SEC * 24; 21 | public static final long ONE_DAY_MS = ONE_HOUR_MS * 24; 22 | 23 | private static synchronized boolean doSyncTime(long serverTime, long timestamp, long delay) { 24 | delay /= 1.7; 25 | long serverTimeDelta = serverTime - timestamp + delay; 26 | long diff = Math.abs(serverTimeDelta - _xulTimeDelta); 27 | if (delay >= _meanDifference || _meanDifference <= 0 || diff > 1.5*(_meanDifference + delay)) { 28 | if (diff < (_meanDifference + delay)) { 29 | return false; 30 | } 31 | _meanDifference = diff * delay / (_meanDifference + delay); 32 | } 33 | double ratio = (double) delay / _meanDifference; 34 | _xulTimeDelta = (long) (serverTimeDelta + (_xulTimeDelta - serverTimeDelta) * ratio); 35 | _meanDifference = (long) (delay + (_meanDifference - delay) * ratio); 36 | XulLog.d(TAG, "doSyncTime delta:", _xulTimeDelta, " mean:", _meanDifference, " delay:", delay, " ratio:", ratio); 37 | XulLog.d(TAG, "doSyncTime " + XulSystemUtil.formatDuring(currentTimeMillis() + getTimeZoneOffsetMS())); 38 | return _meanDifference < 300; 39 | } 40 | 41 | public static boolean syncTime(long serverTime, long delay) { 42 | return doSyncTime(serverTime, XulUtils.timestamp(), delay); 43 | } 44 | 45 | public static long timestampToTime(long timestamp) { 46 | return _xulTimeDelta + timestamp; 47 | } 48 | 49 | public static long timeToTimestamp(long time) { 50 | return time - _xulTimeDelta; 51 | } 52 | 53 | public static void setTimeZoneOffset(int tzOffset) { 54 | _tzOffset = tzOffset; 55 | _tzObject = null; 56 | } 57 | 58 | public static int getTimeZoneOffset() { 59 | return _tzOffset; 60 | } 61 | 62 | public static long getTimeZoneOffsetMS() { 63 | return _tzOffset * ONE_HOUR_MS; 64 | } 65 | 66 | public static TimeZone getTimeZone() { 67 | if (_tzObject == null) { 68 | _tzObject = new SimpleTimeZone((int) (_tzOffset * ONE_HOUR_MS), ""); 69 | } 70 | return _tzObject; 71 | } 72 | 73 | public static boolean isSameDate(long t1, long t2) { 74 | long tzOffsetMS = _tzOffset * ONE_HOUR_MS; 75 | long date1 = (t1 + tzOffsetMS) / ONE_DAY_MS; 76 | long date2 = (t2 + tzOffsetMS) / ONE_DAY_MS; 77 | return date1 == date2; 78 | } 79 | 80 | public static long currentTimeMillis() { 81 | return XulUtils.timestamp() + _xulTimeDelta; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /XulDemo/assets/xul_max_min_width_height_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | vertical 8 | match_parent 9 | 10 | 11 | TEXT 992年,Mary J. Blige分布第一张个人唱片《What's the 411?》。1996年凭借歌曲“I'll Be There For You/You're All I Need To Get 12 | true 13 | true 14 | 15 | 16 | 17 | keep minimum height 18 | true 19 | true 20 | 21 | 22 | 23 | true 24 | true 25 | 26 | 27 | 28 | 29 | 30 | 31 | TEST 32 | 33 | 34 | 35 | 36 | file:///.assets/png/about_logo.png 37 | 38 | 39 | 40 | file:///.assets/png/about_logo.png 41 | center 42 | 80 43 | 44 | 45 | 46 | file:///.assets/png/about_logo.png 47 | center 48 | 500 49 | 50 | 51 | 52 | 53 | 54 | 57 | 66 | 73 | 76 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Graphics/XulDrawable.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Graphics; 2 | 3 | import android.graphics.*; 4 | import android.graphics.drawable.Drawable; 5 | 6 | import java.io.InputStream; 7 | 8 | /** 9 | * Created by hy on 2014/5/27. 10 | */ 11 | public abstract class XulDrawable { 12 | String _url; 13 | String _key; 14 | volatile boolean _isRecycled = false; 15 | 16 | public boolean cacheable() { 17 | return true; 18 | } 19 | 20 | public boolean isRecycled() { 21 | return _isRecycled; 22 | } 23 | 24 | public void recycle() { 25 | _isRecycled = true; 26 | } 27 | 28 | public static XulDrawable fromNinePatchBitmap(Bitmap bmp, String url, String imageKey) { 29 | if (bmp == null) { 30 | return null; 31 | } 32 | 33 | return XulNinePatchDrawable.build(bmp, url, imageKey); 34 | } 35 | 36 | public static XulDrawable fromColor(int color, int width, int height, String url, String imageKey) { 37 | XulColorDrawable drawable = new XulColorDrawable(color, width, height); 38 | drawable._url = url; 39 | drawable._key = imageKey; 40 | return drawable; 41 | } 42 | 43 | public static XulDrawable fromColor(int color, int width, int height, float radiusX, float radiusY, String url, String imageKey) { 44 | XulColorDrawable drawable = new XulColorDrawable(color, width, height, radiusX, radiusY); 45 | drawable._url = url; 46 | drawable._key = imageKey; 47 | return drawable; 48 | } 49 | 50 | public static XulDrawable fromColor(int color, int width, int height, float[] roundRectRadius, String url, String imageKey) { 51 | XulColorDrawable drawable = new XulColorDrawable(color, width, height, roundRectRadius); 52 | drawable._url = url; 53 | drawable._key = imageKey; 54 | return drawable; 55 | } 56 | 57 | public static XulDrawable fromBitmap(Bitmap bitmap, String url, String imageKey) { 58 | if (bitmap == null) { 59 | return null; 60 | } 61 | XulBitmapDrawable drawable = new XulBitmapDrawable(); 62 | drawable._bmp = bitmap; 63 | drawable._url = url; 64 | drawable._key = imageKey; 65 | return drawable; 66 | } 67 | 68 | public static XulDrawable fromDrawable(final Drawable drawable, String url, String imageKey) { 69 | if (drawable == null) { 70 | return null; 71 | } 72 | XulDrawable xulDrawable = new XulAndroidDrawable(drawable); 73 | xulDrawable._url = url; 74 | xulDrawable._key = imageKey; 75 | return xulDrawable; 76 | } 77 | 78 | public static XulDrawable fromGIFFile(InputStream is, String url, String imageKey) { 79 | return XulGIFAnimationDrawable.buildAnimation(is, url, imageKey); 80 | } 81 | 82 | public abstract boolean draw(Canvas canvas, Rect rc, Rect dst, Paint paint); 83 | 84 | public abstract boolean draw(Canvas canvas, Rect rc, RectF dst, Paint paint); 85 | 86 | public abstract int getHeight(); 87 | 88 | public abstract int getWidth(); 89 | 90 | public final String getUrl() { 91 | return _url; 92 | } 93 | 94 | public final String getKey() { 95 | return _key; 96 | } 97 | 98 | public XulDrawable makeClone() { 99 | return null; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Wrapper/XulGroupAreaWrapper.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Wrapper; 2 | 3 | import com.starcor.xul.Render.XulGroupRender; 4 | import com.starcor.xul.XulArea; 5 | import com.starcor.xul.XulView; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by hy on 2014/6/3. 11 | */ 12 | public class XulGroupAreaWrapper extends XulViewWrapper { 13 | public static XulGroupAreaWrapper fromXulView(XulView view) { 14 | if (view == null) { 15 | return null; 16 | } 17 | if (!(view.getRender() instanceof XulGroupRender)) { 18 | return null; 19 | } 20 | return new XulGroupAreaWrapper((XulArea) view); 21 | } 22 | 23 | XulArea _area; 24 | 25 | XulGroupAreaWrapper(XulArea area) { 26 | super(area); 27 | _area = area; 28 | } 29 | 30 | public void setAllUnchecked() { 31 | XulGroupRender render = (XulGroupRender) _area.getRender(); 32 | if (render == null) { 33 | return; 34 | } 35 | render.setAllUnchecked(); 36 | } 37 | 38 | // CHECK模式:设置所有项为选中状态 39 | // RADIO模式:设置第一项为选中状态 40 | public void setAllChecked() { 41 | XulGroupRender render = (XulGroupRender) _area.getRender(); 42 | if (render == null) { 43 | return; 44 | } 45 | render.setAllChecked(); 46 | } 47 | 48 | public void setUnchecked(XulView view) { 49 | XulGroupRender render = (XulGroupRender) _area.getRender(); 50 | if (render == null) { 51 | return; 52 | } 53 | render.setUnchecked(view); 54 | } 55 | 56 | public void setChecked(XulView view) { 57 | XulGroupRender render = (XulGroupRender) _area.getRender(); 58 | if (render == null) { 59 | return; 60 | } 61 | render.setChecked(view); 62 | } 63 | 64 | public boolean isChecked(XulView view) { 65 | XulGroupRender render = (XulGroupRender) _area.getRender(); 66 | if (render == null) { 67 | return false; 68 | } 69 | return render.isChecked(view); 70 | } 71 | 72 | public ArrayList getAllGroupItems() { 73 | XulGroupRender render = (XulGroupRender) _area.getRender(); 74 | if (render == null) { 75 | return null; 76 | } 77 | return render.getAllGroupItems(); 78 | } 79 | 80 | public ArrayList> getAllGroups() { 81 | XulGroupRender render = (XulGroupRender) _area.getRender(); 82 | if (render == null) { 83 | return null; 84 | } 85 | return render.getAllGroups(); 86 | } 87 | 88 | public ArrayList getGroupByItem(XulView view) { 89 | XulGroupRender render = (XulGroupRender) _area.getRender(); 90 | if (render == null) { 91 | return null; 92 | } 93 | return render.getGroupByItem(view); 94 | } 95 | 96 | public ArrayList getAllCheckedItems() { 97 | XulGroupRender render = (XulGroupRender) _area.getRender(); 98 | if (render == null) { 99 | return null; 100 | } 101 | return render.getAllCheckedItems(); 102 | } 103 | 104 | public ArrayList> getAllCheckedGroups() { 105 | XulGroupRender render = (XulGroupRender) _area.getRender(); 106 | if (render == null) { 107 | return null; 108 | } 109 | return render.getAllCheckedGroups(); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Render/Transform/Algorithm/ConstantTransform.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Render.Transform.Algorithm; 2 | 3 | /** 4 | * Created by hy on 2015/5/26. 5 | */ 6 | public class ConstantTransform extends BasicTransformAlgorithmImpl { 7 | @Override 8 | public String name() { 9 | return "constant"; 10 | } 11 | 12 | @Override 13 | public float transform(float[] params, float time, float duration, float fromVal, float toVal) { 14 | float speed = params[0]; 15 | float startDuration = params[1]; 16 | float endDuration = params[2]; 17 | if (speed <= 0) { 18 | return -1000.0f; 19 | } 20 | 21 | float v0 = speed / duration; // px/ms 22 | 23 | float totalRange = Math.abs(toVal - fromVal); 24 | 25 | if (totalRange <= 0.01f) { 26 | return -1000.0f; 27 | } 28 | 29 | float startRange = startDuration * v0 / 2; 30 | float endRange = endDuration * v0 / 2; 31 | float cRange = totalRange - startRange - endRange; 32 | if (cRange <= 0) { 33 | cRange = 0; 34 | startRange = totalRange * startRange / (startDuration + endDuration); 35 | endRange = totalRange - startRange; 36 | } 37 | 38 | float t = cRange / v0; 39 | 40 | float pos; 41 | if (time <= startDuration) { 42 | if (startDuration > 0) { 43 | pos = (float) (Math.pow(time / startDuration, 2) * startRange); 44 | } else { 45 | pos = 0; 46 | } 47 | } else if (time > startDuration + t) { 48 | if (endDuration > 0) { 49 | float v = (time - startDuration - t) / endDuration; 50 | if (v > 1.0f) { 51 | v = 0; 52 | } else { 53 | v = 1.0f - v; 54 | } 55 | pos = totalRange - v * v * endRange; 56 | } else { 57 | pos = totalRange; 58 | } 59 | } else if (t > 0) { 60 | pos = startRange + (time - startDuration) / t * cRange; 61 | } else { 62 | pos = startRange + cRange; 63 | } 64 | 65 | if (pos >= totalRange) { 66 | return -1000; 67 | } 68 | 69 | return pos / totalRange; 70 | } 71 | 72 | @Override 73 | public UpdateResult update(float[] params, long begin, long duration, long progress, float curVal, float srcVal, float oldDestVal, float newDestVal) { 74 | boolean isSameDirection = (oldDestVal - curVal) * (newDestVal - curVal) >= 0; 75 | float startDuration = params[1]; 76 | updateResult.newDest = newDestVal; 77 | updateResult.newSrc = curVal; 78 | if (isSameDirection) { 79 | if (startDuration > 0) { 80 | if (progress >= startDuration) { 81 | updateResult.newBegin = (long) (begin + progress - startDuration); 82 | float percentage = transform(params, startDuration, duration, srcVal, newDestVal); 83 | if (percentage <= -1000) { 84 | percentage = 1; 85 | } 86 | float delta = percentage * (newDestVal - srcVal); 87 | updateResult.newSrc = curVal - delta; 88 | } else { 89 | updateResult.newBegin = begin; 90 | updateResult.newSrc = srcVal; 91 | } 92 | } else { 93 | updateResult.newBegin = begin + progress; 94 | } 95 | } else { 96 | updateResult.newBegin = begin + 2 * progress - duration; 97 | } 98 | return updateResult; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/behavior/XABSelectorSliderDemo.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.behavior; 2 | 3 | import android.text.TextUtils; 4 | import android.widget.RelativeLayout; 5 | 6 | import com.starcor.xul.IXulExternalView; 7 | import com.starcor.xul.Render.XulSliderAreaRender; 8 | import com.starcor.xul.XulArea; 9 | import com.starcor.xul.XulPage; 10 | import com.starcor.xul.XulView; 11 | import com.starcor.xuldemo.utils.log.LogUtil; 12 | import com.starcor.xuldemo.widget.XulExt_ExternalEditBox; 13 | 14 | /** 15 | * Created by hy on 2015/8/7. 16 | */ 17 | public class XABSelectorSliderDemo extends XulActivityBehavior { 18 | 19 | private static final String CITIES_BINDING = "cities"; 20 | private static final String CITIES_DATA_DIR = "file:///.assets/provinces/"; 21 | 22 | public static void register() { 23 | XulActivityBehavior 24 | .registerBehavior("behavior_selector_slider_demo", new IBehaviorFactory() { 25 | @Override 26 | public XulActivityBehavior create() { 27 | return new XABSelectorSliderDemo(); 28 | } 29 | }); 30 | } 31 | 32 | @Override 33 | public void onDoAction(XulView view, String action, String type, String command, 34 | Object userdata) { 35 | if ("onDecide".equals(command)) { 36 | // TODO: 用户选定省份和城市,请在代码中处理业务逻辑 37 | } else if ("onProvinceChecked".equals(command)) { 38 | String citiesData = (String) userdata; 39 | if (TextUtils.isEmpty(citiesData)) { 40 | LogUtil.e("Cities data is empty, please check it!"); 41 | return; 42 | } 43 | 44 | // 请使用InputStream实现 45 | XulPage page = mXulRenderContext.getPage(); 46 | page.refreshBinding(CITIES_BINDING, CITIES_DATA_DIR + citiesData); 47 | } else if ("onCityItemUpdated".equals(command)) { 48 | // 还原city slider状态, 必须在layout后执行 49 | mXulRenderContext.scheduleLayoutFinishedTask(new Runnable() { 50 | @Override 51 | public void run() { 52 | XulPage page = mXulRenderContext.getPage(); 53 | XulArea cityArea = (XulArea) page.findItemById("city_area"); 54 | XulSliderAreaRender sliderRender = (XulSliderAreaRender) page.findItemById( 55 | cityArea, "slider_area").getRender(); 56 | // 若slider没有被显示过,则不需要重置 57 | if (sliderRender.getDrawingRect() != null) { 58 | sliderRender.scrollTo(0, false); 59 | } 60 | } 61 | }); 62 | } 63 | } 64 | 65 | @Override 66 | public IXulExternalView createExternalView(String cls, int x, int y, int width, int height, 67 | XulView view) { 68 | if ("EditBox".equals(cls)) { 69 | XulExt_ExternalEditBox editBox = new XulExt_ExternalEditBox(mXulActivity, view); 70 | ((RelativeLayout) mLayout).addView(editBox, width, height); 71 | return editBox; 72 | } 73 | 74 | return null; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Wrapper/XulImageItemWrapper.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Wrapper; 2 | 3 | import android.graphics.Rect; 4 | import com.starcor.xul.Render.XulImageRender; 5 | import com.starcor.xul.XulView; 6 | 7 | /** 8 | * Created by hy on 2014/6/3. 9 | */ 10 | public class XulImageItemWrapper extends XulViewWrapper { 11 | public static XulImageItemWrapper fromXulView(XulView view) { 12 | if (view == null) { 13 | return null; 14 | } 15 | if (!(view.getRender() instanceof XulImageRender)) { 16 | return null; 17 | } 18 | return new XulImageItemWrapper(view); 19 | } 20 | 21 | XulImageItemWrapper(XulView view) { 22 | super(view); 23 | } 24 | 25 | public boolean hasImageLayer(int idx) { 26 | XulImageRender render = (XulImageRender) _view.getRender(); 27 | if (render == null) { 28 | return false; 29 | } 30 | return render.hasImageLayer(idx); 31 | } 32 | 33 | public int getImageWidth(int layer) { 34 | XulImageRender render = (XulImageRender) _view.getRender(); 35 | if (render == null) { 36 | return -1; 37 | } 38 | return render.getImageWidth(layer); 39 | } 40 | 41 | public int getImageHeight(int layer) { 42 | XulImageRender render = (XulImageRender) _view.getRender(); 43 | if (render == null) { 44 | return -1; 45 | } 46 | return render.getImageHeight(layer); 47 | } 48 | 49 | public boolean resetAnimation(int layer) { 50 | XulImageRender render = (XulImageRender) _view.getRender(); 51 | if (render == null) { 52 | return false; 53 | } 54 | return render.resetAnimation(layer); 55 | } 56 | 57 | public boolean isImageLoaded(int layer) { 58 | XulImageRender render = (XulImageRender) _view.getRender(); 59 | if (render == null) { 60 | return false; 61 | } 62 | return render.isImageLoaded(layer); 63 | } 64 | 65 | public boolean reloadImage(int layer) { 66 | XulImageRender render = (XulImageRender) _view.getRender(); 67 | if (render == null) { 68 | return false; 69 | } 70 | return render.reloadImage(layer); 71 | } 72 | 73 | public boolean isImageVisible(int layer) { 74 | XulImageRender render = (XulImageRender) _view.getRender(); 75 | if (render == null) { 76 | return false; 77 | } 78 | return render.isImageVisible(layer); 79 | } 80 | 81 | public float getImageOpacity(int layer) { 82 | XulImageRender render = (XulImageRender) _view.getRender(); 83 | if (render == null) { 84 | return -1; 85 | } 86 | return render.getImageOpacity(layer); 87 | } 88 | 89 | public String getImageUrl(int layer) { 90 | XulImageRender render = (XulImageRender) _view.getRender(); 91 | if (render == null) { 92 | return null; 93 | } 94 | return render.getImageUrl(layer); 95 | } 96 | 97 | public String getImageResolvedUrl(int layer) { 98 | XulImageRender render = (XulImageRender) _view.getRender(); 99 | if (render == null) { 100 | return null; 101 | } 102 | return render.getImageResolvedUrl(layer); 103 | } 104 | 105 | public Rect getImagePadding(int layer) { 106 | XulImageRender render = (XulImageRender) _view.getRender(); 107 | if (render == null) { 108 | return null; 109 | } 110 | return render.getImagePadding(layer); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /XulDemo/src/com/starcor/xuldemo/behavior/XulActivityBehavior.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xuldemo.behavior; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Rect; 5 | import android.view.View; 6 | 7 | import com.starcor.xul.IXulExternalView; 8 | import com.starcor.xul.XulRenderContext; 9 | import com.starcor.xul.XulView; 10 | import com.starcor.xul.XulWorker; 11 | 12 | import java.io.InputStream; 13 | import java.util.HashMap; 14 | 15 | /** 16 | * Created by hy on 2015/8/7. 17 | */ 18 | public abstract class XulActivityBehavior implements XulRenderContext.IXulRenderHandler { 19 | @Override 20 | public InputStream getSdcardData(XulWorker.DownloadItem item, String path) { 21 | return null; 22 | } 23 | 24 | protected Activity mXulActivity; 25 | protected View mLayout; 26 | protected XulRenderContext mXulRenderContext; 27 | 28 | public void initLayout(Activity xulActivity, View layout) { 29 | mXulActivity = xulActivity; 30 | mLayout = layout; 31 | } 32 | 33 | public void initXulRender(XulRenderContext xulRenderContext) { 34 | mXulRenderContext = xulRenderContext; 35 | } 36 | 37 | @Override 38 | public void invalidate(Rect rect) { 39 | 40 | } 41 | 42 | @Override 43 | public void uiRun(Runnable runnable) { 44 | 45 | } 46 | 47 | @Override 48 | public void uiRun(Runnable runnable, int delayMS) { 49 | 50 | } 51 | 52 | @Override 53 | public void onDoAction(XulView view, String action, String type, String command, 54 | Object userdata) { 55 | 56 | } 57 | 58 | @Override 59 | public IXulExternalView createExternalView(String cls, int x, int y, int width, int height, 60 | XulView view) { 61 | return null; 62 | } 63 | 64 | @Override 65 | public String resolve(XulWorker.DownloadItem item, String path) { 66 | return null; 67 | } 68 | 69 | @Override 70 | public InputStream getAssets(XulWorker.DownloadItem item, String path) { 71 | return null; 72 | } 73 | 74 | @Override 75 | public InputStream getAppData(XulWorker.DownloadItem item, String path) { 76 | return null; 77 | } 78 | 79 | @Override 80 | public void onRenderIsReady() { 81 | 82 | } 83 | 84 | @Override 85 | public void onRenderEvent(int eventId, int param1, int param2, Object msg) { 86 | 87 | } 88 | 89 | public interface IBehaviorFactory { 90 | 91 | XulActivityBehavior create(); 92 | } 93 | 94 | private static HashMap 95 | behaviorMap = 96 | new HashMap(); 97 | 98 | public static void registerBehavior(String behaviorName, IBehaviorFactory factory) { 99 | behaviorMap.put(behaviorName, factory); 100 | } 101 | 102 | public static XulActivityBehavior createBehavior(String behaviorName) { 103 | IBehaviorFactory iBehaviorFactory = behaviorMap.get(behaviorName); 104 | if (iBehaviorFactory == null) { 105 | return null; 106 | } 107 | return iBehaviorFactory.create(); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Factory/XulParserDataStoreSupported.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Factory; 2 | 3 | import org.xmlpull.v1.XmlPullParser; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Created by hy on 2015/4/28. 9 | */ 10 | public class XulParserDataStoreSupported extends XulParserData { 11 | private final XulFactory.IPullParser _parser; 12 | private Object _store_pos; 13 | 14 | private int next_event() throws Exception { 15 | if (_store_pos != null) { 16 | Object store_pos = _store_pos; 17 | _store_pos = null; 18 | return _parser.restoreParserPos(store_pos); 19 | } 20 | return _parser.nextToken(); 21 | } 22 | 23 | public XulParserDataStoreSupported(XulFactory.IPullParser parser, Object store_pos) { 24 | this._parser = parser; 25 | this._store_pos = store_pos; 26 | } 27 | 28 | @Override 29 | public void buildItem(XulFactory.ItemBuilder pageBuilder) { 30 | final ArrayList buildStack = new ArrayList(); 31 | buildStack.add(pageBuilder); 32 | Object result = null; 33 | XulFactory.Attributes pullAttributes = new XulFactory.Attributes() { 34 | @Override 35 | public String getValue(String name) { 36 | return _parser.getAttributeValue(name); 37 | } 38 | 39 | @Override 40 | public String getValue(int i) { 41 | return _parser.getAttributeValue(i); 42 | } 43 | 44 | @Override 45 | public int getLength() { 46 | return _parser.getAttributeCount(); 47 | } 48 | 49 | @Override 50 | public String getName(int i) { 51 | return _parser.getAttributeName(i); 52 | } 53 | }; 54 | try { 55 | while (true) { 56 | int nextTokenId = next_event(); 57 | switch (nextTokenId) { 58 | case XmlPullParser.START_DOCUMENT: 59 | buildStack.clear(); 60 | break; 61 | case XmlPullParser.END_DOCUMENT: 62 | buildStack.clear(); 63 | break; 64 | case XmlPullParser.START_TAG: { 65 | String name = _parser.getName(); 66 | if (buildStack.isEmpty()) { 67 | throw new Exception("can not initialize item builder"); 68 | } else { 69 | XulFactory.ItemBuilder itemBuilder = buildStack.get(buildStack.size() - 1); 70 | XulFactory.ItemBuilder subItemBuilder = itemBuilder.pushSubItem(_parser, "", name, pullAttributes); 71 | if (subItemBuilder == null) { 72 | itemBuilder = buildStack.remove(buildStack.size() - 1); 73 | result = itemBuilder.finalItem(); 74 | continue; 75 | } 76 | buildStack.add(subItemBuilder); 77 | } 78 | } 79 | break; 80 | case XmlPullParser.END_TAG: { 81 | if (buildStack.isEmpty()) { 82 | throw new Exception("result content not match"); 83 | } 84 | XulFactory.ItemBuilder itemBuilder = buildStack.remove(buildStack.size() - 1); 85 | result = itemBuilder.finalItem(); 86 | } 87 | break; 88 | case XmlPullParser.TEXT: 89 | case XmlPullParser.CDSECT: { 90 | XulFactory.ItemBuilder itemBuilder = buildStack.get(buildStack.size() - 1); 91 | itemBuilder.pushText("", _parser); 92 | 93 | } 94 | break; 95 | } 96 | if (nextTokenId == XmlPullParser.END_DOCUMENT) { 97 | break; 98 | } 99 | } 100 | } catch (Exception e) { 101 | e.printStackTrace(); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /XulApp/src/com/starcor/xulapp/model/utils/XulHttpDataOperation.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xulapp.model.utils; 2 | 3 | import com.starcor.xul.XulDataNode; 4 | import com.starcor.xulapp.http.XulHttpRequest; 5 | import com.starcor.xulapp.http.XulHttpResponse; 6 | import com.starcor.xulapp.http.XulHttpStack; 7 | import com.starcor.xulapp.model.XulClauseInfo; 8 | import com.starcor.xulapp.model.XulDataCallback; 9 | import com.starcor.xulapp.model.XulDataException; 10 | import com.starcor.xulapp.model.XulDataOperation; 11 | import com.starcor.xulapp.model.XulDataService; 12 | import com.starcor.xulapp.model.XulDataServiceContext; 13 | import com.starcor.xulapp.utils.XulLog; 14 | 15 | import java.io.InputStream; 16 | 17 | /** 18 | * Created by hy on 2016/1/27. 19 | */ 20 | public abstract class XulHttpDataOperation extends XulDataOperation { 21 | private static final String TAG = XulHttpPullDataCollection.class.getSimpleName(); 22 | XulDataServiceContext _ctx; 23 | XulClauseInfo _clauseInfo; 24 | volatile XulHttpStack.XulHttpTask _apiTask; 25 | XulHttpStack.XulHttpResponseHandler _apiHandler = new XulHttpStack.XulHttpResponseHandler() { 26 | @Override 27 | public int onResult(XulHttpStack.XulHttpTask task, XulHttpRequest request, XulHttpResponse response) { 28 | if (_apiTask != task) { 29 | return 0; 30 | } 31 | _apiTask = null; 32 | onApiResult(_ctx, _clauseInfo, request, response); 33 | return 0; 34 | } 35 | }; 36 | 37 | protected volatile XulDataCallback _callback; 38 | 39 | public XulHttpDataOperation(XulDataServiceContext ctx, XulClauseInfo clauseInfo) { 40 | _ctx = ctx; 41 | _clauseInfo = clauseInfo; 42 | } 43 | 44 | protected void onApiResult(XulDataServiceContext ctx, XulClauseInfo clauseInfo, XulHttpRequest request, XulHttpResponse response) { 45 | XulDataService.Clause clause = this._clauseInfo.getClause(); 46 | if (response.code == 200 && response.data != null) { 47 | try { 48 | XulDataNode result = buildResult(response.data); 49 | deliverResult(ctx, clause, result); 50 | return; 51 | } catch (XulPullCollectionException e) { 52 | clause.setError(e.getCode(), e.getMessage()); 53 | XulLog.e(TAG, e); 54 | } catch (Exception e) { 55 | clause.setError(-1, e.getMessage()); 56 | XulLog.e(TAG, e); 57 | } 58 | } else { 59 | clause.setError(-1, String.format("HTTP Error(%d):%s", response.code, response.message)); 60 | } 61 | ctx.deliverError(_callback, clause); 62 | } 63 | 64 | protected void deliverResult(XulDataServiceContext ctx, XulDataService.Clause clause, XulDataNode result) {ctx.deliverResult(_callback, clause, result);} 65 | 66 | protected abstract XulDataNode buildResult(InputStream data) throws XulPullCollectionException; 67 | 68 | protected abstract XulHttpStack.XulHttpTask createHttpTask(); 69 | 70 | 71 | @Override 72 | public boolean exec(XulDataCallback callback) throws XulDataException { 73 | if (_apiTask != null) { 74 | return false; 75 | } 76 | _ctx.attach(this); 77 | _callback = callback; 78 | _apiTask = createHttpTask(); 79 | _apiTask.get(_apiHandler); 80 | return true; 81 | } 82 | 83 | @Override 84 | public boolean cancel() { 85 | XulHttpStack.XulHttpTask apiTask = _apiTask; 86 | _ctx.attach(this); 87 | _apiTask = null; 88 | if (apiTask != null) { 89 | apiTask.cancel(); 90 | return true; 91 | } 92 | return false; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/Script/V8/V8ScriptFunction.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul.Script.V8; 2 | 3 | import android.util.Log; 4 | import com.starcor.xul.Script.IScript; 5 | import com.starcor.xul.Script.IScriptContext; 6 | import com.starcor.xul.Script.IScriptFinalize; 7 | import com.starcor.xul.Script.IScriptableObject; 8 | import com.starcor.xul.Script.XulScriptFinalizeCollector; 9 | import com.starcor.xul.XulManager; 10 | 11 | /** 12 | * Created by hy on 2015/6/17. 13 | */ 14 | public class V8ScriptFunction implements IScript,IScriptFinalize { 15 | public static final String TAG = V8ScriptFunction.class.getSimpleName(); 16 | V8ScriptContext _ctx; 17 | long _nativeId; 18 | 19 | @Override 20 | protected void finalize() throws Throwable { 21 | if (XulManager.DEBUG_V8_ENGINE) { 22 | Log.d(TAG, String.format("finalize ctx:%x, id:%x", _ctx._nativeId, _nativeId)); 23 | } 24 | markGC(); 25 | super.finalize(); 26 | } 27 | 28 | @Override 29 | public void markGC() { 30 | if (XulManager.DEBUG_V8_ENGINE) { 31 | Log.d(TAG, String.format("markGC ctx:%x, id:%x", _ctx._nativeId, _nativeId)); 32 | } 33 | XulScriptFinalizeCollector.register(this); 34 | } 35 | 36 | @Override 37 | public void doFinalize() { 38 | if (XulManager.DEBUG_V8_ENGINE) { 39 | Log.d(TAG, String.format("doFinalize ctx:%x, id:%x", _ctx._nativeId, _nativeId)); 40 | } 41 | V8Engine.v8DestroyFunction(_ctx._nativeId, _nativeId); 42 | } 43 | 44 | private V8ScriptFunction(V8ScriptContext ctx, long funcId) { 45 | _ctx = ctx; 46 | _nativeId = funcId; 47 | } 48 | 49 | public boolean call(V8ScriptObject thisObject, V8Arguments args) { 50 | long ctxNativeId = _ctx._nativeId; 51 | long funcId = _nativeId; 52 | long thisObjId = thisObject == null ? 0 : thisObject._nativeId; 53 | long argsId = args == null ? 0 : args._nativeId; 54 | if (XulManager.DEBUG_V8_ENGINE) { 55 | Log.d(TAG, String.format("call ctx:%x, func:%x, this:%x, args:%x", ctxNativeId, funcId, thisObjId, argsId)); 56 | } 57 | return V8Engine.v8CallFunction(ctxNativeId, funcId 58 | , thisObjId 59 | , argsId); 60 | } 61 | 62 | static V8ScriptFunction wrapNativeFunction(V8ScriptContext ctx, long funcId) { 63 | if (funcId == 0) { 64 | return null; 65 | } 66 | return new V8ScriptFunction(ctx, funcId); 67 | } 68 | 69 | @Override 70 | public String getScriptType() { 71 | return V8ScriptContext.DEFAULT_SCRIPT_TYPE; 72 | } 73 | 74 | @Override 75 | public Object run(IScriptContext ctx, IScriptableObject ctxObj) { 76 | this.call((V8ScriptObject) ctxObj, null); 77 | return null; 78 | } 79 | 80 | private static V8Arguments cachedArgument; 81 | 82 | @Override 83 | public Object run(IScriptContext ctx, IScriptableObject ctxObj, Object[] args) { 84 | if (cachedArgument == null) { 85 | cachedArgument = V8Arguments.from((V8ScriptContext) ctx, args); 86 | this.call((V8ScriptObject) ctxObj, cachedArgument); 87 | if (cachedArgument != null) { 88 | cachedArgument.reset(); 89 | } 90 | } else if (args != null && args.length > 0) { 91 | cachedArgument.reset(); 92 | cachedArgument.addAll(args); 93 | this.call((V8ScriptObject) ctxObj, cachedArgument); 94 | cachedArgument.reset(); 95 | } else { 96 | this.call((V8ScriptObject) ctxObj, null); 97 | } 98 | return null; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /xul/src/com/starcor/xul/XulSuspendTaskCollector.java: -------------------------------------------------------------------------------- 1 | package com.starcor.xul; 2 | 3 | import com.starcor.xul.Render.XulViewRender; 4 | import com.starcor.xul.Utils.XulCircleQueue; 5 | 6 | import java.lang.ref.WeakReference; 7 | import java.util.Queue; 8 | 9 | /** 10 | * Created by hy on 2015/6/1. 11 | */ 12 | public class XulSuspendTaskCollector { 13 | private WeakReference _root; 14 | private Queue> _stack = new XulCircleQueue>(); 15 | private WeakReference _targetView; 16 | private boolean _finished = false; 17 | private int _recycleLevel = 0; 18 | 19 | 20 | public void init(XulView root) { 21 | WeakReference newRoot = root.getWeakReference(); 22 | if (newRoot.equals(_root)) { 23 | return; 24 | } 25 | _root = newRoot; 26 | _stack.clear(); 27 | _targetView = null; 28 | _finished = false; 29 | } 30 | 31 | public void reset() { 32 | _finished = false; 33 | } 34 | 35 | public void doSuspendWork() { 36 | if (_finished) { 37 | return; 38 | } 39 | 40 | final XulView rootView = _root.get(); 41 | if (rootView == null) { 42 | return; 43 | } 44 | long beginTime = XulUtils.timestamp_us(); 45 | if (_stack.isEmpty()) { 46 | _stack.add(_root); 47 | } 48 | int counter = 0; 49 | final int checkCounterLimit = 32; 50 | final int checkDurationLimit = 400; 51 | while (true) { 52 | ++counter; 53 | if (counter % checkCounterLimit == 0 && XulUtils.timestamp_us() - beginTime >= checkDurationLimit) { 54 | break; 55 | } 56 | XulViewRender viewRender; 57 | WeakReference firstView; 58 | if (_targetView != null) { 59 | firstView = _targetView; 60 | _targetView = null; 61 | 62 | final XulView view = firstView.get(); 63 | if (view == null) { 64 | continue; 65 | } 66 | viewRender = view._render; 67 | if (viewRender == null) { 68 | continue; 69 | } 70 | } else { 71 | firstView = _stack.poll(); 72 | if (firstView == null) { 73 | // finished 74 | _finished = true; 75 | if (XulManager.PERFORMANCE_BENCH) { 76 | // Log.d("BENCH!!!", "collect finished!!!"); 77 | } 78 | break; 79 | } 80 | final XulView view = firstView.get(); 81 | if (view == null) { 82 | continue; 83 | } 84 | viewRender = view._render; 85 | if (viewRender == null) { 86 | continue; 87 | } 88 | if (view instanceof XulArea) { 89 | XulArea area = (XulArea) view; 90 | final XulArea.XulElementArray children = area._children; 91 | final int childrenSize = children.size(); 92 | final XulElement[] array = children.getArray(); 93 | for (int i = 0; i < childrenSize; i++) { 94 | XulElement child = array[i]; 95 | if (child instanceof XulArea) { 96 | _stack.add(((XulView) child).getWeakReference()); 97 | } else if (child instanceof XulView) { 98 | _stack.add(((XulView) child).getWeakReference()); 99 | } 100 | } 101 | } 102 | } 103 | 104 | if (!viewRender.doSuspendRecycle(_recycleLevel)) { 105 | continue; 106 | } 107 | _targetView = firstView; 108 | return; 109 | } 110 | if (XulManager.PERFORMANCE_BENCH) { 111 | // Log.d("BENCH!!!", String.format("collect nothing %d", XulUtils.timestamp_us() - beginTime)); 112 | } 113 | return; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /xul/src/com/caverock/androidsvg/SVGExternalFileResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Paul LeBeau, Cave Rock Software Ltd. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.caverock.androidsvg; 18 | 19 | import android.graphics.Bitmap; 20 | import android.graphics.Typeface; 21 | 22 | import com.caverock.androidsvg.SVG.Style; 23 | 24 | /** 25 | * Resolver class used by the renderer when processing Text and Image elements. 26 | *

    27 | * The default behaviour is to tell AndroidSVG that the reference could not be found. 28 | *

    29 | * Extend this class and override the methods if you want to customise how AndroidSVG treats font and image references. 30 | */ 31 | 32 | public abstract class SVGExternalFileResolver 33 | { 34 | /** 35 | * Called by renderer to resolve font references in <text> elements. 36 | *

    37 | * Return a {@code Typeface} instance, or null if you want the renderer to ignore 38 | * this font and use the default Android font instead. 39 | *

    40 | * Note that AndroidSVG does not attempt to cache Typeface references. If you want 41 | * them cached, for speed or memory reasons, you should do so yourself. 42 | * 43 | * @param fontFamily Font family as specified in a font-family style attribute. 44 | * @param fontWeight Font weight as specified in a font-weight style attribute. 45 | * @param fontStyle Font style as specified in a font-style style attribute. 46 | * @return an Android Typeface instance, or null 47 | */ 48 | public Typeface resolveFont(String fontFamily, int fontWeight, String fontStyle) 49 | { 50 | return null; 51 | } 52 | 53 | /** 54 | * Called by renderer to resolve image file references in <image> elements. 55 | *

    56 | * Return a {@code Bitmap} instance, or null if you want the renderer to ignore 57 | * this image. 58 | *

    59 | * Note that AndroidSVG does not attempt to cache Bitmap references. If you want 60 | * them cached, for speed or memory reasons, you should do so yourself. 61 | * 62 | * @param filename the filename as provided in the xlink:href attribute of a <image> element. 63 | * @return an Android Bitmap object, or null if the image could not be found. 64 | */ 65 | public Bitmap resolveImage(String filename) 66 | { 67 | return null; 68 | } 69 | 70 | /** 71 | * Called by renderer to determine whether a particular format is supported. In particular, 72 | * this method is used in <switch> elements when processing {@code requiredFormats} 73 | * conditionals. 74 | * 75 | * @param mimeType A MIME type (such as "image/jpeg"). 76 | * @return true if your {@code resolveImage()} implementation supports this file format. 77 | */ 78 | public boolean isFormatSupported(String mimeType) 79 | { 80 | return false; 81 | } 82 | } 83 | --------------------------------------------------------------------------------