From 8176184d18a8984edbe2254d9c7cd09d6e699cbd Mon Sep 17 00:00:00 2001 From: 0000226003-fuchi Date: Sat, 31 Jul 2021 10:59:10 +0800 Subject: [PATCH] =?UTF-8?q?checkstyle=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.OPENSOURCE | 2 +- .../sample/MainAbility.java | 2 +- .../sample/MyApplication.java | 2 +- .../sample/slice/MainAbilitySlice.java | 6 ++-- .../util/AnimatorValueExt.java | 14 +++++--- .../util/AnimatorValueUtil.java | 33 ++++++++++--------- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/README.OPENSOURCE b/README.OPENSOURCE index 1cf4bab..387acf0 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 7fccf41..04e4f98 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 deb2840..88afce1 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 b9d876c..70ddef3 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 c569779..109843a 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 0ba85be..c5fd21b 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; -- Gitee