diff --git a/README.OPENSOURCE b/README.OPENSOURCE index 1cf4bab6ba7b98f1876246b8d4148cfa59a6a910..387acf02c6b0672e6c4cda4f2b33abe7c3affabc 100644 --- a/README.OPENSOURCE +++ b/README.OPENSOURCE @@ -4,7 +4,7 @@ "Name": "unifiedcircularpro", - "License": "Apache-2.0 License", + "License": "MIT License", "License File": "LICENSE", diff --git a/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MainAbility.java b/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MainAbility.java index 7fccf41d012f832cfb3e82c43eb4fed27d7d3090..04e4f987a97ada8956abd05259a420d57c6aa8c9 100644 --- a/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MainAbility.java +++ b/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MainAbility.java @@ -1,4 +1,4 @@ -/** +/* * 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. diff --git a/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MyApplication.java b/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MyApplication.java index deb284065685c9fced024692aa78c2953d21e45b..88afce1b6e0aafa9329b1d7f35c525f853a59c49 100644 --- a/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MyApplication.java +++ b/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/MyApplication.java @@ -1,4 +1,4 @@ -/** +/* * 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. diff --git a/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/slice/MainAbilitySlice.java b/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/slice/MainAbilitySlice.java index b9d876ceb6e14173ac9b8cdbc28a70757eeedc90..70ddef336280a09a3b82f2aa9db11d56757308ff 100644 --- a/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/io/github/vrivotti/unifiedcircularprogress/sample/slice/MainAbilitySlice.java @@ -1,11 +1,11 @@ -/** +/* * 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. diff --git a/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueExt.java b/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueExt.java index c569779555a25cb8d57a75deac1f545c9eab0971..109843a0332c8c4c9470e349129911c453273467 100644 --- a/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueExt.java +++ b/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueExt.java @@ -1,11 +1,11 @@ -/** +/* * 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. @@ -53,23 +53,27 @@ public class AnimatorValueExt extends AnimatorValue implements AnimatorValue.Val /** * 获取动画进度 + * * @return float */ public float getAnimatedValue() { return currentValue; } - /** - * 设置动画监听 + /** 设置动画监听 * @param lis 动画监听 */ public void setValueUpdateListener(ValueUpdateListener lis) { this.listener = lis; } + /** 数值更新监听 + * @since 2021-06-15 + */ public interface ValueUpdateListener { /** onAnimationUpdate * @param animatorValue 动画值 + * @since 2021-06-15 */ void onAnimationUpdate(AnimatorValueExt animatorValue); } diff --git a/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueUtil.java b/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueUtil.java index 0ba85be0418b113e3ee04b223db26f63a5c4e051..c5fd21b51c4c841cf6e75652eeb6c6d874339470 100644 --- a/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueUtil.java +++ b/library/src/main/java/io/github/vrivotti/unifiedcircularprogress/util/AnimatorValueUtil.java @@ -1,11 +1,11 @@ -/** +/* * 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. @@ -26,8 +26,10 @@ package io.github.vrivotti.unifiedcircularprogress.util; * @since 2021-04-06 */ public class AnimatorValueUtil { - private int rateSize = 2; - private int negaTive = -1; + static final int RATE_SIZE = 2; + static final int NEGATIVE = -1; + private int rateSize = RATE_SIZE; + private int negaTive = NEGATIVE; private float[] values; private float[][] rate; @@ -36,19 +38,18 @@ public class AnimatorValueUtil { * 如传入连续两个相同参数,则会出现除0异常 * 传参试例: 0.8f,-1.2f,3.5f,0,5 * - * @param tempRate 说明 + * @param tempRate 说明 * @param tempValues 起始值 */ public void ofFloat(float[] tempRate, float[] tempValues) { this.values = tempValues; rate = new float[this.values.length - 1][rateSize]; - // 计算每个变化值的占比和达到该变化值系数 - for (int i = 0; i < rate.length; i++) { - float temp = tempRate[i + 1]; - rate[i][0] = temp; - float tempDuration = this.values[i + 1] - this.values[i]; - rate[i][1] = (this.values[i] > this.values[i + 1] ? negaTive : 1) * - Math.abs(tempDuration / (temp - tempRate[i])); + for (int ii = 0; ii < rate.length; ii++) { // 计算每个变化值的占比和达到该变化值系数 + float temp = tempRate[ii + 1]; + rate[ii][0] = temp; + float tempDuration = this.values[ii + 1] - this.values[ii]; + rate[ii][1] = (this.values[ii] > this.values[ii + 1] ? negaTive : 1) + * Math.abs(tempDuration / (temp - tempRate[ii])); } } @@ -59,9 +60,9 @@ public class AnimatorValueUtil { * @return 通过计算后的值 */ public float getValue(float value) { - for (int i = 0; i < rate.length; i++) { - if (value <= rate[i][0] || value > 1) { - return values[i] + (i == 0 ? value : value - rate[i - 1][0]) * rate[i][1]; + for (int ii = 0; ii < rate.length; ii++) { + if (value <= rate[ii][0] || value > 1) { + return values[ii] + (ii == 0 ? value : value - rate[ii - 1][0]) * rate[ii][1]; } } return value;