use of android.widget.Checkable in project android_frameworks_base by DirtyUnicorns.
the class View method onProvideStructure.
/**
* Called when assist structure is being retrieved from a view as part of
* {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData}.
* @param structure Fill in with structured view data. The default implementation
* fills in all data that can be inferred from the view itself.
*/
public void onProvideStructure(ViewStructure structure) {
final int id = mID;
if (id > 0 && (id & 0xff000000) != 0 && (id & 0x00ff0000) != 0 && (id & 0x0000ffff) != 0) {
String pkg, type, entry;
try {
final Resources res = getResources();
entry = res.getResourceEntryName(id);
type = res.getResourceTypeName(id);
pkg = res.getResourcePackageName(id);
} catch (Resources.NotFoundException e) {
entry = type = pkg = null;
}
structure.setId(id, pkg, type, entry);
} else {
structure.setId(id, null, null, null);
}
structure.setDimens(mLeft, mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop);
if (!hasIdentityMatrix()) {
structure.setTransformation(getMatrix());
}
structure.setElevation(getZ());
structure.setVisibility(getVisibility());
structure.setEnabled(isEnabled());
if (isClickable()) {
structure.setClickable(true);
}
if (isFocusable()) {
structure.setFocusable(true);
}
if (isFocused()) {
structure.setFocused(true);
}
if (isAccessibilityFocused()) {
structure.setAccessibilityFocused(true);
}
if (isSelected()) {
structure.setSelected(true);
}
if (isActivated()) {
structure.setActivated(true);
}
if (isLongClickable()) {
structure.setLongClickable(true);
}
if (this instanceof Checkable) {
structure.setCheckable(true);
if (((Checkable) this).isChecked()) {
structure.setChecked(true);
}
}
if (isContextClickable()) {
structure.setContextClickable(true);
}
structure.setClassName(getAccessibilityClassName().toString());
structure.setContentDescription(getContentDescription());
}
use of android.widget.Checkable in project android_frameworks_base by DirtyUnicorns.
the class CheckBoxPreference method onBindView.
@Override
protected void onBindView(View view) {
super.onBindView(view);
View checkboxView = view.findViewById(com.android.internal.R.id.checkbox);
if (checkboxView != null && checkboxView instanceof Checkable) {
((Checkable) checkboxView).setChecked(mChecked);
}
syncSummaryView(view);
}
use of android.widget.Checkable in project android_frameworks_base by DirtyUnicorns.
the class AdapterHelper method fillView.
private static void fillView(BridgeContext context, View view, AdapterItem item, AdapterItem parentItem, LayoutlibCallback callback, ResourceReference adapterRef) {
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
final int count = group.getChildCount();
for (int i = 0; i < count; i++) {
fillView(context, group.getChildAt(i), item, parentItem, callback, adapterRef);
}
} else {
int id = view.getId();
if (id != 0) {
ResourceReference resolvedRef = context.resolveId(id);
if (resolvedRef != null) {
int fullPosition = item.getFullPosition();
int positionPerType = item.getPositionPerType();
int fullParentPosition = parentItem != null ? parentItem.getFullPosition() : 0;
int parentPositionPerType = parentItem != null ? parentItem.getPositionPerType() : 0;
if (view instanceof TextView) {
TextView tv = (TextView) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.TEXT, tv.getText().toString());
if (value != null) {
if (value.getClass() != ViewAttribute.TEXT.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for TEXT. Expected String, got %s", value.getClass().getName()), null);
} else {
tv.setText((String) value);
}
}
}
if (view instanceof Checkable) {
Checkable cb = (Checkable) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.IS_CHECKED, cb.isChecked());
if (value != null) {
if (value.getClass() != ViewAttribute.IS_CHECKED.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for IS_CHECKED. Expected Boolean, got %s", value.getClass().getName()), null);
} else {
cb.setChecked((Boolean) value);
}
}
}
if (view instanceof ImageView) {
ImageView iv = (ImageView) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.SRC, iv.getDrawable());
if (value != null) {
if (value.getClass() != ViewAttribute.SRC.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for SRC. Expected Boolean, got %s", value.getClass().getName()), null);
} else {
// FIXME
}
}
}
}
}
}
}
use of android.widget.Checkable in project android_frameworks_base by AOSPA.
the class SwitchPreference method onBindView.
@Override
protected void onBindView(View view) {
super.onBindView(view);
View checkableView = view.findViewById(com.android.internal.R.id.switch_widget);
if (checkableView != null && checkableView instanceof Checkable) {
if (checkableView instanceof Switch) {
final Switch switchView = (Switch) checkableView;
switchView.setOnCheckedChangeListener(null);
}
((Checkable) checkableView).setChecked(mChecked);
if (checkableView instanceof Switch) {
final Switch switchView = (Switch) checkableView;
switchView.setTextOn(mSwitchOn);
switchView.setTextOff(mSwitchOff);
switchView.setOnCheckedChangeListener(mListener);
}
}
syncSummaryView(view);
}
use of android.widget.Checkable in project platform_frameworks_base by android.
the class AdapterHelper method fillView.
private static void fillView(BridgeContext context, View view, AdapterItem item, AdapterItem parentItem, LayoutlibCallback callback, ResourceReference adapterRef) {
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
final int count = group.getChildCount();
for (int i = 0; i < count; i++) {
fillView(context, group.getChildAt(i), item, parentItem, callback, adapterRef);
}
} else {
int id = view.getId();
if (id != 0) {
ResourceReference resolvedRef = context.resolveId(id);
if (resolvedRef != null) {
int fullPosition = item.getFullPosition();
int positionPerType = item.getPositionPerType();
int fullParentPosition = parentItem != null ? parentItem.getFullPosition() : 0;
int parentPositionPerType = parentItem != null ? parentItem.getPositionPerType() : 0;
if (view instanceof TextView) {
TextView tv = (TextView) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.TEXT, tv.getText().toString());
if (value != null) {
if (value.getClass() != ViewAttribute.TEXT.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for TEXT. Expected String, got %s", value.getClass().getName()), null);
} else {
tv.setText((String) value);
}
}
}
if (view instanceof Checkable) {
Checkable cb = (Checkable) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.IS_CHECKED, cb.isChecked());
if (value != null) {
if (value.getClass() != ViewAttribute.IS_CHECKED.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for IS_CHECKED. Expected Boolean, got %s", value.getClass().getName()), null);
} else {
cb.setChecked((Boolean) value);
}
}
}
if (view instanceof ImageView) {
ImageView iv = (ImageView) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.SRC, iv.getDrawable());
if (value != null) {
if (value.getClass() != ViewAttribute.SRC.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for SRC. Expected Boolean, got %s", value.getClass().getName()), null);
} else {
// FIXME
}
}
}
}
}
}
}
Aggregations