ADD week 5
This commit is contained in:
@ -0,0 +1,133 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseArray;
|
||||
import androidx.constraintlayout.core.widgets.ConstraintWidget;
|
||||
import androidx.constraintlayout.core.widgets.ConstraintWidgetContainer;
|
||||
import androidx.constraintlayout.core.widgets.HelperWidget;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintSet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Barrier extends ConstraintHelper {
|
||||
public static final int BOTTOM = 3;
|
||||
public static final int END = 6;
|
||||
public static final int LEFT = 0;
|
||||
public static final int RIGHT = 1;
|
||||
public static final int START = 5;
|
||||
public static final int TOP = 2;
|
||||
private androidx.constraintlayout.core.widgets.Barrier mBarrier;
|
||||
private int mIndicatedType;
|
||||
private int mResolvedType;
|
||||
|
||||
public int getType() {
|
||||
return this.mIndicatedType;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.mIndicatedType = type;
|
||||
}
|
||||
|
||||
public Barrier(Context context) {
|
||||
super(context);
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Barrier(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Barrier(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
private void updateType(ConstraintWidget widget, int type, boolean isRtl) {
|
||||
this.mResolvedType = type;
|
||||
if (isRtl) {
|
||||
int i = this.mIndicatedType;
|
||||
if (i == 5) {
|
||||
this.mResolvedType = 1;
|
||||
} else if (i == 6) {
|
||||
this.mResolvedType = 0;
|
||||
}
|
||||
} else {
|
||||
int i2 = this.mIndicatedType;
|
||||
if (i2 == 5) {
|
||||
this.mResolvedType = 0;
|
||||
} else if (i2 == 6) {
|
||||
this.mResolvedType = 1;
|
||||
}
|
||||
}
|
||||
if (widget instanceof androidx.constraintlayout.core.widgets.Barrier) {
|
||||
((androidx.constraintlayout.core.widgets.Barrier) widget).setBarrierType(this.mResolvedType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
public void resolveRtl(ConstraintWidget widget, boolean isRtl) {
|
||||
updateType(widget, this.mIndicatedType, isRtl);
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
protected void init(AttributeSet attrs) {
|
||||
super.init(attrs);
|
||||
this.mBarrier = new androidx.constraintlayout.core.widgets.Barrier();
|
||||
if (attrs != null) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.ConstraintLayout_Layout);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.ConstraintLayout_Layout_barrierDirection) {
|
||||
setType(obtainStyledAttributes.getInt(index, 0));
|
||||
} else if (index == R.styleable.ConstraintLayout_Layout_barrierAllowsGoneWidgets) {
|
||||
this.mBarrier.setAllowsGoneWidget(obtainStyledAttributes.getBoolean(index, true));
|
||||
} else if (index == R.styleable.ConstraintLayout_Layout_barrierMargin) {
|
||||
this.mBarrier.setMargin(obtainStyledAttributes.getDimensionPixelSize(index, 0));
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
this.mHelperWidget = this.mBarrier;
|
||||
validateParams();
|
||||
}
|
||||
|
||||
public void setAllowsGoneWidget(boolean supportGone) {
|
||||
this.mBarrier.setAllowsGoneWidget(supportGone);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean allowsGoneWidget() {
|
||||
return this.mBarrier.getAllowsGoneWidget();
|
||||
}
|
||||
|
||||
public boolean getAllowsGoneWidget() {
|
||||
return this.mBarrier.getAllowsGoneWidget();
|
||||
}
|
||||
|
||||
public void setDpMargin(int margin) {
|
||||
this.mBarrier.setMargin((int) ((margin * getResources().getDisplayMetrics().density) + 0.5f));
|
||||
}
|
||||
|
||||
public int getMargin() {
|
||||
return this.mBarrier.getMargin();
|
||||
}
|
||||
|
||||
public void setMargin(int margin) {
|
||||
this.mBarrier.setMargin(margin);
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
public void loadParameters(ConstraintSet.Constraint constraint, HelperWidget child, ConstraintLayout.LayoutParams layoutParams, SparseArray<ConstraintWidget> mapIdToWidget) {
|
||||
super.loadParameters(constraint, child, layoutParams, mapIdToWidget);
|
||||
if (child instanceof androidx.constraintlayout.core.widgets.Barrier) {
|
||||
androidx.constraintlayout.core.widgets.Barrier barrier = (androidx.constraintlayout.core.widgets.Barrier) child;
|
||||
updateType(barrier, constraint.layout.mBarrierDirection, ((ConstraintWidgetContainer) child.getParent()).isRtl());
|
||||
barrier.setAllowsGoneWidget(constraint.layout.mBarrierAllowsGoneWidgets);
|
||||
barrier.setMargin(constraint.layout.mBarrierMargin);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,447 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.util.Xml;
|
||||
import android.view.View;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConstraintAttribute {
|
||||
private static final String TAG = "TransitionLayout";
|
||||
boolean mBooleanValue;
|
||||
private int mColorValue;
|
||||
private float mFloatValue;
|
||||
private int mIntegerValue;
|
||||
private boolean mMethod;
|
||||
String mName;
|
||||
private String mStringValue;
|
||||
private AttributeType mType;
|
||||
|
||||
public enum AttributeType {
|
||||
INT_TYPE,
|
||||
FLOAT_TYPE,
|
||||
COLOR_TYPE,
|
||||
COLOR_DRAWABLE_TYPE,
|
||||
STRING_TYPE,
|
||||
BOOLEAN_TYPE,
|
||||
DIMENSION_TYPE,
|
||||
REFERENCE_TYPE
|
||||
}
|
||||
|
||||
private static int clamp(int c) {
|
||||
int i = (c & (~(c >> 31))) - 255;
|
||||
return (i & (i >> 31)) + 255;
|
||||
}
|
||||
|
||||
public int getColorValue() {
|
||||
return this.mColorValue;
|
||||
}
|
||||
|
||||
public float getFloatValue() {
|
||||
return this.mFloatValue;
|
||||
}
|
||||
|
||||
public int getIntegerValue() {
|
||||
return this.mIntegerValue;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.mName;
|
||||
}
|
||||
|
||||
public String getStringValue() {
|
||||
return this.mStringValue;
|
||||
}
|
||||
|
||||
public AttributeType getType() {
|
||||
return this.mType;
|
||||
}
|
||||
|
||||
public boolean isBooleanValue() {
|
||||
return this.mBooleanValue;
|
||||
}
|
||||
|
||||
public boolean isMethod() {
|
||||
return this.mMethod;
|
||||
}
|
||||
|
||||
public void setColorValue(int value) {
|
||||
this.mColorValue = value;
|
||||
}
|
||||
|
||||
public void setFloatValue(float value) {
|
||||
this.mFloatValue = value;
|
||||
}
|
||||
|
||||
public void setIntValue(int value) {
|
||||
this.mIntegerValue = value;
|
||||
}
|
||||
|
||||
public void setStringValue(String value) {
|
||||
this.mStringValue = value;
|
||||
}
|
||||
|
||||
public boolean isContinuous() {
|
||||
int i = AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[this.mType.ordinal()];
|
||||
return (i == 1 || i == 2 || i == 3) ? false : true;
|
||||
}
|
||||
|
||||
public int numberOfInterpolatedValues() {
|
||||
int i = AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[this.mType.ordinal()];
|
||||
return (i == 4 || i == 5) ? 4 : 1;
|
||||
}
|
||||
|
||||
public float getValueToInterpolate() {
|
||||
switch (this.mType) {
|
||||
case BOOLEAN_TYPE:
|
||||
return this.mBooleanValue ? 1.0f : 0.0f;
|
||||
case STRING_TYPE:
|
||||
throw new RuntimeException("Cannot interpolate String");
|
||||
case COLOR_TYPE:
|
||||
case COLOR_DRAWABLE_TYPE:
|
||||
throw new RuntimeException("Color does not have a single color to interpolate");
|
||||
case INT_TYPE:
|
||||
return this.mIntegerValue;
|
||||
case FLOAT_TYPE:
|
||||
return this.mFloatValue;
|
||||
case DIMENSION_TYPE:
|
||||
return this.mFloatValue;
|
||||
default:
|
||||
return Float.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public void getValuesToInterpolate(float[] ret) {
|
||||
switch (this.mType) {
|
||||
case BOOLEAN_TYPE:
|
||||
ret[0] = this.mBooleanValue ? 1.0f : 0.0f;
|
||||
return;
|
||||
case STRING_TYPE:
|
||||
throw new RuntimeException("Color does not have a single color to interpolate");
|
||||
case COLOR_TYPE:
|
||||
case COLOR_DRAWABLE_TYPE:
|
||||
int i = (this.mColorValue >> 24) & 255;
|
||||
float pow = (float) Math.pow(((r0 >> 16) & 255) / 255.0f, 2.2d);
|
||||
float pow2 = (float) Math.pow(((r0 >> 8) & 255) / 255.0f, 2.2d);
|
||||
float pow3 = (float) Math.pow((r0 & 255) / 255.0f, 2.2d);
|
||||
ret[0] = pow;
|
||||
ret[1] = pow2;
|
||||
ret[2] = pow3;
|
||||
ret[3] = i / 255.0f;
|
||||
return;
|
||||
case INT_TYPE:
|
||||
ret[0] = this.mIntegerValue;
|
||||
return;
|
||||
case FLOAT_TYPE:
|
||||
ret[0] = this.mFloatValue;
|
||||
return;
|
||||
case DIMENSION_TYPE:
|
||||
ret[0] = this.mFloatValue;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(float[] value) {
|
||||
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[this.mType.ordinal()]) {
|
||||
case 1:
|
||||
case 6:
|
||||
this.mIntegerValue = (int) value[0];
|
||||
return;
|
||||
case 2:
|
||||
this.mBooleanValue = ((double) value[0]) > 0.5d;
|
||||
return;
|
||||
case 3:
|
||||
throw new RuntimeException("Color does not have a single color to interpolate");
|
||||
case 4:
|
||||
case 5:
|
||||
int HSVToColor = Color.HSVToColor(value);
|
||||
this.mColorValue = HSVToColor;
|
||||
this.mColorValue = (clamp((int) (value[3] * 255.0f)) << 24) | (HSVToColor & ViewCompat.MEASURED_SIZE_MASK);
|
||||
return;
|
||||
case 7:
|
||||
this.mFloatValue = value[0];
|
||||
return;
|
||||
case 8:
|
||||
this.mFloatValue = value[0];
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean diff(ConstraintAttribute constraintAttribute) {
|
||||
if (constraintAttribute == null || this.mType != constraintAttribute.mType) {
|
||||
return false;
|
||||
}
|
||||
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[this.mType.ordinal()]) {
|
||||
case 1:
|
||||
case 6:
|
||||
if (this.mIntegerValue == constraintAttribute.mIntegerValue) {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.mBooleanValue == constraintAttribute.mBooleanValue) {
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (this.mIntegerValue == constraintAttribute.mIntegerValue) {
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
if (this.mColorValue == constraintAttribute.mColorValue) {
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (this.mFloatValue == constraintAttribute.mFloatValue) {
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (this.mFloatValue == constraintAttribute.mFloatValue) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ConstraintAttribute(String name, AttributeType attributeType) {
|
||||
this.mMethod = false;
|
||||
this.mName = name;
|
||||
this.mType = attributeType;
|
||||
}
|
||||
|
||||
public ConstraintAttribute(String name, AttributeType attributeType, Object value, boolean method) {
|
||||
this.mName = name;
|
||||
this.mType = attributeType;
|
||||
this.mMethod = method;
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public ConstraintAttribute(ConstraintAttribute source, Object value) {
|
||||
this.mMethod = false;
|
||||
this.mName = source.mName;
|
||||
this.mType = source.mType;
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[this.mType.ordinal()]) {
|
||||
case 1:
|
||||
case 6:
|
||||
this.mIntegerValue = ((Integer) value).intValue();
|
||||
break;
|
||||
case 2:
|
||||
this.mBooleanValue = ((Boolean) value).booleanValue();
|
||||
break;
|
||||
case 3:
|
||||
this.mStringValue = (String) value;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
this.mColorValue = ((Integer) value).intValue();
|
||||
break;
|
||||
case 7:
|
||||
this.mFloatValue = ((Float) value).floatValue();
|
||||
break;
|
||||
case 8:
|
||||
this.mFloatValue = ((Float) value).floatValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<String, ConstraintAttribute> extractAttributes(HashMap<String, ConstraintAttribute> base, View view) {
|
||||
HashMap<String, ConstraintAttribute> hashMap = new HashMap<>();
|
||||
Class<?> cls = view.getClass();
|
||||
for (String str : base.keySet()) {
|
||||
ConstraintAttribute constraintAttribute = base.get(str);
|
||||
try {
|
||||
if (str.equals("BackgroundColor")) {
|
||||
hashMap.put(str, new ConstraintAttribute(constraintAttribute, Integer.valueOf(((ColorDrawable) view.getBackground()).getColor())));
|
||||
} else {
|
||||
hashMap.put(str, new ConstraintAttribute(constraintAttribute, cls.getMethod("getMap" + str, new Class[0]).invoke(view, new Object[0])));
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (InvocationTargetException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public static void setAttributes(View view, HashMap<String, ConstraintAttribute> map) {
|
||||
Class<?> cls = view.getClass();
|
||||
for (String str : map.keySet()) {
|
||||
ConstraintAttribute constraintAttribute = map.get(str);
|
||||
String str2 = constraintAttribute.mMethod ? str : "set" + str;
|
||||
try {
|
||||
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[constraintAttribute.mType.ordinal()]) {
|
||||
case 1:
|
||||
cls.getMethod(str2, Integer.TYPE).invoke(view, Integer.valueOf(constraintAttribute.mIntegerValue));
|
||||
break;
|
||||
case 2:
|
||||
cls.getMethod(str2, Boolean.TYPE).invoke(view, Boolean.valueOf(constraintAttribute.mBooleanValue));
|
||||
break;
|
||||
case 3:
|
||||
cls.getMethod(str2, CharSequence.class).invoke(view, constraintAttribute.mStringValue);
|
||||
break;
|
||||
case 4:
|
||||
cls.getMethod(str2, Integer.TYPE).invoke(view, Integer.valueOf(constraintAttribute.mColorValue));
|
||||
break;
|
||||
case 5:
|
||||
Method method = cls.getMethod(str2, Drawable.class);
|
||||
ColorDrawable colorDrawable = new ColorDrawable();
|
||||
colorDrawable.setColor(constraintAttribute.mColorValue);
|
||||
method.invoke(view, colorDrawable);
|
||||
break;
|
||||
case 6:
|
||||
cls.getMethod(str2, Integer.TYPE).invoke(view, Integer.valueOf(constraintAttribute.mIntegerValue));
|
||||
break;
|
||||
case 7:
|
||||
cls.getMethod(str2, Float.TYPE).invoke(view, Float.valueOf(constraintAttribute.mFloatValue));
|
||||
break;
|
||||
case 8:
|
||||
cls.getMethod(str2, Float.TYPE).invoke(view, Float.valueOf(constraintAttribute.mFloatValue));
|
||||
break;
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(TAG, " Custom Attribute \"" + str + "\" not found on " + cls.getName());
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
Log.e(TAG, e2.getMessage());
|
||||
Log.e(TAG, " Custom Attribute \"" + str + "\" not found on " + cls.getName());
|
||||
Log.e(TAG, cls.getName() + " must have a method " + str2);
|
||||
} catch (InvocationTargetException e3) {
|
||||
Log.e(TAG, " Custom Attribute \"" + str + "\" not found on " + cls.getName());
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applyCustom(View view) {
|
||||
String str;
|
||||
Class<?> cls = view.getClass();
|
||||
String str2 = this.mName;
|
||||
if (this.mMethod) {
|
||||
str = str2;
|
||||
} else {
|
||||
str = "set" + str2;
|
||||
}
|
||||
try {
|
||||
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[this.mType.ordinal()]) {
|
||||
case 1:
|
||||
case 6:
|
||||
cls.getMethod(str, Integer.TYPE).invoke(view, Integer.valueOf(this.mIntegerValue));
|
||||
break;
|
||||
case 2:
|
||||
cls.getMethod(str, Boolean.TYPE).invoke(view, Boolean.valueOf(this.mBooleanValue));
|
||||
break;
|
||||
case 3:
|
||||
cls.getMethod(str, CharSequence.class).invoke(view, this.mStringValue);
|
||||
break;
|
||||
case 4:
|
||||
cls.getMethod(str, Integer.TYPE).invoke(view, Integer.valueOf(this.mColorValue));
|
||||
break;
|
||||
case 5:
|
||||
Method method = cls.getMethod(str, Drawable.class);
|
||||
ColorDrawable colorDrawable = new ColorDrawable();
|
||||
colorDrawable.setColor(this.mColorValue);
|
||||
method.invoke(view, colorDrawable);
|
||||
break;
|
||||
case 7:
|
||||
cls.getMethod(str, Float.TYPE).invoke(view, Float.valueOf(this.mFloatValue));
|
||||
break;
|
||||
case 8:
|
||||
cls.getMethod(str, Float.TYPE).invoke(view, Float.valueOf(this.mFloatValue));
|
||||
break;
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(TAG, " Custom Attribute \"" + str2 + "\" not found on " + cls.getName());
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
Log.e(TAG, e2.getMessage());
|
||||
Log.e(TAG, " Custom Attribute \"" + str2 + "\" not found on " + cls.getName());
|
||||
Log.e(TAG, cls.getName() + " must have a method " + str);
|
||||
} catch (InvocationTargetException e3) {
|
||||
Log.e(TAG, " Custom Attribute \"" + str2 + "\" not found on " + cls.getName());
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void parse(Context context, XmlPullParser parser, HashMap<String, ConstraintAttribute> custom) {
|
||||
AttributeType attributeType;
|
||||
Object valueOf;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.CustomAttribute);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
String str = null;
|
||||
Object obj = null;
|
||||
AttributeType attributeType2 = null;
|
||||
boolean z = false;
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.CustomAttribute_attributeName) {
|
||||
str = obtainStyledAttributes.getString(index);
|
||||
if (str != null && str.length() > 0) {
|
||||
str = Character.toUpperCase(str.charAt(0)) + str.substring(1);
|
||||
}
|
||||
} else if (index == R.styleable.CustomAttribute_methodName) {
|
||||
str = obtainStyledAttributes.getString(index);
|
||||
z = true;
|
||||
} else if (index == R.styleable.CustomAttribute_customBoolean) {
|
||||
obj = Boolean.valueOf(obtainStyledAttributes.getBoolean(index, false));
|
||||
attributeType2 = AttributeType.BOOLEAN_TYPE;
|
||||
} else {
|
||||
if (index == R.styleable.CustomAttribute_customColorValue) {
|
||||
attributeType = AttributeType.COLOR_TYPE;
|
||||
valueOf = Integer.valueOf(obtainStyledAttributes.getColor(index, 0));
|
||||
} else if (index == R.styleable.CustomAttribute_customColorDrawableValue) {
|
||||
attributeType = AttributeType.COLOR_DRAWABLE_TYPE;
|
||||
valueOf = Integer.valueOf(obtainStyledAttributes.getColor(index, 0));
|
||||
} else if (index == R.styleable.CustomAttribute_customPixelDimension) {
|
||||
attributeType = AttributeType.DIMENSION_TYPE;
|
||||
valueOf = Float.valueOf(TypedValue.applyDimension(1, obtainStyledAttributes.getDimension(index, 0.0f), context.getResources().getDisplayMetrics()));
|
||||
} else if (index == R.styleable.CustomAttribute_customDimension) {
|
||||
attributeType = AttributeType.DIMENSION_TYPE;
|
||||
valueOf = Float.valueOf(obtainStyledAttributes.getDimension(index, 0.0f));
|
||||
} else if (index == R.styleable.CustomAttribute_customFloatValue) {
|
||||
attributeType = AttributeType.FLOAT_TYPE;
|
||||
valueOf = Float.valueOf(obtainStyledAttributes.getFloat(index, Float.NaN));
|
||||
} else if (index == R.styleable.CustomAttribute_customIntegerValue) {
|
||||
attributeType = AttributeType.INT_TYPE;
|
||||
valueOf = Integer.valueOf(obtainStyledAttributes.getInteger(index, -1));
|
||||
} else if (index == R.styleable.CustomAttribute_customStringValue) {
|
||||
attributeType = AttributeType.STRING_TYPE;
|
||||
valueOf = obtainStyledAttributes.getString(index);
|
||||
} else if (index == R.styleable.CustomAttribute_customReference) {
|
||||
attributeType = AttributeType.REFERENCE_TYPE;
|
||||
int resourceId = obtainStyledAttributes.getResourceId(index, -1);
|
||||
if (resourceId == -1) {
|
||||
resourceId = obtainStyledAttributes.getInt(index, -1);
|
||||
}
|
||||
valueOf = Integer.valueOf(resourceId);
|
||||
}
|
||||
Object obj2 = valueOf;
|
||||
attributeType2 = attributeType;
|
||||
obj = obj2;
|
||||
}
|
||||
}
|
||||
if (str != null && obj != null) {
|
||||
custom.put(str, new ConstraintAttribute(str, attributeType2, obj, z));
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
@ -0,0 +1,472 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import androidx.constraintlayout.core.widgets.ConstraintWidget;
|
||||
import androidx.constraintlayout.core.widgets.ConstraintWidgetContainer;
|
||||
import androidx.constraintlayout.core.widgets.Helper;
|
||||
import androidx.constraintlayout.core.widgets.HelperWidget;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintSet;
|
||||
import androidx.constraintlayout.widget.R;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ConstraintHelper extends View {
|
||||
protected int mCount;
|
||||
protected Helper mHelperWidget;
|
||||
protected int[] mIds;
|
||||
protected HashMap<Integer, String> mMap;
|
||||
protected String mReferenceIds;
|
||||
protected String mReferenceTags;
|
||||
protected boolean mUseViewMeasure;
|
||||
private View[] mViews;
|
||||
protected Context myContext;
|
||||
|
||||
protected void applyLayoutFeaturesInConstraintSet(ConstraintLayout container) {
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onDraw(Canvas canvas) {
|
||||
}
|
||||
|
||||
public void resolveRtl(ConstraintWidget widget, boolean isRtl) {
|
||||
}
|
||||
|
||||
public void updatePostConstraints(ConstraintLayout container) {
|
||||
}
|
||||
|
||||
public void updatePostLayout(ConstraintLayout container) {
|
||||
}
|
||||
|
||||
public void updatePostMeasure(ConstraintLayout container) {
|
||||
}
|
||||
|
||||
public void updatePreDraw(ConstraintLayout container) {
|
||||
}
|
||||
|
||||
public ConstraintHelper(Context context) {
|
||||
super(context);
|
||||
this.mIds = new int[32];
|
||||
this.mUseViewMeasure = false;
|
||||
this.mViews = null;
|
||||
this.mMap = new HashMap<>();
|
||||
this.myContext = context;
|
||||
init(null);
|
||||
}
|
||||
|
||||
public ConstraintHelper(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.mIds = new int[32];
|
||||
this.mUseViewMeasure = false;
|
||||
this.mViews = null;
|
||||
this.mMap = new HashMap<>();
|
||||
this.myContext = context;
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public ConstraintHelper(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mIds = new int[32];
|
||||
this.mUseViewMeasure = false;
|
||||
this.mViews = null;
|
||||
this.mMap = new HashMap<>();
|
||||
this.myContext = context;
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
protected void init(AttributeSet attrs) {
|
||||
if (attrs != null) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.ConstraintLayout_Layout);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.ConstraintLayout_Layout_constraint_referenced_ids) {
|
||||
String string = obtainStyledAttributes.getString(index);
|
||||
this.mReferenceIds = string;
|
||||
setIds(string);
|
||||
} else if (index == R.styleable.ConstraintLayout_Layout_constraint_referenced_tags) {
|
||||
String string2 = obtainStyledAttributes.getString(index);
|
||||
this.mReferenceTags = string2;
|
||||
setReferenceTags(string2);
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
String str = this.mReferenceIds;
|
||||
if (str != null) {
|
||||
setIds(str);
|
||||
}
|
||||
String str2 = this.mReferenceTags;
|
||||
if (str2 != null) {
|
||||
setReferenceTags(str2);
|
||||
}
|
||||
}
|
||||
|
||||
public void addView(View view) {
|
||||
if (view == this) {
|
||||
return;
|
||||
}
|
||||
if (view.getId() == -1) {
|
||||
Log.e("ConstraintHelper", "Views added to a ConstraintHelper need to have an id");
|
||||
} else {
|
||||
if (view.getParent() == null) {
|
||||
Log.e("ConstraintHelper", "Views added to a ConstraintHelper need to have a parent");
|
||||
return;
|
||||
}
|
||||
this.mReferenceIds = null;
|
||||
addRscID(view.getId());
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public int removeView(View view) {
|
||||
int i;
|
||||
int id = view.getId();
|
||||
int i2 = -1;
|
||||
if (id == -1) {
|
||||
return -1;
|
||||
}
|
||||
this.mReferenceIds = null;
|
||||
int i3 = 0;
|
||||
while (true) {
|
||||
if (i3 >= this.mCount) {
|
||||
break;
|
||||
}
|
||||
if (this.mIds[i3] == id) {
|
||||
int i4 = i3;
|
||||
while (true) {
|
||||
i = this.mCount;
|
||||
if (i4 >= i - 1) {
|
||||
break;
|
||||
}
|
||||
int[] iArr = this.mIds;
|
||||
int i5 = i4 + 1;
|
||||
iArr[i4] = iArr[i5];
|
||||
i4 = i5;
|
||||
}
|
||||
this.mIds[i - 1] = 0;
|
||||
this.mCount = i - 1;
|
||||
i2 = i3;
|
||||
} else {
|
||||
i3++;
|
||||
}
|
||||
}
|
||||
requestLayout();
|
||||
return i2;
|
||||
}
|
||||
|
||||
public int[] getReferencedIds() {
|
||||
return Arrays.copyOf(this.mIds, this.mCount);
|
||||
}
|
||||
|
||||
public void setReferencedIds(int[] ids) {
|
||||
this.mReferenceIds = null;
|
||||
this.mCount = 0;
|
||||
for (int i : ids) {
|
||||
addRscID(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void addRscID(int id) {
|
||||
if (id == getId()) {
|
||||
return;
|
||||
}
|
||||
int i = this.mCount + 1;
|
||||
int[] iArr = this.mIds;
|
||||
if (i > iArr.length) {
|
||||
this.mIds = Arrays.copyOf(iArr, iArr.length * 2);
|
||||
}
|
||||
int[] iArr2 = this.mIds;
|
||||
int i2 = this.mCount;
|
||||
iArr2[i2] = id;
|
||||
this.mCount = i2 + 1;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (this.mUseViewMeasure) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
} else {
|
||||
setMeasuredDimension(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void validateParams() {
|
||||
if (this.mHelperWidget == null) {
|
||||
return;
|
||||
}
|
||||
ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
||||
if (layoutParams instanceof ConstraintLayout.LayoutParams) {
|
||||
((ConstraintLayout.LayoutParams) layoutParams).widget = (ConstraintWidget) this.mHelperWidget;
|
||||
}
|
||||
}
|
||||
|
||||
private void addID(String idString) {
|
||||
if (idString == null || idString.length() == 0 || this.myContext == null) {
|
||||
return;
|
||||
}
|
||||
String trim = idString.trim();
|
||||
if (getParent() instanceof ConstraintLayout) {
|
||||
}
|
||||
int findId = findId(trim);
|
||||
if (findId != 0) {
|
||||
this.mMap.put(Integer.valueOf(findId), trim);
|
||||
addRscID(findId);
|
||||
} else {
|
||||
Log.w("ConstraintHelper", "Could not find id of \"" + trim + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
private void addTag(String tagString) {
|
||||
if (tagString == null || tagString.length() == 0 || this.myContext == null) {
|
||||
return;
|
||||
}
|
||||
String trim = tagString.trim();
|
||||
ConstraintLayout constraintLayout = getParent() instanceof ConstraintLayout ? (ConstraintLayout) getParent() : null;
|
||||
if (constraintLayout == null) {
|
||||
Log.w("ConstraintHelper", "Parent not a ConstraintLayout");
|
||||
return;
|
||||
}
|
||||
int childCount = constraintLayout.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = constraintLayout.getChildAt(i);
|
||||
ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
|
||||
if ((layoutParams instanceof ConstraintLayout.LayoutParams) && trim.equals(((ConstraintLayout.LayoutParams) layoutParams).constraintTag)) {
|
||||
if (childAt.getId() == -1) {
|
||||
Log.w("ConstraintHelper", "to use ConstraintTag view " + childAt.getClass().getSimpleName() + " must have an ID");
|
||||
} else {
|
||||
addRscID(childAt.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int findId(String referenceId) {
|
||||
ConstraintLayout constraintLayout = getParent() instanceof ConstraintLayout ? (ConstraintLayout) getParent() : null;
|
||||
int i = 0;
|
||||
if (isInEditMode() && constraintLayout != null) {
|
||||
Object designInformation = constraintLayout.getDesignInformation(0, referenceId);
|
||||
if (designInformation instanceof Integer) {
|
||||
i = ((Integer) designInformation).intValue();
|
||||
}
|
||||
}
|
||||
if (i == 0 && constraintLayout != null) {
|
||||
i = findId(constraintLayout, referenceId);
|
||||
}
|
||||
if (i == 0) {
|
||||
try {
|
||||
i = R.id.class.getField(referenceId).getInt(null);
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
return i == 0 ? this.myContext.getResources().getIdentifier(referenceId, "id", this.myContext.getPackageName()) : i;
|
||||
}
|
||||
|
||||
private int findId(ConstraintLayout container, String idString) {
|
||||
Resources resources;
|
||||
String str;
|
||||
if (idString == null || container == null || (resources = this.myContext.getResources()) == null) {
|
||||
return 0;
|
||||
}
|
||||
int childCount = container.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = container.getChildAt(i);
|
||||
if (childAt.getId() != -1) {
|
||||
try {
|
||||
str = resources.getResourceEntryName(childAt.getId());
|
||||
} catch (Resources.NotFoundException unused) {
|
||||
str = null;
|
||||
}
|
||||
if (idString.equals(str)) {
|
||||
return childAt.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void setIds(String idList) {
|
||||
this.mReferenceIds = idList;
|
||||
if (idList == null) {
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
this.mCount = 0;
|
||||
while (true) {
|
||||
int indexOf = idList.indexOf(44, i);
|
||||
if (indexOf == -1) {
|
||||
addID(idList.substring(i));
|
||||
return;
|
||||
} else {
|
||||
addID(idList.substring(i, indexOf));
|
||||
i = indexOf + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setReferenceTags(String tagList) {
|
||||
this.mReferenceTags = tagList;
|
||||
if (tagList == null) {
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
this.mCount = 0;
|
||||
while (true) {
|
||||
int indexOf = tagList.indexOf(44, i);
|
||||
if (indexOf == -1) {
|
||||
addTag(tagList.substring(i));
|
||||
return;
|
||||
} else {
|
||||
addTag(tagList.substring(i, indexOf));
|
||||
i = indexOf + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyLayoutFeatures(ConstraintLayout container) {
|
||||
int visibility = getVisibility();
|
||||
float elevation = getElevation();
|
||||
for (int i = 0; i < this.mCount; i++) {
|
||||
View viewById = container.getViewById(this.mIds[i]);
|
||||
if (viewById != null) {
|
||||
viewById.setVisibility(visibility);
|
||||
if (elevation > 0.0f) {
|
||||
viewById.setTranslationZ(viewById.getTranslationZ() + elevation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyLayoutFeatures() {
|
||||
ViewParent parent = getParent();
|
||||
if (parent == null || !(parent instanceof ConstraintLayout)) {
|
||||
return;
|
||||
}
|
||||
applyLayoutFeatures((ConstraintLayout) parent);
|
||||
}
|
||||
|
||||
public void updatePreLayout(ConstraintLayout container) {
|
||||
String str;
|
||||
int findId;
|
||||
if (isInEditMode()) {
|
||||
setIds(this.mReferenceIds);
|
||||
}
|
||||
Helper helper = this.mHelperWidget;
|
||||
if (helper == null) {
|
||||
return;
|
||||
}
|
||||
helper.removeAllIds();
|
||||
for (int i = 0; i < this.mCount; i++) {
|
||||
int i2 = this.mIds[i];
|
||||
View viewById = container.getViewById(i2);
|
||||
if (viewById == null && (findId = findId(container, (str = this.mMap.get(Integer.valueOf(i2))))) != 0) {
|
||||
this.mIds[i] = findId;
|
||||
this.mMap.put(Integer.valueOf(findId), str);
|
||||
viewById = container.getViewById(findId);
|
||||
}
|
||||
if (viewById != null) {
|
||||
this.mHelperWidget.add(container.getViewWidget(viewById));
|
||||
}
|
||||
}
|
||||
this.mHelperWidget.updateConstraints(container.mLayoutWidget);
|
||||
}
|
||||
|
||||
public void updatePreLayout(ConstraintWidgetContainer container, Helper helper, SparseArray<ConstraintWidget> map) {
|
||||
helper.removeAllIds();
|
||||
for (int i = 0; i < this.mCount; i++) {
|
||||
helper.add(map.get(this.mIds[i]));
|
||||
}
|
||||
}
|
||||
|
||||
protected View[] getViews(ConstraintLayout layout) {
|
||||
View[] viewArr = this.mViews;
|
||||
if (viewArr == null || viewArr.length != this.mCount) {
|
||||
this.mViews = new View[this.mCount];
|
||||
}
|
||||
for (int i = 0; i < this.mCount; i++) {
|
||||
this.mViews[i] = layout.getViewById(this.mIds[i]);
|
||||
}
|
||||
return this.mViews;
|
||||
}
|
||||
|
||||
public void loadParameters(ConstraintSet.Constraint constraint, HelperWidget child, ConstraintLayout.LayoutParams layoutParams, SparseArray<ConstraintWidget> mapIdToWidget) {
|
||||
if (constraint.layout.mReferenceIds != null) {
|
||||
setReferencedIds(constraint.layout.mReferenceIds);
|
||||
} else if (constraint.layout.mReferenceIdString != null) {
|
||||
if (constraint.layout.mReferenceIdString.length() > 0) {
|
||||
constraint.layout.mReferenceIds = convertReferenceString(this, constraint.layout.mReferenceIdString);
|
||||
} else {
|
||||
constraint.layout.mReferenceIds = null;
|
||||
}
|
||||
}
|
||||
if (child != null) {
|
||||
child.removeAllIds();
|
||||
if (constraint.layout.mReferenceIds != null) {
|
||||
for (int i = 0; i < constraint.layout.mReferenceIds.length; i++) {
|
||||
ConstraintWidget constraintWidget = mapIdToWidget.get(constraint.layout.mReferenceIds[i]);
|
||||
if (constraintWidget != null) {
|
||||
child.add(constraintWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int[] convertReferenceString(View view, String referenceIdString) {
|
||||
String[] split = referenceIdString.split(",");
|
||||
view.getContext();
|
||||
int[] iArr = new int[split.length];
|
||||
int i = 0;
|
||||
for (String str : split) {
|
||||
int findId = findId(str.trim());
|
||||
if (findId != 0) {
|
||||
iArr[i] = findId;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i != split.length ? Arrays.copyOf(iArr, i) : iArr;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setTag(int key, Object tag) {
|
||||
super.setTag(key, tag);
|
||||
if (tag == null && this.mReferenceIds == null) {
|
||||
addRscID(key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsId(final int id) {
|
||||
for (int i : this.mIds) {
|
||||
if (i == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int indexFromId(final int id) {
|
||||
int i = -1;
|
||||
for (int i2 : this.mIds) {
|
||||
i++;
|
||||
if (i2 == id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,305 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.Xml;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConstraintLayoutStates {
|
||||
private static final boolean DEBUG = false;
|
||||
public static final String TAG = "ConstraintLayoutStates";
|
||||
private final ConstraintLayout mConstraintLayout;
|
||||
ConstraintSet mDefaultConstraintSet;
|
||||
int mCurrentStateId = -1;
|
||||
int mCurrentConstraintNumber = -1;
|
||||
private SparseArray<State> mStateList = new SparseArray<>();
|
||||
private SparseArray<ConstraintSet> mConstraintSetMap = new SparseArray<>();
|
||||
private ConstraintsChangedListener mConstraintsChangedListener = null;
|
||||
|
||||
public void setOnConstraintsChanged(ConstraintsChangedListener constraintsChangedListener) {
|
||||
this.mConstraintsChangedListener = constraintsChangedListener;
|
||||
}
|
||||
|
||||
ConstraintLayoutStates(Context context, ConstraintLayout layout, int resourceID) {
|
||||
this.mConstraintLayout = layout;
|
||||
load(context, resourceID);
|
||||
}
|
||||
|
||||
public boolean needsToChange(int id, float width, float height) {
|
||||
int i = this.mCurrentStateId;
|
||||
if (i != id) {
|
||||
return true;
|
||||
}
|
||||
State valueAt = id == -1 ? this.mStateList.valueAt(0) : this.mStateList.get(i);
|
||||
return (this.mCurrentConstraintNumber == -1 || !valueAt.mVariants.get(this.mCurrentConstraintNumber).match(width, height)) && this.mCurrentConstraintNumber != valueAt.findMatch(width, height);
|
||||
}
|
||||
|
||||
public void updateConstraints(int id, float width, float height) {
|
||||
ConstraintSet constraintSet;
|
||||
int i;
|
||||
State state;
|
||||
int findMatch;
|
||||
int i2;
|
||||
int i3 = this.mCurrentStateId;
|
||||
if (i3 == id) {
|
||||
if (id == -1) {
|
||||
state = this.mStateList.valueAt(0);
|
||||
} else {
|
||||
state = this.mStateList.get(i3);
|
||||
}
|
||||
if ((this.mCurrentConstraintNumber == -1 || !state.mVariants.get(this.mCurrentConstraintNumber).match(width, height)) && this.mCurrentConstraintNumber != (findMatch = state.findMatch(width, height))) {
|
||||
ConstraintSet constraintSet2 = findMatch == -1 ? this.mDefaultConstraintSet : state.mVariants.get(findMatch).mConstraintSet;
|
||||
if (findMatch == -1) {
|
||||
i2 = state.mConstraintID;
|
||||
} else {
|
||||
i2 = state.mVariants.get(findMatch).mConstraintID;
|
||||
}
|
||||
if (constraintSet2 == null) {
|
||||
return;
|
||||
}
|
||||
this.mCurrentConstraintNumber = findMatch;
|
||||
ConstraintsChangedListener constraintsChangedListener = this.mConstraintsChangedListener;
|
||||
if (constraintsChangedListener != null) {
|
||||
constraintsChangedListener.preLayoutChange(-1, i2);
|
||||
}
|
||||
constraintSet2.applyTo(this.mConstraintLayout);
|
||||
ConstraintsChangedListener constraintsChangedListener2 = this.mConstraintsChangedListener;
|
||||
if (constraintsChangedListener2 != null) {
|
||||
constraintsChangedListener2.postLayoutChange(-1, i2);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.mCurrentStateId = id;
|
||||
State state2 = this.mStateList.get(id);
|
||||
int findMatch2 = state2.findMatch(width, height);
|
||||
if (findMatch2 == -1) {
|
||||
constraintSet = state2.mConstraintSet;
|
||||
} else {
|
||||
constraintSet = state2.mVariants.get(findMatch2).mConstraintSet;
|
||||
}
|
||||
if (findMatch2 == -1) {
|
||||
i = state2.mConstraintID;
|
||||
} else {
|
||||
i = state2.mVariants.get(findMatch2).mConstraintID;
|
||||
}
|
||||
if (constraintSet == null) {
|
||||
Log.v("ConstraintLayoutStates", "NO Constraint set found ! id=" + id + ", dim =" + width + ", " + height);
|
||||
return;
|
||||
}
|
||||
this.mCurrentConstraintNumber = findMatch2;
|
||||
ConstraintsChangedListener constraintsChangedListener3 = this.mConstraintsChangedListener;
|
||||
if (constraintsChangedListener3 != null) {
|
||||
constraintsChangedListener3.preLayoutChange(id, i);
|
||||
}
|
||||
constraintSet.applyTo(this.mConstraintLayout);
|
||||
ConstraintsChangedListener constraintsChangedListener4 = this.mConstraintsChangedListener;
|
||||
if (constraintsChangedListener4 != null) {
|
||||
constraintsChangedListener4.postLayoutChange(id, i);
|
||||
}
|
||||
}
|
||||
|
||||
static class State {
|
||||
int mConstraintID;
|
||||
ConstraintSet mConstraintSet;
|
||||
int mId;
|
||||
ArrayList<Variant> mVariants = new ArrayList<>();
|
||||
|
||||
public State(Context context, XmlPullParser parser) {
|
||||
this.mConstraintID = -1;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.State);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.State_android_id) {
|
||||
this.mId = obtainStyledAttributes.getResourceId(index, this.mId);
|
||||
} else if (index == R.styleable.State_constraints) {
|
||||
this.mConstraintID = obtainStyledAttributes.getResourceId(index, this.mConstraintID);
|
||||
String resourceTypeName = context.getResources().getResourceTypeName(this.mConstraintID);
|
||||
context.getResources().getResourceName(this.mConstraintID);
|
||||
if ("layout".equals(resourceTypeName)) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
this.mConstraintSet = constraintSet;
|
||||
constraintSet.clone(context, this.mConstraintID);
|
||||
}
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
void add(Variant size) {
|
||||
this.mVariants.add(size);
|
||||
}
|
||||
|
||||
public int findMatch(float width, float height) {
|
||||
for (int i = 0; i < this.mVariants.size(); i++) {
|
||||
if (this.mVariants.get(i).match(width, height)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static class Variant {
|
||||
int mConstraintID;
|
||||
ConstraintSet mConstraintSet;
|
||||
int mId;
|
||||
float mMaxHeight;
|
||||
float mMaxWidth;
|
||||
float mMinHeight;
|
||||
float mMinWidth;
|
||||
|
||||
public Variant(Context context, XmlPullParser parser) {
|
||||
this.mMinWidth = Float.NaN;
|
||||
this.mMinHeight = Float.NaN;
|
||||
this.mMaxWidth = Float.NaN;
|
||||
this.mMaxHeight = Float.NaN;
|
||||
this.mConstraintID = -1;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.Variant);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.Variant_constraints) {
|
||||
this.mConstraintID = obtainStyledAttributes.getResourceId(index, this.mConstraintID);
|
||||
String resourceTypeName = context.getResources().getResourceTypeName(this.mConstraintID);
|
||||
context.getResources().getResourceName(this.mConstraintID);
|
||||
if ("layout".equals(resourceTypeName)) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
this.mConstraintSet = constraintSet;
|
||||
constraintSet.clone(context, this.mConstraintID);
|
||||
}
|
||||
} else if (index == R.styleable.Variant_region_heightLessThan) {
|
||||
this.mMaxHeight = obtainStyledAttributes.getDimension(index, this.mMaxHeight);
|
||||
} else if (index == R.styleable.Variant_region_heightMoreThan) {
|
||||
this.mMinHeight = obtainStyledAttributes.getDimension(index, this.mMinHeight);
|
||||
} else if (index == R.styleable.Variant_region_widthLessThan) {
|
||||
this.mMaxWidth = obtainStyledAttributes.getDimension(index, this.mMaxWidth);
|
||||
} else if (index == R.styleable.Variant_region_widthMoreThan) {
|
||||
this.mMinWidth = obtainStyledAttributes.getDimension(index, this.mMinWidth);
|
||||
} else {
|
||||
Log.v("ConstraintLayoutStates", "Unknown tag");
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
boolean match(float widthDp, float heightDp) {
|
||||
if (!Float.isNaN(this.mMinWidth) && widthDp < this.mMinWidth) {
|
||||
return false;
|
||||
}
|
||||
if (!Float.isNaN(this.mMinHeight) && heightDp < this.mMinHeight) {
|
||||
return false;
|
||||
}
|
||||
if (Float.isNaN(this.mMaxWidth) || widthDp <= this.mMaxWidth) {
|
||||
return Float.isNaN(this.mMaxHeight) || heightDp <= this.mMaxHeight;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void load(Context context, int resourceId) {
|
||||
XmlResourceParser xml = context.getResources().getXml(resourceId);
|
||||
try {
|
||||
int eventType = xml.getEventType();
|
||||
State state = null;
|
||||
while (true) {
|
||||
char c = 1;
|
||||
if (eventType == 1) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 0) {
|
||||
xml.getName();
|
||||
} else if (eventType == 2) {
|
||||
String name = xml.getName();
|
||||
switch (name.hashCode()) {
|
||||
case -1349929691:
|
||||
if (name.equals("ConstraintSet")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 80204913:
|
||||
if (name.equals("State")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1382829617:
|
||||
if (name.equals("StateSet")) {
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1657696882:
|
||||
if (name.equals("layoutDescription")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1901439077:
|
||||
if (name.equals("Variant")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
default:
|
||||
c = 65535;
|
||||
break;
|
||||
}
|
||||
if (c == 2) {
|
||||
state = new State(context, xml);
|
||||
this.mStateList.put(state.mId, state);
|
||||
} else if (c == 3) {
|
||||
Variant variant = new Variant(context, xml);
|
||||
if (state != null) {
|
||||
state.add(variant);
|
||||
}
|
||||
} else if (c == 4) {
|
||||
parseConstraintSet(context, xml);
|
||||
}
|
||||
}
|
||||
eventType = xml.next();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (XmlPullParserException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void parseConstraintSet(Context context, XmlPullParser parser) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
int attributeCount = parser.getAttributeCount();
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
String attributeName = parser.getAttributeName(i);
|
||||
String attributeValue = parser.getAttributeValue(i);
|
||||
if (attributeName != null && attributeValue != null && "id".equals(attributeName)) {
|
||||
int identifier = attributeValue.contains("/") ? context.getResources().getIdentifier(attributeValue.substring(attributeValue.indexOf(47) + 1), "id", context.getPackageName()) : -1;
|
||||
if (identifier == -1) {
|
||||
if (attributeValue.length() > 1) {
|
||||
identifier = Integer.parseInt(attributeValue.substring(1));
|
||||
} else {
|
||||
Log.e("ConstraintLayoutStates", "error in parsing id");
|
||||
}
|
||||
}
|
||||
constraintSet.load(context, parser);
|
||||
this.mConstraintSetMap.put(identifier, constraintSet);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,620 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConstraintProperties {
|
||||
public static final int BASELINE = 5;
|
||||
public static final int BOTTOM = 4;
|
||||
public static final int END = 7;
|
||||
public static final int LEFT = 1;
|
||||
public static final int MATCH_CONSTRAINT = 0;
|
||||
public static final int MATCH_CONSTRAINT_SPREAD = 0;
|
||||
public static final int MATCH_CONSTRAINT_WRAP = 1;
|
||||
public static final int PARENT_ID = 0;
|
||||
public static final int RIGHT = 2;
|
||||
public static final int START = 6;
|
||||
public static final int TOP = 3;
|
||||
public static final int UNSET = -1;
|
||||
public static final int WRAP_CONTENT = -2;
|
||||
ConstraintLayout.LayoutParams mParams;
|
||||
View mView;
|
||||
|
||||
private String sideToString(int side) {
|
||||
switch (side) {
|
||||
case 1:
|
||||
return "left";
|
||||
case 2:
|
||||
return "right";
|
||||
case 3:
|
||||
return "top";
|
||||
case 4:
|
||||
return "bottom";
|
||||
case 5:
|
||||
return "baseline";
|
||||
case 6:
|
||||
return "start";
|
||||
case 7:
|
||||
return "end";
|
||||
default:
|
||||
return "undefined";
|
||||
}
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
}
|
||||
|
||||
public ConstraintProperties scaleY(float scaleY) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties center(int firstID, int firstSide, int firstMargin, int secondId, int secondSide, int secondMargin, float bias) {
|
||||
if (firstMargin < 0) {
|
||||
throw new IllegalArgumentException("margin must be > 0");
|
||||
}
|
||||
if (secondMargin < 0) {
|
||||
throw new IllegalArgumentException("margin must be > 0");
|
||||
}
|
||||
if (bias <= 0.0f || bias > 1.0f) {
|
||||
throw new IllegalArgumentException("bias must be between 0 and 1 inclusive");
|
||||
}
|
||||
if (firstSide == 1 || firstSide == 2) {
|
||||
connect(1, firstID, firstSide, firstMargin);
|
||||
connect(2, secondId, secondSide, secondMargin);
|
||||
this.mParams.horizontalBias = bias;
|
||||
} else if (firstSide == 6 || firstSide == 7) {
|
||||
connect(6, firstID, firstSide, firstMargin);
|
||||
connect(7, secondId, secondSide, secondMargin);
|
||||
this.mParams.horizontalBias = bias;
|
||||
} else {
|
||||
connect(3, firstID, firstSide, firstMargin);
|
||||
connect(4, secondId, secondSide, secondMargin);
|
||||
this.mParams.verticalBias = bias;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties centerHorizontally(int leftId, int leftSide, int leftMargin, int rightId, int rightSide, int rightMargin, float bias) {
|
||||
connect(1, leftId, leftSide, leftMargin);
|
||||
connect(2, rightId, rightSide, rightMargin);
|
||||
this.mParams.horizontalBias = bias;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties centerHorizontallyRtl(int startId, int startSide, int startMargin, int endId, int endSide, int endMargin, float bias) {
|
||||
connect(6, startId, startSide, startMargin);
|
||||
connect(7, endId, endSide, endMargin);
|
||||
this.mParams.horizontalBias = bias;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties centerVertically(int topId, int topSide, int topMargin, int bottomId, int bottomSide, int bottomMargin, float bias) {
|
||||
connect(3, topId, topSide, topMargin);
|
||||
connect(4, bottomId, bottomSide, bottomMargin);
|
||||
this.mParams.verticalBias = bias;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties centerHorizontally(int toView) {
|
||||
if (toView == 0) {
|
||||
center(0, 1, 0, 0, 2, 0, 0.5f);
|
||||
} else {
|
||||
center(toView, 2, 0, toView, 1, 0, 0.5f);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties centerHorizontallyRtl(int toView) {
|
||||
if (toView == 0) {
|
||||
center(0, 6, 0, 0, 7, 0, 0.5f);
|
||||
} else {
|
||||
center(toView, 7, 0, toView, 6, 0, 0.5f);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties centerVertically(int toView) {
|
||||
if (toView == 0) {
|
||||
center(0, 3, 0, 0, 4, 0, 0.5f);
|
||||
} else {
|
||||
center(toView, 4, 0, toView, 3, 0, 0.5f);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties removeConstraints(int anchor) {
|
||||
switch (anchor) {
|
||||
case 1:
|
||||
this.mParams.leftToRight = -1;
|
||||
this.mParams.leftToLeft = -1;
|
||||
this.mParams.leftMargin = -1;
|
||||
this.mParams.goneLeftMargin = Integer.MIN_VALUE;
|
||||
return this;
|
||||
case 2:
|
||||
this.mParams.rightToRight = -1;
|
||||
this.mParams.rightToLeft = -1;
|
||||
this.mParams.rightMargin = -1;
|
||||
this.mParams.goneRightMargin = Integer.MIN_VALUE;
|
||||
return this;
|
||||
case 3:
|
||||
this.mParams.topToBottom = -1;
|
||||
this.mParams.topToTop = -1;
|
||||
this.mParams.topMargin = -1;
|
||||
this.mParams.goneTopMargin = Integer.MIN_VALUE;
|
||||
return this;
|
||||
case 4:
|
||||
this.mParams.bottomToTop = -1;
|
||||
this.mParams.bottomToBottom = -1;
|
||||
this.mParams.bottomMargin = -1;
|
||||
this.mParams.goneBottomMargin = Integer.MIN_VALUE;
|
||||
return this;
|
||||
case 5:
|
||||
this.mParams.baselineToBaseline = -1;
|
||||
return this;
|
||||
case 6:
|
||||
this.mParams.startToEnd = -1;
|
||||
this.mParams.startToStart = -1;
|
||||
this.mParams.setMarginStart(-1);
|
||||
this.mParams.goneStartMargin = Integer.MIN_VALUE;
|
||||
return this;
|
||||
case 7:
|
||||
this.mParams.endToStart = -1;
|
||||
this.mParams.endToEnd = -1;
|
||||
this.mParams.setMarginEnd(-1);
|
||||
this.mParams.goneEndMargin = Integer.MIN_VALUE;
|
||||
return this;
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown constraint");
|
||||
}
|
||||
}
|
||||
|
||||
public ConstraintProperties margin(int anchor, int value) {
|
||||
switch (anchor) {
|
||||
case 1:
|
||||
this.mParams.leftMargin = value;
|
||||
return this;
|
||||
case 2:
|
||||
this.mParams.rightMargin = value;
|
||||
return this;
|
||||
case 3:
|
||||
this.mParams.topMargin = value;
|
||||
return this;
|
||||
case 4:
|
||||
this.mParams.bottomMargin = value;
|
||||
return this;
|
||||
case 5:
|
||||
throw new IllegalArgumentException("baseline does not support margins");
|
||||
case 6:
|
||||
this.mParams.setMarginStart(value);
|
||||
return this;
|
||||
case 7:
|
||||
this.mParams.setMarginEnd(value);
|
||||
return this;
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown constraint");
|
||||
}
|
||||
}
|
||||
|
||||
public ConstraintProperties goneMargin(int anchor, int value) {
|
||||
switch (anchor) {
|
||||
case 1:
|
||||
this.mParams.goneLeftMargin = value;
|
||||
return this;
|
||||
case 2:
|
||||
this.mParams.goneRightMargin = value;
|
||||
return this;
|
||||
case 3:
|
||||
this.mParams.goneTopMargin = value;
|
||||
return this;
|
||||
case 4:
|
||||
this.mParams.goneBottomMargin = value;
|
||||
return this;
|
||||
case 5:
|
||||
throw new IllegalArgumentException("baseline does not support margins");
|
||||
case 6:
|
||||
this.mParams.goneStartMargin = value;
|
||||
return this;
|
||||
case 7:
|
||||
this.mParams.goneEndMargin = value;
|
||||
return this;
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown constraint");
|
||||
}
|
||||
}
|
||||
|
||||
public ConstraintProperties horizontalBias(float bias) {
|
||||
this.mParams.horizontalBias = bias;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties verticalBias(float bias) {
|
||||
this.mParams.verticalBias = bias;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties dimensionRatio(String ratio) {
|
||||
this.mParams.dimensionRatio = ratio;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties visibility(int visibility) {
|
||||
this.mView.setVisibility(visibility);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties alpha(float alpha) {
|
||||
this.mView.setAlpha(alpha);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties elevation(float elevation) {
|
||||
this.mView.setElevation(elevation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties rotation(float rotation) {
|
||||
this.mView.setRotation(rotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties rotationX(float rotationX) {
|
||||
this.mView.setRotationX(rotationX);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties rotationY(float rotationY) {
|
||||
this.mView.setRotationY(rotationY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties scaleX(float scaleX) {
|
||||
this.mView.setScaleY(scaleX);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties transformPivotX(float transformPivotX) {
|
||||
this.mView.setPivotX(transformPivotX);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties transformPivotY(float transformPivotY) {
|
||||
this.mView.setPivotY(transformPivotY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties transformPivot(float transformPivotX, float transformPivotY) {
|
||||
this.mView.setPivotX(transformPivotX);
|
||||
this.mView.setPivotY(transformPivotY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties translationX(float translationX) {
|
||||
this.mView.setTranslationX(translationX);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties translationY(float translationY) {
|
||||
this.mView.setTranslationY(translationY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties translation(float translationX, float translationY) {
|
||||
this.mView.setTranslationX(translationX);
|
||||
this.mView.setTranslationY(translationY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties translationZ(float translationZ) {
|
||||
this.mView.setTranslationZ(translationZ);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainHeight(int height) {
|
||||
this.mParams.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainWidth(int width) {
|
||||
this.mParams.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainMaxHeight(int height) {
|
||||
this.mParams.matchConstraintMaxHeight = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainMaxWidth(int width) {
|
||||
this.mParams.matchConstraintMaxWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainMinHeight(int height) {
|
||||
this.mParams.matchConstraintMinHeight = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainMinWidth(int width) {
|
||||
this.mParams.matchConstraintMinWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainDefaultHeight(int height) {
|
||||
this.mParams.matchConstraintDefaultHeight = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties constrainDefaultWidth(int width) {
|
||||
this.mParams.matchConstraintDefaultWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties horizontalWeight(float weight) {
|
||||
this.mParams.horizontalWeight = weight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties verticalWeight(float weight) {
|
||||
this.mParams.verticalWeight = weight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties horizontalChainStyle(int chainStyle) {
|
||||
this.mParams.horizontalChainStyle = chainStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties verticalChainStyle(int chainStyle) {
|
||||
this.mParams.verticalChainStyle = chainStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties addToHorizontalChain(int leftId, int rightId) {
|
||||
connect(1, leftId, leftId == 0 ? 1 : 2, 0);
|
||||
connect(2, rightId, rightId == 0 ? 2 : 1, 0);
|
||||
if (leftId != 0) {
|
||||
new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(leftId)).connect(2, this.mView.getId(), 1, 0);
|
||||
}
|
||||
if (rightId != 0) {
|
||||
new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(rightId)).connect(1, this.mView.getId(), 2, 0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties addToHorizontalChainRTL(int leftId, int rightId) {
|
||||
connect(6, leftId, leftId == 0 ? 6 : 7, 0);
|
||||
connect(7, rightId, rightId == 0 ? 7 : 6, 0);
|
||||
if (leftId != 0) {
|
||||
new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(leftId)).connect(7, this.mView.getId(), 6, 0);
|
||||
}
|
||||
if (rightId != 0) {
|
||||
new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(rightId)).connect(6, this.mView.getId(), 7, 0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties addToVerticalChain(int topId, int bottomId) {
|
||||
connect(3, topId, topId == 0 ? 3 : 4, 0);
|
||||
connect(4, bottomId, bottomId == 0 ? 4 : 3, 0);
|
||||
if (topId != 0) {
|
||||
new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(topId)).connect(4, this.mView.getId(), 3, 0);
|
||||
}
|
||||
if (bottomId != 0) {
|
||||
new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(bottomId)).connect(3, this.mView.getId(), 4, 0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties removeFromVerticalChain() {
|
||||
int i = this.mParams.topToBottom;
|
||||
int i2 = this.mParams.bottomToTop;
|
||||
if (i != -1 || i2 != -1) {
|
||||
ConstraintProperties constraintProperties = new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(i));
|
||||
ConstraintProperties constraintProperties2 = new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(i2));
|
||||
ConstraintLayout.LayoutParams layoutParams = this.mParams;
|
||||
if (i != -1 && i2 != -1) {
|
||||
constraintProperties.connect(4, i2, 3, 0);
|
||||
constraintProperties2.connect(3, i, 4, 0);
|
||||
} else if (i != -1 || i2 != -1) {
|
||||
int i3 = layoutParams.bottomToBottom;
|
||||
ConstraintLayout.LayoutParams layoutParams2 = this.mParams;
|
||||
if (i3 != -1) {
|
||||
constraintProperties.connect(4, layoutParams2.bottomToBottom, 4, 0);
|
||||
} else {
|
||||
int i4 = layoutParams2.topToTop;
|
||||
ConstraintLayout.LayoutParams layoutParams3 = this.mParams;
|
||||
if (i4 != -1) {
|
||||
constraintProperties2.connect(3, layoutParams3.topToTop, 3, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
removeConstraints(3);
|
||||
removeConstraints(4);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties removeFromHorizontalChain() {
|
||||
int i = this.mParams.leftToRight;
|
||||
int i2 = this.mParams.rightToLeft;
|
||||
ConstraintLayout.LayoutParams layoutParams = this.mParams;
|
||||
if (i != -1 || i2 != -1) {
|
||||
ConstraintProperties constraintProperties = new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(i));
|
||||
ConstraintProperties constraintProperties2 = new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(i2));
|
||||
ConstraintLayout.LayoutParams layoutParams2 = this.mParams;
|
||||
if (i != -1 && i2 != -1) {
|
||||
constraintProperties.connect(2, i2, 1, 0);
|
||||
constraintProperties2.connect(1, i, 2, 0);
|
||||
} else if (i != -1 || i2 != -1) {
|
||||
int i3 = layoutParams2.rightToRight;
|
||||
ConstraintLayout.LayoutParams layoutParams3 = this.mParams;
|
||||
if (i3 != -1) {
|
||||
constraintProperties.connect(2, layoutParams3.rightToRight, 2, 0);
|
||||
} else {
|
||||
int i4 = layoutParams3.leftToLeft;
|
||||
ConstraintLayout.LayoutParams layoutParams4 = this.mParams;
|
||||
if (i4 != -1) {
|
||||
constraintProperties2.connect(1, layoutParams4.leftToLeft, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
removeConstraints(1);
|
||||
removeConstraints(2);
|
||||
} else {
|
||||
int i5 = layoutParams.startToEnd;
|
||||
int i6 = this.mParams.endToStart;
|
||||
if (i5 != -1 || i6 != -1) {
|
||||
ConstraintProperties constraintProperties3 = new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(i5));
|
||||
ConstraintProperties constraintProperties4 = new ConstraintProperties(((ViewGroup) this.mView.getParent()).findViewById(i6));
|
||||
ConstraintLayout.LayoutParams layoutParams5 = this.mParams;
|
||||
if (i5 != -1 && i6 != -1) {
|
||||
constraintProperties3.connect(7, i6, 6, 0);
|
||||
constraintProperties4.connect(6, i, 7, 0);
|
||||
} else if (i != -1 || i6 != -1) {
|
||||
int i7 = layoutParams5.rightToRight;
|
||||
ConstraintLayout.LayoutParams layoutParams6 = this.mParams;
|
||||
if (i7 != -1) {
|
||||
constraintProperties3.connect(7, layoutParams6.rightToRight, 7, 0);
|
||||
} else {
|
||||
int i8 = layoutParams6.leftToLeft;
|
||||
ConstraintLayout.LayoutParams layoutParams7 = this.mParams;
|
||||
if (i8 != -1) {
|
||||
constraintProperties4.connect(6, layoutParams7.leftToLeft, 6, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
removeConstraints(6);
|
||||
removeConstraints(7);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstraintProperties connect(int startSide, int endID, int endSide, int margin) {
|
||||
switch (startSide) {
|
||||
case 1:
|
||||
if (endSide == 1) {
|
||||
this.mParams.leftToLeft = endID;
|
||||
this.mParams.leftToRight = -1;
|
||||
} else if (endSide == 2) {
|
||||
this.mParams.leftToRight = endID;
|
||||
this.mParams.leftToLeft = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Left to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.leftMargin = margin;
|
||||
return this;
|
||||
case 2:
|
||||
if (endSide == 1) {
|
||||
this.mParams.rightToLeft = endID;
|
||||
this.mParams.rightToRight = -1;
|
||||
} else if (endSide == 2) {
|
||||
this.mParams.rightToRight = endID;
|
||||
this.mParams.rightToLeft = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("right to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.rightMargin = margin;
|
||||
return this;
|
||||
case 3:
|
||||
if (endSide == 3) {
|
||||
this.mParams.topToTop = endID;
|
||||
this.mParams.topToBottom = -1;
|
||||
this.mParams.baselineToBaseline = -1;
|
||||
this.mParams.baselineToTop = -1;
|
||||
this.mParams.baselineToBottom = -1;
|
||||
} else if (endSide == 4) {
|
||||
this.mParams.topToBottom = endID;
|
||||
this.mParams.topToTop = -1;
|
||||
this.mParams.baselineToBaseline = -1;
|
||||
this.mParams.baselineToTop = -1;
|
||||
this.mParams.baselineToBottom = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("right to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.topMargin = margin;
|
||||
return this;
|
||||
case 4:
|
||||
if (endSide == 4) {
|
||||
this.mParams.bottomToBottom = endID;
|
||||
this.mParams.bottomToTop = -1;
|
||||
this.mParams.baselineToBaseline = -1;
|
||||
this.mParams.baselineToTop = -1;
|
||||
this.mParams.baselineToBottom = -1;
|
||||
} else if (endSide == 3) {
|
||||
this.mParams.bottomToTop = endID;
|
||||
this.mParams.bottomToBottom = -1;
|
||||
this.mParams.baselineToBaseline = -1;
|
||||
this.mParams.baselineToTop = -1;
|
||||
this.mParams.baselineToBottom = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("right to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.bottomMargin = margin;
|
||||
return this;
|
||||
case 5:
|
||||
if (endSide == 5) {
|
||||
this.mParams.baselineToBaseline = endID;
|
||||
this.mParams.bottomToBottom = -1;
|
||||
this.mParams.bottomToTop = -1;
|
||||
this.mParams.topToTop = -1;
|
||||
this.mParams.topToBottom = -1;
|
||||
}
|
||||
if (endSide == 3) {
|
||||
this.mParams.baselineToTop = endID;
|
||||
this.mParams.bottomToBottom = -1;
|
||||
this.mParams.bottomToTop = -1;
|
||||
this.mParams.topToTop = -1;
|
||||
this.mParams.topToBottom = -1;
|
||||
} else if (endSide == 4) {
|
||||
this.mParams.baselineToBottom = endID;
|
||||
this.mParams.bottomToBottom = -1;
|
||||
this.mParams.bottomToTop = -1;
|
||||
this.mParams.topToTop = -1;
|
||||
this.mParams.topToBottom = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("right to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.baselineMargin = margin;
|
||||
return this;
|
||||
case 6:
|
||||
if (endSide == 6) {
|
||||
this.mParams.startToStart = endID;
|
||||
this.mParams.startToEnd = -1;
|
||||
} else if (endSide == 7) {
|
||||
this.mParams.startToEnd = endID;
|
||||
this.mParams.startToStart = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("right to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.setMarginStart(margin);
|
||||
return this;
|
||||
case 7:
|
||||
if (endSide == 7) {
|
||||
this.mParams.endToEnd = endID;
|
||||
this.mParams.endToStart = -1;
|
||||
} else if (endSide == 6) {
|
||||
this.mParams.endToStart = endID;
|
||||
this.mParams.endToEnd = -1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("right to " + sideToString(endSide) + " undefined");
|
||||
}
|
||||
this.mParams.setMarginEnd(margin);
|
||||
return this;
|
||||
default:
|
||||
throw new IllegalArgumentException(sideToString(startSide) + " to " + sideToString(endSide) + " unknown");
|
||||
}
|
||||
}
|
||||
|
||||
public ConstraintProperties(View view) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (layoutParams instanceof ConstraintLayout.LayoutParams) {
|
||||
this.mParams = (ConstraintLayout.LayoutParams) layoutParams;
|
||||
this.mView = view;
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException("Only children of ConstraintLayout.LayoutParams supported");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,162 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Constraints extends ViewGroup {
|
||||
public static final String TAG = "Constraints";
|
||||
ConstraintSet myConstraintSet;
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
}
|
||||
|
||||
public Constraints(Context context) {
|
||||
super(context);
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Constraints(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(attrs);
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Constraints(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(attrs);
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public LayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||
return new LayoutParams(getContext(), attrs);
|
||||
}
|
||||
|
||||
public static class LayoutParams extends ConstraintLayout.LayoutParams {
|
||||
public float alpha;
|
||||
public boolean applyElevation;
|
||||
public float elevation;
|
||||
public float rotation;
|
||||
public float rotationX;
|
||||
public float rotationY;
|
||||
public float scaleX;
|
||||
public float scaleY;
|
||||
public float transformPivotX;
|
||||
public float transformPivotY;
|
||||
public float translationX;
|
||||
public float translationY;
|
||||
public float translationZ;
|
||||
|
||||
public LayoutParams(int width, int height) {
|
||||
super(width, height);
|
||||
this.alpha = 1.0f;
|
||||
this.applyElevation = false;
|
||||
this.elevation = 0.0f;
|
||||
this.rotation = 0.0f;
|
||||
this.rotationX = 0.0f;
|
||||
this.rotationY = 0.0f;
|
||||
this.scaleX = 1.0f;
|
||||
this.scaleY = 1.0f;
|
||||
this.transformPivotX = 0.0f;
|
||||
this.transformPivotY = 0.0f;
|
||||
this.translationX = 0.0f;
|
||||
this.translationY = 0.0f;
|
||||
this.translationZ = 0.0f;
|
||||
}
|
||||
|
||||
public LayoutParams(LayoutParams source) {
|
||||
super((ConstraintLayout.LayoutParams) source);
|
||||
this.alpha = 1.0f;
|
||||
this.applyElevation = false;
|
||||
this.elevation = 0.0f;
|
||||
this.rotation = 0.0f;
|
||||
this.rotationX = 0.0f;
|
||||
this.rotationY = 0.0f;
|
||||
this.scaleX = 1.0f;
|
||||
this.scaleY = 1.0f;
|
||||
this.transformPivotX = 0.0f;
|
||||
this.transformPivotY = 0.0f;
|
||||
this.translationX = 0.0f;
|
||||
this.translationY = 0.0f;
|
||||
this.translationZ = 0.0f;
|
||||
}
|
||||
|
||||
public LayoutParams(Context c, AttributeSet attrs) {
|
||||
super(c, attrs);
|
||||
this.alpha = 1.0f;
|
||||
this.applyElevation = false;
|
||||
this.elevation = 0.0f;
|
||||
this.rotation = 0.0f;
|
||||
this.rotationX = 0.0f;
|
||||
this.rotationY = 0.0f;
|
||||
this.scaleX = 1.0f;
|
||||
this.scaleY = 1.0f;
|
||||
this.transformPivotX = 0.0f;
|
||||
this.transformPivotY = 0.0f;
|
||||
this.translationX = 0.0f;
|
||||
this.translationY = 0.0f;
|
||||
this.translationZ = 0.0f;
|
||||
TypedArray obtainStyledAttributes = c.obtainStyledAttributes(attrs, R.styleable.ConstraintSet);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.ConstraintSet_android_alpha) {
|
||||
this.alpha = obtainStyledAttributes.getFloat(index, this.alpha);
|
||||
} else if (index == R.styleable.ConstraintSet_android_elevation) {
|
||||
this.elevation = obtainStyledAttributes.getFloat(index, this.elevation);
|
||||
this.applyElevation = true;
|
||||
} else if (index == R.styleable.ConstraintSet_android_rotationX) {
|
||||
this.rotationX = obtainStyledAttributes.getFloat(index, this.rotationX);
|
||||
} else if (index == R.styleable.ConstraintSet_android_rotationY) {
|
||||
this.rotationY = obtainStyledAttributes.getFloat(index, this.rotationY);
|
||||
} else if (index == R.styleable.ConstraintSet_android_rotation) {
|
||||
this.rotation = obtainStyledAttributes.getFloat(index, this.rotation);
|
||||
} else if (index == R.styleable.ConstraintSet_android_scaleX) {
|
||||
this.scaleX = obtainStyledAttributes.getFloat(index, this.scaleX);
|
||||
} else if (index == R.styleable.ConstraintSet_android_scaleY) {
|
||||
this.scaleY = obtainStyledAttributes.getFloat(index, this.scaleY);
|
||||
} else if (index == R.styleable.ConstraintSet_android_transformPivotX) {
|
||||
this.transformPivotX = obtainStyledAttributes.getFloat(index, this.transformPivotX);
|
||||
} else if (index == R.styleable.ConstraintSet_android_transformPivotY) {
|
||||
this.transformPivotY = obtainStyledAttributes.getFloat(index, this.transformPivotY);
|
||||
} else if (index == R.styleable.ConstraintSet_android_translationX) {
|
||||
this.translationX = obtainStyledAttributes.getFloat(index, this.translationX);
|
||||
} else if (index == R.styleable.ConstraintSet_android_translationY) {
|
||||
this.translationY = obtainStyledAttributes.getFloat(index, this.translationY);
|
||||
} else if (index == R.styleable.ConstraintSet_android_translationZ) {
|
||||
this.translationZ = obtainStyledAttributes.getFloat(index, this.translationZ);
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.view.ViewGroup
|
||||
public LayoutParams generateDefaultLayoutParams() {
|
||||
return new LayoutParams(-2, -2);
|
||||
}
|
||||
|
||||
private void init(AttributeSet attrs) {
|
||||
Log.v(TAG, " ################# init");
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
|
||||
return new ConstraintLayout.LayoutParams(p);
|
||||
}
|
||||
|
||||
public ConstraintSet getConstraintSet() {
|
||||
if (this.myConstraintSet == null) {
|
||||
this.myConstraintSet = new ConstraintSet();
|
||||
}
|
||||
this.myConstraintSet.clone(this);
|
||||
return this.myConstraintSet;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ConstraintsChangedListener {
|
||||
public void postLayoutChange(int stateId, int constraintId) {
|
||||
}
|
||||
|
||||
public void preLayoutChange(int stateId, int constraintId) {
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Group extends ConstraintHelper {
|
||||
public Group(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public Group(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public Group(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
protected void init(AttributeSet attrs) {
|
||||
super.init(attrs);
|
||||
this.mUseViewMeasure = false;
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper, android.view.View
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
applyLayoutFeatures();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
applyLayoutFeatures();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setElevation(float elevation) {
|
||||
super.setElevation(elevation);
|
||||
applyLayoutFeatures();
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
protected void applyLayoutFeaturesInConstraintSet(ConstraintLayout container) {
|
||||
applyLayoutFeatures(container);
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
public void updatePostLayout(ConstraintLayout container) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.widget.setWidth(0);
|
||||
layoutParams.widget.setHeight(0);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Guideline extends View {
|
||||
private boolean mFilterRedundantCalls;
|
||||
|
||||
@Override // android.view.View
|
||||
public void draw(Canvas canvas) {
|
||||
}
|
||||
|
||||
public void setFilterRedundantCalls(boolean filter) {
|
||||
this.mFilterRedundantCalls = filter;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setVisibility(int visibility) {
|
||||
}
|
||||
|
||||
public Guideline(Context context) {
|
||||
super(context);
|
||||
this.mFilterRedundantCalls = true;
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Guideline(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.mFilterRedundantCalls = true;
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Guideline(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mFilterRedundantCalls = true;
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
public Guideline(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mFilterRedundantCalls = true;
|
||||
super.setVisibility(8);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(0, 0);
|
||||
}
|
||||
|
||||
public void setGuidelineBegin(int margin) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
if (this.mFilterRedundantCalls && layoutParams.guideBegin == margin) {
|
||||
return;
|
||||
}
|
||||
layoutParams.guideBegin = margin;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
public void setGuidelineEnd(int margin) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
if (this.mFilterRedundantCalls && layoutParams.guideEnd == margin) {
|
||||
return;
|
||||
}
|
||||
layoutParams.guideEnd = margin;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
public void setGuidelinePercent(float ratio) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
if (this.mFilterRedundantCalls && layoutParams.guidePercent == ratio) {
|
||||
return;
|
||||
}
|
||||
layoutParams.guidePercent = ratio;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.constraintlayout.core.widgets.ConstraintWidget;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Placeholder extends View {
|
||||
private View mContent;
|
||||
private int mContentId;
|
||||
private int mEmptyVisibility;
|
||||
|
||||
public View getContent() {
|
||||
return this.mContent;
|
||||
}
|
||||
|
||||
public int getEmptyVisibility() {
|
||||
return this.mEmptyVisibility;
|
||||
}
|
||||
|
||||
public void setEmptyVisibility(int visibility) {
|
||||
this.mEmptyVisibility = visibility;
|
||||
}
|
||||
|
||||
public Placeholder(Context context) {
|
||||
super(context);
|
||||
this.mContentId = -1;
|
||||
this.mContent = null;
|
||||
this.mEmptyVisibility = 4;
|
||||
init(null);
|
||||
}
|
||||
|
||||
public Placeholder(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.mContentId = -1;
|
||||
this.mContent = null;
|
||||
this.mEmptyVisibility = 4;
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public Placeholder(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mContentId = -1;
|
||||
this.mContent = null;
|
||||
this.mEmptyVisibility = 4;
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public Placeholder(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mContentId = -1;
|
||||
this.mContent = null;
|
||||
this.mEmptyVisibility = 4;
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
private void init(AttributeSet attrs) {
|
||||
super.setVisibility(this.mEmptyVisibility);
|
||||
this.mContentId = -1;
|
||||
if (attrs != null) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.ConstraintLayout_placeholder);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.ConstraintLayout_placeholder_content) {
|
||||
this.mContentId = obtainStyledAttributes.getResourceId(index, this.mContentId);
|
||||
} else if (index == R.styleable.ConstraintLayout_placeholder_placeholder_emptyVisibility) {
|
||||
this.mEmptyVisibility = obtainStyledAttributes.getInt(index, this.mEmptyVisibility);
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (isInEditMode()) {
|
||||
canvas.drawRGB(223, 223, 223);
|
||||
Paint paint = new Paint();
|
||||
paint.setARGB(255, 210, 210, 210);
|
||||
paint.setTextAlign(Paint.Align.CENTER);
|
||||
paint.setTypeface(Typeface.create(Typeface.DEFAULT, 0));
|
||||
Rect rect = new Rect();
|
||||
canvas.getClipBounds(rect);
|
||||
paint.setTextSize(rect.height());
|
||||
int height = rect.height();
|
||||
int width = rect.width();
|
||||
paint.setTextAlign(Paint.Align.LEFT);
|
||||
paint.getTextBounds("?", 0, 1, rect);
|
||||
canvas.drawText("?", ((width / 2.0f) - (rect.width() / 2.0f)) - rect.left, ((height / 2.0f) + (rect.height() / 2.0f)) - rect.bottom, paint);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePreLayout(ConstraintLayout container) {
|
||||
if (this.mContentId == -1 && !isInEditMode()) {
|
||||
setVisibility(this.mEmptyVisibility);
|
||||
}
|
||||
View findViewById = container.findViewById(this.mContentId);
|
||||
this.mContent = findViewById;
|
||||
if (findViewById != null) {
|
||||
((ConstraintLayout.LayoutParams) findViewById.getLayoutParams()).isInPlaceholder = true;
|
||||
this.mContent.setVisibility(0);
|
||||
setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setContentId(int id) {
|
||||
View findViewById;
|
||||
if (this.mContentId == id) {
|
||||
return;
|
||||
}
|
||||
View view = this.mContent;
|
||||
if (view != null) {
|
||||
view.setVisibility(0);
|
||||
((ConstraintLayout.LayoutParams) this.mContent.getLayoutParams()).isInPlaceholder = false;
|
||||
this.mContent = null;
|
||||
}
|
||||
this.mContentId = id;
|
||||
if (id == -1 || (findViewById = ((View) getParent()).findViewById(id)) == null) {
|
||||
return;
|
||||
}
|
||||
findViewById.setVisibility(8);
|
||||
}
|
||||
|
||||
public void updatePostMeasure(ConstraintLayout container) {
|
||||
if (this.mContent == null) {
|
||||
return;
|
||||
}
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
ConstraintLayout.LayoutParams layoutParams2 = (ConstraintLayout.LayoutParams) this.mContent.getLayoutParams();
|
||||
layoutParams2.widget.setVisibility(0);
|
||||
if (layoutParams.widget.getHorizontalDimensionBehaviour() != ConstraintWidget.DimensionBehaviour.FIXED) {
|
||||
layoutParams.widget.setWidth(layoutParams2.widget.getWidth());
|
||||
}
|
||||
if (layoutParams.widget.getVerticalDimensionBehaviour() != ConstraintWidget.DimensionBehaviour.FIXED) {
|
||||
layoutParams.widget.setHeight(layoutParams2.widget.getHeight());
|
||||
}
|
||||
layoutParams2.widget.setVisibility(8);
|
||||
}
|
||||
}
|
2991
02-Easy5/E5/sources/androidx/constraintlayout/widget/R.java
Normal file
2991
02-Easy5/E5/sources/androidx/constraintlayout/widget/R.java
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,190 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.SharedValues;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ReactiveGuide extends View implements SharedValues.SharedValuesListener {
|
||||
private boolean mAnimateChange;
|
||||
private boolean mApplyToAllConstraintSets;
|
||||
private int mApplyToConstraintSetId;
|
||||
private int mAttributeId;
|
||||
|
||||
@Override // android.view.View
|
||||
public void draw(Canvas canvas) {
|
||||
}
|
||||
|
||||
public int getApplyToConstraintSetId() {
|
||||
return this.mApplyToConstraintSetId;
|
||||
}
|
||||
|
||||
public int getAttributeId() {
|
||||
return this.mAttributeId;
|
||||
}
|
||||
|
||||
public boolean isAnimatingChange() {
|
||||
return this.mAnimateChange;
|
||||
}
|
||||
|
||||
public void setAnimateChange(boolean animate) {
|
||||
this.mAnimateChange = animate;
|
||||
}
|
||||
|
||||
public void setApplyToConstraintSetId(int id) {
|
||||
this.mApplyToConstraintSetId = id;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setVisibility(int visibility) {
|
||||
}
|
||||
|
||||
public ReactiveGuide(Context context) {
|
||||
super(context);
|
||||
this.mAttributeId = -1;
|
||||
this.mAnimateChange = false;
|
||||
this.mApplyToConstraintSetId = 0;
|
||||
this.mApplyToAllConstraintSets = true;
|
||||
super.setVisibility(8);
|
||||
init(null);
|
||||
}
|
||||
|
||||
public ReactiveGuide(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.mAttributeId = -1;
|
||||
this.mAnimateChange = false;
|
||||
this.mApplyToConstraintSetId = 0;
|
||||
this.mApplyToAllConstraintSets = true;
|
||||
super.setVisibility(8);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public ReactiveGuide(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mAttributeId = -1;
|
||||
this.mAnimateChange = false;
|
||||
this.mApplyToConstraintSetId = 0;
|
||||
this.mApplyToAllConstraintSets = true;
|
||||
super.setVisibility(8);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public ReactiveGuide(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.mAttributeId = -1;
|
||||
this.mAnimateChange = false;
|
||||
this.mApplyToConstraintSetId = 0;
|
||||
this.mApplyToAllConstraintSets = true;
|
||||
super.setVisibility(8);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
private void init(AttributeSet attrs) {
|
||||
if (attrs != null) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.ConstraintLayout_ReactiveGuide);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.ConstraintLayout_ReactiveGuide_reactiveGuide_valueId) {
|
||||
this.mAttributeId = obtainStyledAttributes.getResourceId(index, this.mAttributeId);
|
||||
} else if (index == R.styleable.ConstraintLayout_ReactiveGuide_reactiveGuide_animateChange) {
|
||||
this.mAnimateChange = obtainStyledAttributes.getBoolean(index, this.mAnimateChange);
|
||||
} else if (index == R.styleable.ConstraintLayout_ReactiveGuide_reactiveGuide_applyToConstraintSet) {
|
||||
this.mApplyToConstraintSetId = obtainStyledAttributes.getResourceId(index, this.mApplyToConstraintSetId);
|
||||
} else if (index == R.styleable.ConstraintLayout_ReactiveGuide_reactiveGuide_applyToAllConstraintSets) {
|
||||
this.mApplyToAllConstraintSets = obtainStyledAttributes.getBoolean(index, this.mApplyToAllConstraintSets);
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
if (this.mAttributeId != -1) {
|
||||
ConstraintLayout.getSharedValues().addListener(this.mAttributeId, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttributeId(int id) {
|
||||
SharedValues sharedValues = ConstraintLayout.getSharedValues();
|
||||
int i = this.mAttributeId;
|
||||
if (i != -1) {
|
||||
sharedValues.removeListener(i, this);
|
||||
}
|
||||
this.mAttributeId = id;
|
||||
if (id != -1) {
|
||||
sharedValues.addListener(id, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(0, 0);
|
||||
}
|
||||
|
||||
public void setGuidelineBegin(int margin) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.guideBegin = margin;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
public void setGuidelineEnd(int margin) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.guideEnd = margin;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
public void setGuidelinePercent(float ratio) {
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.guidePercent = ratio;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.SharedValues.SharedValuesListener
|
||||
public void onNewValue(int key, int newValue, int oldValue) {
|
||||
setGuidelineBegin(newValue);
|
||||
int id = getId();
|
||||
if (id > 0 && (getParent() instanceof MotionLayout)) {
|
||||
MotionLayout motionLayout = (MotionLayout) getParent();
|
||||
int currentState = motionLayout.getCurrentState();
|
||||
int i = this.mApplyToConstraintSetId;
|
||||
if (i != 0) {
|
||||
currentState = i;
|
||||
}
|
||||
int i2 = 0;
|
||||
if (!this.mAnimateChange) {
|
||||
if (this.mApplyToAllConstraintSets) {
|
||||
int[] constraintSetIds = motionLayout.getConstraintSetIds();
|
||||
while (i2 < constraintSetIds.length) {
|
||||
changeValue(newValue, id, motionLayout, constraintSetIds[i2]);
|
||||
i2++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
changeValue(newValue, id, motionLayout, currentState);
|
||||
return;
|
||||
}
|
||||
if (this.mApplyToAllConstraintSets) {
|
||||
int[] constraintSetIds2 = motionLayout.getConstraintSetIds();
|
||||
while (i2 < constraintSetIds2.length) {
|
||||
int i3 = constraintSetIds2[i2];
|
||||
if (i3 != currentState) {
|
||||
changeValue(newValue, id, motionLayout, i3);
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
ConstraintSet cloneConstraintSet = motionLayout.cloneConstraintSet(currentState);
|
||||
cloneConstraintSet.setGuidelineEnd(id, newValue);
|
||||
motionLayout.updateStateAnimate(currentState, cloneConstraintSet, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeValue(int newValue, int id, MotionLayout motionLayout, int currentState) {
|
||||
ConstraintSet constraintSet = motionLayout.getConstraintSet(currentState);
|
||||
constraintSet.setGuidelineEnd(id, newValue);
|
||||
motionLayout.updateState(currentState, constraintSet);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.util.SparseIntArray;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SharedValues {
|
||||
public static final int UNSET = -1;
|
||||
private SparseIntArray mValues = new SparseIntArray();
|
||||
private HashMap<Integer, HashSet<WeakReference<SharedValuesListener>>> mValuesListeners = new HashMap<>();
|
||||
|
||||
public interface SharedValuesListener {
|
||||
void onNewValue(int key, int newValue, int oldValue);
|
||||
}
|
||||
|
||||
public void addListener(int key, SharedValuesListener listener) {
|
||||
HashSet<WeakReference<SharedValuesListener>> hashSet = this.mValuesListeners.get(Integer.valueOf(key));
|
||||
if (hashSet == null) {
|
||||
hashSet = new HashSet<>();
|
||||
this.mValuesListeners.put(Integer.valueOf(key), hashSet);
|
||||
}
|
||||
hashSet.add(new WeakReference<>(listener));
|
||||
}
|
||||
|
||||
public void removeListener(int key, SharedValuesListener listener) {
|
||||
HashSet<WeakReference<SharedValuesListener>> hashSet = this.mValuesListeners.get(Integer.valueOf(key));
|
||||
if (hashSet == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<WeakReference<SharedValuesListener>> it = hashSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<SharedValuesListener> next = it.next();
|
||||
SharedValuesListener sharedValuesListener = next.get();
|
||||
if (sharedValuesListener == null || sharedValuesListener == listener) {
|
||||
arrayList.add(next);
|
||||
}
|
||||
}
|
||||
hashSet.removeAll(arrayList);
|
||||
}
|
||||
|
||||
public void removeListener(SharedValuesListener listener) {
|
||||
Iterator<Integer> it = this.mValuesListeners.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
removeListener(it.next().intValue(), listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearListeners() {
|
||||
this.mValuesListeners.clear();
|
||||
}
|
||||
|
||||
public int getValue(int key) {
|
||||
return this.mValues.get(key, -1);
|
||||
}
|
||||
|
||||
public void fireNewValue(int key, int value) {
|
||||
int i = this.mValues.get(key, -1);
|
||||
if (i == value) {
|
||||
return;
|
||||
}
|
||||
this.mValues.put(key, value);
|
||||
HashSet<WeakReference<SharedValuesListener>> hashSet = this.mValuesListeners.get(Integer.valueOf(key));
|
||||
if (hashSet == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<WeakReference<SharedValuesListener>> it = hashSet.iterator();
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
SharedValuesListener sharedValuesListener = it.next().get();
|
||||
if (sharedValuesListener != null) {
|
||||
sharedValuesListener.onNewValue(key, value, i);
|
||||
} else {
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<WeakReference<SharedValuesListener>> it2 = hashSet.iterator();
|
||||
while (it2.hasNext()) {
|
||||
WeakReference<SharedValuesListener> next = it2.next();
|
||||
if (next.get() == null) {
|
||||
arrayList.add(next);
|
||||
}
|
||||
}
|
||||
hashSet.removeAll(arrayList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,276 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.Xml;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StateSet {
|
||||
private static final boolean DEBUG = false;
|
||||
public static final String TAG = "ConstraintLayoutStates";
|
||||
ConstraintSet mDefaultConstraintSet;
|
||||
int mDefaultState = -1;
|
||||
int mCurrentStateId = -1;
|
||||
int mCurrentConstraintNumber = -1;
|
||||
private SparseArray<State> mStateList = new SparseArray<>();
|
||||
private SparseArray<ConstraintSet> mConstraintSetMap = new SparseArray<>();
|
||||
private ConstraintsChangedListener mConstraintsChangedListener = null;
|
||||
|
||||
public void setOnConstraintsChanged(ConstraintsChangedListener constraintsChangedListener) {
|
||||
this.mConstraintsChangedListener = constraintsChangedListener;
|
||||
}
|
||||
|
||||
public StateSet(Context context, XmlPullParser parser) {
|
||||
load(context, parser);
|
||||
}
|
||||
|
||||
private void load(Context context, XmlPullParser parser) {
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.StateSet);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.StateSet_defaultState) {
|
||||
this.mDefaultState = obtainStyledAttributes.getResourceId(index, this.mDefaultState);
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
try {
|
||||
int eventType = parser.getEventType();
|
||||
State state = null;
|
||||
while (true) {
|
||||
char c = 1;
|
||||
if (eventType == 1) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 0) {
|
||||
parser.getName();
|
||||
} else if (eventType == 2) {
|
||||
String name = parser.getName();
|
||||
switch (name.hashCode()) {
|
||||
case 80204913:
|
||||
if (name.equals("State")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1301459538:
|
||||
if (name.equals("LayoutDescription")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1382829617:
|
||||
if (name.equals("StateSet")) {
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1901439077:
|
||||
if (name.equals("Variant")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
default:
|
||||
c = 65535;
|
||||
break;
|
||||
}
|
||||
if (c == 2) {
|
||||
state = new State(context, parser);
|
||||
this.mStateList.put(state.mId, state);
|
||||
} else if (c == 3) {
|
||||
Variant variant = new Variant(context, parser);
|
||||
if (state != null) {
|
||||
state.add(variant);
|
||||
}
|
||||
}
|
||||
} else if (eventType != 3) {
|
||||
continue;
|
||||
} else if ("StateSet".equals(parser.getName())) {
|
||||
return;
|
||||
}
|
||||
eventType = parser.next();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (XmlPullParserException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean needsToChange(int id, float width, float height) {
|
||||
int i = this.mCurrentStateId;
|
||||
if (i != id) {
|
||||
return true;
|
||||
}
|
||||
State valueAt = id == -1 ? this.mStateList.valueAt(0) : this.mStateList.get(i);
|
||||
return (this.mCurrentConstraintNumber == -1 || !valueAt.mVariants.get(this.mCurrentConstraintNumber).match(width, height)) && this.mCurrentConstraintNumber != valueAt.findMatch(width, height);
|
||||
}
|
||||
|
||||
public int stateGetConstraintID(int id, int width, int height) {
|
||||
return updateConstraints(-1, id, width, height);
|
||||
}
|
||||
|
||||
public int convertToConstraintSet(int currentConstrainSettId, int stateId, float width, float height) {
|
||||
State state = this.mStateList.get(stateId);
|
||||
if (state == null) {
|
||||
return stateId;
|
||||
}
|
||||
if (width == -1.0f || height == -1.0f) {
|
||||
if (state.mConstraintID == currentConstrainSettId) {
|
||||
return currentConstrainSettId;
|
||||
}
|
||||
Iterator<Variant> it = state.mVariants.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (currentConstrainSettId == it.next().mConstraintID) {
|
||||
return currentConstrainSettId;
|
||||
}
|
||||
}
|
||||
return state.mConstraintID;
|
||||
}
|
||||
Iterator<Variant> it2 = state.mVariants.iterator();
|
||||
Variant variant = null;
|
||||
while (it2.hasNext()) {
|
||||
Variant next = it2.next();
|
||||
if (next.match(width, height)) {
|
||||
if (currentConstrainSettId == next.mConstraintID) {
|
||||
return currentConstrainSettId;
|
||||
}
|
||||
variant = next;
|
||||
}
|
||||
}
|
||||
if (variant != null) {
|
||||
return variant.mConstraintID;
|
||||
}
|
||||
return state.mConstraintID;
|
||||
}
|
||||
|
||||
public int updateConstraints(int currentId, int id, float width, float height) {
|
||||
State state;
|
||||
int findMatch;
|
||||
if (currentId != id) {
|
||||
State state2 = this.mStateList.get(id);
|
||||
if (state2 == null) {
|
||||
return -1;
|
||||
}
|
||||
int findMatch2 = state2.findMatch(width, height);
|
||||
return findMatch2 == -1 ? state2.mConstraintID : state2.mVariants.get(findMatch2).mConstraintID;
|
||||
}
|
||||
if (id == -1) {
|
||||
state = this.mStateList.valueAt(0);
|
||||
} else {
|
||||
state = this.mStateList.get(this.mCurrentStateId);
|
||||
}
|
||||
if (state == null) {
|
||||
return -1;
|
||||
}
|
||||
return ((this.mCurrentConstraintNumber == -1 || !state.mVariants.get(currentId).match(width, height)) && currentId != (findMatch = state.findMatch(width, height))) ? findMatch == -1 ? state.mConstraintID : state.mVariants.get(findMatch).mConstraintID : currentId;
|
||||
}
|
||||
|
||||
static class State {
|
||||
int mConstraintID;
|
||||
int mId;
|
||||
boolean mIsLayout;
|
||||
ArrayList<Variant> mVariants = new ArrayList<>();
|
||||
|
||||
public State(Context context, XmlPullParser parser) {
|
||||
this.mConstraintID = -1;
|
||||
this.mIsLayout = false;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.State);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.State_android_id) {
|
||||
this.mId = obtainStyledAttributes.getResourceId(index, this.mId);
|
||||
} else if (index == R.styleable.State_constraints) {
|
||||
this.mConstraintID = obtainStyledAttributes.getResourceId(index, this.mConstraintID);
|
||||
String resourceTypeName = context.getResources().getResourceTypeName(this.mConstraintID);
|
||||
context.getResources().getResourceName(this.mConstraintID);
|
||||
if ("layout".equals(resourceTypeName)) {
|
||||
this.mIsLayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
void add(Variant size) {
|
||||
this.mVariants.add(size);
|
||||
}
|
||||
|
||||
public int findMatch(float width, float height) {
|
||||
for (int i = 0; i < this.mVariants.size(); i++) {
|
||||
if (this.mVariants.get(i).match(width, height)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static class Variant {
|
||||
int mConstraintID;
|
||||
int mId;
|
||||
boolean mIsLayout;
|
||||
float mMaxHeight;
|
||||
float mMaxWidth;
|
||||
float mMinHeight;
|
||||
float mMinWidth;
|
||||
|
||||
public Variant(Context context, XmlPullParser parser) {
|
||||
this.mMinWidth = Float.NaN;
|
||||
this.mMinHeight = Float.NaN;
|
||||
this.mMaxWidth = Float.NaN;
|
||||
this.mMaxHeight = Float.NaN;
|
||||
this.mConstraintID = -1;
|
||||
this.mIsLayout = false;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.Variant);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.Variant_constraints) {
|
||||
this.mConstraintID = obtainStyledAttributes.getResourceId(index, this.mConstraintID);
|
||||
String resourceTypeName = context.getResources().getResourceTypeName(this.mConstraintID);
|
||||
context.getResources().getResourceName(this.mConstraintID);
|
||||
if ("layout".equals(resourceTypeName)) {
|
||||
this.mIsLayout = true;
|
||||
}
|
||||
} else if (index == R.styleable.Variant_region_heightLessThan) {
|
||||
this.mMaxHeight = obtainStyledAttributes.getDimension(index, this.mMaxHeight);
|
||||
} else if (index == R.styleable.Variant_region_heightMoreThan) {
|
||||
this.mMinHeight = obtainStyledAttributes.getDimension(index, this.mMinHeight);
|
||||
} else if (index == R.styleable.Variant_region_widthLessThan) {
|
||||
this.mMaxWidth = obtainStyledAttributes.getDimension(index, this.mMaxWidth);
|
||||
} else if (index == R.styleable.Variant_region_widthMoreThan) {
|
||||
this.mMinWidth = obtainStyledAttributes.getDimension(index, this.mMinWidth);
|
||||
} else {
|
||||
Log.v("ConstraintLayoutStates", "Unknown tag");
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
boolean match(float widthDp, float heightDp) {
|
||||
if (!Float.isNaN(this.mMinWidth) && widthDp < this.mMinWidth) {
|
||||
return false;
|
||||
}
|
||||
if (!Float.isNaN(this.mMinHeight) && heightDp < this.mMinHeight) {
|
||||
return false;
|
||||
}
|
||||
if (Float.isNaN(this.mMaxWidth) || widthDp <= this.mMaxWidth) {
|
||||
return Float.isNaN(this.mMaxHeight) || heightDp <= this.mMaxHeight;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package androidx.constraintlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class VirtualLayout extends ConstraintHelper {
|
||||
private boolean mApplyElevationOnAttach;
|
||||
private boolean mApplyVisibilityOnAttach;
|
||||
|
||||
public void onMeasure(androidx.constraintlayout.core.widgets.VirtualLayout layout, int widthMeasureSpec, int heightMeasureSpec) {
|
||||
}
|
||||
|
||||
public VirtualLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public VirtualLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public VirtualLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
protected void init(AttributeSet attrs) {
|
||||
super.init(attrs);
|
||||
if (attrs != null) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.ConstraintLayout_Layout);
|
||||
int indexCount = obtainStyledAttributes.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
int index = obtainStyledAttributes.getIndex(i);
|
||||
if (index == R.styleable.ConstraintLayout_Layout_android_visibility) {
|
||||
this.mApplyVisibilityOnAttach = true;
|
||||
} else if (index == R.styleable.ConstraintLayout_Layout_android_elevation) {
|
||||
this.mApplyElevationOnAttach = true;
|
||||
}
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper, android.view.View
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (this.mApplyVisibilityOnAttach || this.mApplyElevationOnAttach) {
|
||||
ViewParent parent = getParent();
|
||||
if (parent instanceof ConstraintLayout) {
|
||||
ConstraintLayout constraintLayout = (ConstraintLayout) parent;
|
||||
int visibility = getVisibility();
|
||||
float elevation = getElevation();
|
||||
for (int i = 0; i < this.mCount; i++) {
|
||||
View viewById = constraintLayout.getViewById(this.mIds[i]);
|
||||
if (viewById != null) {
|
||||
if (this.mApplyVisibilityOnAttach) {
|
||||
viewById.setVisibility(visibility);
|
||||
}
|
||||
if (this.mApplyElevationOnAttach && elevation > 0.0f) {
|
||||
viewById.setTranslationZ(viewById.getTranslationZ() + elevation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
applyLayoutFeatures();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setElevation(float elevation) {
|
||||
super.setElevation(elevation);
|
||||
applyLayoutFeatures();
|
||||
}
|
||||
|
||||
@Override // androidx.constraintlayout.widget.ConstraintHelper
|
||||
protected void applyLayoutFeaturesInConstraintSet(ConstraintLayout container) {
|
||||
applyLayoutFeatures(container);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user