From 7018d993d9d46dfa5dbddb85ee6d45fa5e98c2a0 Mon Sep 17 00:00:00 2001 From: jianbo <263303411@qq.com> Date: Thu, 23 Sep 2021 18:07:41 +0800 Subject: [PATCH] atom --- .../fisherbone/fuzhu/LiveSuiJiActivity.java | 20 + .../fuzhu/entity/LiveSuiJiBean.java | 37 +- .../fisherbone/fuzhu/step/HongbaoBase.java | 72 +- .../fisherbone/fuzhu/step/TestAblStep31.java | 517 +++++++--- .../fuzhu/step/TestAblStep31bei.java | 923 ++++++++++++++++++ .../fisherbone/fuzhu/step/TestAblStep34.java | 56 +- .../fuzhu/utils/ProfileSpUtils.java | 2 +- .../main/res/layout/activity_live_sui_ji.xml | 106 ++ 8 files changed, 1526 insertions(+), 207 deletions(-) create mode 100644 app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java diff --git a/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java b/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java index bef4347..5a46d7d 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java +++ b/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java @@ -1,6 +1,7 @@ package com.fisherbone.fuzhu; import android.os.Bundle; +import android.util.Log; import android.view.View; import androidx.databinding.DataBindingUtil; @@ -10,6 +11,7 @@ import com.fisherbone.fuzhu.entity.FourEvent; import com.fisherbone.fuzhu.entity.LiveSuiJiBean; import com.fisherbone.fuzhu.utils.ProfileSpUtils; import com.fisherbone.fuzhu.widget.TitleBar; +import com.jeremyliao.liveeventbus.LiveEventBus; import de.greenrobot.event.EventBus; @@ -28,6 +30,24 @@ public class LiveSuiJiActivity extends BaseActivity { mTitleBar = (TitleBar) findViewById(R.id.title_bar); mTitleBar.setTitle("随机直播间抢福袋"); initNormalBack(); + binding.radioButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(liveSuiJiBean.getSwitchfive()) { + liveSuiJiBean.setSwitchsix(false); + Log.e("TIAOSHI###", "获得的关键词内容" + "2"); + } + } + }); + binding.radioButton2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(liveSuiJiBean.getSwitchsix()) { + liveSuiJiBean.setSwitchfive(false); + Log.e("TIAOSHI###", "获得的关键词内容" + "4"); + } + } + }); } public class Presenter { public void onClick(View view){ diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java index 033df75..87f0be8 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java @@ -19,7 +19,7 @@ public class LiveSuiJiBean extends BaseObservable { public LiveSuiJiBean(){ } - public LiveSuiJiBean(String str1,String str2,String str3,String str4,Boolean str5,Boolean str6,Boolean str7,Boolean str8,String str9) { + public LiveSuiJiBean(String str1,String str2,String str3,String str4,Boolean str5,Boolean str6,Boolean str7,Boolean str8,String str9,Boolean str10,Boolean str11) { this.minnum = str1; this.maxnum = str2; @@ -30,6 +30,8 @@ public class LiveSuiJiBean extends BaseObservable { this.switchthree=str7; this.switchfour=str8; this.minutetwo=str9; + this.switchfive=str10; + this.switchsix=str11; } public List getBigshotdatas() { @@ -164,5 +166,38 @@ public class LiveSuiJiBean extends BaseObservable { private Boolean switchtwo; private Boolean switchthree; private Boolean switchfour; + //直播间个数 + String livenum = ""; + @Bindable + public String getLivenum() { + return livenum; + } + + public void setLivenum(String livenum) { + this.livenum = livenum; + notifyPropertyChanged(BR.livenum); + } + @Bindable + public Boolean getSwitchfive() { + return switchfive; + } + + public void setSwitchfive(Boolean switchfive) { + this.switchfive = switchfive; + notifyPropertyChanged(BR.switchfive); + } + + private Boolean switchfive; + @Bindable + public Boolean getSwitchsix() { + return switchsix; + } + + public void setSwitchsix(Boolean switchsix) { + this.switchsix = switchsix; + notifyPropertyChanged(BR.switchsix); + } + + private Boolean switchsix; } diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java b/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java index 4e8e8e9..c00769c 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java +++ b/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java @@ -16,6 +16,7 @@ import com.fisherbone.fuzhu.db.CommentBeanData; import com.fisherbone.fuzhu.db.RedenvBeanData; import com.fisherbone.fuzhu.db.dao.CommentDao; import com.fisherbone.fuzhu.hongbao.RedEnv; +import com.jeremyliao.liveeventbus.LiveEventBus; import java.util.ArrayList; import java.util.List; @@ -79,15 +80,16 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF /** * 关闭确认支付弹框 + * * @param instance */ public void closedzfDialog(AblService instance) { //处理我知道了的弹框 AccessibilityNodeInfo zhidao = AblViewUtil.findByText("确认支付", 0); - if(zhidao==null){ - Log.e("TIAOSHI###", "没有找到确认支付的弹窗" ); - }else { - Log.e("TIAOSHI###", "弹出了确认支付的弹窗" ); + if (zhidao == null) { + Log.e("TIAOSHI###", "没有找到确认支付的弹窗"); + } else { + Log.e("TIAOSHI###", "弹出了确认支付的弹窗"); AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("确认并不再提醒", 0); AblService.getInstance().clickcommontwo(zaishuo, "确认并不再提醒"); AblViewUtil.mySleep(1); @@ -138,7 +140,7 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF for (int y = 0; y < child.getChildCount(); y++) { AccessibilityNodeInfo child1 = child.getChild(y); // Log.e("TIAOSHI###", "one----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - if(child1!=null) { + if (child1 != null) { for (int j = 0; j < child1.getChildCount(); j++) { AccessibilityNodeInfo child2 = child1.getChild(j); // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); @@ -235,13 +237,13 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF if (root != null) { for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); for (int y = 0; y < child.getChildCount(); y++) { AccessibilityNodeInfo child1 = child.getChild(y); - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - Rect rect = new Rect(); - child1.getBoundsInScreen(rect); - if(child1!=null) { + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if (child1 != null) { + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); if (rect.top >= 319 && rect.bottom <= 418 && rect.right < 706) { if ("android.widget.FrameLayout".equals(child1.getClassName())) { accessibilityNodeInfos.add(child1); @@ -255,7 +257,6 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF } - /** * 判断页面类型 * @@ -274,12 +275,12 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF childCount = root.getChildCount(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { childCount = 4; } - if("android.widget.Button".equals(child.getClassName())){ - childCount =21; + if ("android.widget.Button".equals(child.getClassName())) { + childCount = 21; } } } @@ -356,19 +357,19 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF zhibodianzanb(64); AblViewUtil.mySleep(3); int pagetype = pagetype(); - if (pagetype==21) { + if (pagetype == 21) { Log.e("TIAOSHI###", "有红包弹框,点击关闭"); - // AblViewUtil.back(); + // AblViewUtil.back(); AblService.getInstance().clickPoint(540, 1663, 300); - // (100,563),(980,1746) + // (100,563),(980,1746) } else { Log.e("TIAOSHI###", "没有有红包弹框,不点击返回"); } AblViewUtil.mySleep(1); int pagenum = pagetype(); - if(pagenum!=21) { + if (pagenum != 21) { AblStepHandler.sendMsg(AblSteps.STEP_254); - }else { + } else { Log.e("TIAOSHI###", "有红包弹框,再次点击关闭"); AblService.getInstance().clickPoint(540, 1663, 300); AblStepHandler.sendMsg(AblSteps.STEP_254); @@ -380,7 +381,6 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF } - /** * 直播间点赞 * @@ -556,9 +556,25 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF return false; } + // @Override +// public boolean enterLive() { +// return false; +// } @Override public boolean enterLive() { - return false; + boolean ifEnterOne = true; + //进入推荐页(刷新) + AblViewUtil.mySleep(1); + getNodeInfo("2"); + Log.e("TIAOSHI###", "点击关注"); + AblViewUtil.mySleep(5); + enterOneNodeInfo(); + AblViewUtil.mySleep(4); + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + ifEnterOne = true; + } + return ifEnterOne; } @Override @@ -799,7 +815,7 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if(child!=null) { + if (child != null) { if ("android.widget.FrameLayout".equals(child.getClassName())) { AblViewUtil.mySleep(2); Log.e("TIAOSHI###", "出现了取消关注的弹框,点击坐标540,500关闭"); @@ -869,4 +885,16 @@ class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeF return nodeInfo; } + public void runLog(String str) { + LiveEventBus.get("some_key").post(str); + Log.e("TIAOSHI###", str); + } + public boolean enterLivetwo() { + boolean ifEnterOne = false; + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + ifEnterOne = true; + } + return ifEnterOne; + } } diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java index d170670..99cf999 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java @@ -14,6 +14,7 @@ import com.fisherbone.fuzhu.abllib.AblService; import com.fisherbone.fuzhu.abllib.AblStepHandler; import com.fisherbone.fuzhu.abllib.AblSteps; import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.RedenvBeanData; import com.fisherbone.fuzhu.entity.LiveSuiJiBean; import com.fisherbone.fuzhu.utils.ProfileSpUtils; @@ -37,69 +38,54 @@ public class TestAblStep31 extends HongbaoBase { private List hongbaos; private List times; private int num3; - private boolean noqinmidu=true; + private boolean noqinmidu = true; + private int livePosition = 0; + //true 为向下滑动状态 + private boolean slidingDir = true; + private LiveSuiJiBean liveSuiJiBean; @Override public void onStep(int step, Message msg) { switch (step) { case AblSteps.STEP_221: + livePosition = 0; + slidingDir = true; + liveSuiJiBean = ProfileSpUtils.getInstance().getLiveSuiJiBean(); AblViewUtil.startApplication(); jiluBeans = new ArrayList<>(); AblViewUtil.mySleep(3); allowed(); AblViewUtil.mySleep(5); - //点击直播1080 - AblService.getInstance().clickPoint(90, 163, 300); - AblViewUtil.mySleep(3); - AblStepHandler.sendMsg(AblSteps.STEP_222); + if (ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchfive()) { + AblService.getInstance().clickPoint(90, 163, 300); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + if (ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchsix()) { + enfirstLive(); + } break; +// case AblSteps.STEP_222: +// Log.e("TIAOSHI###", "福袋测试STEP_222"); +// AblViewUtil.mySleep(2); +// AblStepHandler.sendMsg(AblSteps.STEP_223); +// break; case AblSteps.STEP_222: Log.e("TIAOSHI###", "福袋测试STEP_222"); AblViewUtil.mySleep(2); - //直播间的人数判断,不满足条件直接滑走 - String minnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMinnum(); - int conminnum = Integer.valueOf(minnum); - String maxnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMaxnum(); - int conmaxnum = Integer.valueOf(maxnum); - - //获取直播间人数 -// int personNum = getPersonNum(); -// AblViewUtil.mySleep(1); -// if(personNum<=conminnum||personNum>=conmaxnum){ -// huodong(); -// Log.e("TIAOSHI###", personNum+"直播间人数没有达到条件"+ChangLiang.phonetype); -// return; -// } - - //监听一次有没有控件 -// int jiedianhuoqutwo = jiedianhuoqutwo(); -// Log.e("TIAOSHI###", "获得的控件个数==" + jiedianhuoqutwo); -// if(jiedianhuoqutwo>=3){ -// huodong(); -// Log.e("TIAOSHI###", "控件数是>=3,肯定包含优惠卷和充能,滑走"+ChangLiang.phonetype); -// } -// if (jiedianhuoqutwo != 0) { -// AblStepHandler.sendMsg(AblSteps.STEP_223); -// } else { -// Log.e("TIAOSHI###", "没有监听到三个控件"); -// huodong(); -// } - - AblStepHandler.sendMsg(AblSteps.STEP_223); - break; - case AblSteps.STEP_223: - Log.e("TIAOSHI###", "福袋测试STEP_223"); - AblViewUtil.mySleep(2); if (ifControlView()) { AblViewUtil.mySleep(2); kongjiandingweitwo(); - boolean shifouyoufudai = shifouyoufudai(); - Log.e("TIAOSHI###", "是否有福袋控件" + shifouyoufudai); - if (!shifouyoufudai) { - Log.e("TIAOSHI###", "页面布局发生变化,此位置上没有福袋控件"); - huodong(); + if (!ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchthree()) { + boolean shifouyoufudai = shifouyoufudai(); + Log.e("TIAOSHI###", "是否有福袋控件" + shifouyoufudai); + if (!shifouyoufudai) { + Log.e("TIAOSHI###", "页面布局发生变化,此位置上没有福袋控件"); + huodong(); + } } + } else { Log.e("TIAOSHI###", "页面上没有控件,滑走"); huodong(); @@ -108,7 +94,7 @@ public class TestAblStep31 extends HongbaoBase { case AblSteps.STEP_224: //直播间点赞 Boolean switchtwo = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchtwo(); - if(switchtwo) { + if (switchtwo) { zhibodianzan(50); } AblStepHandler.sendMsg(AblSteps.STEP_225); @@ -116,52 +102,10 @@ public class TestAblStep31 extends HongbaoBase { case AblSteps.STEP_225: AblViewUtil.mySleep(5); Boolean switchone = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchone(); - if(switchone) { + if (switchone) { String conment = getConment(); fasongpingluntwo(conment); } - AblStepHandler.sendMsg(AblSteps.STEP_226); - break; - case AblSteps.STEP_226: - AblViewUtil.mySleep(5); - Boolean switchthree = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchthree(); - if (switchthree) { - int num = jiedianhuoqutwo(); - if (num == 2) { - //做标记 - kongjiandingweitwo(); - //做时间判断,逻辑是福袋的时间比红包时间多60秒 - int hongbaoweizhi = hongbaoweizhi(); - int fudaiposition = fudaiposition(); - String hongbaotime = times.get(hongbaoweizhi); - String[] buff = hongbaotime.split(":"); - int num1 = Integer.valueOf(buff[0]); - int num2 = Integer.valueOf(buff[1]); - int num3 = num1 * 60 + num2; - Log.e("TIAOSHI###", "获得红包倒计时的秒数是----" + num3); - String fudaitime = times.get(fudaiposition); - String[] bufff = fudaitime.split(":"); - int num11 = Integer.valueOf(bufff[0]); - int num22 = Integer.valueOf(bufff[1]); - int num33 = num11 * 60 + num22; - Log.e("TIAOSHI###", "获得福袋倒计时的秒数是----" + num33); - if(num33-num3>60){ - Log.e("TIAOSHI###", "获得红包==倒计时的秒数是----" + num3); - //参与抢福袋 - int childCount = canyuqiangfeidai().getChildCount(); - if (childCount >= hongbaoweizhi) { - AccessibilityNodeInfo child = canyuqiangfeidai().getChild(hongbaoweizhi); - clickcommonthree(child, "点击红包"); - // AblViewUtil.mySleep(3); - //监听时间 - //这里需要再一次获取时间,确保时间同步,还没做 - homgbaodaojishi(num3-2); - } else { - Log.e("TIAOSHI###", "页面布局发生变化,次位置上没有控件"); - } - } - } - } break; default: } @@ -187,11 +131,79 @@ public class TestAblStep31 extends HongbaoBase { * 向上滑动 */ private void huodong() { - AblService.getInstance().randomSwipetwo(); + if (ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchfive()) { + AblService.getInstance().randomSwipetwo(); AblViewUtil.mySleep(3); AblStepHandler.sendMsg(AblSteps.STEP_222); + } + if (ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchsix()) { + if (slidingDir) { + // AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "滑——向上滑前直播间的位置" + livePosition); + if (Integer.valueOf(liveSuiJiBean.getLivenum()) > 1) { + liveUp(); + } + String livenum = liveSuiJiBean.getLivenum(); + int livenumd = Integer.valueOf(livenum); + Log.e("TIAOSHI###", livenumd + "个直播间"); + if (livePosition == livenumd - 1) { + slidingDir = false; + } + Log.e("TIAOSHI###", "slidingDir==" + slidingDir); + } else { + // AblService.getInstance().randomSwipethree(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "滑——向下滑前直播间的位置" + livePosition); + if (Integer.valueOf(liveSuiJiBean.getLivenum()) > 1) { + liveDown(); + } + if (livePosition == 0) { + slidingDir = true; + } + Log.e("TIAOSHI###", "slidingDir==" + slidingDir); + } + Log.e("TIAOSHI###", "滑——滑动后直播间的位置" + livePosition); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + } + /** + * 直播间上滑 + */ + public void liveUp() { + AccessibilityNodeInfo getdaohang = getdaohang(); + if (getdaohang != null) { + boolean b = getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + Log.e("TIAOSHI###", "测试向上滑动" + b); + if (b) { + livePosition = livePosition + 1; + againStart("1"); + } else { + againStart("0"); + } + } + } + + /** + * 直播间下滑 + */ + public void liveDown() { + AccessibilityNodeInfo getdaohang = getdaohang(); + if (getdaohang != null) { + boolean b = getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + Log.e("TIAOSHI###", "测试向下滑动" + b); + if (b) { + livePosition = livePosition - 1; + againStart("1"); + } else { + againStart("0"); + } + } + } + + /** * 控件定位 */ @@ -225,12 +237,18 @@ public class TestAblStep31 extends HongbaoBase { } else if (pagetype == 2) { jiluBeans.add("福袋"); boolean enterfensituan = enterfensituan(); - if (enterfensituan) { + if (enterfensituan && !ChangLiang.fudaineirong.equals("助力主播心愿") && !ChangLiang.fudaineirong.equals("分享直播间")) { AblViewUtil.mySleep(1); //开始计时间 taskdaojishi(num3 + 10); getdodsfsdfdsuyin(); } else { + if (ChangLiang.fudaineirong.equals("助力主播心愿")) { + Log.e("TIAOSHI###", "含有助力主播心愿----"); + } + if (ChangLiang.fudaineirong.equals("分享直播间")) { + Log.e("TIAOSHI###", "含有分享直播间----"); + } Log.e("TIAOSHI###", "不满足抢福袋的条件----"); AblViewUtil.back(); AblViewUtil.mySleep(1); @@ -240,8 +258,22 @@ public class TestAblStep31 extends HongbaoBase { } else if (pagetype == 21) { jiluBeans.add("红包"); AblViewUtil.mySleep(1); - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); +// AblService.getInstance().clickPoint(100, 100, 300); +// AblViewUtil.mySleep(1); + if (!ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchthree()) { + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + if (ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchthree()) { + boolean getdoubi = getdoubi(); + if (getdoubi) { + getNodeInQiangtwo(); + } else { + Log.e("TIAOSHI###", "----抖币数不够条件"); + } + break; + } + } else if (pagetype == 4) { AblViewUtil.mySleep(2); AblService.getInstance().clickPoint(100, 100, 300); @@ -254,6 +286,7 @@ public class TestAblStep31 extends HongbaoBase { } } } + /** * 参与抢福袋 */ @@ -324,7 +357,7 @@ public class TestAblStep31 extends HongbaoBase { * 是否中奖概率 */ boolean winningpro = false; - noqinmidu=true; + noqinmidu = true; /** * 中奖的概率 */ @@ -357,7 +390,7 @@ public class TestAblStep31 extends HongbaoBase { child8.getBoundsInScreen(rect); Log.e("TIAOSHI###", "----9Node:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - if(SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)){ + if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { if (rect.top >= 1351 && rect.bottom <= 1459 && rect.left >= 91 && rect.right <= 273) { if ("android.view.View".equals(child8.getClassName())) { String time = child8.getText().toString(); @@ -421,26 +454,30 @@ public class TestAblStep31 extends HongbaoBase { } } for (int q = 0; q < child8.getChildCount(); q++) { - AccessibilityNodeInfo child9 = child8.getChild( q); + AccessibilityNodeInfo child9 = child8.getChild(q); Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); nodeZuobiao(child9); if ("android.view.View".equals(child9.getClassName())) { String text = child9.getText().toString(); if (!TextUtils.isEmpty(text)) { if ("提升亲密度".equals(text)) { - noqinmidu=false; + noqinmidu = false; break; } if ("加入粉丝团(1抖币)".equals(text)) { - noqinmidu=true; + noqinmidu = true; break; } if ("去发表评论".equals(text)) { - noqinmidu=true; + noqinmidu = true; break; } if ("助力主播心愿".equals(text)) { - noqinmidu=false; + noqinmidu = false; + break; + } + if ("点亮粉丝团(1抖币)".equals(text)) { + noqinmidu = false; break; } } @@ -462,17 +499,17 @@ public class TestAblStep31 extends HongbaoBase { int winningratevalue = Integer.valueOf(winningrate); if (baifenshu >= winningratevalue) { winningpro = true; - }else { - Log.e("TIAOSHI###", "抢福袋的抢种概率<=参数值:"+winningratevalue); + } else { + Log.e("TIAOSHI###", "抢福袋的抢种概率<=参数值:" + winningratevalue); } // if(!noqinmidu){ // Log.e("TIAOSHI###", "点开福袋后含有提升亲密度和加团1抖币"); // noqinmidu=false; // } - Log.e("TIAOSHI###", "timeconditions=="+timeconditions); - Log.e("TIAOSHI###", "winningpro=="+winningpro); - Log.e("TIAOSHI###", "noqinmidu=="+noqinmidu); - if (timeconditions && winningpro&&noqinmidu) { + Log.e("TIAOSHI###", "timeconditions==" + timeconditions); + Log.e("TIAOSHI###", "winningpro==" + winningpro); + Log.e("TIAOSHI###", "noqinmidu==" + noqinmidu); + if (timeconditions && winningpro && noqinmidu) { conditions = true; } return conditions; @@ -490,7 +527,7 @@ public class TestAblStep31 extends HongbaoBase { int minute = Integer.valueOf(liveSuiJiBean.getMinute()) * 60; int minutetwo = Integer.valueOf(liveSuiJiBean.getMinutetwo()) * 60; if (substring <= minute && substring >= minutetwo) { - Log.e("TIAOSHI###", "倒计时在设置的参数范围内=="+minutetwo+"->"+minute); + Log.e("TIAOSHI###", "倒计时在设置的参数范围内==" + minutetwo + "->" + minute); return true; } else { Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走" + "==" + minute + "=====" + minutetwo); @@ -502,7 +539,7 @@ public class TestAblStep31 extends HongbaoBase { AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); for (int y = 0; y < child.getChildCount(); y++) { AccessibilityNodeInfo child1 = child.getChild(y); // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); @@ -523,12 +560,12 @@ public class TestAblStep31 extends HongbaoBase { // Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText() + ":" + child6.getContentDescription()); for (int t = 0; t < child6.getChildCount(); t++) { AccessibilityNodeInfo child7 = child6.getChild(t); - // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); + // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); for (int u = 0; u < child7.getChildCount(); u++) { AccessibilityNodeInfo child8 = child7.getChild(u); - // Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); + // Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); for (int q = 0; q < child8.getChildCount(); q++) { - AccessibilityNodeInfo child9 = child8.getChild( q); + AccessibilityNodeInfo child9 = child8.getChild(q); Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); nodeZuobiao(child9); if ("android.view.View".equals(child9.getClassName())) { @@ -596,7 +633,7 @@ public class TestAblStep31 extends HongbaoBase { public void accept(Long aLong) throws Exception { long b = a - aLong; Log.e("TIAOSHI###", b + ""); - if(b==30){ + if (b == 30) { //打开福袋 if (ifControlView()) { openFudai(); @@ -619,7 +656,7 @@ public class TestAblStep31 extends HongbaoBase { .subscribe(); } - private void openFudai(){ + private void openFudai() { for (int j = 0; j < accessibilityNodeInfos.size(); j++) { AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); if (child2 != null) { @@ -632,7 +669,7 @@ public class TestAblStep31 extends HongbaoBase { AblViewUtil.mySleep(2); int pagetype = pagetype(); if (pagetype == 1) { - Log.e("TIAOSHI###","福袋测试1"); + Log.e("TIAOSHI###", "福袋测试1"); AblViewUtil.mySleep(1); AblService.getInstance().clickPoint(540, 1663, 300); AblViewUtil.mySleep(1); @@ -679,45 +716,6 @@ public class TestAblStep31 extends HongbaoBase { } - /** - * 参与抢红包的结束计时 - * - * @param a - */ - private void homgbaodaojishi(final int a) { - //启动计时器 - //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 - Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .doOnNext(new Consumer() { - @Override - public void accept(Long aLong) throws Exception { - long b = a - aLong; - Log.e("TIAOSHI###", b + ""); - } - }) - .doOnComplete(new Action() { - @Override - public void run() throws Exception { - //抢红包 - // qianghongbaoo(); - AblService.getInstance().clickPoint(360, 714, 300); - AblService.getInstance().clickPoint(360, 714, 300); - AblService.getInstance().clickPoint(360, 714, 300); - AblService.getInstance().clickPoint(360, 714, 300); - AblService.getInstance().clickPoint(360, 714, 300); - AblService.getInstance().clickPoint(360, 714, 300); - AblViewUtil.mySleep(5); - //关闭红包 - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); - - } - }) - .subscribe(); - } - - /** * 获得直播间人数 */ @@ -726,17 +724,17 @@ public class TestAblStep31 extends HongbaoBase { AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); for (int y = 0; y < child.getChildCount(); y++) { AccessibilityNodeInfo child1 = child.getChild(y); - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); for (int j = 0; j < child1.getChildCount(); j++) { AccessibilityNodeInfo child2 = child1.getChild(j); // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); // nodeZuobiao(child2); Rect rect = new Rect(); child2.getBoundsInScreen(rect); - // Log.e("TIAOSHI###", "----threeNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + // Log.e("TIAOSHI###", "----threeNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); //红米7A(560,77),(632,137) 畅想20(560,70),(632,130) 红米9(860,129),(959,212) if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { if (rect.left > 360 && rect.top >= 77 && rect.bottom <= 137) { @@ -793,6 +791,215 @@ public class TestAblStep31 extends HongbaoBase { } return personnum; } + + private void enfirstLive() { +// livePosition = 0; +// slidingDir = true; + AblViewUtil.mySleep(2); + boolean b12 = enterLive(); + if (b12) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b2 = enterLivetwo(); + if (b2) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b3 = enterLivetwo(); + if (b3) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + runLog("进入第一个直播间失败"); + } + } + } + } + + public boolean getdoubi() { + boolean flag = true; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); +// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); +// nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); +// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); +// nodeZuobiao(child1); + if (child1 != null) { + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + //(547,1437),(613,1510) + if (rect.top >= 1437 && rect.bottom <= 1510) { + if ("android.widget.TextView".equals(child1.getClassName())) { + String doubigeshu = child1.getText().toString(); + Log.e("TIAOSHI###", "----获取的抖币数:" + doubigeshu); + int doubi = Integer.valueOf(doubigeshu); + int doubic = Integer.valueOf(10); + Log.e("TIAOSHI###", "----获取的条件抖币数:" + doubic); + if (doubi > doubic) { + flag = true; + } else { + flag = false; + } + break; + } + } + } + } + } + return flag; + } + + /** + * 获取抢的控件 + * ----oneNode:android.widget.TextView:200:null + * ----显示节点的坐标:(521,1342),(620,1416) + *

+ * ----oneNode:android.widget.TextView:520:null + * ----显示节点的坐标:(565,1398),(624,1443) + */ + public void getNodeInQiangtwo() { + AccessibilityNodeInfo timechild = null; + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + nodeZuobiao(child1); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if (rect.top >= 1192 && rect.bottom <= 1286) { + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + timechild = child1; + flag = true; + } else { + // Log.e("TIAOSHI###", "没有控件"); + } + } + } + if (flag) { + Log.e("TIAOSHI###", "红包有时间"); + qiangHongbao(timechild); + } else { + Log.e("TIAOSHI###", "红包没有时间"); + // (462,1192),(618,1286) + AblService.getInstance().clickPoint(540, 1239, 300); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_222); + AblViewUtil.mySleep(1); + } + + } + + private void qiangHongbao(AccessibilityNodeInfo child1) { + String s = child1.getText().toString(); + int daojishimiao = daojishimiao(s); + String qiehuantime = "60"; + int qihuanshijian = Integer.valueOf(qiehuantime); + if (daojishimiao < qihuanshijian) { + Log.e("TIAOSHI###", "时间在" + qihuanshijian + "秒内"); + //等待抢红包 + hongbaojishi(daojishimiao - 2); + } else { + //更新时间 + Log.e("TIAOSHI###", "更新时间"); + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 21) { + Log.e("TIAOSHI###", "有倒计时红包弹框,点击返回"); + AblViewUtil.back(); + } else { + Log.e("TIAOSHI###", "有红包倒计时,没有有红包弹框,不点击返回"); + } + //AblViewUtil.back(); + AblViewUtil.mySleep(1); + huodong(); + } + } + + /** + * 停任务的倒计时 + * + * @param a + */ + public void hongbaojishi(final int a) { + + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + AblStepHandler.getInstance().setStop(false); + Log.e("TIAOSHI###", "开始点击抢红包"); + zhibodianzanb(64); + AblViewUtil.mySleep(3); + int pagetype = pagetype(); + if (pagetype == 21) { + Log.e("TIAOSHI###", "有红包弹框,点击关闭"); + // AblViewUtil.back(); + AblService.getInstance().clickPoint(540, 1663, 300); + // (100,563),(980,1746) + } else { + Log.e("TIAOSHI###", "没有有红包弹框,不点击返回"); + } + AblViewUtil.mySleep(1); + int pagenum = pagetype(); + if (pagenum != 21) { + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + Log.e("TIAOSHI###", "有红包弹框,再次点击关闭"); + AblService.getInstance().clickPoint(540, 1663, 300); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + AblViewUtil.mySleep(1); + } + }) + .subscribe(); + } + + + /** + * 计算红包的倒计时 + * + * @param str 红包控件的值 + * @return + */ + private int daojishimiao(String str) { + int daojishitiem = 0; + if (str.contains("可抢")) { + String[] str1 = str.split("秒"); + String str2 = str1[0]; + String[] str3 = str2.split("分"); + String str4 = str3[0]; + daojishitiem = Integer.valueOf(str4) * 60 + Integer.valueOf(str3[1]); + } else { + daojishitiem = Integer.valueOf(str); + } + Log.e("TIAOSHI###", "倒计时" + daojishitiem); + return daojishitiem; + } + + } diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java new file mode 100644 index 0000000..063b36e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java @@ -0,0 +1,923 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.entity.LiveSuiJiBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Flowable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +/** + * @author keriezhang + * @description 随机直播间抢福袋 + * @return + */ +public class TestAblStep31bei extends HongbaoBase { + private List jiluBeans; + private List hongbaos; + private List times; + private int num3; + private boolean noqinmidu=true; + + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_221: + AblViewUtil.startApplication(); + jiluBeans = new ArrayList<>(); + AblViewUtil.mySleep(3); + allowed(); + AblViewUtil.mySleep(5); + if(ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchfive()) { + //点击直播1080 + AblService.getInstance().clickPoint(90, 163, 300); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + if(ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchsix()) { + // + enfirstLive(); + } + + break; + case AblSteps.STEP_222: + Log.e("TIAOSHI###", "福袋测试STEP_222"); + AblViewUtil.mySleep(2); + //直播间的人数判断,不满足条件直接滑走 + String minnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMinnum(); + int conminnum = Integer.valueOf(minnum); + String maxnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMaxnum(); + int conmaxnum = Integer.valueOf(maxnum); + //获取直播间人数 +// int personNum = getPersonNum(); +// AblViewUtil.mySleep(1); +// if(personNum<=conminnum||personNum>=conmaxnum){ +// huodong(); +// Log.e("TIAOSHI###", personNum+"直播间人数没有达到条件"+ChangLiang.phonetype); +// return; +// } + AblStepHandler.sendMsg(AblSteps.STEP_223); + break; + case AblSteps.STEP_223: + Log.e("TIAOSHI###", "福袋测试STEP_223"); + AblViewUtil.mySleep(2); + if (ifControlView()) { + AblViewUtil.mySleep(2); + kongjiandingweitwo(); + boolean shifouyoufudai = shifouyoufudai(); + Log.e("TIAOSHI###", "是否有福袋控件" + shifouyoufudai); + if (!shifouyoufudai) { + Log.e("TIAOSHI###", "页面布局发生变化,此位置上没有福袋控件"); + huodong(); + } + } else { + Log.e("TIAOSHI###", "页面上没有控件,滑走"); + huodong(); + } + break; + case AblSteps.STEP_224: + //直播间点赞 + Boolean switchtwo = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchtwo(); + if(switchtwo) { + zhibodianzan(50); + } + AblStepHandler.sendMsg(AblSteps.STEP_225); + break; + case AblSteps.STEP_225: + AblViewUtil.mySleep(5); + Boolean switchone = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchone(); + if(switchone) { + String conment = getConment(); + fasongpingluntwo(conment); + } + AblStepHandler.sendMsg(AblSteps.STEP_226); + break; + default: + } + } + + + /** + * 定位结果中是否有红包 + */ + public boolean shifouyoufudai() { + boolean flag = false; + for (int i = 0; i < jiluBeans.size(); i++) { + String s = jiluBeans.get(i); + if ("福袋".equals(s)) { + flag = true; + break; + } + } + return flag; + } + + /** + * 向上滑动 + */ + private void huodong() { + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + + /** + * 控件定位 + */ + public void kongjiandingweitwo() { + jiluBeans.clear(); + for (int j = 0; j < accessibilityNodeInfos.size(); j++) { + AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); + if (child2 != null) { + clickNodeInfo(child2, ""); + Log.e("TIAOSHI###", "点击控件" + j); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(540, 1663, 300); + AblViewUtil.mySleep(1); + int pagetype1 = pagetype(); + if (pagetype1 == 1) { + Log.e("TIAOSHI###", "第一次点击没有关掉"); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "再次点击关闭按钮"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "优惠卷弹框关闭了"); + } + } else if (pagetype == 2) { + jiluBeans.add("福袋"); + boolean enterfensituan = enterfensituan(); + if (enterfensituan&&!ChangLiang.fudaineirong.equals("助力主播心愿")) { + AblViewUtil.mySleep(1); + //开始计时间 + taskdaojishi(num3 + 10); + getdodsfsdfdsuyin(); + } else { + Log.e("TIAOSHI###", "不满足抢福袋的条件----"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + huodong(); + } + break; + } else if (pagetype == 21) { + jiluBeans.add("红包"); + AblViewUtil.mySleep(1); +// AblService.getInstance().clickPoint(100, 100, 300); +// AblViewUtil.mySleep(1); + + boolean getdoubi = getdoubi(); + if (getdoubi) { + getNodeInQiangtwo(); + } else { + Log.e("TIAOSHI###", "----抖币数不够条件"); + } + } else if (pagetype == 4) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + jiluBeans.add("红包"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + } + } + /** + * 参与抢福袋 + */ + private AccessibilityNodeInfo canyuqiangfeidai() { + AccessibilityNodeInfo kongjian = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { + kongjian = child1; + } + } + } + return kongjian; + } + + /** + * 获得红包的位置 + * + * @return + */ + private int hongbaoweizhi() { + int position = 0; + for (int i = 0; i < hongbaos.size(); i++) { + String s = hongbaos.get(i); + if ("红包".equals(s)) { + position = i; + break; + } + } + return position; + } + + /** + * 获得福袋的位置 + * + * @return + */ + private int fudaiposition() { + int position = 0; + for (int i = 0; i < hongbaos.size(); i++) { + String s = hongbaos.get(i); + if ("福袋".equals(s)) { + position = i; + break; + } + } + return position; + } + + /** + * 获取参与抢福袋的条件值 + * + * @return + */ + private boolean enterfensituan() { + /** + * 条件 + */ + boolean conditions = false; + /** + * 是否满足时间条件 + */ + boolean timeconditions = false; + /** + * 是否中奖概率 + */ + boolean winningpro = false; + noqinmidu=true; + /** + * 中奖的概率 + */ + int baifenshu = 0; + double fudainum = 0; + double renshunum = 1; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + for (int p = 0; p < child5.getChildCount(); p++) { + AccessibilityNodeInfo child6 = child5.getChild(p); + for (int t = 0; t < child6.getChildCount(); t++) { + AccessibilityNodeInfo child7 = child6.getChild(t); + // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); + for (int u = 0; u < child7.getChildCount(); u++) { + AccessibilityNodeInfo child8 = child7.getChild(u); + Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); + nodeZuobiao(child8); + Rect rect = new Rect(); + child8.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----9Node:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + + if(SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)){ + if (rect.top >= 1351 && rect.bottom <= 1459 && rect.left >= 91 && rect.right <= 273) { + if ("android.view.View".equals(child8.getClassName())) { + String time = child8.getText().toString(); + Log.e("TIAOSHI###", "----获取的时间" + time); + if (!TextUtils.isEmpty(time)) { + String[] buff = time.split(":"); + int num1 = Integer.valueOf(buff[0]); + int num2 = Integer.valueOf(buff[1]); + num3 = num1 * 60 + num2; + Log.e("TIAOSHI###", "获得倒计时的秒数是----" + num3); + timeconditions = isfuhe(num3); + if (!isfuhe(num3)) { + Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走"); + } + } + } + } + if (rect.top >= 1354 && rect.bottom <= 1442 && rect.left >= 540) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + if (!TextUtils.isEmpty(text)) { + // Log.e("TIAOSHI###", "----获取的内容:" + text); + if (text.contains("总") || text.contains("抖币")) { + } else { + Log.e("TIAOSHI###", "----获取的总抖币数量:" + text); + } + } + } + } + if (rect.top >= 1453 && rect.bottom <= 1497 && rect.left >= 540 && rect.right <= 784) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + String[] all = child8.getText().toString().split("个"); + fudainum = Integer.valueOf(all[0]); + if (!TextUtils.isEmpty(text)) { + Log.e("TIAOSHI###", "----获取的福袋个数:" + all[0]); + } + } + } + if (rect.top >= 1453 && rect.bottom <= 1497 && rect.left >= 787 && rect.right <= 1000) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + String[] all = child8.getText().toString().split("人"); + renshunum = Integer.valueOf(all[0]); + if (!TextUtils.isEmpty(text)) { + Log.e("TIAOSHI###", "----获取的参与人数:" + all[0]); + } + } + } + //获得发表的评论内容(60,1350),(288,1388) + if (rect.top >= 1758 && rect.bottom <= 1816 && rect.left >= 91 && rect.right <= 872) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + if (!TextUtils.isEmpty(text)) { + String[] buff = text.split(":"); + String sdfsd = buff[buff.length - 1]; + Log.e("TIAOSHI###", "获取的评论内容----:" + sdfsd); + ChangLiang.fudaineirong = sdfsd; + } + } + } + } + for (int q = 0; q < child8.getChildCount(); q++) { + AccessibilityNodeInfo child9 = child8.getChild( q); + Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); + nodeZuobiao(child9); + if ("android.view.View".equals(child9.getClassName())) { + String text = child9.getText().toString(); + if (!TextUtils.isEmpty(text)) { + if ("提升亲密度".equals(text)) { + noqinmidu=false; + break; + } + if ("加入粉丝团(1抖币)".equals(text)) { + noqinmidu=true; + break; + } + if ("去发表评论".equals(text)) { + noqinmidu=true; + break; + } + if ("助力主播心愿".equals(text)) { + noqinmidu=false; + break; + } + } + } + } + } + } + } + } + } + } + } + } + } + Double baifenshuu = (int) fudainum / renshunum * 100; + baifenshu = baifenshuu.intValue(); + Log.e("TIAOSHI###", "抢福袋的抢种概率==" + baifenshu); + String winningrate = ProfileSpUtils.getInstance().getLiveSuiJiBean().getWinningrate(); + int winningratevalue = Integer.valueOf(winningrate); + if (baifenshu >= winningratevalue) { + winningpro = true; + }else { + Log.e("TIAOSHI###", "抢福袋的抢种概率<=参数值:"+winningratevalue); + } +// if(!noqinmidu){ +// Log.e("TIAOSHI###", "点开福袋后含有提升亲密度和加团1抖币"); +// noqinmidu=false; +// } + Log.e("TIAOSHI###", "timeconditions=="+timeconditions); + Log.e("TIAOSHI###", "winningpro=="+winningpro); + Log.e("TIAOSHI###", "noqinmidu=="+noqinmidu); + if (timeconditions && winningpro&&noqinmidu) { + conditions = true; + } + return conditions; + } + + + /** + * 判断福袋的时间是否在设置范围内 + * + * @param substring + * @return + */ + public boolean isfuhe(int substring) { + LiveSuiJiBean liveSuiJiBean = ProfileSpUtils.getInstance().getLiveSuiJiBean(); + int minute = Integer.valueOf(liveSuiJiBean.getMinute()) * 60; + int minutetwo = Integer.valueOf(liveSuiJiBean.getMinutetwo()) * 60; + if (substring <= minute && substring >= minutetwo) { + Log.e("TIAOSHI###", "倒计时在设置的参数范围内=="+minutetwo+"->"+minute); + return true; + } else { + Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走" + "==" + minute + "=====" + minutetwo); + return false; + } + } + + private void getdodsfsdfdsuyin() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); + // Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + // Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText() + ":" + child5.getContentDescription()); + for (int p = 0; p < child5.getChildCount(); p++) { + AccessibilityNodeInfo child6 = child5.getChild(p); + // Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText() + ":" + child6.getContentDescription()); + for (int t = 0; t < child6.getChildCount(); t++) { + AccessibilityNodeInfo child7 = child6.getChild(t); + // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); + for (int u = 0; u < child7.getChildCount(); u++) { + AccessibilityNodeInfo child8 = child7.getChild(u); + // Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); + for (int q = 0; q < child8.getChildCount(); q++) { + AccessibilityNodeInfo child9 = child8.getChild( q); + Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); + nodeZuobiao(child9); + if ("android.view.View".equals(child9.getClassName())) { + String text = child9.getText().toString(); + if (!TextUtils.isEmpty(text)) { + if ("加入粉丝团(1抖币)".equals(text)) { + AblViewUtil.mySleep(2); + //点击加入粉丝团 + clickcommonthree(child9, "了加入粉丝团"); + AblViewUtil.mySleep(2); + closedzfDialog(AblService.getInstance()); + AblViewUtil.mySleep(3); + clickcommonthree(child9, "去发表评论"); + AblViewUtil.mySleep(2); + //去发表评论 + //直播间发送评论 + fasongpinglun(ChangLiang.fudaineirong); + break; + } else if ("去发表评论".equals(text)) { + AblViewUtil.mySleep(2); + clickcommonthree(child9, "去发表评论"); + AblViewUtil.mySleep(2); + //去发表评论 + //直播间发送评论 + fasongpinglun(ChangLiang.fudaineirong); + break; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + private void fasongpinglun(String conment) { + //直播间话术 + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(1); + AccessibilityNodeInfo geouyintdd = geouyintdd(); + AblService.getInstance().clickcommontwo(geouyintdd, "点击发送评论"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_224); + + } + + /** + * 参与抢福袋的结束计时 + * + * @param a + */ + public void taskdaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + if(b==30){ + //打开福袋 + if (ifControlView()) { + openFudai(); + } + } + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + //关闭结果弹框 + + AblService.getInstance().clickPoint(100, 100, 300); + // closedjieguo(); + //继续抢福袋 + AblStepHandler.sendMsg(AblSteps.STEP_222); + + } + }) + .subscribe(); + } + + private void openFudai(){ + for (int j = 0; j < accessibilityNodeInfos.size(); j++) { + AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); + if (child2 != null) { + clickNodeInfo(child2, ""); + Log.e("TIAOSHI###", "点击控件" + j); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + Log.e("TIAOSHI###","福袋测试1"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(540, 1663, 300); + AblViewUtil.mySleep(1); + int pagetype1 = pagetype(); + if (pagetype1 == 1) { + Log.e("TIAOSHI###", "第一次点击没有关掉"); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "再次点击关闭按钮"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "优惠卷弹框关闭了"); + } + } else if (pagetype == 2) { + break; + } else if (pagetype == 21) { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + + } else if (pagetype == 4) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮"); + } + } + + + + /** + * 获得直播间人数 + */ + public int getPersonNum() { + int personnum = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + // Log.e("TIAOSHI###", "----threeNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + //红米7A(560,77),(632,137) 畅想20(560,70),(632,130) 红米9(860,129),(959,212) + if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { + if (rect.left > 360 && rect.top >= 77 && rect.bottom <= 137) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } else if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { + if (rect.left > 540 && rect.top >= 129 && rect.bottom <= 212) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } else { + // 16.5版本(561,69),(633,129) 14.6版本(560,70),(632,130) + if (rect.left > 360 && rect.top >= 68 && rect.bottom <= 130) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } + } + } + } + return personnum; + } + private void enfirstLive(){ +// livePosition = 0; +// slidingDir = true; + AblViewUtil.mySleep(2); + boolean b12 = enterLive(); + if (b12) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b2 = enterLivetwo(); + if (b2) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b3 = enterLivetwo(); + if (b3) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + runLog("进入第一个直播间失败"); + } + } + } + } + + public boolean getdoubi() { + boolean flag = true; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); + if (child1 != null) { + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + //(547,1437),(613,1510) + if (rect.top >= 1437 && rect.bottom <= 1510) { + if ("android.widget.TextView".equals(child1.getClassName())) { + String doubigeshu = child1.getText().toString(); + Log.e("TIAOSHI###", "----获取的抖币数:" + doubigeshu); + int doubi = Integer.valueOf(doubigeshu); + int doubic = Integer.valueOf(10); + Log.e("TIAOSHI###", "----获取的条件抖币数:" + doubic); + if (doubi > doubic) { + flag = true; + } else { + flag = false; + } + break; + } + } + } + } + } + return flag; + } + /** + * 获取抢的控件 + * ----oneNode:android.widget.TextView:200:null + * ----显示节点的坐标:(521,1342),(620,1416) + *

+ * ----oneNode:android.widget.TextView:520:null + * ----显示节点的坐标:(565,1398),(624,1443) + */ + public void getNodeInQiangtwo() { + AccessibilityNodeInfo timechild = null; + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + nodeZuobiao(child1); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if (rect.top >= 1192 && rect.bottom <= 1286) { + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + timechild = child1; + flag = true; + } else { + Log.e("TIAOSHI###", "没有控件"); + } + } + } + if (flag) { + Log.e("TIAOSHI###", "红包有时间"); + qiangHongbao(timechild); + } else { + Log.e("TIAOSHI###", "红包没有时间"); + // (462,1192),(618,1286) + AblService.getInstance().clickPoint(540, 1239, 300); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_254); + AblViewUtil.mySleep(1); + } + + } + + private void qiangHongbao(AccessibilityNodeInfo child1) { + String s = child1.getText().toString(); + int daojishimiao = daojishimiao(s); + String qiehuantime = "60"; + int qihuanshijian = Integer.valueOf(qiehuantime); + if (daojishimiao < qihuanshijian) { + Log.e("TIAOSHI###", "时间在" + qihuanshijian + "秒内"); + //等待抢红包 + hongbaojishi(daojishimiao - 2); + } else { + //更新时间 + Log.e("TIAOSHI###", "更新时间"); + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 21 ) { + Log.e("TIAOSHI###", "有倒计时红包弹框,点击返回"); + AblViewUtil.back(); + } else { + Log.e("TIAOSHI###", "有红包倒计时,没有有红包弹框,不点击返回"); + } + //AblViewUtil.back(); + AblViewUtil.mySleep(1); + } + } + /** + * 停任务的倒计时 + * + * @param a + */ + public void hongbaojishi(final int a) { + + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + AblStepHandler.getInstance().setStop(false); + Log.e("TIAOSHI###", "开始点击抢红包"); + zhibodianzanb(64); + AblViewUtil.mySleep(3); + int pagetype = pagetype(); + if (pagetype == 21) { + Log.e("TIAOSHI###", "有红包弹框,点击关闭"); + // AblViewUtil.back(); + AblService.getInstance().clickPoint(540, 1663, 300); + // (100,563),(980,1746) + } else { + Log.e("TIAOSHI###", "没有有红包弹框,不点击返回"); + } + AblViewUtil.mySleep(1); + int pagenum = pagetype(); + if (pagenum != 21) { + AblStepHandler.sendMsg(AblSteps.STEP_222); + } else { + Log.e("TIAOSHI###", "有红包弹框,再次点击关闭"); + AblService.getInstance().clickPoint(540, 1663, 300); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + AblViewUtil.mySleep(1); + } + }) + .subscribe(); + } + + + /** + * 计算红包的倒计时 + * + * @param str 红包控件的值 + * @return + */ + private int daojishimiao(String str) { + int daojishitiem = 0; + if (str.contains("可抢")) { + String[] str1 = str.split("秒"); + String str2 = str1[0]; + String[] str3 = str2.split("分"); + String str4 = str3[0]; + daojishitiem = Integer.valueOf(str4) * 60 + Integer.valueOf(str3[1]); + } else { + daojishitiem = Integer.valueOf(str); + } + Log.e("TIAOSHI###", "倒计时" + daojishitiem); + return daojishitiem; + } + + +} + + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java index b6ff025..8021455 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java @@ -342,10 +342,10 @@ public class TestAblStep34 extends HongbaoBase implements RedEnv.RedEnvFunc, Red }); } - private void runLog(String str) { - LiveEventBus.get("some_key").post(str); - Log.e("TIAOSHI###", str); - } +// private void runLog(String str) { +// LiveEventBus.get("some_key").post(str); +// Log.e("TIAOSHI###", str); +// } /** * 记录抖币的数量 ,任务开始执行的时候记录一次,以后每次循环记录一次 ||记录直播的时间 @@ -373,31 +373,31 @@ public class TestAblStep34 extends HongbaoBase implements RedEnv.RedEnvFunc, Red return ifOpen; } - @Override - public boolean enterLive() { - boolean ifEnterOne = true; - //进入推荐页(刷新) - AblViewUtil.mySleep(1); - getNodeInfo("2"); - Log.e("TIAOSHI###", "点击关注"); - AblViewUtil.mySleep(5); - enterOneNodeInfo(); - AblViewUtil.mySleep(4); - AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); - if (nodeInfoS != null) { - ifEnterOne = true; - } - return ifEnterOne; - } +// @Override +// public boolean enterLive() { +// boolean ifEnterOne = true; +// //进入推荐页(刷新) +// AblViewUtil.mySleep(1); +// getNodeInfo("2"); +// Log.e("TIAOSHI###", "点击关注"); +// AblViewUtil.mySleep(5); +// enterOneNodeInfo(); +// AblViewUtil.mySleep(4); +// AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); +// if (nodeInfoS != null) { +// ifEnterOne = true; +// } +// return ifEnterOne; +// } - public boolean enterLivetwo() { - boolean ifEnterOne = false; - AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); - if (nodeInfoS != null) { - ifEnterOne = true; - } - return ifEnterOne; - } +// public boolean enterLivetwo() { +// boolean ifEnterOne = false; +// AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); +// if (nodeInfoS != null) { +// ifEnterOne = true; +// } +// return ifEnterOne; +// } @Override public boolean liveTime() { diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java index c8ef3e3..ae550ce 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java @@ -420,7 +420,7 @@ public class ProfileSpUtils { public LiveSuiJiBean getLiveSuiJiBean() { String userStr = sharedPreferences.getString(KEY_LIVESUIJIBEAN, ""); if (TextUtils.isEmpty(userStr)) { - return new LiveSuiJiBean("50","1000","5","20",false,false,false,false,"1"); + return new LiveSuiJiBean("50","1000","5","20",false,false,false,false,"1",true,false); } return new Gson().fromJson(userStr, LiveSuiJiBean.class); } diff --git a/app/src/main/res/layout/activity_live_sui_ji.xml b/app/src/main/res/layout/activity_live_sui_ji.xml index 999b6c4..410c46a 100644 --- a/app/src/main/res/layout/activity_live_sui_ji.xml +++ b/app/src/main/res/layout/activity_live_sui_ji.xml @@ -103,6 +103,72 @@ android:layout_height="4dp" android:background="@color/txt_color" /> + + + + + + + + + + + + + + + + + + + + + + + + + + +