use of android.widget.Checkable in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UsbModeChooserActivity method inflateOption.
private void inflateOption(final int mode, boolean selected, LinearLayout container, final boolean disallowedByAdmin) {
/** UsbSecurity is disable
boolean isSimCardInserted = SystemProperties.getBoolean(
"persist.sys.sim.activate", false);
boolean isUsbSecurityEnable = SystemProperties.getBoolean(
"persist.sys.usb.security", false);
**/
View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
TextView titleView = (TextView) v.findViewById(android.R.id.title);
titleView.setText(getTitle(mode));
TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
summaryView.setText(getSummary(mode));
if (disallowedByAdmin) {
if (mEnforcedAdmin != null) {
setDisabledByAdmin(v, titleView, summaryView);
} else {
return;
}
}
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (disallowedByAdmin && mEnforcedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(UsbModeChooserActivity.this, mEnforcedAdmin);
return;
}
if (!ActivityManager.isUserAMonkey()) {
mBackend.setMode(mode);
}
mDialog.dismiss();
finish();
}
});
((Checkable) v).setChecked(selected);
/** UsbSecurity is disable
if( !isSimCardInserted && isUsbSecurityEnable )
{
v.setEnabled(selected);
}**/
container.addView(v);
}
use of android.widget.Checkable in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictBackgroundDataPreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
View switchView = holder.findViewById(android.R.id.switch_widget);
switchView.setClickable(false);
((Checkable) switchView).setChecked(mChecked);
}
use of android.widget.Checkable in project UltimateAndroid by cymcsg.
the class FreeFlowContainer method updateOnScreenCheckedViews.
/**
* Perform a quick, in-place update of the checked or activated state on all
* visible item views. This should only be called when a valid choice mode
* is active.
*/
private void updateOnScreenCheckedViews() {
Iterator<?> it = frames.entrySet().iterator();
View child = null;
while (it.hasNext()) {
Map.Entry<?, FreeFlowItem> pairs = (Map.Entry<?, FreeFlowItem>) it.next();
child = pairs.getValue().view;
boolean isChecked = isChecked(pairs.getValue().itemSection, pairs.getValue().itemIndex);
if (child instanceof Checkable) {
((Checkable) child).setChecked(isChecked);
} else {
child.setActivated(isChecked);
}
}
}
Aggregations