api-impl: stubs and fixes for Breezy Weather

This commit is contained in:
Julian Winkler
2025-10-01 09:57:01 +02:00
parent ffbd63cb75
commit a09aa53ecf
20 changed files with 105 additions and 7 deletions

View File

@@ -1,9 +1,20 @@
package android.animation;
public class ArgbEvaluator implements TypeEvaluator {
import android.graphics.Color;
public class ArgbEvaluator implements TypeEvaluator<Integer> {
public static ArgbEvaluator getInstance() {
return null;
}
@Override
public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
return Color.argb(
(int)(fraction * Color.alpha(endValue) + (1 - fraction) * Color.alpha(startValue)+.5f),
(int)(fraction * Color.red(endValue) + (1 - fraction) * Color.red(startValue)+.5f),
(int)(fraction * Color.green(endValue) + (1 - fraction) * Color.green(startValue)+.5f),
(int)(fraction * Color.blue(endValue) + (1 - fraction) * Color.blue(startValue)+.5f));
}
}

View File

@@ -19,7 +19,7 @@ package android.animation;
/**
* This evaluator can be used to perform type interpolation between <code>float</code> values.
*/
public class FloatEvaluator /*implements TypeEvaluator<Number>*/ {
public class FloatEvaluator implements TypeEvaluator<Number> {
/**
* This function returns the result of linearly interpolating the start and end values, with

View File

@@ -13,6 +13,7 @@ public class PropertyValuesHolder {
private String property_name;
private Method setter;
Property property;
private TypeEvaluator<Object> evaluator;
public static PropertyValuesHolder ofFloat(String propertyName, float... values) {
PropertyValuesHolder propertyValuesHolder = new PropertyValuesHolder();
@@ -27,6 +28,7 @@ public class PropertyValuesHolder {
propertyValuesHolder.values_object = values;
propertyValuesHolder.property_name = propertyName;
propertyValuesHolder.value = values[0];
propertyValuesHolder.evaluator = evaluator;
return propertyValuesHolder;
}
@@ -53,6 +55,7 @@ public class PropertyValuesHolder {
propertyValuesHolder.property_name = property.getName();
propertyValuesHolder.property = property;
propertyValuesHolder.value = values[0];
propertyValuesHolder.evaluator = evaluator;
return propertyValuesHolder;
}
@@ -97,14 +100,20 @@ public class PropertyValuesHolder {
return value;
}
public void setEvaluator(TypeEvaluator value) {}
public void setEvaluator(TypeEvaluator<Object> evaluator) {
this.evaluator = evaluator;
}
public void calculateValue(float fraction) {
if (fraction < 0f)
fraction = 0f;
if (fraction > 1f)
fraction = 1f;
if (values_object != null) {
if (values_object != null && evaluator != null) {
int i = (int) (fraction * (values_object.length - 1));
float f = fraction * (values_object.length - 1) - i;
value = evaluator.evaluate(f, values_object[i], values_object[i >= values_object.length - 1 ? i : i+1]);
} else if (values_object != null) {
value = values_object[(int) (fraction * (values_object.length - 1) + 0.5f)];
} else if (values_float != null) {
int i = (int) (fraction * (values_float.length - 1));

View File

@@ -1,5 +1,7 @@
package android.animation;
public interface TypeEvaluator {
public interface TypeEvaluator<T> {
public T evaluate(float fraction, T startValue, T endValue);
}