本站所有的下载内容都包含解压密码,解压密码均为:123456
目的:去掉每次启动的5秒等待

妈的每次测试进入都要等待5秒,等五秒就算了,还要手动点击进入。5秒浪费人生宝贵时间。先把它干掉。

猜测一下好,这个玩意等待需要时间,等待完成,肯定要进入主Activity,获取下这个主要Activity的名字,MainActivity,然后在SplashActivity里面查找一下,发现是在h方法里面,那好说了,我们在他源码启动等待计时器的地方,直接调用这个h方法就行了。h方法签名如下:


    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">h</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.f &amp;&amp; !<span class="hljs-keyword">this</span>.i) {   <span class="hljs-comment">//要想调用h方法,这两个判断条件必须通过</span>
            <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.m != null) {
                <span class="hljs-keyword">this</span>.m.cancel();
            }
            startActivity(<span class="hljs-keyword">new</span> Intent(<span class="hljs-keyword">this</span>, MainActivity.<span class="hljs-keyword">class</span>));
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
            finish();
        }
    }

就是分析发现,g方法是启动定时器的地方,而g被f调用,那么我们直接在f里面调用h就行了,但是h里面会有if判断,让判断为true就行了。

这种方式很简单,但是发现还是会有个”大美女”一闪而过,我特么每次不想看到这个东西。我们来看下这个美女怎么出来的。

通过monitor分析,得到显示图片的ImageView 的id为:

com.amahua.ompimdrt:id/splash_bg

所以找到设置图片的地方就ok了,去SplashActivity里面看看,搜索splash_bg 得到 ,this.c ,然后搜索this.c


<span class="hljs-comment">//根据变量名猜测这玩意就是设置广告的地方,直接把这个方法屏蔽掉。</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">a</span><span class="hljs-params">(<span class="hljs-keyword">long</span> j, List&lt;AdsResponse&gt; <span class="hljs-built_in">list</span>, boolean z)</span> </span>{
        <span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>;
        <span class="hljs-keyword">this</span>.g = <span class="hljs-keyword">true</span>;
        <span class="hljs-keyword">this</span>.h = z;
        <span class="hljs-comment">//从这个命名可以看出,这个项目用了mvp架构,</span>
        <span class="hljs-comment">//那么这个方法,从结构上猜测应该是网络请求之后的回调,</span>
        <span class="hljs-comment">//那么应该属于view的接口方法,那么应该在 SplashPresenter 里面调用。</span>
        <span class="hljs-comment">//根据继承关系查看,这个方法是在 com.mh.movie.core.mvp.a.ba.b 里面声明的</span>
        ((SplashPresenter) <span class="hljs-keyword">this</span>.b).e();
        ((SplashPresenter) <span class="hljs-keyword">this</span>.b).g();
        <span class="hljs-keyword">if</span> (!(<span class="hljs-built_in">list</span> == null || <span class="hljs-built_in">list</span>.isEmpty())) {
            <span class="hljs-keyword">int</span> c = d.c(<span class="hljs-keyword">this</span>, com.mh.movie.core.mvp.ui.b.w);
            <span class="hljs-keyword">int</span> i2 = <span class="hljs-number">0</span>;
            <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.e == null || !((AdsResponse) <span class="hljs-keyword">this</span>.e.get(<span class="hljs-number">0</span>)).getThumbnailUrl().equals(((AdsResponse) <span class="hljs-built_in">list</span>.get(<span class="hljs-number">0</span>)).getThumbnailUrl())) {
                d.a((Context) <span class="hljs-keyword">this</span>, com.mh.movie.core.mvp.ui.b.q, <span class="hljs-keyword">new</span> e().a((Object) <span class="hljs-built_in">list</span>));
                <span class="hljs-keyword">while</span> (i &lt; <span class="hljs-built_in">list</span>.size()) {
                    <span class="hljs-keyword">if</span> (!TextUtils.isEmpty(((AdsResponse) <span class="hljs-built_in">list</span>.get(i)).getThumbnailUrl())) {
                        Glide.with((FragmentActivity) <span class="hljs-keyword">this</span>).load(((AdsResponse) <span class="hljs-built_in">list</span>.get(i)).getThumbnailUrl()).preload();
                    }
                    i++;
                }
            } <span class="hljs-keyword">else</span> {
                i2 = (c + <span class="hljs-number">1</span>) % <span class="hljs-built_in">list</span>.size();
            }
            d.a((Context) <span class="hljs-keyword">this</span>, com.mh.movie.core.mvp.ui.b.w, i2);
            <span class="hljs-keyword">this</span>.d = (AdsResponse) <span class="hljs-built_in">list</span>.get(i2);
            Glide.with((FragmentActivity) <span class="hljs-keyword">this</span>).load(<span class="hljs-keyword">this</span>.d.getThumbnailUrl()).apply(<span class="hljs-keyword">new</span> RequestOptions().placeholder(<span class="hljs-keyword">this</span>.c.getDrawable())).into(<span class="hljs-keyword">this</span>.c);
            com.mh.movie.core.mvp.ui.b.c = d.b(<span class="hljs-keyword">this</span>.r, <span class="hljs-string">"is_first_partner"</span>);
        }
        f();<span class="hljs-comment">//倒计时在这个方法调用的g方法里面。所以如果屏蔽当前方法,那么这个启动主界面的操作必须手动调用</span>
    }

直接在a方法里面打断点,然后运行项目观察调用堆栈


.method <span class="hljs-keyword">public</span> a(JLjava/util/<span class="hljs-keyword">List</span>;Z)V
    .locals <span class="hljs-number">2</span>
    .annotation system Ldalvik/annotation/Signature;
        value = {
            <span class="hljs-string">"(J"</span>,
            <span class="hljs-string">"Ljava/util/List&lt;"</span>,
            <span class="hljs-string">"Lcom/mh/movie/core/mvp/model/entity/response/AdsResponse;"</span>,
            <span class="hljs-string">"&gt;;Z)V"</span>
        }
    .end annotation
<span class="hljs-comment">#只是为了查看调用堆栈,断点打在下面这行就行</span>
    <span class="hljs-keyword">const</span>/<span class="hljs-number">4</span> p1, <span class="hljs-number">0x1</span>

    .line <span class="hljs-number">332</span>
    iput-boolean p1, p0, Lcom/mh/movie/core/mvp/ui/activity/SplashActivity;-&gt;g:Z
    <span class="hljs-comment">##。。。。。 省略无用代码</span>

结果如下:


<span class="hljs-variable">a:332</span>, SplashActivity (<span class="hljs-keyword">com</span>.mh.movie.core.mvp.ui.activity)
# $<span class="hljs-number">1</span> 理论上来说是这个类里面的第一个匿名内部类
<span class="hljs-variable">a:122</span>, SplashPresenter$<span class="hljs-number">1</span> (<span class="hljs-keyword">com</span>.mh.movie.core.mvp.presenter)
<span class="hljs-variable">a:103</span>, SplashPresenter$<span class="hljs-number">1</span> (<span class="hljs-keyword">com</span>.mh.movie.core.mvp.presenter)
<span class="hljs-variable">a:69</span>, <span class="hljs-keyword">b</span> (<span class="hljs-keyword">com</span>.mh.movie.core.mvp.model.<span class="hljs-keyword">a</span>)
##....省略无用堆栈

根据特征码,可以定位到如下方法:


    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">a</span><span class="hljs-params">(LoginRequest loginRequest, <span class="hljs-keyword">boolean</span> z)</span> </span>{
        ((a) <span class="hljs-keyword">this</span>.c).a(loginRequest).compose(a(<span class="hljs-keyword">this</span>.f, <span class="hljs-keyword">this</span>.d, z)).subscribe(<span class="hljs-keyword">new</span> com.mh.movie.core.mvp.model.a.b&lt;LoginResponse&gt;(<span class="hljs-keyword">this</span>.e, <span class="hljs-keyword">new</span> com.google.gson.b.a&lt;BaseResponse&lt;LoginResponse&gt;&gt;() {
        }.getType()) {
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">a</span><span class="hljs-params">(LoginResponse loginResponse)</span> </span>{
                com.mh.movie.core.mvp.ui.b.a(loginResponse.getUserInfo());
                <span class="hljs-keyword">if</span> (loginResponse.getUserInfo().getUserType() == <span class="hljs-number">0</span>) {
                    d.a(SplashPresenter.<span class="hljs-keyword">this</span>.f.getBaseContext(), com.mh.movie.core.mvp.ui.b.i, <span class="hljs-keyword">false</span>);
                }
                com.mh.movie.core.mvp.ui.b.a(SplashPresenter.<span class="hljs-keyword">this</span>.f.getBaseContext(), loginResponse.getUserInfo().getToken());
                com.mh.movie.core.mvp.ui.b.a(SplashPresenter.<span class="hljs-keyword">this</span>.f.getBaseContext(), loginResponse.getUid());
                d.a(SplashPresenter.<span class="hljs-keyword">this</span>.f, com.mh.movie.core.mvp.ui.b.f, XMLUtils.bean2Json(loginResponse.getUserInfo()));
                d.a(SplashPresenter.<span class="hljs-keyword">this</span>.f, com.mh.movie.core.mvp.ui.b.h, loginResponse.getUid());
                com.mh.movie.core.mvp.ui.b.a(loginResponse.getUrlMap());
                com.mh.movie.core.mvp.ui.b.a(<span class="hljs-keyword">true</span>);
                <span class="hljs-comment">//看下面这一行,就是调用显示广告的额地方,理论上来说直接屏蔽这行就行了,其实仔细分析下,第三个参数,从名字上来看说是要不要加载广告</span>
                ((b) SplashPresenter.<span class="hljs-keyword">this</span>.d).a(loginResponse.getUid(), loginResponse.getAdsList(), loginResponse.isBootadSwitch());
                SplashPresenter.<span class="hljs-keyword">this</span>.f();
                SplashPresenter.<span class="hljs-keyword">this</span>.j();
                SplashPresenter.<span class="hljs-keyword">this</span>.i();
                SplashPresenter.<span class="hljs-keyword">this</span>.k();
            }
            <span class="hljs-comment">//省略代码</span>
}

