本文整理汇总了Java中android.view.accessibility.AccessibilityNodeInfo.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityNodeInfo.getParent方法的具体用法?Java AccessibilityNodeInfo.getParent怎么用?Java AccessibilityNodeInfo.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.accessibility.AccessibilityNodeInfo
的用法示例。
在下文中一共展示了AccessibilityNodeInfo.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iteratorSMZDM
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void iteratorSMZDM(AccessibilityNodeInfo info) {
if (info.getChildCount() == 0 && info.getText() != null) {
if (info.getText().equals("签到")) {
AccessibilityNodeInfo parent = info.getParent();
if ("android.widget.RelativeLayout".equals(parent.getClassName())
&& parent.isClickable()) {
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iteratorSMZDM(info.getChild(i));
}
}
}
return ;
}
示例2: findGiftInChat
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void findGiftInChat() {
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
if (nodeInfo == null) {
Log.w(TAG, "rootWindow为空");
return;
}
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(DINGDING_ACTION_SEE_GIFT);
if (list != null) {
for (AccessibilityNodeInfo n : list) {
//点击父控件 ListView的Item
AccessibilityNodeInfo parent = n.getParent();
Log.i(TAG, "-->聊天界面寻找钉钉红包:" + n);
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
break;
}
}
}
示例3: enterChatHasGift
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void enterChatHasGift() {
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
if (nodeInfo == null) {
Log.w(TAG, "rootWindow为空");
return;
}
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(DINGDING_ENVELOPE_TEXT_KEY);
if (list != null) {
for (AccessibilityNodeInfo n : list) {
//点击父控件 ListView的Item
AccessibilityNodeInfo parent = n.getParent();
Log.i(TAG, "-->主界面寻找钉钉红包:" + n);
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
break;
}
}
}
示例4: getRedSenderInfo
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static String getRedSenderInfo(AccessibilityNodeInfo node) {
AccessibilityNodeInfo nodeParent = node.getParent();
if ("android.widget.ListView".equals(nodeParent)) return null;
if (!TextUtils.isEmpty(nodeParent.getChild(0).getText()))
content = nodeParent.getChild(0).getText().toString();//get content
nodeParent = nodeParent.getParent();
if (null==nodeParent)return null;
if (!TextUtils.isEmpty(nodeParent.getChild(0).getText()))
sendTime = nodeParent.getChild(0).getText().toString();//get Time
for (int i = 0; i < nodeParent.getChildCount(); i++) {
AccessibilityNodeInfo nodeChild = nodeParent.getChild(i);
if ("android.widget.ImageView".equals(nodeChild.getClassName())) {
CharSequence contentDescription = nodeChild.getContentDescription();
if (null != contentDescription)
sender = contentDescription.toString().replaceAll("头像$", ""); //get sender
}
}
Log.e("LSeven", " red info===>" + sender + " " + content + " " + sendTime);
return sender+"|"+content+"|"+sendTime;
}
示例5: getRootAccessibilityNodeInfo
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static AccessibilityNodeInfo getRootAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo accessibilityNodeInfo) throws MyException {
if (null == accessibilityNodeInfo) {
throw new NullPointerException("accessibilityNodeInfo");
}
AccessibilityNodeInfo current = null;
try {
current = accessibilityNodeInfo;
while (true) {
AccessibilityNodeInfo parent = current.getParent();
if (null == parent) {
return current;
}
current = parent;
}
} catch (Exception e) {
if (null != current) {
current.recycle();
}
throw new MyException(e);
}
}
示例6: iteratorJD
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void iteratorJD(AccessibilityNodeInfo info) {
if (info.getText() != null) {
if (info.getText().toString().contains("会员") && !info.getText().equals("PLUS会员")) {
AccessibilityNodeInfo parent = info.getParent();
if ("android.widget.RelativeLayout".equals(parent.getClassName())
&& parent.isClickable()) {
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return ;
}
}
if (info.getText().equals("签到")
&& info.findAccessibilityNodeInfosByViewId("com.jd.lib.coupon:id/sign_get_button") != null
&& info.isClickable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iteratorJD(info.getChild(i));
}
}
}
return ;
}
示例7: getClickableNode
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* 获取一个可以点击的节点
*/
private AccessibilityNodeInfo getClickableNode(AccessibilityNodeInfo node){
AccessibilityNodeInfo parent=node;
while(parent!=null){
if(parent.isClickable()){
break;
}
parent=parent.getParent();
}
return parent;
}
示例8: recycle
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public void recycle(AccessibilityNodeInfo info) {
try {
if (info.getChildCount() == 0) {
if (info.getText() != null) {
if ("领取红包".equals(info.getText().toString())) {
if (info.isClickable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
AccessibilityNodeInfo parent = info.getParent();
while (parent != null) {
if (parent.isClickable()) {
parents.add(parent);
break;
}
parent = parent.getParent();
}
}
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if (info.getChild(i) != null) {
recycle(info.getChild(i));
}
}
}
} catch (Exception e) {
}
}
示例9: findNodeAllParents
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static void findNodeAllParents(AccessibilityNodeInfo topNode,List<AccessibilityNodeInfo> list){
if (topNode.getParent() != null) {
AccessibilityNodeInfo parent = topNode.getParent();
list.add(parent);
findNodeAllParents(parent,list);
}
}
示例10: getFromLastNode
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* 搜索包含红包的UI节点, 点击末几个
*
* @param root 根UI节点
* @param size 点击最后size个
* @param ignoreDup 是否无视重复检测
* @return 成功点击的红包数
*/
Integer getFromLastNode(AccessibilityNodeInfo root, Integer size, boolean ignoreDup)
{
List<AccessibilityNodeInfo> mNodes =
root.findAccessibilityNodeInfosByText(getResources().getString(R.string.chat_pattern));
size = Math.min(size, mNodes.size()); // 先设成功点击数为预计点击的红包数目
for (Integer i = mNodes.size() - size; i < mNodes.size(); i++)
{
AccessibilityNodeInfo node = mNodes.get(i);
// Log.d("node", node.toString());
AccessibilityNodeInfo parent = node.getParent();
if (parent == null)
{
//Log.d("node.parent", "null"); // 有时候没有父节点, 蜜汁bug
}
else
{
if (ignoreDup || (lastNode != node.hashCode()))
{ // 非重复红包, 点击
// Log.d("click", "GET" + Integer.valueOf(node.hashCode()).toString());
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
cnt_get += 1;
lastNode = node.hashCode();
}
else
{
// Log.d("node duplicate", Integer.valueOf(node.hashCode()).toString());
size -= 1; // 重复红包, 减少成功计数
}
}
}
return size;
}
示例11: getRoot
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
AccessibilityNodeInfo getRoot(AccessibilityNodeInfo node)
{
AccessibilityNodeInfo parent;
parent = node.getParent();
while (parent != null)
{
node = parent;
parent = node.getParent();
}
return node;
}
示例12: getClickableNode
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* 获取一个可以点击的节点
*/
private AccessibilityNodeInfo getClickableNode(AccessibilityNodeInfo node)
{
AccessibilityNodeInfo parent=node;
while (parent != null)
{
if (parent.isClickable())
{
break;
}
parent = parent.getParent();
}
return parent;
}
示例13: generateSignature
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public boolean generateSignature(AccessibilityNodeInfo node, String excludeWords) {
try {
/* The hongbao container node. It should be a LinearLayout. By specifying that, we can avoid text messages. */
AccessibilityNodeInfo hongbaoNode = node.getParent();
if (!"android.widget.LinearLayout".equals(hongbaoNode.getClassName())) return false;
/* The text in the hongbao. Should mean something. */
String hongbaoContent = hongbaoNode.getChild(0).getText().toString();
if (hongbaoContent == null || "查看红包".equals(hongbaoContent)) return false;
/* Check the user's exclude words list. */
String[] excludeWordsArray = excludeWords.split(" +");
for (String word : excludeWordsArray) {
if (word.length() > 0 && hongbaoContent.contains(word)) return false;
}
/* The container node for a piece of message. It should be inside the screen.
Or sometimes it will get opened twice while scrolling. */
AccessibilityNodeInfo messageNode = hongbaoNode.getParent();
Rect bounds = new Rect();
messageNode.getBoundsInScreen(bounds);
if (bounds.top < 0) return false;
/* The sender and possible timestamp. Should mean something too. */
String[] hongbaoInfo = getSenderContentDescriptionFromNode(messageNode);
if (this.getSignature(hongbaoInfo[0], hongbaoContent, hongbaoInfo[1]).equals(this.toString())) return false;
/* So far we make sure it's a valid new coming hongbao. */
this.sender = hongbaoInfo[0];
this.time = hongbaoInfo[1];
this.content = hongbaoContent;
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例14: parseNodeInfoAndOpenGetPacketDialog
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void parseNodeInfoAndOpenGetPacketDialog(AccessibilityNodeInfo accessibilityNodeInfo){
if(accessibilityNodeInfo != null && accessibilityNodeInfo.getChildCount() >0){
for(int i = 0;i<accessibilityNodeInfo.getChildCount();i++){
AccessibilityNodeInfo child = accessibilityNodeInfo.getChild(i);
parseNodeInfoAndOpenGetPacketDialog(child);
}
}else{
if(accessibilityNodeInfo != null && !TextUtils.isEmpty(accessibilityNodeInfo.getText())&&accessibilityNodeInfo.getText().toString().contains("领取红包")){
Log.i(TAG,"领取红包");
if(accessibilityNodeInfo.isClickable()){
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}else{
AccessibilityNodeInfo parent = accessibilityNodeInfo.getParent();
while(parent != null ){
if(parent.isClickable()){
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
break;
}
parent = parent.getParent();
Log.i(TAG," 找到一个可以点击的节点");
}
}
}
}
}
示例15: onAccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
int eventType = event.getEventType();
CharSequence packageName = event.getPackageName();
switch (eventType) {
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
AccessibilityNodeInfo rootNode = getRootInActiveWindow();
if (rootNode != null) {
if (packageName.equals("com.android.settings")) {
AccessibilityNodeInfo settingNode = AceHelper.findNodeByText(rootNode,"WLAN");
AceHelper.performClick(settingNode);
rootNode.recycle();
} else if (packageName.equals("com.android.wifisettings")) {
AccessibilityNodeInfo wifiNode = AceHelper.findNodeByText(rootNode, "TP-LINK_F770");
AccessibilityNodeInfo wifiNodeParent = wifiNode.getParent();
AccessibilityNodeInfo iconNode = AceHelper.findNodeById(wifiNodeParent, "com.android.wifisettings:id/advance_layout");
AceHelper.performClick(iconNode);
}
}
break;
case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
Toast.makeText(this, "Notify", Toast.LENGTH_SHORT).show();
event.getSource().recycle();
break;
case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
break;
default:
break;
}
}