diff --git a/README.md b/README.md index 42f0b53dfcbd11dc3ab0a8055d6c8ecd37df73af..0187c10024c7e1eb406a875430e11eed0e9f6dc9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -FabDialogMorph + ====================== #### 项目介绍 - 项目名称:FabDialogMorph @@ -6,18 +6,18 @@ FabDialogMorph - 功能:Ohos 上的 Fab 和对话框变形动画 - 项目移植状态:完成 - 调用差异:无 -- 开发版本:sdk5,DevEco Studio2.1 release +- 开发版本:sdk6,DevEco Studio2.2 Beat1 - 基线版本:master分支 #### 效果演示 ![效果演示](https://images.gitee.com/uploads/images/2021/0621/110947_e51f6b29_7918188.gif "FABDialog.gif") #### 安装教程 -本项目不涉及 +无 + #### 使用说明 java ```java - public void setStackLayoutWindow(StackLayout stackLayout, boolean isShow) { int intColor = Color.getIntColor("#AA000000"); @@ -92,7 +92,7 @@ CodeCheck代码测试无异常 CloudTest代码测试无异常 -火绒安全病毒安全检测通过 +病毒安全检测通过 当前版本demo功能与原组件基本无差异 diff --git a/build.gradle b/build.gradle index d3c9f1fef7ce4e18162867c20c11bfc65e1a8d28..8c592a611e3fcbe90cf76d82e59ca599eaa8ce2b 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,9 @@ apply plugin: 'com.huawei.ohos.app' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 5 + compatibleSdkVersion 6 } } @@ -19,8 +19,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.4.2' - classpath 'com.huawei.ohos:decctest:1.0.0.7' + classpath 'com.huawei.ohos:hap:2.4.5.0' + classpath 'com.huawei.ohos:decctest:1.2.4.1' } } diff --git a/entry/build.gradle b/entry/build.gradle index 23707da0b48341452e97037483a31de38eba5e31..1d576fe1cddeadf4744e4876ca59ab70c2fe68a4 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,9 +1,9 @@ apply plugin: 'com.huawei.ohos.hap' apply plugin: 'com.huawei.ohos.decctest' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 5 + compatibleSdkVersion 6 } buildTypes { release { diff --git a/entry/src/main/java/io/fabdialogmorph/helper/AnimationHelper.java b/entry/src/main/java/io/fabdialogmorph/helper/AnimationHelper.java index 941bcdf30a773a7501813dc80f7ecc04754084b9..3411d351c2b3e615a18bedaa346b5fa322a13b12 100644 --- a/entry/src/main/java/io/fabdialogmorph/helper/AnimationHelper.java +++ b/entry/src/main/java/io/fabdialogmorph/helper/AnimationHelper.java @@ -1,3 +1,19 @@ +/* + * 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 io.fabdialogmorph.helper; import io.fabdialogmorph.utils.ColorUtils; @@ -63,42 +79,24 @@ public class AnimationHelper { srcollAnimatorValue.setDuration(duration); endAnimatorValue.setDuration(duration); endDialogAnimatorValue.setDuration(duration); + checkIf(viewBean, dialogView, component); - if (isShowDialog) { - dialogView.setContentPositionX(viewBean.getLocationX()); - dialogView.setContentPositionY(viewBean.getLocationY()); - dialogView.setVisibility(Component.VISIBLE); - dialogView.setScale(0, 0); - dialogView.setPivotX(viewBean.getLocationX()); - dialogView.setPivotY(viewBean.getLocationY()); - dialogAnimatorValue.moveToX(viewBean.getMoveX()).moveToY(viewBean.getMoveY()); - dialogAnimatorValue.scaleX(1).scaleY(1).alpha(1); - allAnimatorValue.alpha(1); - } else { - dialogView.setScale(1, 1); - dialogView.setPivotX(viewBean.getMoveX()); - dialogView.setPivotY(viewBean.getMoveY()); - - dialogAnimatorValue.scaleX(0).scaleY(0).alpha(1); - dialogAnimatorValue.moveFromX(dialogView.getContentPositionX()). - moveToX(component.getContentPositionX() - component.getWidth() / NUM_2). - moveFromY(dialogView.getContentPositionY()). - moveToY(component.getContentPositionY() - (viewBean.getWindowFloat().getHeight() / NUM_3 * NUM_2 + viewBean.getWindowFloat().getMarginBottom())); - allAnimatorValue.alpha(1); - } dialogAnimatorValue.setStateChangedListener(new Animator.StateChangedListener() { @Override public void onStart(Animator animator) { } + @Override public void onStop(Animator animator) { if (!isShowDialog) { component.setVisibility(Component.VISIBLE); } } + @Override public void onCancel(Animator animator) { } + @Override public void onEnd(Animator animator) { end.animationGroupEnd(); @@ -115,7 +113,11 @@ public class AnimationHelper { }); animatorGroup.runParallel(dialogAnimatorValue, allAnimatorValue, srcollAnimatorValue); animatorGroup.start(); + exeListener(animatorGroup, end); + } + + private void exeListener(AnimatorGroup animatorGroup, AnimationGroupEnd end) { animatorGroup.setStateChangedListener(new Animator.StateChangedListener() { @Override public void onStart(Animator animator) { @@ -149,7 +151,32 @@ public class AnimationHelper { } }); + } + + private void checkIf(ViewBean viewBean, ComponentContainer dialogView, Component component) { + if (isShowDialog) { + dialogView.setContentPositionX(viewBean.getLocationX()); + dialogView.setContentPositionY(viewBean.getLocationY()); + dialogView.setVisibility(Component.VISIBLE); + dialogView.setScale(0, 0); + dialogView.setPivotX(viewBean.getLocationX()); + dialogView.setPivotY(viewBean.getLocationY()); + dialogAnimatorValue.moveToX(viewBean.getMoveX()).moveToY(viewBean.getMoveY()); + dialogAnimatorValue.scaleX(1).scaleY(1).alpha(1); + allAnimatorValue.alpha(1); + } else { + dialogView.setScale(1, 1); + dialogView.setPivotX(viewBean.getMoveX()); + dialogView.setPivotY(viewBean.getMoveY()); + dialogAnimatorValue.scaleX(0).scaleY(0).alpha(1); + dialogAnimatorValue.moveFromX(dialogView.getContentPositionX()) + .moveToX(component.getContentPositionX() - component.getWidth() / NUM_2) + .moveFromY(dialogView.getContentPositionY()).moveToY(component.getContentPositionY() + - (viewBean.getWindowFloat().getHeight() / NUM_3 * NUM_2 + viewBean + .getWindowFloat().getMarginBottom())); + allAnimatorValue.alpha(1); + } } /** @@ -203,17 +230,14 @@ public class AnimationHelper { animatorValue.setStateChangedListener(new Animator.StateChangedListener() { @Override public void onStart(Animator animator) { - } @Override public void onStop(Animator animator) { - } @Override public void onCancel(Animator animator) { - } @Override @@ -224,12 +248,10 @@ public class AnimationHelper { @Override public void onPause(Animator animator) { - } @Override public void onResume(Animator animator) { - } }); return true; @@ -388,5 +410,4 @@ public class AnimationHelper { RgbColor rgbColor = new RgbColor(ColorUtils.redInt(color), ColorUtils.greenInt(color), ColorUtils.blueInt(color), Color.alpha(color)); } - }