我们尝试修改第三个参数为false。找到loginResponse.isBootadSwitch() 方法,然后让她永远返回false就好了:


.<span class="hljs-function">method <span class="hljs-keyword">public</span> <span class="hljs-title">isBootadSwitch</span><span class="hljs-params">()</span>Z
    .locals 1

    .line 77
    #iget-<span class="hljs-keyword">boolean</span> v0, p0, Lcom/mh/movie/core/mvp/model/entity/response/LoginResponse</span>;-&gt;bootadSwitch:Z
<span class="hljs-keyword">const</span>/<span class="hljs-number">4</span> v0, <span class="hljs-number">0x0</span>
    <span class="hljs-keyword">return</span> v0
.end method

发现没起作用。。。。

然后我们把尝试下,把 a的调用注释点也即是 下面这行代码,注释掉:


((<span class="hljs-tag">b</span>) <span class="hljs-tag">SplashPresenter</span><span class="hljs-class">.this</span><span class="hljs-class">.d</span>)<span class="hljs-class">.a</span>(<span class="hljs-tag">loginResponse</span><span class="hljs-class">.getUid</span>(), <span class="hljs-tag">loginResponse</span><span class="hljs-class">.getAdsList</span>(),

发现还是有闪屏广告,我擦嘞。。。。想一下,那这个地方的广告应该是有缓存,就是在没有网的情况下也可以显示。ok,继续去看 SplashActivity,如果存在这种情况肯定在这个Activity初始化的时候就有了。

继续搜索,this.c


    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">b</span><span class="hljs-params">(@Nullable Bundle bundle)</span> </span>{
        <span class="hljs-keyword">this</span>.k = (TextView) findViewById(R.id.button_enter);
        <span class="hljs-keyword">this</span>.l = (ViewPager) findViewById(R.id.features);
        <span class="hljs-keyword">this</span>.c = (ImageView) findViewById(R.id.splash_bg);
        <span class="hljs-keyword">this</span>.o = (TextView) findViewById(R.id.tv_start);
        <span class="hljs-keyword">this</span>.c.setOnClickListener(<span class="hljs-keyword">this</span>.j);
        com.jakewharton.rxbinding.view.b.a(<span class="hljs-keyword">this</span>.k).a(<span class="hljs-number">1</span>, TimeUnit.SECONDS).a(<span class="hljs-keyword">new</span> aw(<span class="hljs-keyword">this</span>));
        <span class="hljs-comment">//下面的都删了就行</span>
        <span class="hljs-comment">/*int c = d.c(this, com.mh.movie.core.mvp.ui.b.w);
        e eVar = new e();
        String a = d.a(this, com.mh.movie.core.mvp.ui.b.q);
        if (a != null) {
            this.e = (List) eVar.a(a, new com.google.gson.b.a&lt;List&lt;AdsResponse&gt;&gt;() {
            }.getType());
            this.d = (AdsResponse) this.e.get((c + 1) % this.e.size());
            Glide.with((FragmentActivity) this).load(this.d.getThumbnailUrl()).apply(new RequestOptions().placeholder(R.mipmap.launch_screen)).into(this.c);
        }*/</span>
    }

