
回复
项目名称:CanAnimation
所属系列:openharmony的第三方组件适配移植
功能:使用openharmony属性动画写的一个库,可组建动画队列,可实现同时、顺序、重复播放等。
项目移植状态:翻转动画效果未实现,OpenHarmony没有对应的Camera类支持
调用差异:
开发版本:sdk6,DevEco Studio2.2 Beta1
基线版本: Release 1.0.3
1.在项目根目录下的build.gradle文件中,
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
}
2.在entry模块的build.gradle文件中,
dependencies {
implementation('com.gitee.chinasoft_ohos:canAnimation:1.0.0')
......
}
在sdk5,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
CanObjectAnimator 属性动画使用代码:
CanObjectAnimator builder = CanObjectAnimator.on(view);
animationSequence(builder.moveTo(center.x, center.y, 0),
animationTogether(builder.moveTo(center.x,newPos.x,center.y, newPos.y, 2),
builder.rotateTo(360, 2)
),
animationTogether(builder.scaleTo(0.5f, 0.5f,2),
builder.rotateTo(720,2)
),
animationTogether(
builder.moveTo(newPos.x,center.x, newPos.y,center.y, 2),
builder.scaleTo(0.5f,2, 0.5f,2, 2),
builder.rotateTo(360, 2)
),
CanAnimation.run(new Runnable() {
@Override
public void run() {
if (finalI == 5) {
start_animator.setVisibility(Component.VISIBLE);
}
}
})
).start();
CanObjectAnimator 普通动画使用代码:
AnimatorProperty animatorValue = view.createAnimatorProperty();
animatorValue.moveToX(newPos.getPointX()).moveToY(newPos.getPointY());
animatorValue.setDuration(2000);
Animator end = CanAnimation.run(new Runnable() {
@Override
public void run() {
if (finalI == 5) {
start_animator.setVisibility(Component.VISIBLE);
}
}
});
CanAnimation.animSmall2Big(view, animatorValue, end).start();
过度动画使用 PageFlipper + AnimatorProperty 实现。使用代码:
viewFlipper = (PageFlipper) findComponentById(ResourceTable.Id_vf);
viewFlipper.setTouchEventListener(this::onTouchEvent);
viewFlipper.setDraggedListener(Component.DRAG_HORIZONTAL_VERTICAL, this);
viewFlipper.setFlipPeriod(3000);
viewFlipper.showNext();
viewFlipper.showPrevious();
Optional<Display> display = DisplayManager.getInstance().getDefaultDisplay(this);
DisplayAttributes displayAttributes = display.get().getAttributes();
int width = displayAttributes.width;
AnimatorProperty lInAnim = viewFlipper.createAnimatorProperty();
lInAnim.moveFromX(width).moveToX(0).alphaFrom(0.1f).alpha(1.0f).setDuration(1500);
AnimatorProperty lOutAnim = viewFlipper.createAnimatorProperty();
lOutAnim.moveFromX(0).moveToX(-width).alphaFrom(1.0f).alpha(0.1f).setDuration(1500);
viewFlipper.setIncomingAnimation(lInAnim);
viewFlipper.setOutgoingAnimation(lOutAnim);
if (!viewFlipper.isFlipping()) {
viewFlipper.startFlipping();
}
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
Copyright 2016 canyinghao
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.