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
-[](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
-
-
-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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/fragment_list.xml b/entry/src/main/resources/base/layout/fragment_list.xml
new file mode 100644
index 0000000000000000000000000000000000000000..07c7da61fb9aabc4ec4cf50c4488ff47a307b227
--- /dev/null
+++ b/entry/src/main/resources/base/layout/fragment_list.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/item_ratingbar.xml b/entry/src/main/resources/base/layout/item_ratingbar.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9e7459c757be87df2fe5ac4b5e5b058f5f515c03
--- /dev/null
+++ b/entry/src/main/resources/base/layout/item_ratingbar.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/entry/src/main/resources/en/element/string.json b/entry/src/main/resources/en/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0b4658b4a7347751c70be586352893a423fda99c
--- /dev/null
+++ b/entry/src/main/resources/en/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"
+ }
+ ]
+}
diff --git a/entry/src/main/resources/zh/element/string.json b/entry/src/main/resources/zh/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..332da83a6d32c4c9a8d117cb21de8d1df902e5c7
--- /dev/null
+++ b/entry/src/main/resources/zh/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "Example"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "你好,世界"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/willy/example/ExampleOhosTest.java b/entry/src/ohosTest/java/com/willy/example/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c64ed17372b17ec43e5306bee2a9b907bdd9133b
--- /dev/null
+++ b/entry/src/ohosTest/java/com/willy/example/ExampleOhosTest.java
@@ -0,0 +1,217 @@
+package com.willy.example;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.willy.example", actualBundleName);
+ }
+
+ @Test
+ public void getNumStars() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.SimpleRatingBar");
+ Method log = fileListItem.getMethod("getNumStars");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getRating() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.SimpleRatingBar");
+ Method log = fileListItem.getMethod("getRating");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getStarWidth() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.SimpleRatingBar");
+ Method log = fileListItem.getMethod("getStarWidth");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getStarHeight() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.SimpleRatingBar");
+ Method log = fileListItem.getMethod("getStarHeight");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getStarPadding() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.SimpleRatingBar");
+ Method log = fileListItem.getMethod("getStarPadding");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getStepSize() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.SimpleRatingBar");
+ Method log = fileListItem.getMethod("getStepSize");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getDecimalFormat() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.RatingBarUtils");
+ Method log = fileListItem.getMethod("getDecimalFormat");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void init() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.PartialView");
+ Method log = fileListItem.getMethod("init");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void setFilled() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.PartialView");
+ Method log = fileListItem.getMethod("setFilled");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+
+ @Test
+ public void setEmpty() {
+ try {
+ Class fileListItem = Class.forName("com.willy.ratingbar.PartialView");
+ Method log = fileListItem.getMethod("setEmpty");
+ Object obj = fileListItem.getConstructor().newInstance();
+ log.invoke(obj);
+ } catch (ClassNotFoundException ep) {
+ ep.printStackTrace();
+ } catch (NoSuchMethodException ep) {
+ ep.printStackTrace();
+ } catch (IllegalAccessException ep) {
+ ep.printStackTrace();
+ } catch (InstantiationException ep) {
+ ep.printStackTrace();
+ } catch (InvocationTargetException ep) {
+ ep.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/willy/example/ExampleTest.java b/entry/src/test/java/com/willy/example/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a28d11e01b88c7a85299025a98b0f06104bf703f
--- /dev/null
+++ b/entry/src/test/java/com/willy/example/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.willy.example;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/example/build.gradle b/example/build.gradle
deleted file mode 100644
index dfefd44e2319fd55882b98aa46167aaa5d559c45..0000000000000000000000000000000000000000
--- a/example/build.gradle
+++ /dev/null
@@ -1,40 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 30
- buildToolsVersion '29.0.3'
-
- defaultConfig {
- applicationId "com.willy.example"
- minSdkVersion 15
- targetSdkVersion 30
- versionCode 1
- versionName "1.0"
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- implementation 'androidx.recyclerview:recyclerview:1.1.0'
- implementation 'com.google.android.material:material:1.0.0'
- androidTestImplementation 'junit:junit:4.12'
- implementation project(':library')
-}
diff --git a/example/proguard-rules.pro b/example/proguard-rules.pro
deleted file mode 100644
index 55d531aa3eec505c5f22ab7c913f6c5ef2f629ec..0000000000000000000000000000000000000000
--- a/example/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/willy/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml
deleted file mode 100644
index dcc9315eb060385e536f0f5117701304774505c5..0000000000000000000000000000000000000000
--- a/example/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/src/main/java/com/willy/example/DemoFragment.java b/example/src/main/java/com/willy/example/DemoFragment.java
deleted file mode 100644
index c6897275ce41bbcb9efffa3ae0e902297ebb513e..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/willy/example/DemoFragment.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.willy.example;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-
-import com.willy.ratingbar.BaseRatingBar;
-import com.willy.ratingbar.RotationRatingBar;
-import com.willy.ratingbar.ScaleRatingBar;
-
-public class DemoFragment
- extends Fragment {
-
- public static final String TAG = "SimpleRatingBar";
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_demo, container, false);
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- final BaseRatingBar baseRatingBar = view.findViewById(R.id.baseratingbar_main);
- final ScaleRatingBar scaleRatingBar = view.findViewById(R.id.scaleRatingBar);
- final RotationRatingBar rotationRatingBar = view.findViewById(R.id.rotationratingbar_main);
- baseRatingBar.setClearRatingEnabled(false);
- baseRatingBar.setOnRatingChangeListener((ratingBar, rating, fromUser) -> Log
- .d(TAG, "BaseRatingBar onRatingChange: " + rating));
-
- scaleRatingBar.setOnRatingChangeListener((ratingBar, rating, fromUser) -> Log
- .d(TAG, "ScaleRatingBar onRatingChange: " + rating));
-
- rotationRatingBar.setOnRatingChangeListener((ratingBar, rating, fromUser) -> Log
- .d(TAG, "RotationRatingBar onRatingChange: " + rating));
-
- Button addRatingButton = view.findViewById(R.id.button_main_add_rating);
- addRatingButton.setOnClickListener(v -> {
- 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);
- });
- }
-}
diff --git a/example/src/main/java/com/willy/example/EntryActivity.java b/example/src/main/java/com/willy/example/EntryActivity.java
deleted file mode 100644
index dd2d0f98ce7322931d44126eb3f81272657ecb50..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/willy/example/EntryActivity.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.willy.example;
-
-import android.os.Bundle;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentStatePagerAdapter;
-import androidx.viewpager.widget.ViewPager;
-
-import com.google.android.material.tabs.TabLayout;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by willy on 2017/10/13.
- */
-
-public class EntryActivity
- extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_entry);
-
- final ViewPager viewPager = findViewById(R.id.viewPager);
- viewPager.setAdapter(new SamplePagerAdapter(getSupportFragmentManager()));
-
- final TabLayout tabLayout = findViewById(R.id.tabLayout);
- tabLayout.addTab(tabLayout.newTab().setText("Animation Demo"));
- tabLayout.addTab(tabLayout.newTab().setText("RecyclerView Demo"));
- tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
- @Override
- public void onTabSelected(TabLayout.Tab tab) {
- viewPager.setCurrentItem(tab.getPosition());
- }
-
- @Override
- public void onTabUnselected(TabLayout.Tab tab) {
-
- }
-
- @Override
- public void onTabReselected(TabLayout.Tab tab) {
-
- }
- });
-
- viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
- }
-
- private class SamplePagerAdapter
- extends FragmentStatePagerAdapter {
-
- private List fragments;
-
- private SamplePagerAdapter(FragmentManager fm) {
- super(fm);
- fragments = new ArrayList<>();
- fragments.add(new DemoFragment());
- fragments.add(new ListFragment());
- }
-
- @Override
- public int getCount() {
- return fragments.size();
- }
-
- @Override
- public Fragment getItem(int position) {
- return fragments.get(position);
- }
- }
-}
diff --git a/example/src/main/java/com/willy/example/ListFragment.java b/example/src/main/java/com/willy/example/ListFragment.java
deleted file mode 100644
index 2dc05803022eee4f85bff5b879760bf716c85dac..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/willy/example/ListFragment.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.willy.example;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.RecyclerView;
-
-public class ListFragment
- extends Fragment {
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_list, container, false);
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
- recyclerView.setAdapter(new MyAdapter(getContext()));
- }
-}
diff --git a/example/src/main/java/com/willy/example/MyAdapter.java b/example/src/main/java/com/willy/example/MyAdapter.java
deleted file mode 100644
index 8a081b1aa7a188a49332bc575a74dfdd06108d5a..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/willy/example/MyAdapter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.willy.example;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.willy.ratingbar.ScaleRatingBar;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by willy on 2017/10/3.
- */
-
-public class MyAdapter
- extends RecyclerView.Adapter {
-
- private Context mContext;
- private List list;
-
- public MyAdapter(Context context) {
- mContext = context;
- list = new ArrayList<>();
-
- for (int i = 1; i < 20; i++) {
- list.add(i % 6f);
- }
- }
-
- @NonNull
- @Override
- public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(mContext).inflate(R.layout.item_ratingbar, null);
- return new MyViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(final MyViewHolder holder, int position) {
- holder.ratingBar.setTag(position);
- holder.ratingBar.setRating(list.get(position));
- }
-
- @Override
- public int getItemCount() {
- return list.size();
- }
-
- public class MyViewHolder
- extends RecyclerView.ViewHolder {
-
- private ScaleRatingBar ratingBar;
-
- public MyViewHolder(View itemView) {
- super(itemView);
-// ratingBar = itemView.findViewById(R.id.ratingBar);
-// ratingBar = itemView.findViewById(R.id.ratingBar);
- ratingBar = itemView.findViewById(R.id.ratingBar);
- ratingBar.setOnRatingChangeListener((ratingBar, rating, fromUser) -> {
- int position = (int) ratingBar.getTag();
- list.set(position, rating);
- });
- }
- }
-}
diff --git a/example/src/main/res/drawable/empty2.png b/example/src/main/res/drawable/empty2.png
deleted file mode 100644
index 1e019b82b6f2097d2b2d5878e70b0106d2881e49..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/drawable/empty2.png and /dev/null differ
diff --git a/example/src/main/res/drawable/filled2.png b/example/src/main/res/drawable/filled2.png
deleted file mode 100644
index 1a3be2e0047d1f064eb6a1bea12ad1550ef39328..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/drawable/filled2.png and /dev/null differ
diff --git a/example/src/main/res/layout/activity_entry.xml b/example/src/main/res/layout/activity_entry.xml
deleted file mode 100644
index a95c07800948113f929065bb7d19454fd7e6a958..0000000000000000000000000000000000000000
--- a/example/src/main/res/layout/activity_entry.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/example/src/main/res/layout/fragment_demo.xml b/example/src/main/res/layout/fragment_demo.xml
deleted file mode 100644
index c3708f11ba6d6d272845e42e965606e6d20bb384..0000000000000000000000000000000000000000
--- a/example/src/main/res/layout/fragment_demo.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/example/src/main/res/layout/fragment_list.xml b/example/src/main/res/layout/fragment_list.xml
deleted file mode 100644
index 8b5c69d30031b9345bf0d08e747638935d709f27..0000000000000000000000000000000000000000
--- a/example/src/main/res/layout/fragment_list.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
diff --git a/example/src/main/res/layout/item_ratingbar.xml b/example/src/main/res/layout/item_ratingbar.xml
deleted file mode 100644
index efd90f4bb6c025006b62114bb695b17c31c692ad..0000000000000000000000000000000000000000
--- a/example/src/main/res/layout/item_ratingbar.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
diff --git a/example/src/main/res/mipmap-hdpi/ic_launcher.png b/example/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-hdpi/ic_launcher_round.png b/example/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 9a078e3e1a42d474c78470a73c7987cf7ac5d9a0..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-mdpi/ic_launcher.png b/example/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-mdpi/ic_launcher_round.png b/example/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index efc028a636dd690a51db5a525cf781a5a7daba68..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 3af2608a4492ef9ae63a77ec3305aedda89594cb..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index 9bec2e623103ac9713b00cad8502a057c1efda61..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index 34947cd6bbf9c729be83edc96ad08a1d42b82bc9..0000000000000000000000000000000000000000
Binary files a/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/example/src/main/res/values/colors.xml b/example/src/main/res/values/colors.xml
deleted file mode 100644
index 3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0..0000000000000000000000000000000000000000
--- a/example/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
diff --git a/example/src/main/res/values/strings.xml b/example/src/main/res/values/strings.xml
deleted file mode 100644
index 433cad670f23c9b891c349ef8ae1123ffbc7708b..0000000000000000000000000000000000000000
--- a/example/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
- Example
-
- BaseRatingBar
- ScaleRatingBar
- RotationRatingBar
- Add rating
-
diff --git a/example/src/main/res/values/styles.xml b/example/src/main/res/values/styles.xml
deleted file mode 100644
index 5885930df6d10edf3d6df40d6556297d11f953da..0000000000000000000000000000000000000000
--- a/example/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/gradle.properties b/gradle.properties
index 9e6fce102d11ffba5aae545fe7b688386407e699..be492496f9a20ac2d980ef4fc30061f4184c1c40 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,19 +1,13 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-android.enableJetifier=true
-android.useAndroidX=true
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
+# If the Chinese output is garbled, please configure the following parameter.
+# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
+# more information see https://docs.gradle.org/current/userguide/performance.html
+# org.gradle.parallel=false
+# org.gradle.jvmargs=-Dfile.encoding=GBK
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b9f3d3091341b33cb761b8a1144efa1c84fa66cd..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon Dec 14 21:44:11 AEDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..536f0272dd995f3afdb5e34e0f42bdf3d1986c22 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
##############################################################################
##
@@ -6,155 +22,162 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG=$(dirname "$PRG")"/$link"
+ fi
+done
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=$(basename "$0")
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
- echo "$*"
+warn() {
+ echo "$*"
}
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
+die() {
+ echo
+ echo "$*"
+ echo
+ exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
+nonstop=false
+case "$(uname)" in
+CYGWIN*)
+ cygwin=true
+ ;;
+Darwin*)
+ darwin=true
+ ;;
+MINGW*)
+ msys=true
+ ;;
+NONSTOP*)
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ]; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
- fi
+ fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then
+ MAX_FD_LIMIT=$(ulimit -H -n)
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ MAX_FD="$MAX_FD_LIMIT"
fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+ APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+ CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+ JAVACMD=$(cygpath --unix "$JAVACMD")
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ]; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@"; do
+ CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -)
+ CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition
+ eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
+ else
+ eval $(echo args$i)="\"$arg\""
fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
+ i=$(expr $i + 1)
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save() {
+ for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index aec99730b4e8fcd90b57a0e8e01544fea7c31a89..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,90 +1,103 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/images/demo.gif b/images/demo.gif
deleted file mode 100644
index b9347de96e9f2f9d8af2fbc09d25d4a8308bba60..0000000000000000000000000000000000000000
Binary files a/images/demo.gif and /dev/null differ
diff --git a/images/screenshot.png b/images/screenshot.png
deleted file mode 100644
index b92511aed2dd114965dd466a816f8165ea0f55a5..0000000000000000000000000000000000000000
Binary files a/images/screenshot.png and /dev/null differ
diff --git a/img/gif.gif b/img/gif.gif
new file mode 100644
index 0000000000000000000000000000000000000000..6da8a4e74cca7953859b40861a17feb6a92dd7f3
Binary files /dev/null and b/img/gif.gif differ
diff --git a/library/build.gradle b/library/build.gradle
index fd9e351a617efb7e0f2ce1a7a40b3528526c4d17..09e9f30de24628b6ea4dd241329a4a2ddbb80d81 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,30 +1,22 @@
-apply plugin: 'com.android.library'
-apply plugin: 'maven'
-group = 'com.github.ome450901'
-
-android {
- compileSdkVersion 30
- buildToolsVersion '29.0.3'
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 6
defaultConfig {
- minSdkVersion 15
- targetSdkVersion 30
- versionCode 1
- versionName "1.5.1"
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
- compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- }
+
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'androidx.appcompat:appcompat:1.1.0'
+ testImplementation 'junit:junit:4.13'
}
diff --git a/library/consumer-rules.pro b/library/consumer-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..9dccc613bc71b04b83531f550bdab2fb667ecfc9
--- /dev/null
+++ b/library/consumer-rules.pro
@@ -0,0 +1 @@
+# Add har specific ProGuard rules for consumer here.
\ No newline at end of file
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
index 55d531aa3eec505c5f22ab7c913f6c5ef2f629ec..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -1,25 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/willy/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/library/src/androidTest/java/com/willy/ratingbar/ExampleInstrumentedTest.java b/library/src/androidTest/java/com/willy/ratingbar/ExampleInstrumentedTest.java
deleted file mode 100644
index 245b11d98dba203dc6cf53a8115f68b5f09aff4d..0000000000000000000000000000000000000000
--- a/library/src/androidTest/java/com/willy/ratingbar/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.willy.ratingbar;
-
-import android.content.Context;
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.willy.ratingbar.test", appContext.getPackageName());
- }
-}
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index 9cc57e61ad5bfd94fdbcd546e62caee93836ef0c..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..d0147893a7ead6f47049f007e1c7301e10192915
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,23 @@
+{
+ "app": {
+ "bundleName": "com.willy.example",
+ "vendor": "willy",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.willy.ratingbar",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/willy/ratingbar/AnimationRatingBar.java b/library/src/main/java/com/willy/ratingbar/AnimationRatingBar.java
index bc85b11b3cedcb46adc9b5f147f6dd7cf5b96d83..235312276ca1c2c9c4b61b0e3f5074528af77f1d 100644
--- a/library/src/main/java/com/willy/ratingbar/AnimationRatingBar.java
+++ b/library/src/main/java/com/willy/ratingbar/AnimationRatingBar.java
@@ -1,10 +1,9 @@
package com.willy.ratingbar;
-import android.content.Context;
-import android.os.Handler;
-import android.os.SystemClock;
-import androidx.annotation.Nullable;
-import android.util.AttributeSet;
+import ohos.agp.components.AttrSet;
+import ohos.app.Context;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
import java.util.UUID;
@@ -14,37 +13,29 @@ import java.util.UUID;
public class AnimationRatingBar extends BaseRatingBar {
- protected Handler mHandler;
+ protected EventHandler mHandler;
protected Runnable mRunnable;
- protected String mRunnableToken = UUID.randomUUID().toString();
- protected AnimationRatingBar(Context context) {
- super(context);
- init();
- }
-
- protected AnimationRatingBar(Context context, @Nullable AttributeSet attrs) {
+ protected AnimationRatingBar(Context context, AttrSet attrs) {
super(context, attrs);
init();
}
- protected AnimationRatingBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ protected AnimationRatingBar(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
- mHandler = new Handler();
+ EventRunner runner = EventRunner.create(true);
+ mHandler = new EventHandler(runner);
}
- protected void postRunnable(Runnable runnable, long ANIMATION_DELAY) {
+ protected void postRunnable(Runnable runnable, long animationDelay) {
if (mHandler == null) {
- mHandler = new Handler();
+ EventRunner runner = EventRunner.create(true);
+ mHandler = new EventHandler(runner);
}
-
- long timeMillis = SystemClock.uptimeMillis() + ANIMATION_DELAY;
- mHandler.postAtTime(runnable, mRunnableToken, timeMillis);
+ mHandler.postTask(runnable, animationDelay, EventHandler.Priority.IMMEDIATE);
}
-
-}
-
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/willy/ratingbar/BaseRatingBar.java b/library/src/main/java/com/willy/ratingbar/BaseRatingBar.java
index 13e28df85fe871a2dbd1e731c6ac4516e8d53bc6..ec35c9d921b055bd50a05f598a3d5c2e79067bd5 100644
--- a/library/src/main/java/com/willy/ratingbar/BaseRatingBar.java
+++ b/library/src/main/java/com/willy/ratingbar/BaseRatingBar.java
@@ -1,21 +1,19 @@
package com.willy.ratingbar;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.os.Parcelable;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.FloatRange;
-import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
-
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.DirectionalLayout;
+import ohos.agp.components.PageSlider;
+import ohos.app.Context;
+import ohos.global.resource.RawFileEntry;
+import ohos.global.resource.ResourceManager;
+import ohos.media.image.ImageSource;
+import ohos.media.image.PixelMap;
+import ohos.multimodalinput.event.TouchEvent;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -23,13 +21,9 @@ import java.util.List;
* Created by willy on 2017/5/5.
*/
-public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
-
- public interface OnRatingChangeListener {
- void onRatingChange(BaseRatingBar ratingBar, float rating, boolean fromUser);
- }
+public class BaseRatingBar extends DirectionalLayout implements SimpleRatingBar, Component.TouchEventListener {
- public static final String TAG = "SimpleRatingBar";
+ private static final String FORMAT = "image/jpg";
private int mNumStars;
private int mPadding = 20;
@@ -39,6 +33,7 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
private float mRating = -1;
private float mStepSize = 1f;
private float mPreviousRating = 0;
+ private float mNmu = 10;
private boolean mIsIndicator = false;
private boolean mIsScrollable = true;
@@ -48,94 +43,120 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
private float mStartX;
private float mStartY;
- private Drawable mEmptyDrawable;
- private Drawable mFilledDrawable;
+ private PixelMap mEmptyDrawable;
+ private PixelMap mFilledDrawable;
private OnRatingChangeListener mOnRatingChangeListener;
protected List mPartialViews;
- public BaseRatingBar(Context context) {
- this(context, null);
- }
-
- /* Call by xml layout */
- public BaseRatingBar(Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
+ public BaseRatingBar(Context context, AttrSet attrs) {
+ this(context, attrs, "0");
}
/**
* @param context context
* @param attrs attributes from XML => app:mainText="mainText"
- * @param defStyleAttr attributes from default style (Application theme or activity theme)
+ * @param defStyleAttr attributes from default style (Application theme or theme)
*/
- public BaseRatingBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ public BaseRatingBar(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
-
- TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BaseRatingBar);
- final float rating = typedArray.getFloat(R.styleable.BaseRatingBar_srb_rating, 0);
-
- initParamsValue(typedArray, context);
+ setOrientation(HORIZONTAL);
+ initParamsValue(attrs, context);
verifyParamsValue();
initRatingView();
+ float rating = 0;
+ if (isPresent(attrs, "srb_rating")) {
+ rating = attrs.getAttr("srb_rating").get().getFloatValue();
+ }
setRating(rating);
+ setTouchEventListener(this);
+ }
+
+ private void initParamsValue(AttrSet attrs, Context context) {
+ mEmptyDrawable = getPixelMap("resources/rawfile/empty.png");
+ mFilledDrawable = getPixelMap("resources/rawfile/filled.png");
+ if (isPresent(attrs, "srb_numStars")) {
+ mNumStars = attrs.getAttr("srb_numStars").get().getIntegerValue();
+ }
+ if (isPresent(attrs, "srb_starPadding")) {
+ mPadding = attrs.getAttr("srb_starPadding").get().getDimensionValue();
+ }
+ if (isPresent(attrs, "srb_starWidth")) {
+ mStarWidth = attrs.getAttr("srb_starWidth").get().getDimensionValue();
+ }
+ if (isPresent(attrs, "srb_starHeight")) {
+ mStarHeight = attrs.getAttr("srb_starHeight").get().getDimensionValue();
+ }
+ if (isPresent(attrs, "srb_stepSize")) {
+ mStepSize = attrs.getAttr("srb_stepSize").get().getFloatValue();
+ }
+ if (isPresent(attrs, "srb_minimumStars")) {
+ mMinimumStars = attrs.getAttr("srb_minimumStars").get().getFloatValue();
+ }
+ if (isPresent(attrs, "srb_isIndicator")) {
+ mIsIndicator = attrs.getAttr("srb_isIndicator").get().getBoolValue();
+ }
+ if (isPresent(attrs, "srb_scrollable")) {
+ mIsScrollable = attrs.getAttr("srb_scrollable").get().getBoolValue();
+ }
+ if (isPresent(attrs, "srb_clickable")) {
+ mIsClickable = attrs.getAttr("srb_clickable").get().getBoolValue();
+ }
+ if (isPresent(attrs, "srb_clearRatingEnabled")) {
+ mClearRatingEnabled = attrs.getAttr("srb_clearRatingEnabled").get().getBoolValue();
+ }
}
- private void initParamsValue(TypedArray typedArray, Context context) {
- mNumStars = typedArray.getInt(R.styleable.BaseRatingBar_srb_numStars, mNumStars);
- mStepSize = typedArray.getFloat(R.styleable.BaseRatingBar_srb_stepSize, mStepSize);
- mMinimumStars = typedArray.getFloat(R.styleable.BaseRatingBar_srb_minimumStars, mMinimumStars);
- mPadding = typedArray.getDimensionPixelSize(R.styleable.BaseRatingBar_srb_starPadding, mPadding);
- mStarWidth = typedArray.getDimensionPixelSize(R.styleable.BaseRatingBar_srb_starWidth, 0);
- mStarHeight = typedArray.getDimensionPixelSize(R.styleable.BaseRatingBar_srb_starHeight, 0);
- mEmptyDrawable = typedArray.hasValue(R.styleable.BaseRatingBar_srb_drawableEmpty) ? ContextCompat.getDrawable(context, typedArray.getResourceId(R.styleable.BaseRatingBar_srb_drawableEmpty, View.NO_ID)) : null;
- mFilledDrawable = typedArray.hasValue(R.styleable.BaseRatingBar_srb_drawableFilled) ? ContextCompat.getDrawable(context, typedArray.getResourceId(R.styleable.BaseRatingBar_srb_drawableFilled, View.NO_ID)) : null;
- mIsIndicator = typedArray.getBoolean(R.styleable.BaseRatingBar_srb_isIndicator, mIsIndicator);
- mIsScrollable = typedArray.getBoolean(R.styleable.BaseRatingBar_srb_scrollable, mIsScrollable);
- mIsClickable = typedArray.getBoolean(R.styleable.BaseRatingBar_srb_clickable, mIsClickable);
- mClearRatingEnabled = typedArray.getBoolean(R.styleable.BaseRatingBar_srb_clearRatingEnabled, mClearRatingEnabled);
- typedArray.recycle();
+ private boolean isPresent(AttrSet attrs, String name) {
+ return attrs.getAttr(name).isPresent();
}
private void verifyParamsValue() {
if (mNumStars <= 0) {
mNumStars = 5;
}
-
if (mPadding < 0) {
mPadding = 0;
}
-
if (mEmptyDrawable == null) {
- mEmptyDrawable = ContextCompat.getDrawable(getContext(), R.drawable.empty);
+ mEmptyDrawable = getPixelMap("resources/rawfile/empty.png");
}
-
if (mFilledDrawable == null) {
- mFilledDrawable = ContextCompat.getDrawable(getContext(), R.drawable.filled);
+ mFilledDrawable = getPixelMap("resources/rawfile/filled.png");
}
-
if (mStepSize > 1.0f) {
mStepSize = 1.0f;
} else if (mStepSize < 0.1f) {
mStepSize = 0.1f;
}
-
mMinimumStars = RatingBarUtils.getValidMinimumStars(mMinimumStars, mNumStars, mStepSize);
}
+ private PixelMap getPixelMap(String rawfile) {
+ ResourceManager resManager = getResourceManager();
+ RawFileEntry rawFileEntry = resManager.getRawFileEntry(rawfile);
+ try {
+ InputStream resource = rawFileEntry.openRawFile();
+ ImageSource imageSource = ImageSource.create(resource, null);
+ return imageSource.createPixelmap(null);
+ } catch (IOException e) {
+ System.out.println(e);
+ }
+ return null;
+ }
+
private void initRatingView() {
mPartialViews = new ArrayList<>();
-
- for (int i = 1; i <= mNumStars; i++) {
- PartialView partialView = getPartialView(i, mStarWidth, mStarHeight, mPadding, mFilledDrawable, mEmptyDrawable);
- addView(partialView);
-
+ for (int pos = 1; pos <= mNumStars; pos++) {
+ PartialView partialView = getPartialView(pos, mStarWidth, mStarHeight, mPadding, mFilledDrawable, mEmptyDrawable);
+ addComponent(partialView);
mPartialViews.add(partialView);
}
}
private PartialView getPartialView(final int partialViewId, int starWidth, int starHeight, int padding,
- Drawable filledDrawable, Drawable emptyDrawable) {
+ PixelMap filledDrawable, PixelMap emptyDrawable) {
PartialView partialView = new PartialView(getContext(), partialViewId, starWidth, starHeight, padding);
partialView.setFilledDrawable(filledDrawable);
partialView.setEmptyDrawable(emptyDrawable);
@@ -150,21 +171,17 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
/**
- * Use {maxIntOfRating} because if the rating is 3.5
- * the view which id is 3 also need to be filled.
+ * the view which id is 3 also need to be filled
+ *
+ * @param rating rating
*/
protected void fillRatingBar(final float rating) {
+ double maxIntOfRating = Math.ceil(rating);
for (PartialView partialView : mPartialViews) {
int ratingViewId = (int) partialView.getTag();
- double maxIntOfRating = Math.ceil(rating);
-
if (ratingViewId > maxIntOfRating) {
partialView.setEmpty();
continue;
- }
-
- if (ratingViewId == maxIntOfRating) {
- partialView.setPartialFilled(rating);
} else {
partialView.setFilled();
}
@@ -176,10 +193,8 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
if (numStars <= 0) {
return;
}
-
mPartialViews.clear();
- removeAllViews();
-
+ removeAllComponents();
mNumStars = numStars;
initRatingView();
}
@@ -198,25 +213,22 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
if (rating > mNumStars) {
rating = mNumStars;
}
-
if (rating < mMinimumStars) {
rating = mMinimumStars;
}
- if (mRating == rating) {
+ BigDecimal bignum1 = new BigDecimal(mRating);
+ BigDecimal bignum2 = new BigDecimal(rating);
+ float value = bignum1.subtract(bignum2).floatValue();
+ if (Math.abs(value) <= 0) {
return;
}
-
// Respect Step size. So if the defined step size is 0.5, and we're attributing it a 4.7 rating,
// it should actually be set to `4.5` rating.
- float stepAbidingRating = Double.valueOf(Math.floor(rating/mStepSize)).floatValue() * mStepSize;
-
- mRating = stepAbidingRating;
-
+ mRating = Double.valueOf(Math.floor(rating / mStepSize)).floatValue() * mStepSize;
if (mOnRatingChangeListener != null) {
mOnRatingChangeListener.onRatingChange(this, mRating, fromUser);
}
-
fillRatingBar(mRating);
}
@@ -226,8 +238,7 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
@Override
- // Unit is pixel
- public void setStarWidth(@IntRange(from = 0) int starWidth) {
+ public void setStarWidth(int starWidth) {
mStarWidth = starWidth;
for (PartialView partialView : mPartialViews) {
partialView.setStarWidth(starWidth);
@@ -240,8 +251,7 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
@Override
- // Unit is pixel
- public void setStarHeight(@IntRange(from = 0) int starHeight) {
+ public void setStarHeight(int starHeight) {
mStarHeight = starHeight;
for (PartialView partialView : mPartialViews) {
partialView.setStarHeight(starHeight);
@@ -272,24 +282,38 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
@Override
- public void setEmptyDrawableRes(@DrawableRes int res) {
- Drawable drawable = ContextCompat.getDrawable(getContext(), res);
+ public void setEmptyDrawableRes(int res) {
+
+ PixelMap drawable = getPixelMapFromResource(getContext(), res);
if (drawable != null) {
setEmptyDrawable(drawable);
}
}
- @Override
- public void setFilledDrawableRes(@DrawableRes int res) {
- Drawable drawable = ContextCompat.getDrawable(getContext(), res);
+ private PixelMap getPixelMapFromResource(Context context, int resId) {
+ PixelMap pixelmap;
+ try (InputStream drawableInputStream = context.getResourceManager().getResource(resId)) {
+ ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions();
+ sourceOptions.formatHint = FORMAT;
+ ImageSource imageSource = ImageSource.create(drawableInputStream, sourceOptions);
+ pixelmap = imageSource.createPixelmap(null);
+ return pixelmap;
+ } catch (Exception e) {
+ e.getMessage();
+ }
+ return null;
+ }
+ @Override
+ public void setFilledDrawableRes(int res) {
+ PixelMap drawable = getPixelMapFromResource(getContext(), res);
if (drawable != null) {
setFilledDrawable(drawable);
}
}
@Override
- public void setEmptyDrawable(@NonNull Drawable drawable) {
+ public void setEmptyDrawable(PixelMap drawable) {
mEmptyDrawable = drawable;
for (PartialView partialView : mPartialViews) {
partialView.setEmptyDrawable(drawable);
@@ -297,7 +321,7 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
@Override
- public void setFilledDrawable(@NonNull Drawable drawable) {
+ public void setFilledDrawable(PixelMap drawable) {
mFilledDrawable = drawable;
for (PartialView partialView : mPartialViews) {
partialView.setFilledDrawable(drawable);
@@ -305,7 +329,7 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
@Override
- public void setMinimumStars(@FloatRange(from = 0.0) float minimumStars) {
+ public void setMinimumStars(float minimumStars) {
mMinimumStars = RatingBarUtils.getValidMinimumStars(minimumStars, mNumStars, mStepSize);
}
@@ -355,62 +379,66 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
@Override
- public void setStepSize(@FloatRange(from = 0.1, to = 1.0) float stepSize) {
+ public void setStepSize(float stepSize) {
this.mStepSize = stepSize;
}
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- return true;
- }
@Override
- public boolean onTouchEvent(MotionEvent event) {
+ public boolean onTouchEvent(Component component, TouchEvent event) {
if (isIndicator()) {
return false;
}
-
- float eventX = event.getX();
- float eventY = event.getY();
+ float eventX = event.getPointerPosition(0).getX();
+ float eventY = event.getPointerPosition(0).getY();
switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
+ case TouchEvent.PRIMARY_POINT_DOWN:
mStartX = eventX;
mStartY = eventY;
mPreviousRating = mRating;
+ TouchEventManager.getInstance().getResultCallback().onTouch();
break;
- case MotionEvent.ACTION_MOVE:
+ case TouchEvent.POINT_MOVE:
+ TouchEventManager.getInstance().getResultCallback().onTouch();
if (!isScrollable()) {
return false;
}
-
handleMoveEvent(eventX);
break;
- case MotionEvent.ACTION_UP:
+ case TouchEvent.PRIMARY_POINT_UP:
+ TouchEventManager.getInstance().getResultCallback().onCancel();
if (!RatingBarUtils.isClickEvent(mStartX, mStartY, event) || !isClickable()) {
return false;
}
-
handleClickEvent(eventX);
+ case TouchEvent.CANCEL:
+ TouchEventManager.getInstance().getResultCallback().onCancel();
+ break;
}
-
- getParent().requestDisallowInterceptTouchEvent(true);
return true;
}
private void handleMoveEvent(float eventX) {
for (PartialView partialView : mPartialViews) {
- if (eventX < partialView.getWidth() / 10f + (mMinimumStars * partialView.getWidth())) {
+ BigDecimal bignum1 = new BigDecimal(partialView.getWidth());
+ BigDecimal bignum2 = new BigDecimal(mNmu);
+ BigDecimal bignum3 = new BigDecimal(mMinimumStars);
+ BigDecimal multiply = bignum1.divide(bignum2);
+ BigDecimal multiply1 = bignum3.multiply(bignum1);
+ float temp = multiply.add(multiply1).floatValue();
+ if (eventX < temp) {
setRating(mMinimumStars, true);
return;
}
-
if (!isPositionInRatingView(eventX, partialView)) {
continue;
}
-
float rating = RatingBarUtils.calculateRating(partialView, mStepSize, eventX);
- if (mRating != rating) {
+ BigDecimal bignum4 = new BigDecimal(mRating);
+ BigDecimal bignum5 = new BigDecimal(rating);
+ float floatValue = bignum4.subtract(bignum5).floatValue();
+ if (Math.abs(floatValue) > 0) {
setRating(rating, true);
}
}
@@ -422,8 +450,12 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
continue;
}
- float rating = mStepSize == 1 ? (int) partialView.getTag() : RatingBarUtils.calculateRating(partialView, mStepSize, eventX);
-
+ float rating;
+ if (mStepSize == 1) {
+ rating = (int) partialView.getTag();
+ } else {
+ rating = RatingBarUtils.calculateRating(partialView, mStepSize, eventX);
+ }
if (mPreviousRating == rating && isClearRatingEnabled()) {
setRating(mMinimumStars, true);
} else {
@@ -433,28 +465,15 @@ public class BaseRatingBar extends LinearLayout implements SimpleRatingBar {
}
}
- private boolean isPositionInRatingView(float eventX, View ratingView) {
+ private boolean isPositionInRatingView(float eventX, Component ratingView) {
return eventX > ratingView.getLeft() && eventX < ratingView.getRight();
}
- public void setOnRatingChangeListener(OnRatingChangeListener onRatingChangeListener) {
- mOnRatingChangeListener = onRatingChangeListener;
- }
-
- @Override
- protected Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState ss = new SavedState(superState);
-
- ss.setRating(mRating);
- return ss;
+ public interface OnRatingChangeListener {
+ void onRatingChange(BaseRatingBar ratingBar, float rating, boolean fromUser);
}
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
- super.onRestoreInstanceState(ss.getSuperState());
-
- setRating(ss.getRating());
+ public void setOnRatingChangeListener(OnRatingChangeListener onRatingChangeListener) {
+ mOnRatingChangeListener = onRatingChangeListener;
}
}
\ No newline at end of file
diff --git a/library/src/main/java/com/willy/ratingbar/PartialView.java b/library/src/main/java/com/willy/ratingbar/PartialView.java
index b17fb1ecea68683f3c7dca0f814778f4dffeb9eb..bd8b38e02797b5606aeef2743c7b74d737c3004f 100644
--- a/library/src/main/java/com/willy/ratingbar/PartialView.java
+++ b/library/src/main/java/com/willy/ratingbar/PartialView.java
@@ -1,130 +1,152 @@
package com.willy.ratingbar;
-import android.content.Context;
-import android.graphics.drawable.ClipDrawable;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-
-import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.DependentLayout;
+import ohos.agp.components.DirectionalLayout;
+import ohos.agp.components.Image;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.app.Context;
+import ohos.global.resource.RawFileEntry;
+import ohos.global.resource.ResourceManager;
+import ohos.media.image.ImageSource;
+import ohos.media.image.PixelMap;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+
+import static ohos.agp.components.DependentLayout.LayoutConfig.CENTER_IN_PARENT;
/**
- * Created by willy on 2017/6/3.
+ * Created by willy
+ * on 2017/6/3.
*/
+class PartialView extends DependentLayout {
-class PartialView
- extends RelativeLayout {
-
- private ImageView mFilledView;
- private ImageView mEmptyView;
- private int mStarWidth = 0;
- private int mStarHeight = 0;
+ private Image mFilledView;
+ private Image mEmptyView;
+ private Image mHalfView;
+ private int mStarWidth = 100;
+ private int mStarHeight = 100;
public PartialView(Context context, int partialViewId, int starWidth, int startHeight,
int padding) {
super(context);
-
mStarWidth = starWidth;
mStarHeight = startHeight;
-
setTag(partialViewId);
setPadding(padding, padding, padding, padding);
init();
}
- public PartialView(Context context, AttributeSet attrs) {
+ public PartialView(Context context, AttrSet attrs) {
super(context, attrs);
init();
}
- public PartialView(Context context, AttributeSet attrs, int defStyleAttr) {
+ public PartialView(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
- // Make PartialViews use the space when the RatingBar has more width (e.g. match_parent)
- setLayoutParams(new LinearLayout.LayoutParams(
- LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT,
+ setLayoutConfig(new DirectionalLayout.LayoutConfig(
+ LayoutConfig.MATCH_CONTENT,
+ LayoutConfig.MATCH_CONTENT,
+ LayoutAlignment.CENTER,
1f));
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
- mStarWidth == 0 ? LayoutParams.WRAP_CONTENT : mStarWidth,
- mStarHeight == 0 ? LayoutParams.WRAP_CONTENT : mStarHeight);
+ DependentLayout.LayoutConfig params = new DependentLayout.LayoutConfig(
+ mStarWidth == 0 ? LayoutConfig.MATCH_CONTENT : mStarWidth,
+ mStarHeight == 0 ? LayoutConfig.MATCH_CONTENT : mStarHeight);
params.addRule(CENTER_IN_PARENT);
- mFilledView = new ImageView(getContext());
- mFilledView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- addView(mFilledView, params);
-
- mEmptyView = new ImageView(getContext());
- mEmptyView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- addView(mEmptyView, params);
-
+ mFilledView = new Image(getContext());
+ mFilledView.setScaleMode(Image.ScaleMode.STRETCH);
+ mFilledView.setPixelMap(getPixelMap("resources/rawfile/filled.png"));
+ addComponent(mFilledView, params);
+ mEmptyView = new Image(getContext());
+ mEmptyView.setScaleMode(Image.ScaleMode.STRETCH);
+ mEmptyView.setPixelMap(getPixelMap("resources/rawfile/empty.png"));
+ addComponent(mEmptyView, params);
+ mHalfView = new Image(getContext());
+ mHalfView.setScaleMode(Image.ScaleMode.STRETCH);
+ mHalfView.setPixelMap(getPixelMap("resources/rawfile/half.png"));
+ addComponent(mHalfView, params);
setEmpty();
}
- public void setFilledDrawable(@NonNull Drawable drawable) {
- if (drawable.getConstantState() == null) {
- return;
+ private PixelMap getPixelMap(String rawfile) {
+ ResourceManager resManager = getResourceManager();
+ RawFileEntry rawFileEntry = resManager.getRawFileEntry(rawfile);
+ try {
+ InputStream resource = rawFileEntry.openRawFile();
+ ImageSource imageSource = ImageSource.create(resource, null);
+ return imageSource.createPixelmap(null);
+ } catch (IOException e) {
+ System.out.println(e);
}
-
- ClipDrawable clipDrawable =
- new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.START,
- ClipDrawable.HORIZONTAL);
- mFilledView.setImageDrawable(clipDrawable);
+ return null;
}
- public void setEmptyDrawable(@NonNull Drawable drawable) {
- if (drawable.getConstantState() == null) {
+ public void setFilledDrawable(PixelMap drawable) {
+ if (drawable == null) {
return;
}
+ mFilledView.setPixelMap(drawable);
+ }
- ClipDrawable clipDrawable =
- new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.END,
- ClipDrawable.HORIZONTAL);
- mEmptyView.setImageDrawable(clipDrawable);
+ public void setEmptyDrawable(PixelMap drawable) {
+ if (drawable == null) {
+ return;
+ }
+ mEmptyView.setPixelMap(drawable);
}
public void setFilled() {
- mFilledView.setImageLevel(10000);
- mEmptyView.setImageLevel(0);
+ mFilledView.setVisibility(VISIBLE);
+ mEmptyView.setVisibility(HIDE);
+ mHalfView.setVisibility(HIDE);
}
public void setPartialFilled(float rating) {
- float percentage = rating % 1;
+ BigDecimal decimal1 = new BigDecimal(rating);
+ BigDecimal decimal2 = new BigDecimal(1);
+ BigDecimal[] decimal3 = decimal1.divideAndRemainder(decimal2);
+ float percentage = decimal3[1].floatValue();
int level = (int) (10000 * percentage);
level = level == 0 ? 10000 : level;
- mFilledView.setImageLevel(level);
- mEmptyView.setImageLevel(10000 - level);
+ if (level > 5000) {
+ mFilledView.setVisibility(VISIBLE);
+ mEmptyView.setVisibility(HIDE);
+ mHalfView.setVisibility(HIDE);
+ } else {
+ mFilledView.setVisibility(HIDE);
+ mEmptyView.setVisibility(HIDE);
+ mHalfView.setVisibility(VISIBLE);
+ }
}
public void setEmpty() {
- mFilledView.setImageLevel(0);
- mEmptyView.setImageLevel(10000);
+ mFilledView.setVisibility(HIDE);
+ mHalfView.setVisibility(HIDE);
+ mEmptyView.setVisibility(VISIBLE);
}
- public void setStarWidth(@IntRange(from = 0) int starWidth) {
+ public void setStarWidth(int starWidth) {
mStarWidth = starWidth;
-
- ViewGroup.LayoutParams params = mFilledView.getLayoutParams();
+ ComponentContainer.LayoutConfig params = mFilledView.getLayoutConfig();
params.width = mStarWidth;
- mFilledView.setLayoutParams(params);
- mEmptyView.setLayoutParams(params);
+ mFilledView.setLayoutConfig(params);
+ mEmptyView.setLayoutConfig(params);
}
- public void setStarHeight(@IntRange(from = 0) int starHeight) {
+ public void setStarHeight(int starHeight) {
mStarHeight = starHeight;
-
- ViewGroup.LayoutParams params = mFilledView.getLayoutParams();
+ ComponentContainer.LayoutConfig params = mFilledView.getLayoutConfig();
params.height = mStarHeight;
- mFilledView.setLayoutParams(params);
- mEmptyView.setLayoutParams(params);
+ mFilledView.setLayoutConfig(params);
+ mEmptyView.setLayoutConfig(params);
}
-}
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/willy/ratingbar/RatingBarUtils.java b/library/src/main/java/com/willy/ratingbar/RatingBarUtils.java
index 34d9b54b715ea6405e4f7dd825facd0b59f3633d..eec874d8bac8b9c730afcab4128bf84dabc9ffce 100644
--- a/library/src/main/java/com/willy/ratingbar/RatingBarUtils.java
+++ b/library/src/main/java/com/willy/ratingbar/RatingBarUtils.java
@@ -1,7 +1,8 @@
package com.willy.ratingbar;
-import android.view.MotionEvent;
+import ohos.multimodalinput.event.TouchEvent;
+import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
@@ -16,22 +17,35 @@ class RatingBarUtils {
private static final int MAX_CLICK_DISTANCE = 5;
private static final int MAX_CLICK_DURATION = 200;
- static boolean isClickEvent(float startX, float startY, MotionEvent event) {
- float duration = event.getEventTime() - event.getDownTime();
+ static boolean isClickEvent(float startX, float startY, TouchEvent event) {
+ float duration = event.getStartTime() - event.getOccurredTime();
if (duration > MAX_CLICK_DURATION) {
return false;
}
-
- float differenceX = Math.abs(startX - event.getX());
- float differenceY = Math.abs(startY - event.getY());
+ BigDecimal bignum1 = new BigDecimal(startX);
+ BigDecimal bignum2 = new BigDecimal(event.getPointerPosition(0).getX());
+ float floatValue = bignum1.subtract(bignum2).floatValue();
+ float differenceX = Math.abs(floatValue);
+ BigDecimal bignum3 = new BigDecimal(startY);
+ BigDecimal bignum4 = new BigDecimal(event.getPointerPosition(0).getY());
+ float floatValue2 = bignum3.subtract(bignum4).floatValue();
+ float differenceY = Math.abs(floatValue2);
return !(differenceX > MAX_CLICK_DISTANCE || differenceY > MAX_CLICK_DISTANCE);
}
static float calculateRating(PartialView partialView, float stepSize, float eventX) {
DecimalFormat decimalFormat = RatingBarUtils.getDecimalFormat();
- float ratioOfView = Float.parseFloat(decimalFormat.format((eventX - partialView.getLeft()) / partialView.getWidth()));
+ BigDecimal bignum1 = new BigDecimal(eventX);
+ BigDecimal bignum2 = new BigDecimal(partialView.getLeft());
+ float value = bignum1.subtract(bignum2).floatValue();
+ float ratioOfView = Float.parseFloat(decimalFormat.format((value) / partialView.getWidth()));
float steps = Math.round(ratioOfView / stepSize) * stepSize;
- return Float.parseFloat(decimalFormat.format((int) partialView.getTag() - (1 - steps)));
+ BigDecimal bignum3 = new BigDecimal(1);
+ BigDecimal bignum4 = new BigDecimal(steps);
+ BigDecimal subtract = bignum3.subtract(bignum4);
+ BigDecimal bignum5 = new BigDecimal((int) partialView.getTag());
+ float value1 = bignum5.subtract(subtract).floatValue();
+ return Float.parseFloat(decimalFormat.format(value1));
}
static float getValidMinimumStars(float minimumStars, int numStars, float stepSize) {
@@ -43,7 +57,10 @@ class RatingBarUtils {
minimumStars = numStars;
}
- if (minimumStars % stepSize != 0) {
+ BigDecimal decimal1 = new BigDecimal(minimumStars);
+ BigDecimal decimal2 = new BigDecimal(stepSize);
+ BigDecimal[] cc = decimal1.divideAndRemainder(decimal2);
+ if (cc[1].floatValue() != 0) {
minimumStars = stepSize;
}
return minimumStars;
diff --git a/library/src/main/java/com/willy/ratingbar/RotationRatingBar.java b/library/src/main/java/com/willy/ratingbar/RotationRatingBar.java
index 388125eb243693e1eb78924c82d9c2588953d2ad..b30ce7181e4b55078dd1a5976ce35697cd121e2e 100644
--- a/library/src/main/java/com/willy/ratingbar/RotationRatingBar.java
+++ b/library/src/main/java/com/willy/ratingbar/RotationRatingBar.java
@@ -1,11 +1,13 @@
package com.willy.ratingbar;
-import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorProperty;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.components.AttrSet;
+import ohos.app.Context;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* Created by nappannda on 2017/05/16.
@@ -15,16 +17,13 @@ public class RotationRatingBar extends AnimationRatingBar {
// Control animation speed
private static final long ANIMATION_DELAY = 15;
+ private Map animatorMap = new HashMap<>();
- public RotationRatingBar(Context context) {
- super(context);
- }
-
- public RotationRatingBar(Context context, @Nullable AttributeSet attrs) {
+ public RotationRatingBar(Context context, AttrSet attrs) {
super(context, attrs);
}
- public RotationRatingBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ public RotationRatingBar(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@@ -32,12 +31,12 @@ public class RotationRatingBar extends AnimationRatingBar {
protected void emptyRatingBar() {
// Need to remove all previous runnable to prevent emptyRatingBar and fillRatingBar out of sync
if (mRunnable != null) {
- mHandler.removeCallbacksAndMessages(mRunnableToken);
+ mHandler.removeAllEvent();
}
long delay = 0;
for (final PartialView partialView : mPartialViews) {
- mHandler.postDelayed(new Runnable() {
+ mHandler.postTask(new Runnable() {
@Override
public void run() {
partialView.setEmpty();
@@ -50,7 +49,7 @@ public class RotationRatingBar extends AnimationRatingBar {
protected void fillRatingBar(final float rating) {
// Need to remove all previous runnable to prevent emptyRatingBar and fillRatingBar out of sync
if (mRunnable != null) {
- mHandler.removeCallbacksAndMessages(mRunnableToken);
+ mHandler.removeAllEvent();
}
for (final PartialView partialView : mPartialViews) {
@@ -67,21 +66,66 @@ public class RotationRatingBar extends AnimationRatingBar {
}
}
- @NonNull
private Runnable getAnimationRunnable(final float rating, final PartialView partialView, final int ratingViewId, final double maxIntOfRating) {
return new Runnable() {
@Override
public void run() {
- if (ratingViewId == maxIntOfRating) {
- partialView.setPartialFilled(rating);
- } else {
- partialView.setFilled();
- }
+ getContext().getUITaskDispatcher().asyncDispatch(new Runnable() {
+ @Override
+ public void run() {
+ if (ratingViewId == maxIntOfRating) {
+ partialView.setPartialFilled(rating);
+ } else {
+ partialView.setFilled();
+ }
+ if (ratingViewId == rating) {
+ AnimatorProperty animatorProperty;
+ int tag = (int)partialView.getTag();
+ boolean key = animatorMap.containsKey(tag);
+ if (key){
+ animatorProperty = animatorMap.get(tag);
+ }else{
+ animatorProperty = partialView.createAnimatorProperty();
+ animatorMap.put(tag,animatorProperty);
+ }
+ animatorProperty.stop();
- if (ratingViewId == rating) {
- Animation rotation = AnimationUtils.loadAnimation(getContext(), R.anim.rotation);
- partialView.startAnimation(rotation);
- }
+ animatorProperty.rotate(0).rotate(360).setDuration(500);
+ animatorProperty.setStateChangedListener(new Animator.StateChangedListener() {
+ @Override
+ public void onStart(Animator animator) {
+
+ }
+
+ @Override
+ public void onStop(Animator animator) {
+ animatorProperty.reset();
+ }
+
+ @Override
+ public void onCancel(Animator animator) {
+ animatorProperty.reset();
+ }
+
+ @Override
+ public void onEnd(Animator animator) {
+ animatorProperty.reset();
+ }
+
+ @Override
+ public void onPause(Animator animator) {
+
+ }
+
+ @Override
+ public void onResume(Animator animator) {
+
+ }
+ });
+ animatorProperty.start();
+ }
+ }
+ });
}
};
}
diff --git a/library/src/main/java/com/willy/ratingbar/SavedState.java b/library/src/main/java/com/willy/ratingbar/SavedState.java
index 2e9fdc0f36b66a1d727cada7affbb485988bfb77..be0d23e597cffd126a7a1f7da3f85f30c52fb18a 100644
--- a/library/src/main/java/com/willy/ratingbar/SavedState.java
+++ b/library/src/main/java/com/willy/ratingbar/SavedState.java
@@ -1,54 +1,49 @@
package com.willy.ratingbar;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.view.View;
+import ohos.utils.Parcel;
+import ohos.utils.Sequenceable;
/**
* Created by willy on 2017/11/16.
*/
-class SavedState extends View.BaseSavedState {
+class SavedState implements Sequenceable {
private float rating;
- /**
- * Constructor called from {@link BaseRatingBar#onSaveInstanceState()}
- */
- SavedState(Parcelable superState) {
- super(superState);
+ SavedState() {
}
- /**
- * Constructor called from {@link #CREATOR}
- */
private SavedState(Parcel in) {
- super(in);
rating = in.readFloat();
}
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeFloat(rating);
+ public float getRating() {
+ return rating;
}
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
+ public void setRating(float rating) {
+ this.rating = rating;
+ }
- public SavedState[] newArray(int size) {
- return new SavedState[size];
+ public static final Producer PRODUCER = new Producer() {
+
+ public SavedState createFromParcel(Parcel in) {
+ SavedState adrecordstore = new SavedState(in);
+ adrecordstore.unmarshalling(in);
+ return adrecordstore;
}
};
- public float getRating() {
- return rating;
+ @Override
+ public boolean marshalling(Parcel parcel) {
+ parcel.writeFloat(rating);
+ return false;
}
- public void setRating(float rating) {
- this.rating = rating;
+ @Override
+ public boolean unmarshalling(Parcel parcel) {
+ rating = parcel.readFloat();
+ return false;
}
}
diff --git a/library/src/main/java/com/willy/ratingbar/ScaleRatingBar.java b/library/src/main/java/com/willy/ratingbar/ScaleRatingBar.java
index c49fb31c02bbac4b777c75e184c8e57cd873e804..e3d7f3ff61ff2d56094a11055b5845d48931738f 100644
--- a/library/src/main/java/com/willy/ratingbar/ScaleRatingBar.java
+++ b/library/src/main/java/com/willy/ratingbar/ScaleRatingBar.java
@@ -1,11 +1,14 @@
package com.willy.ratingbar;
-import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorProperty;
+import ohos.agp.components.AttrSet;
+import ohos.app.Context;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* Created by willy on 2017/5/5.
@@ -13,31 +16,25 @@ import android.view.animation.AnimationUtils;
public class ScaleRatingBar extends AnimationRatingBar {
- // Control animation speed
private static final long ANIMATION_DELAY = 15;
+ private Map animatorMap = new HashMap<>();
- public ScaleRatingBar(Context context) {
- super(context);
- }
-
- public ScaleRatingBar(Context context, @Nullable AttributeSet attrs) {
+ public ScaleRatingBar(Context context, AttrSet attrs) {
super(context, attrs);
}
- public ScaleRatingBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ public ScaleRatingBar(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void emptyRatingBar() {
- // Need to remove all previous runnable to prevent emptyRatingBar and fillRatingBar out of sync
if (mRunnable != null) {
- mHandler.removeCallbacksAndMessages(mRunnableToken);
+ mHandler.removeAllEvent();
}
-
long delay = 0;
for (final PartialView view : mPartialViews) {
- mHandler.postDelayed(new Runnable() {
+ mHandler.postTask(new Runnable() {
@Override
public void run() {
view.setEmpty();
@@ -50,40 +47,80 @@ public class ScaleRatingBar extends AnimationRatingBar {
protected void fillRatingBar(final float rating) {
// Need to remove all previous runnable to prevent emptyRatingBar and fillRatingBar out of sync
if (mRunnable != null) {
- mHandler.removeCallbacksAndMessages(mRunnableToken);
+ mHandler.removeAllEvent();
}
-
+ double maxIntOfRating = Math.ceil(rating);
for (final PartialView partialView : mPartialViews) {
final int ratingViewId = (int) partialView.getTag();
- final double maxIntOfRating = Math.ceil(rating);
-
if (ratingViewId > maxIntOfRating) {
partialView.setEmpty();
continue;
}
-
mRunnable = getAnimationRunnable(rating, partialView, ratingViewId, maxIntOfRating);
postRunnable(mRunnable, ANIMATION_DELAY);
}
}
- @NonNull
private Runnable getAnimationRunnable(final float rating, final PartialView partialView, final int ratingViewId, final double maxIntOfRating) {
return new Runnable() {
@Override
public void run() {
- if (ratingViewId == maxIntOfRating) {
- partialView.setPartialFilled(rating);
- } else {
- partialView.setFilled();
- }
-
- if (ratingViewId == rating) {
- Animation scaleUp = AnimationUtils.loadAnimation(getContext(), R.anim.scale_up);
- Animation scaleDown = AnimationUtils.loadAnimation(getContext(), R.anim.scale_down);
- partialView.startAnimation(scaleUp);
- partialView.startAnimation(scaleDown);
- }
+ getContext().getUITaskDispatcher().asyncDispatch(new Runnable() {
+ @Override
+ public void run() {
+ if (ratingViewId == maxIntOfRating) {
+ partialView.setPartialFilled(rating);
+ } else {
+ partialView.setFilled();
+ }
+ if (ratingViewId == rating) {
+ AnimatorProperty animatorProperty;
+ int tag = (int)partialView.getTag();
+ boolean key = animatorMap.containsKey(tag);
+ if (key){
+ animatorProperty = animatorMap.get(tag);
+ }else{
+ animatorProperty = partialView.createAnimatorProperty();
+ animatorMap.put(tag,animatorProperty);
+ }
+ animatorProperty.stop();
+
+ animatorProperty.scaleX(1.0f).scaleX(1.3f).scaleY(1.0f).scaleY(1.3f).setDuration(500);
+ animatorProperty.setStateChangedListener(new Animator.StateChangedListener() {
+ @Override
+ public void onStart(Animator animator) {
+
+ }
+
+ @Override
+ public void onStop(Animator animator) {
+ animatorProperty.reset();
+ }
+
+ @Override
+ public void onCancel(Animator animator) {
+ animatorProperty.reset();
+ }
+
+ @Override
+ public void onEnd(Animator animator) {
+ animatorProperty.reset();
+ }
+
+ @Override
+ public void onPause(Animator animator) {
+
+ }
+
+ @Override
+ public void onResume(Animator animator) {
+
+ }
+ });
+ animatorProperty.start();
+ }
+ }
+ });
}
};
}
diff --git a/library/src/main/java/com/willy/ratingbar/SimpleRatingBar.java b/library/src/main/java/com/willy/ratingbar/SimpleRatingBar.java
index 887bf8400eeeedb0df90d38b0b13fd3482432c63..43e0dfbbe6e979f32fe0cb380a1055da1f3ff952 100644
--- a/library/src/main/java/com/willy/ratingbar/SimpleRatingBar.java
+++ b/library/src/main/java/com/willy/ratingbar/SimpleRatingBar.java
@@ -1,10 +1,6 @@
package com.willy.ratingbar;
-import android.graphics.drawable.Drawable;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.FloatRange;
-import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
+import ohos.media.image.PixelMap;
/**
* Created by willy on 2017/5/10.
@@ -19,11 +15,11 @@ interface SimpleRatingBar {
float getRating();
- void setStarWidth(@IntRange(from = 0) int starWidth);
+ void setStarWidth(int starWidth);
int getStarWidth();
- void setStarHeight(@IntRange(from = 0) int starHeight);
+ void setStarHeight(int starHeight);
int getStarHeight();
@@ -31,15 +27,15 @@ interface SimpleRatingBar {
int getStarPadding();
- void setEmptyDrawable(@NonNull Drawable drawable);
+ void setEmptyDrawable(PixelMap drawable);
- void setEmptyDrawableRes(@DrawableRes int res);
+ void setEmptyDrawableRes(int res);
- void setFilledDrawable(@NonNull Drawable drawable);
+ void setFilledDrawable(PixelMap drawable);
- void setFilledDrawableRes(@DrawableRes int res);
+ void setFilledDrawableRes(int res);
- void setMinimumStars(@FloatRange(from = 0.0) float minimumStars);
+ void setMinimumStars(float minimumStars);
boolean isIndicator();
@@ -59,7 +55,5 @@ interface SimpleRatingBar {
float getStepSize();
- void setStepSize(@FloatRange(from = 0.1, to = 1.0) float stepSize);
-
-
-}
+ void setStepSize(float stepSize);
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/willy/ratingbar/TouchEventManager.java b/library/src/main/java/com/willy/ratingbar/TouchEventManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..371544bd233a1329fcff6706f10af8896ea9c35c
--- /dev/null
+++ b/library/src/main/java/com/willy/ratingbar/TouchEventManager.java
@@ -0,0 +1,74 @@
+/*
+ * 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.ratingbar;
+
+/** TouchEventManager
+ *
+ * @author ljx
+ * @since 2021-07-02
+ */
+public class TouchEventManager {
+ private static TouchEventManager instance;
+ /**
+ * resultCallback
+ */
+ private TouchEventCallback resultCallback;
+
+ /** getInstance
+ *
+ * @return TouchEventManager
+ */
+ public static synchronized TouchEventManager getInstance() {
+ if (instance == null) {
+ instance = new TouchEventManager();
+ }
+ return instance;
+ }
+
+ /** OnScanResultCallback
+ *
+ * @author ljx
+ * @since 2021-07-02
+ */
+ public interface TouchEventCallback {
+ /**
+ * 获得触摸事件回调
+ */
+ void onTouch();
+ /**
+ * 失去触摸事件回调
+ */
+ void onCancel();
+ }
+
+ /**
+ * 获得TouchEventCallback
+ *
+ * @return TouchEventCallback
+ */
+ public TouchEventCallback getResultCallback() {
+ return resultCallback;
+ }
+
+ /**
+ * 设置TouchEventCallback
+ *
+ * @param resultCallback TouchEventCallback
+ */
+ public void setResultCallback(TouchEventCallback resultCallback) {
+ this.resultCallback = resultCallback;
+ }
+}
diff --git a/library/src/main/res/anim/rotation.xml b/library/src/main/res/anim/rotation.xml
deleted file mode 100644
index b458208911f8b7fad247745fb2b9003c6832d52d..0000000000000000000000000000000000000000
--- a/library/src/main/res/anim/rotation.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
\ No newline at end of file
diff --git a/library/src/main/res/anim/scale_down.xml b/library/src/main/res/anim/scale_down.xml
deleted file mode 100644
index 5e245c8fb84814cffc99d710e4f05e64e60968dc..0000000000000000000000000000000000000000
--- a/library/src/main/res/anim/scale_down.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
diff --git a/library/src/main/res/anim/scale_up.xml b/library/src/main/res/anim/scale_up.xml
deleted file mode 100644
index 17d2a5e5bdff169dd2398ab581df39236e330045..0000000000000000000000000000000000000000
--- a/library/src/main/res/anim/scale_up.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
deleted file mode 100644
index d3f34d58c23c2e6ac9282df668bf251135905e7d..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index 1963ac330850fac730dedb853990c6e3012baa15..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- SimpleRatingBar
-
diff --git a/library/src/main/resources/base/element/string.json b/library/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..211a936b6a562815c346636393376e8f1a72a08e
--- /dev/null
+++ b/library/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "library_library",
+ "value": "library_library"
+ }
+ ]
+}
diff --git a/library/src/main/res/drawable/empty.png b/library/src/main/resources/base/media/empty.png
similarity index 100%
rename from library/src/main/res/drawable/empty.png
rename to library/src/main/resources/base/media/empty.png
diff --git a/library/src/main/res/drawable/filled.png b/library/src/main/resources/base/media/filled.png
similarity index 100%
rename from library/src/main/res/drawable/filled.png
rename to library/src/main/resources/base/media/filled.png
diff --git a/library/src/main/resources/base/media/half.png b/library/src/main/resources/base/media/half.png
new file mode 100644
index 0000000000000000000000000000000000000000..ad3e50f92bbf879b8fb38ed6ae9a65d0c4bd7ceb
Binary files /dev/null and b/library/src/main/resources/base/media/half.png differ
diff --git a/library/src/main/resources/rawfile/empty.png b/library/src/main/resources/rawfile/empty.png
new file mode 100644
index 0000000000000000000000000000000000000000..3c7d2dbcb15fd2d8dd220ad0f9abdad4087ba081
Binary files /dev/null and b/library/src/main/resources/rawfile/empty.png differ
diff --git a/library/src/main/resources/rawfile/filled.png b/library/src/main/resources/rawfile/filled.png
new file mode 100644
index 0000000000000000000000000000000000000000..c65ae7316c6650c7a4fcf41ea3f7c6d13bf55537
Binary files /dev/null and b/library/src/main/resources/rawfile/filled.png differ
diff --git a/library/src/main/resources/rawfile/half.png b/library/src/main/resources/rawfile/half.png
new file mode 100644
index 0000000000000000000000000000000000000000..ad3e50f92bbf879b8fb38ed6ae9a65d0c4bd7ceb
Binary files /dev/null and b/library/src/main/resources/rawfile/half.png differ
diff --git a/library/src/test/java/com/willy/ratingbar/ExampleTest.java b/library/src/test/java/com/willy/ratingbar/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..2d2ee30a2aa47d20c65233c27231ac24cabe52df
--- /dev/null
+++ b/library/src/test/java/com/willy/ratingbar/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.willy.ratingbar;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/library/src/test/java/com/willy/ratingbar/ExampleUnitTest.java b/library/src/test/java/com/willy/ratingbar/ExampleUnitTest.java
deleted file mode 100644
index c49991ae047a0f76ab41d95d560f4c31953b0481..0000000000000000000000000000000000000000
--- a/library/src/test/java/com/willy/ratingbar/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.willy.ratingbar;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 7294b5837e9fe73624dc8bef5ae81b4a5d7668e2..d0c7ee8440156d4a9324ac5357770747425fef57 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':library', ':example'
+include ':entry', ':library'