然后把a方法里面的广告加载都删除了:


   <span class="hljs-comment">/*public void a(long j, List&lt;AdsResponse&gt; list, boolean z) {
        int i = 1;
        this.g = true;
        this.h = z;
        ((SplashPresenter) this.b).e();
        ((SplashPresenter) this.b).g();
        if (!(list == null || list.isEmpty())) {
            int c = d.c(this, com.mh.movie.core.mvp.ui.b.w);
            int i2 = 0;
            if (this.e == null || !((AdsResponse) this.e.get(0)).getThumbnailUrl().equals(((AdsResponse) list.get(0)).getThumbnailUrl())) {
                d.a((Context) this, com.mh.movie.core.mvp.ui.b.q, new e().a((Object) list));
                while (i &lt; list.size()) {
                    if (!TextUtils.isEmpty(((AdsResponse) list.get(i)).getThumbnailUrl())) {
                        Glide.with((FragmentActivity) this).load(((AdsResponse) list.get(i)).getThumbnailUrl()).preload();
                    }
                    i++;
                }
            } else {
                i2 = (c + 1) % list.size();
            }
            d.a((Context) this, com.mh.movie.core.mvp.ui.b.w, i2);
            this.d = (AdsResponse) list.get(i2);
            Glide.with((FragmentActivity) this).load(this.d.getThumbnailUrl()).apply(new RequestOptions().placeholder(this.c.getDrawable())).into(this.c);
            com.mh.movie.core.mvp.ui.b.c = d.b(this.r, "is_first_partner");
        }*/</span>
        f();
    }

总结一下去掉闪屏广告:

  1. 去掉从缓存里面加载广告
  2. 去掉请求广告api成功的显示广告
  3. 去掉延迟启动主界面 (MainActivity)

好了,世界从此干净了。。。

最后说一点,每次启动到MainActivity都会问我要不要登陆。我不想看到它。


    <span class="hljs-annotation">@Subscriber</span>(tag = <span class="hljs-string">"sign_up_success"</span>)
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">signupSuccess</span><span class="hljs-params">(String str)</span> </span>{
        <span class="hljs-keyword">this</span>.p = <span class="hljs-string">""</span>;
        <span class="hljs-keyword">if</span> (com.mh.movie.core.mvp.ui.b.H &gt; <span class="hljs-number">0</span>) {
            CustomToast.makeTitleText(<span class="hljs-keyword">this</span>.r, <span class="hljs-string">"新手奖励"</span>, String.format(<span class="hljs-string">"恭喜你获得新会员奖励:%s麻花币,快去看看吧!"</span>, <span class="hljs-keyword">new</span> Object[]{Integer.valueOf(com.mh.movie.core.mvp.ui.b.H)})).show();
        }
    }

 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">f</span><span class="hljs-params">()</span> </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.d || com.mh.movie.core.mvp.ui.b.H &lt;= <span class="hljs-number">0</span>) {
        g();
        <span class="hljs-keyword">return</span>;
    }
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.h == <span class="hljs-keyword">null</span>) {
        <span class="hljs-keyword">this</span>.h = <span class="hljs-keyword">new</span> RequestPermissionDialog(<span class="hljs-keyword">this</span>.r, <span class="hljs-number">3</span>, <span class="hljs-number">2</span>);
        <span class="hljs-keyword">this</span>.h.a(<span class="hljs-string">"新手奖励"</span>);
        <span class="hljs-keyword">this</span>.h.b(String.format(<span class="hljs-string">"恭喜你获得新会员奖励:%s麻花币,麻花币可以兑换特权和奖品哦!"</span>, <span class="hljs-keyword">new</span> Object[]{Integer.valueOf(com.mh.movie.core.mvp.ui.b.H)}));
        <span class="hljs-keyword">this</span>.h.a(<span class="hljs-keyword">new</span> RequestPermissionDialog.a() {
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">a</span><span class="hljs-params">()</span> </span>{
                MainActivity.<span class="hljs-keyword">this</span>.h.dismiss();
                MainActivity.<span class="hljs-keyword">this</span>.startActivity(<span class="hljs-keyword">new</span> Intent(MainActivity.<span class="hljs-keyword">this</span>.r, RegistActivity.class));
            }

            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">b</span><span class="hljs-params">()</span> </span>{
                MainActivity.<span class="hljs-keyword">this</span>.h.dismiss();
                MainActivity.<span class="hljs-keyword">this</span>.g();
            }
        });
    }
    <span class="hljs-keyword">this</span>.h.show();
}

把这个方法注释了。就行了。这篇文章是开始,没啥技术含量

 

 

转自52pojie.cn,原文地址:https://www.52pojie.cn/thread-843407-1-1.html
本站所有的下载内容都包含解压密码,解压密码均为:123456

原创文章,转载请注明: 转载自全索引

本文链接地址: 去掉麻花影视闪屏广告

点击量:217