diff --git a/.gitignore b/.gitignore index 09b993d06b143170bc65a305a2d6acff8d0350c4..37a4eb8b43d978ea05b2c6e3fb934f9b40dddd4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,15 @@ *.iml .gradle /local.properties -/.idea +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml .DS_Store /build /captures .externalNativeBuild +/entry/.preview +.cxx diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..4a5d65b913340ebfd6c085ee6888ea06a3e1d317 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +## 1.0.1 + +发布正式版本 + +## 0.0.2-SNAPSHOT + +* ohos 第一个版本,完整实现了原库的全部 api +* 与原项目显示有轻微差异(原项目按钮自带点击效果,openharmony按钮没有带点击效果) diff --git a/README.OPENSOURCE b/README.OPENSOURCE new file mode 100644 index 0000000000000000000000000000000000000000..271bc13b619563cd8f5c7db0801ef46c632499b8 --- /dev/null +++ b/README.OPENSOURCE @@ -0,0 +1,10 @@ +[ + { + "Name": "SimpleRatingBar", + "License": "MIT", + "License File": "LICENSE", + "Version Number": "1.5.1", + "Upstream URL": "https://github.com/williamyyu/SimpleRatingBar", + "Description": "一个简单的星级评分,您可以更轻松地自定义图像和动画。" + } +] \ No newline at end of file diff --git a/README.md b/README.md index c45536a907657d51960b53910893c98be0410226..51f6d0fde1a2d876c0b57b733468b0fc07be6792 100644 --- a/README.md +++ b/README.md @@ -1,124 +1,92 @@ # SimpleRatingBar -[![JitPack](https://jitpack.io/v/ome450901/SimpleRatingBar.svg)](https://jitpack.io/#ome450901/SimpleRatingBar) - ->The simplest RatingBar library, create your own animate RatingBar in a few steps! - -Provide three RatingBars at the moment: -- BaseRatingBar - A RatingBar without any animation. -- ScaleRatingBar - A RatingBar with progressive and scale animation. -- RotationRatingBar (contributed by [nappannda](https://github.com/nappannda)) - A RatingBar with progressive and rotate animation. - -## What's Next? -- Release the Kotlin version of the library! -- Feel free to post any suggestions you would like to improve! - -## Demo -![](images/demo.gif) -![](images/screenshot.png) -Icon made by [Freepik](http://www.freepik.com/) from www.flaticon.com - -## What's New (v1.5.1) -- Fixed stepSize bug (#91) -- Fixed the match parent issue(start didn't consume the whole width) - -## Feature -- Allow half star through click event. (contributed by [ANPez](https://github.com/ANPez)) -- Support step size setting(range from 0.1 to 1.0). -- Support float rating - - Now you can set a float rating like 3.5, 2.3, 4.7, etc., but you only need to provide two images: `filled` and `empty`, and Library will auto processes your images to support float showing! -- Stars width and height setting. (contributed by [zhangruize](https://github.com/zhangruize)) -- Support use touch to change rating -- Custom drawable's padding -- Custom your empty and filled drawable -- Click again to clear rating -- IsIndicator, Scrollable, Touchable and Clickable settings -- Rotate animation -- Scale animation - -## How To Use -### Install -from JitPack: - -```gradle -allprojects { + +#### 项目介绍 +- 项目名称:SimpleRatingBar +- 所属系列:openharmony的第三方组件适配移植 +- 功能:一个简单的星级评分,您可以更轻松地自定义图像和动画。 +- 项目移植状态:主功能完成 +- 调用差异:无 +- 开发版本:sdk6,DevEco Studio 2.2 Beta1 +- 基线版本:Release 1.5.1 + +#### 效果演示 + + +#### 安装教程 + +1.在项目根目录下的build.gradle文件中, + ``` + allprojects { repositories { - ... - maven { url 'https://jitpack.io' } + maven { + url 'https://s01.oss.sonatype.org/content/repositories/releases/' + } } -} - -dependencies { - compile 'com.github.ome450901:SimpleRatingBar:LATEST_VERSION' -} + } +``` +2.在entry模块的build.gradle文件中, + ``` + dependencies { + implementation('com.gitee.chinasoft_ohos:SimpleRatingBar:1.0.1') + ...... + } ``` - -### In Xml -```xml - - +在sdk6,DevEco Studio 2.2 beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 + +#### 使用说明 + +1、您可以添加到您的xml布局: + ``` + +``` +2、在MainAbilitySlice中找到控件。 +``` + BaseRatingBar baseRatingBar = (BaseRatingBar) layout.findComponentById(ResourceTable.Id_baseratingbar_main); + baseRatingBar.setClearRatingEnabled(false); + baseRatingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() { + @Override + public void onRatingChange(BaseRatingBar ratingBar, float rating, boolean fromUser) { + System.out.println(rating); + } + }); ``` -### In Your Code -```java -ScaleRatingBar ratingBar = new ScaleRatingBar(this); -ratingBar.setNumStars(5); -ratingBar.setMinimumStars(1); -ratingBar.setRating(3); -ratingBar.setStarPadding(10); -ratingBar.setStepSize(0.5f); -ratingBar.setWidth(105); -ratingBar.setHeight(105); -ratingbar.setIsIndicator(false); -ratingbar.setClickable(true); -ratingbar.setScrollable(true); -ratingbar.setClearRatingEnabled(true); -ratingBar.setEmptyDrawableRes(R.drawable.start_empty); -ratingBar.setFilledDrawableRes(R.drawable.start_empty); -ratingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() { - @Override - public void onRatingChange(BaseRatingBar ratingBar, int rating, boolean fromUser) { - Log.e(TAG, "onRatingChange: " + rating); - } -}); +3、目前提供三个 RatingBars: +``` + BaseRatingBar + 没有任何动画的 RatingBar。 + ScaleRatingBar + 缩放动画的 RatingBar。 + RotationRatingBar + 旋转动画的RatingBar。 ``` -## Want to Implement Your Own Animation? -#### Only TWO STEPS you need to do: -- Create a class that extend `BaseRatingBar` -- Override the `emptyRatingBar` and `fillRatingBar` this two method, and then you can start implement your own animaion! +#### 测试信息 ->You can follow [ScaleRatingBar](https://github.com/ome450901/SimpleRatingBar/blob/master/library/src/main/java/com/willy/ratingbar/ScaleRatingBar.java) to implement your own class. +CodeCheck代码测试无异常 -## Todo -- Implement some other animations -- Find a better way to implement animation +CloudTest代码测试无异常 -## About Me -Follow me at [Medium](https://medium.com/@ome450901). +病毒安全检测通过 -## License -``` +当前版本demo功能与原组件基本无差异 + +#### 版本迭代 + +- 1.0.1 + +#### 版权和许可信息 MIT License Copyright (c) 2019 WilliamYu @@ -139,5 +107,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` +SOFTWARE. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5407a125c38a35ee6c8b17f69b944f672abc07ff..beb725b382cf676ecc575d677f179c30d1ae3b3b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,44 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 5 + } +} buildscript { repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } jcenter() - mavenCentral() - google() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.huawei.ohos:hap:2.4.5.0' + classpath 'com.huawei.ohos:decctest:1.2.4.1' } } allprojects { repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + maven { + url 'https://s01.oss.sonatype.org/content/repositories/releases/' + } + maven { + url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' + } jcenter() - maven { url 'https://jitpack.io' } - google() } } - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/example/.gitignore b/entry/.gitignore similarity index 100% rename from example/.gitignore rename to entry/.gitignore diff --git a/entry/build.gradle b/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..f396a3abd7fc3eea059c64076f1279fe94380c48 --- /dev/null +++ b/entry/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 5 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' + implementation('com.gitee.chinasoft_ohos:SimpleRatingBar:1.0.1') + // compile project(":library") +} +decc { + supportType = ['html', 'xml'] +} diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro new file mode 100644 index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a --- /dev/null +++ b/entry/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/entry/src/main/config.json b/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..502b6195ea0b95de136613a69fd86df891f96f83 --- /dev/null +++ b/entry/src/main/config.json @@ -0,0 +1,55 @@ +{ + "app": { + "bundleName": "com.willy.example", + "vendor": "willy", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.willy.example", + "name": ".MyApplication", + "mainAbility": "com.willy.example.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": "com.willy.example.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard", + "metaData": { + "customizeData": [ + { + "extra": "", + "name": "hwc-theme", + "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar" + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/java/com/willy/example/DemoFragment.java b/entry/src/main/java/com/willy/example/DemoFragment.java new file mode 100644 index 0000000000000000000000000000000000000000..71d50f3ae3ca479666b1b0190ec0869f83b9772c --- /dev/null +++ b/entry/src/main/java/com/willy/example/DemoFragment.java @@ -0,0 +1,62 @@ +package com.willy.example; + +import com.willy.ratingbar.BaseRatingBar; +import com.willy.ratingbar.RotationRatingBar; +import com.willy.ratingbar.ScaleRatingBar; +import ohos.agp.components.Button; +import ohos.agp.components.Component; +import ohos.agp.components.DirectionalLayout; +import ohos.agp.components.LayoutScatter; +import ohos.agp.window.dialog.ToastDialog; +import ohos.app.Context; +import ohos.eventhandler.EventHandler; +import ohos.eventhandler.EventRunner; + +public class DemoFragment extends DirectionalLayout { + + private boolean isFlag = true; + + public DemoFragment(Context context) { + super(context); + DirectionalLayout layout = (DirectionalLayout) LayoutScatter.getInstance(context) + .parse(ResourceTable.Layout_demo_fragment, null, false); + addComponent(layout); + BaseRatingBar baseRatingBar = (BaseRatingBar) layout.findComponentById(ResourceTable.Id_baseratingbar_main); + baseRatingBar.setClearRatingEnabled(false); + ScaleRatingBar scaleRatingBar = (ScaleRatingBar) layout.findComponentById(ResourceTable.Id_scaleRatingBar); + RotationRatingBar rotationRatingBar = (RotationRatingBar) layout.findComponentById(ResourceTable.Id_rotationratingbar_main); + baseRatingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() { + @Override + public void onRatingChange(BaseRatingBar ratingBar, float rating, boolean fromUser) { + System.out.println(rating); + } + }); + scaleRatingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() { + @Override + public void onRatingChange(BaseRatingBar ratingBar, float rating, boolean fromUser) { + System.out.println(rating); + } + }); + rotationRatingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() { + @Override + public void onRatingChange(BaseRatingBar ratingBar, float rating, boolean fromUser) { + System.out.println(rating); + } + }); + Button addRatingButton = (Button) layout.findComponentById(ResourceTable.Id_button_main_add_rating); + addRatingButton.setClickedListener(v -> { + if (isFlag){ + isFlag = false; + float currentRating = baseRatingBar.getRating(); + baseRatingBar.setRating(currentRating + 0.25f); + currentRating = scaleRatingBar.getRating(); + scaleRatingBar.setRating(currentRating + 0.25f); + currentRating = rotationRatingBar.getRating(); + rotationRatingBar.setRating(currentRating + 0.25f); + context.getUITaskDispatcher().delayDispatch(() -> { + isFlag = true; + }, 700); + } + }); + } +} diff --git a/entry/src/main/java/com/willy/example/ListFragment.java b/entry/src/main/java/com/willy/example/ListFragment.java new file mode 100644 index 0000000000000000000000000000000000000000..a56b31ba03fe1445927b6d1cd21d4c729f213f45 --- /dev/null +++ b/entry/src/main/java/com/willy/example/ListFragment.java @@ -0,0 +1,19 @@ +package com.willy.example; + +import ohos.agp.components.DirectionalLayout; +import ohos.agp.components.LayoutScatter; +import ohos.agp.components.ListContainer; +import ohos.app.Context; + +public class ListFragment extends DirectionalLayout { + + public ListFragment(Context context) { + super(context); + DirectionalLayout layout = (DirectionalLayout) LayoutScatter.getInstance(context) + .parse(ResourceTable.Layout_fragment_list, null, false); + addComponent(layout); + + ListContainer recyclerView = (ListContainer) layout.findComponentById(ResourceTable.Id_recyclerView); + recyclerView.setItemProvider(new MyAdapter(getContext())); + } +} diff --git a/entry/src/main/java/com/willy/example/MainAbility.java b/entry/src/main/java/com/willy/example/MainAbility.java new file mode 100644 index 0000000000000000000000000000000000000000..bc34b24338cc4f6baa1e7b9e71a9528c918824b6 --- /dev/null +++ b/entry/src/main/java/com/willy/example/MainAbility.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.willy.example; + +import com.willy.example.slice.MainAbilitySlice; +import ohos.aafwk.ability.Ability; +import ohos.aafwk.content.Intent; + +/** MainAbility + * + * @author ljx + * @since 2021-07-02 + */ +public class MainAbility extends Ability { + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setMainRoute(MainAbilitySlice.class.getName()); + } +} diff --git a/entry/src/main/java/com/willy/example/MyAdapter.java b/entry/src/main/java/com/willy/example/MyAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..f1cab8663ceaa21a7bbfe5d29a248144081f38e9 --- /dev/null +++ b/entry/src/main/java/com/willy/example/MyAdapter.java @@ -0,0 +1,63 @@ +package com.willy.example; + +import com.willy.ratingbar.ScaleRatingBar; +import ohos.agp.components.BaseItemProvider; +import ohos.agp.components.Component; +import ohos.agp.components.ComponentContainer; +import ohos.agp.components.LayoutScatter; +import ohos.app.Context; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class MyAdapter extends BaseItemProvider { + + private final Context mContext; + private final List list; + + public MyAdapter(Context context) { + mContext = context; + list = new ArrayList<>(); + for (int index = 1; index < 20; index++) { + list.add(index % 6); + } + } + + @Override + public int getCount() { + return list.size(); + } + + @Override + public Object getItem(int position) { + if (list != null && position >= 0 && position < list.size()) { + return list.get(position); + } + return Optional.empty(); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public Component getComponent(int position, Component convertComponent, ComponentContainer componentContainer) { + final Component cpt; + if (convertComponent == null) { + cpt = LayoutScatter.getInstance(mContext).parse(ResourceTable.Layout_item_ratingbar, null, false); + } else { + cpt = convertComponent; + } + ScaleRatingBar srb = (ScaleRatingBar) cpt.findComponentById(ResourceTable.Id_ratingBar); + srb.setTag(position); + srb.setRating(list.get(position)); + srb.setOnRatingChangeListener((ratingBar, rating, fromUser) -> { + int pos = (int) ratingBar.getTag(); + list.set(pos, (int) rating); + }); + return cpt; + } +} diff --git a/entry/src/main/java/com/willy/example/MyApplication.java b/entry/src/main/java/com/willy/example/MyApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..9767e0bc5a193be01b26b11e10094699bfb4ea81 --- /dev/null +++ b/entry/src/main/java/com/willy/example/MyApplication.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.willy.example; + +import ohos.aafwk.ability.AbilityPackage; + +/** TouchEventManager + * + * @author ljx + * @since 2021-07-02 + */ +public class MyApplication extends AbilityPackage { + @Override + public void onInitialize() { + super.onInitialize(); + } +} diff --git a/entry/src/main/java/com/willy/example/slice/MainAbilitySlice.java b/entry/src/main/java/com/willy/example/slice/MainAbilitySlice.java new file mode 100644 index 0000000000000000000000000000000000000000..1bde284c230d1cd02f65f81ed437f4a5737c6c9e --- /dev/null +++ b/entry/src/main/java/com/willy/example/slice/MainAbilitySlice.java @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.willy.example.slice; + +import com.willy.example.DemoFragment; +import com.willy.example.ListFragment; +import com.willy.example.ResourceTable; +import com.willy.ratingbar.TouchEventManager; +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.agp.components.Component; +import ohos.agp.components.ComponentContainer; +import ohos.agp.components.PageSlider; +import ohos.agp.components.PageSliderProvider; +import ohos.agp.components.StackLayout; +import ohos.agp.components.TabList; +import ohos.agp.utils.Color; +import ohos.agp.window.service.WindowManager; +import ohos.app.Context; +import ohos.eventhandler.EventHandler; +import ohos.eventhandler.EventRunner; + +/** MainAbilitySlice + * + * @author ljx + * @since 2021-07-02 + */ +public class MainAbilitySlice extends AbilitySlice { + + private PageSlider pageSlider; + private TabList tabList; + private Context mContext; + private static DemoFragment demoFragment; + private static ListFragment listFragment; + + @Override + public void onStart(Intent intent) { + super.onStart(intent); + WindowManager.getInstance().getTopWindow().get().setStatusBarColor(new Color(Color.getIntColor("#3F51B5")).getValue()); + super.setUIContent(ResourceTable.Layout_ability_main); + mContext = getContext(); + initTabList(); + initPageSlider(); + } + + private void initTabList() { + tabList = (TabList) findComponentById(ResourceTable.Id_tab_list); + TabList.Tab tab = tabList.new Tab(getContext()); + tab.setText("ANIMATION DEMO"); + tabList.addTab(tab); + TabList.Tab tab2 = tabList.new Tab(getContext()); + tab2.setText("RECYCLERVIEW DEMO"); + tabList.addTab(tab2); + tabList.setFixedMode(true); + tab.select(); + tabList.addTabSelectedListener(new TabList.TabSelectedListener() { + @Override + public void onSelected(TabList.Tab tab) { + int position = tab.getPosition(); + pageSlider.setCurrentPage(position); + } + + @Override + public void onUnselected(TabList.Tab tab) { + + } + + @Override + public void onReselected(TabList.Tab tab) { + + } + }); + } + + private void initPageSlider() { + demoFragment = new DemoFragment(mContext); + demoFragment.setLayoutConfig( + new StackLayout.LayoutConfig( + ComponentContainer.LayoutConfig.MATCH_PARENT, + ComponentContainer.LayoutConfig.MATCH_PARENT)); + listFragment = new ListFragment(mContext); + listFragment.setLayoutConfig( + new StackLayout.LayoutConfig( + ComponentContainer.LayoutConfig.MATCH_PARENT, + ComponentContainer.LayoutConfig.MATCH_PARENT)); + + pageSlider = (PageSlider) findComponentById(ResourceTable.Id_page_slider); + pageSlider.setProvider(new MyPagerProvider()); + pageSlider.setEnabled(false); + pageSlider.addPageChangedListener(new PageSlider.PageChangedListener() { + @Override + public void onPageSliding(int itemPos, float itemPosOffset, int itemPosPixles) { + + } + + @Override + public void onPageSlideStateChanged(int state) { + + } + + @Override + public void onPageChosen(int itemPos) { + tabList.selectTabAt(itemPos); + } + }); + + TouchEventManager.getInstance().setResultCallback(new TouchEventManager.TouchEventCallback() { + + @Override + public void onTouch() { + pageSlider.setEnabled(false); + } + + @Override + public void onCancel() { + EventRunner runner = EventRunner.create(true); + EventHandler mHandler = new EventHandler(runner); + mHandler.postTask(new Runnable() { + @Override + public void run() { + pageSlider.setEnabled(true); + } + }, 600, EventHandler.Priority.IMMEDIATE); + } + }); + pageSlider.setEnabled(true); + } + + public static class MyPagerProvider extends PageSliderProvider { + + @Override + public int getCount() { + return 2; + } + + @Override + public Object createPageInContainer(ComponentContainer componentContainer, int pos) { + if (pos == 0) { + componentContainer.addComponent(demoFragment); + return demoFragment; + } + if (pos == 1) { + componentContainer.addComponent(listFragment); + return listFragment; + } + return null; + } + + @Override + public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) { + componentContainer.removeComponent((Component) o); + } + + @Override + public boolean isPageMatchToObject(Component component, Object o) { + return true; + } + } + + @Override + public void onActive() { + super.onActive(); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3d3fdc7eb8c83f7f6a96c6e2fecae239b8310101 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "Example" + }, + { + "name": "mainability_description", + "value": "Java_Empty Ability" + }, + { + "name": "mainability_HelloWorld", + "value": "Hello World" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0 --- /dev/null +++ b/entry/src/main/resources/base/graphic/background_ability_main.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..6f818beaed8138aa86f44cc1584637815d312204 --- /dev/null +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -0,0 +1,37 @@ + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/layout/demo_fragment.xml b/entry/src/main/resources/base/layout/demo_fragment.xml new file mode 100644 index 0000000000000000000000000000000000000000..16ce9db0462102be0a29aeb8cc3eb7f8d7110a4d --- /dev/null +++ b/entry/src/main/resources/base/layout/demo_fragment.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + +