# BGABadgeView-Ohos **Repository Path**: chinasoft2_ohos/BGABadgeView-ohos ## Basic Information - **Project Name**: BGABadgeView-Ohos - **Description**: 实现消息徽章拖拽出范围后爆炸效果。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-05-06 - **Last Updated**: 2024-06-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BGABadgeView-Ohos #### 项目介绍 - 项目名称:BGABadgeView-Ohos - 所属系列:openharmony的第三方组件适配移植 - 功能:实现消息徽章拖拽出范围后爆炸效果。 - 项目移植状态:主功能完成 - 调用差异:有,详见调用差异说明 - 开发版本:sdk6,DevEco Studio 2.2 Beta1 - 基线版本:Release 1.2.0 #### 效果演示 #### 安装教程 1.在项目根目录下的build.gradle文件中, ```java allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } } ``` 2.在entry模块的build.gradle文件中, ```java dependencies { implementation('com.gitee.chinasoft_ohos:BGABadgeView-ohos:1.0.0') ...... } ``` 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 组件主要由自定义Component控件和自定义动画组成。 1.自定义控件中实现BGABadgeable接口 2.初始化: ```java // 设置文字徽章 mChatBfab.showTextBadge("8"); // 设置拖动删除徽章的代理 mChatBfab.setDragDismissDelegate(new BGADragDismissDelegate() { @Override public void onDismiss(BGABadgeable badgeable) { // 消息拖动删除回调 } }); // 注册需要添加的徽章自定义View componentList.add(mChatBfab); // componentList徽章自定义View集合,进行统一注册 // topComponent当前view的根布局 BgaBadgeTool.initBgaBadgeDrawView(topComponent, componentList); ``` 3.接口说明: ```java /** * 显示圆点徽章 */ void showCirclePointBadge(); /** * 显示文字徽章 * * @param badgeText */ void showTextBadge(String badgeText); /** * 隐藏徽章 */ void hiddenBadge(); /** * 显示图像徽章 * * @param bitmap */ void showDrawableBadge(Bitmap bitmap); /** * 设置拖动删除徽章的代理 * * @param delegate */ void setDragDismissDelegage(BGADragDismissDelegate delegate); /** * 是否显示徽章 * * @return */ boolean isShowBadge(); /** * 是否可拖动 * * @return */ boolean isDraggable(); /** * 是否正在拖动 * * @return */ boolean isDragging(); /** * 当前Component * * @return */ Component getComponentRect(); /** * 顶层Component */ void setComponent(Component topComponent); /** * 注册顶层Component的Canvas * * @return */ void setDrawTask(Canvas canvas); ``` 4.自定义属性说明 | name | type | info | |-------------------------|-----------|--------------------------------------------------------| | badge_bgColor | color | 徽章背景色| | badge_textColor | color | 徽章文本的颜色 | | badge_textSize | dimension | 徽章文本字体大小 | | badge_verticalMargin | dimension | 徽章背景与宿主控件上下边缘间距离 | | badge_horizontalMargin | dimension | 徽章背景与宿主控件左右边缘间距离 | | badge_padding | dimension | 徽章文本边缘与徽章背景边缘间的距离 | | badge_gravity | string |徽章在宿主控件中的位置 | | badge_draggable | boolean | 是否开启拖拽删除徽章| | badge_isResumeTravel | boolean | 拖拽徽章超出轨迹范围后,再次放回到轨迹范围时,是否恢复轨迹 | | badge_borderWidth | dimension | 徽章描边宽度 | | badge_borderColor | color | 徽章描边颜色 | | badge_dragExtra | dimension | 触发开始拖拽徽章事件的扩展触摸距离 | 5.调用差异说明 删除注解类annotation和注解生成类compiler,采用手动实现接口BGABadgeable来实现。原因说明:Annotation 外部依赖原因无法生成注解类 新增徽章View统一注册API,BgaBadgeTool.initBgaBadgeDrawView(topComponent, componentList); 原因说明:拖拽徽章需要添加到系统级window上并需要监听onTouchEvent事件来进行拖拽和复位效果,系统window不支持。所以在顶层的Component上添加,并使用顶层的Component的画布进行绘制操作 ## 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 ## 版本迭代 - 1.0.0 ## 版权和许可信息 ``` Copyright 2015 bingoogolapple 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. ```