《Android-Java 巧用16进制进行属性设置》 ----方便Boolean属性复制

38 篇文章 0 订阅

方便Boolean属性复制

代码摘自 android.view.accessibility.AccessibilityNodeInfo

//*****************************************************
// Boolean attributes.

private static final int BOOLEAN_PROPERTY_CHECKABLE = 0x00000001;

private static final int BOOLEAN_PROPERTY_CHECKED = 0x00000002;

private static final int BOOLEAN_PROPERTY_FOCUSABLE = 0x00000004;

private static final int BOOLEAN_PROPERTY_FOCUSED = 0x00000008;

private static final int BOOLEAN_PROPERTY_SELECTED = 0x00000010;

private static final int BOOLEAN_PROPERTY_CLICKABLE = 0x00000020;

private static final int BOOLEAN_PROPERTY_LONG_CLICKABLE = 0x00000040;

private static final int BOOLEAN_PROPERTY_ENABLED = 0x00000080;

private static final int BOOLEAN_PROPERTY_PASSWORD = 0x00000100;

private static final int BOOLEAN_PROPERTY_SCROLLABLE = 0x00000200;

private static final int BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400;

private static final int BOOLEAN_PROPERTY_VISIBLE_TO_USER = 0x00000800;

private static final int BOOLEAN_PROPERTY_EDITABLE = 0x00001000;

private static final int BOOLEAN_PROPERTY_OPENS_POPUP = 0x00002000;


//*****************************************************
/**
 * Gets the value of a boolean property.
 *
 * @param property The property.
 * @return The value.
 */
private boolean getBooleanProperty(int property) {
    return (mBooleanProperties & property) != 0;
}

/**
 * Sets a boolean property.
 *
 * @param property The property.
 * @param value The value.
 *
 * @throws IllegalStateException If called from an AccessibilityService.
 */
private void setBooleanProperty(int property, boolean value) {
    enforceNotSealed();
    if (value) {
        mBooleanProperties |= property;
    } else {
        mBooleanProperties &= ~property;
    }
}


//*****************************************************
/**
 * Gets whether this node is checkable.
 *
 * @return True if the node is checkable.
 */
public boolean isCheckable() {
    return getBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE);
}

/**
 * Sets whether this node is checkable.
 * <p>
 *   <strong>Note:</strong> Cannot be called from an
 *   {@link android.accessibilityservice.AccessibilityService}.
 *   This class is made immutable before being delivered to an AccessibilityService.
 * </p>
 *
 * @param checkable True if the node is checkable.
 *
 * @throws IllegalStateException If called from an AccessibilityService.
 */
public void setCheckable(boolean checkable) {
    setBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE, checkable);
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值