<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>NotionNext BLOG</title>
        <link>https://bigademo.com/</link>
        <description>这是一个由NotionNext生成的站点</description>
        <lastBuildDate>Sun, 10 Sep 2023 04:32:23 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2023, Tony</copyright>
        <item>
            <title><![CDATA[使用Android Things开发简单的智(diǎo)能(sī)台灯]]></title>
            <link>https://bigademo.com/article/fd832531-b432-497e-9742-60b2804e4e8e</link>
            <guid>https://bigademo.com/article/fd832531-b432-497e-9742-60b2804e4e8e</guid>
            <pubDate>Wed, 11 Jul 2018 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-fd832531b432497e974260b2804e4e8e"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-8fa2f781a9774480a65afead7a6a85fd">前几日和朋友说起小米的智能电饭煲，能在回家前把粥煮好，简单的理解就是定时接通电源或远程接通电源开始煮粥，于是本人就想的写一个远程控制电源的台灯，来一个初步实现。先来上一个图。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-43fcaf19288a47458885f75f1fe229fb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:384px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/smartlight.gif" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-8321d0451b4d439f8bc1ae671ca59359">分为软件和硬件两个部分来记录。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ae7c803129b343b588a843a1e76b9d31" data-id="ae7c803129b343b588a843a1e76b9d31"><span><div id="ae7c803129b343b588a843a1e76b9d31" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ae7c803129b343b588a843a1e76b9d31" title="软件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">软件</span></span></h3><div class="notion-text notion-block-f5cf88f4968b45c597ebdbe53a773551">控制端和被控制端都是用的Android来开发的。两个终端使用MQTT协议进行关联的。因为关于MQTT的内容太多，这个就不赘述了。分享一个不错的链接</div><div class="notion-text notion-block-f493271632974a12a571bf4819bf89db"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://www.iteye.com/blogs/subjects/mqtt">MQTT</a></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9fd015fd0d0b4f8b835cc379bcfa6a26"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/mqtt.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-9c93a65ad10d4b6bb690cb9a4fb38f7b">&lt;!-- more --&gt;</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-c7c09be9ec0140d494d36c1f4776dad4" data-id="c7c09be9ec0140d494d36c1f4776dad4"><span><div id="c7c09be9ec0140d494d36c1f4776dad4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c7c09be9ec0140d494d36c1f4776dad4" title="手机控制端"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">手机控制端</span></span></h4><div class="notion-text notion-block-7778601b72df4387a2b56881d8da8e5c"><b>MainActivity.class</b>
用一个Button发送指令，EventBus通知MQTTService发出开关的指令</div><div class="notion-text notion-block-71477d4fdef54b839851828dafdd90dd"><b>MQTTService.class</b></div><div class="notion-text notion-block-9b918466805a42568cd9ae5aab7c9f8a"><b>ServerMQTT.class</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-a1db2c2af57b412f9e410a725a082957" data-id="a1db2c2af57b412f9e410a725a082957"><span><div id="a1db2c2af57b412f9e410a725a082957" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a1db2c2af57b412f9e410a725a082957" title="树莓派端"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">树莓派端</span></span></h4><div class="notion-text notion-block-17bd5d807d1c4d5690eecff318e01b83"><b>MainActivity.class</b></div><div class="notion-text notion-block-336127e258f44da89cb300dd1df97566"><b>ClientMQTTService.class</b></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-eff56ba8ee534e4aadaba87238dd575d" data-id="eff56ba8ee534e4aadaba87238dd575d"><span><div id="eff56ba8ee534e4aadaba87238dd575d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#eff56ba8ee534e4aadaba87238dd575d" title="硬件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">硬件</span></span></h3><div class="notion-text notion-block-2d4ca528c26f454ab626b20cc46b4bd3">使用的是树莓派3，刷的是Android Things。关于Raspberry怎么刷Android Things网上有很多教程，就略过了。硬件嘛，主要是继电器的接线。整理自己在接线中遇到的问题。按照输入到输出的顺序记录。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-0cd5c45b7239473d9324f59c3792de05" data-id="0cd5c45b7239473d9324f59c3792de05"><span><div id="0cd5c45b7239473d9324f59c3792de05" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0cd5c45b7239473d9324f59c3792de05" title="1. 继电器。"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 继电器。</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-69a42e60c9ac48cd84a97b444249bd2f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://pic.bigademo.com/jidianqi.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-9cda607de85146d2812a31f3ec1355ef" data-id="9cda607de85146d2812a31f3ec1355ef"><span><div id="9cda607de85146d2812a31f3ec1355ef" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9cda607de85146d2812a31f3ec1355ef" title="1.1 输入电源"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.1 输入电源</span></span></h4><div class="notion-text notion-block-a17fcdb47102449d8e5a17316319b1a4"><b>不要使用树莓派提供的电压</b>。如果连接Raspberry的电源只有一个还可以，如果太多，负载太大，容易把Raspberry烧了，毕竟一个Raspberry也有500多，能省则省。</div><div class="notion-text notion-block-f76c9fcf33524681acb67d318cdbb1d5">我买的继电器要求输入电压是5V的，我找了半天，发现手机的充电器提供的就是5V的电压，于是找了一个USB的数据线，将连接手机端的接口拆开，发现有4条线（红白绿黑）。红色和黑色是电线，白绿是数据线。先百度然后用万能表测一下就知道了。红色是正极，黑色是负极。红色接DC+，黑色接DC-。IN的接触点连接Raspberry。当IN接入高电平的时候，会听见继电器有**“咔”**的一声，同时继电器模块上的小灯也会亮起。这就是初中物理的电磁铁吸合的声音。<b>如果你和我一样，以为这样就可以咔的一声的话，就错了！！！还需要将 DC- 与Raspberry的GND连接起来</b>。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-b8875030db8f437c89f3bd76747e3149" data-id="b8875030db8f437c89f3bd76747e3149"><span><div id="b8875030db8f437c89f3bd76747e3149" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b8875030db8f437c89f3bd76747e3149" title="1.2 输出电源"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.2 输出电源</span></span></h4><div class="notion-text notion-block-b0c765477870430a8280c74358314ef8">好了，继电器的输入完了，现在开始说继电器的输出。
Emmmmmmm，不知道怎么说，来个很傻很直白的图。然后插座常开接一个台灯就OK了。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a3d9d1b3c28644ad934c212341ab1506"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/jiexiantu.png" alt="notion image" loading="lazy" decoding="async"/></div></figure></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用gradle使App变种，在一个项目里生成不同的变种]]></title>
            <link>https://bigademo.com/article/46cd8fe7-9d62-4084-b1b7-278e1b0558a0</link>
            <guid>https://bigademo.com/article/46cd8fe7-9d62-4084-b1b7-278e1b0558a0</guid>
            <pubDate>Fri, 26 Oct 2018 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-46cd8fe79d624084b1b7278e1b0558a0"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-450f8628962a4434b481ae399484d507" data-id="450f8628962a4434b481ae399484d507"><span><div id="450f8628962a4434b481ae399484d507" class="notion-header-anchor"></div><a class="notion-hash-link" href="#450f8628962a4434b481ae399484d507" title="前言"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">前言</span></span></h3><div class="notion-text notion-block-c30e356466b640faa41a62a03768a56b">记得之前做过一个电梯的项目，分为监管端和客户端。两端的数据基本相同，仅仅是页面的布局和文字信息不同。当初为了省事在代码里控制了不同角色使用不同的文字和布局，现在想来耦合度很高，很不利于以后的维护。今天在《巧用gradle构建Android应用》的书中看到了，使用gradle来构建不同的变种来解决一个项目不同的体现效果。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-f4c08c200623461eaf3a598e1e5f094d" data-id="f4c08c200623461eaf3a598e1e5f094d"><span><div id="f4c08c200623461eaf3a598e1e5f094d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f4c08c200623461eaf3a598e1e5f094d" title="官方文档的讲解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">官方文档的讲解</span></span></h3><div class="notion-text notion-block-b9d9da9dc500404992950c32a2f92257"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://developer.android.com/studio/build/build-variants?utm_source=android-studio#product-flavors">https://developer.android.com/studio/build/build-variants?utm_source=android-studio#product-flavors</a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-71ecb2bf44f04474a98d36bfea4cd896" data-id="71ecb2bf44f04474a98d36bfea4cd896"><span><div id="71ecb2bf44f04474a98d36bfea4cd896" class="notion-header-anchor"></div><a class="notion-hash-link" href="#71ecb2bf44f04474a98d36bfea4cd896" title="开工"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">开工</span></span></h3><div class="notion-text notion-block-6445ca8cc6844147988510b244d28d04">假如项目需要构建A，B，C这个不同风格的App。A端是监管端，B端是商家端，C端是用户端。<b>使用gradle的DSL里的productFlavors来为三个不同的App进行配置</b></div><div class="notion-text notion-block-d1bdf020049e4b7dbd62c220cb2357ab">或者使用<b>applicationIdSuffix</b>来简化<b>applicationId</b>,这样最后生成的applicationId就是<b>applicationId + applicationIdSuffix</b></div><div class="notion-blank notion-block-052e1e7d354145169604e01d91166fec"> </div><div class="notion-text notion-block-544ff21370b14023b92a0920aea5c121">有了App的ApplicaiotnId以后，设置每个端的布局和文字，甚至代码。首先按照下图新建文件夹。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-362393f034414223ad6050f240481dc7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/styledemo_1.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-22d051f7073642f3bb18d1d5b4ff8bd9">当创建完以后会发现类似a和c文件夹的情况，都是灰色的，和main的目录文件夹图片不一样。好像只是普通的文件夹，怎么可能生成Apk呢。接下来看下图的操作。点击AS左侧的</div><div class="notion-text notion-block-7aa7efeaf66842afba43839657818709"><b>Build Varinat</b></div><div class="notion-text notion-block-78ad8523938c424085650c4ee447e6f5">，然后在</div><div class="notion-text notion-block-3f53e122587b4d3fa131366b57a03c38"><b>Build Variant</b></div><div class="notion-text notion-block-7b894dfba015461fa818ce62baa45363">的面板里选择。当选择a的时候，a的目录就变成了和main目录一样的文件夹图片了。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2015c8a4a7f14b07b195d3c5f914feea"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/styledemo_2.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-748ecfc45c0443c6848ca108a9fef82d">接下来就是让app变种的时候了。在a,b,c文件夹下的res下创建 values/string.xml的文件，（和main/res/values/string.xml一样）,新建一个名叫title_name的string。</div><div class="notion-text notion-block-dd57fb9a386d46db8559b099ef585a7d"><b>a/res/values/string.xml</b></div><div class="notion-text notion-block-edadd420fb944c4f8622c08fd35674d3"><b>b/res/values/string.xml</b></div><div class="notion-text notion-block-08d695f2d0a34c878c44672b309c1b19"><b>c/res/values/string.xml</b></div><div class="notion-text notion-block-9531b314871745219ea4159636629405">然后在</div><div class="notion-text notion-block-3f809c2968db43c894384b0ba2dfc15a"><b>main/res/layout/activity_main.xml中引用@string/title_name</b></div><div class="notion-text notion-block-0cb766a009d841ec9bcb66417d6ab51a">,最后切换Build Variants中的a,b,c，当构建的时候，会发现布局文件里的文本已经发生了变化。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ab88b1e6b16e4812ba054b09318e4c7d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://pic.bigademo.com/styledemo_3.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-eeaaf6c07c4541f9b99edacd14d46c4d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://pic.bigademo.com/styledemo_4.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-addf7335200044b38ca863290d772f8b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://pic.bigademo.com/styledemo_5.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-03f094cb522c4c5b82c463477d96508c">到这里基本的变种算是实现了，但是我们会开发版的经常碰到最低版本号多少合适的问题。试想一下，现在的手机更新换代这么快，如果是直播类的app那么使用的群体必然是80年以后的人了，手机的更新程度也应该是比较快的，所以直播类的app，一般都会把最低版本设置在5.0，或者4.4。而对于有些商家来说，只要手机能打电话，发短信，微信，日常的基本使用就行了，一般两到三年才会换手机，甚至需要更久的时间，那么，我们在设置最低版本的时候，设置在4.0，是比较合适。那么现在对a,b两个变种使用最低4.0的版本，c变种使用5.0的最低版本。</div><div class="notion-text notion-block-856039ae56bf4bc7bb43b67d7dcfedbc">当gradle同步完以后，会发现在Build Variant里会发现变的更丰富了。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-87092107cdf64f0ea83c899fadbbfe96"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/styledemo_6.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-218f969ff2984921b7aa46850e3cbc4b">。那么现在可以在一个设备上安装不同类型的app了。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android增量更新从入坑到成功]]></title>
            <link>https://bigademo.com/article/d4ef393e-8092-4732-8084-3a44ed37fee4</link>
            <guid>https://bigademo.com/article/d4ef393e-8092-4732-8084-3a44ed37fee4</guid>
            <pubDate>Fri, 04 Jan 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-d4ef393e8092473280843a44ed37fee4"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-b0651f06346740bea61d9a954a1e394c" data-id="b0651f06346740bea61d9a954a1e394c"><span><div id="b0651f06346740bea61d9a954a1e394c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b0651f06346740bea61d9a954a1e394c" title="流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">流程</span></span></h3><ul class="notion-list notion-list-disc notion-block-dd86c388441a47ff9a1dba37b23d6cc8"><li>step1 使用bsdiff生成差异包PATCH.patch</li></ul><ul class="notion-list notion-list-disc notion-block-8f6ee7e0c4544c8896832f2b669d9b94"><li>step2 在手机上合并base包和差异包，生成新版本的安装包</li></ul><ul class="notion-list notion-list-disc notion-block-91c1bb3abcfd4aa4865364f56f6f02f1"><li>step3 安装新的安装包</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6cb06087395845248eeaaee54c773eaf" data-id="6cb06087395845248eeaaee54c773eaf"><span><div id="6cb06087395845248eeaaee54c773eaf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6cb06087395845248eeaaee54c773eaf" title="准备"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">准备</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-9c449f745187445c9df974e0bc204d89"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://www.daemonology.net/bsdiff/bsdiff-4.3.tar.gz">bsdiff-4.3</a> （用于生成差异包，合并新包）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-967eaa32b253416baf156c31b302e46f"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://sourceforge.net/projects/bzip2/files/latest/download">bzip2</a> （bsdiff要使用到）</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-24e086fb709e46328be6b95846056386" data-id="24e086fb709e46328be6b95846056386"><span><div id="24e086fb709e46328be6b95846056386" class="notion-header-anchor"></div><a class="notion-hash-link" href="#24e086fb709e46328be6b95846056386" title="试验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">试验</span></span></h3><ul class="notion-list notion-list-disc notion-block-610df915b2d24982b6ef75894a35aaab"><li>step1 解压bsdiff4.3的压缩包</li></ul><ul class="notion-list notion-list-disc notion-block-4351a8ef36ad4842a52ea2ad77d815be"><li>step2 修改Makefile文件，将**.ifndef<b>和</b>.endif**缩进，要么无法进行后面的操作</li></ul><ul class="notion-list notion-list-disc notion-block-1b09342d57ce42f397e17410ac4685ec"><li>step3 在该文件夹的命令行里执行<b>make</b>命令，会生成<b>bsdiff</b>和<b>bspatch</b>两个可执行的文件。如果是从上面的地址下载的bsdiff的话，会爆出<b>bspatch.c:39:21: error: unknown type name &#x27;u_char&#x27;; did you mean &#x27;char&#x27;?</b><b>这样的错误。这是由于bspatch.c中缺少了</b><b>#include &lt;sys/types.h&gt;</b> ，加上即可。然后执行make命令。</li></ul><div class="notion-text notion-block-4db334ac411a4218b3e766688c0f38d0">&lt;!-- more --&gt;</div><ul class="notion-list notion-list-disc notion-block-d6a916b0d29347cd8310ce56b5b392c5"><li>step4 准备两个<b>同一签名</b>的apk，<em>old.apk</em>和*.apk*，放在<b>bsdiff-4.3</b>解压后的文件夹里。</li></ul><ul class="notion-list notion-list-disc notion-block-30de00f54a25468bb89f1067d21b55ee"><li>step5 使用<b>bsdiff</b>生成差异文件PATCH.patch，命令格式：<b>bsdiff oldfile newfile patchfile</b>（这一步操作可以放在服务端来执行）</li></ul><ul class="notion-list notion-list-disc notion-block-9cd739a0472c4a50a26bc1e6d95fb6ca"><li>step6 使用<b>bspatch</b>合成新的apk，dest.apk。命令格式：<b>bspatch oldfile newfile patchfile</b></li></ul><ul class="notion-list notion-list-disc notion-block-f6e11e46b8be49208634faea5171a1bd"><li>step7 验证生成的dest.apk和之前的new.apk使用一样，验证两个apk的md5值，即可。</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ee659febafcb44558521b51acbfe2adb" data-id="ee659febafcb44558521b51acbfe2adb"><span><div id="ee659febafcb44558521b51acbfe2adb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ee659febafcb44558521b51acbfe2adb" title="在Android中使用增量更新"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">在Android中使用增量更新</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-d0f5e90e692f48ada43a7841655d7045" data-id="d0f5e90e692f48ada43a7841655d7045"><span><div id="d0f5e90e692f48ada43a7841655d7045" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d0f5e90e692f48ada43a7841655d7045" title="ndk部分"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">ndk部分</span></span></h4><ul class="notion-list notion-list-disc notion-block-1a204d7230a24228b2ca339348ded82d"><li>step1 新建一个PatchUtils的类，用于调用native的方法</li></ul><ul class="notion-list notion-list-disc notion-block-812fddeb21c740d6a9916acc97204065"><li>step2 使用<b>javah</b>命令生成PatchUtils的头文件，或者使用ndk-build里的javah生成头文件。会在jni文件夹下生成一个<b>com_bigademo_updatedemo_PatchUtils.h</b>的文件，其中<b>com_bigademo_updatedemo</b>是我的包名。</li></ul><ul class="notion-list notion-list-disc notion-block-735eeb9af4f1446a8f64ab10db8d2005"><li>step3 将<b>bsdiff4.3文件夹</b>中的<b>bspatch.c</b>文件导入到<b>jni</b>文件夹下。</li></ul><ul class="notion-list notion-list-disc notion-block-ac0b94a185c04a4088f7e60fe3422af8"><li>step4 将<b>bzip2文件夹</b>导入到<b>jni</b>文件夹下</li></ul><ul class="notion-list notion-list-disc notion-block-080405ba4bf44667b2e7c0e2e52b075b"><li>step5 删除bzip2中的<b>除了以c和h结尾的其他文件</b>。
如图：</li><ul class="notion-list notion-list-disc notion-block-080405ba4bf44667b2e7c0e2e52b075b"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d8f7a1d6a76b499cae12a0e568006b5f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://pic.bigademo.com/jni.png" alt="notion image" loading="lazy" decoding="async"/></div></figure></ul></ul><ul class="notion-list notion-list-disc notion-block-2066dcb9ec8d4b93b7817c4b742312f0"><li>step6 修改<b>bspatch.c</b>。引入bzip的文件，引入<b>com_bigademo_updatedemo_PatchUtils.h</b>，在bspatch.c中重写<b>JNIEXPORT jint JNICALL Java_com_bigademo_updatedemo_PatchUtils_bspatch</b>方法。代码如下</li></ul><ul class="notion-list notion-list-disc notion-block-f1b1b8fd6ca64219b4a05726ef810283"><li>step7 在<b>jni</b>下创建Android.mk和Application.mk两个文件</li></ul><div class="notion-text notion-block-acf475ac272741f3b5603c882e6e5699"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://android.mk/"><b>Android.mk</b></a></div><div class="notion-text notion-block-3099c92f40784d53a2e892fae393057c"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://application.mk/"><b>Application.mk</b></a></div><ul class="notion-list notion-list-disc notion-block-bcb104c3d10d494a994cbb48269bdc77"><li>step8 在module中的build.gradle中配置ndk。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-6cc9df5693f142779187f92e955900b4" data-id="6cc9df5693f142779187f92e955900b4"><span><div id="6cc9df5693f142779187f92e955900b4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6cc9df5693f142779187f92e955900b4" title="java部分"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">java部分</span></span></h4><div class="notion-text notion-block-bdde9d02c32843d5875a354caeeee08c">创建一个<b>ApkExtract</b>类，用于获取当前app的apk和安装新的apk。因为涉及到Android 7.0的，需要处理Provider的问题，同时在AndroidManifest.xml增加一些代码</div><div class="notion-text notion-block-dca1eed356a44d8aba6e51b20fc6c8c9"><b>androidmanifest.xml</b></div><div class="notion-text notion-block-01fbc6c6ad9f4c488a0f144ce5a0c5b6">最后在需要更新的时候调用下面这个方法，当然先做一下动态调用读写权限的操作。</div><div class="notion-text notion-block-ba8bd189ec114071850907ff35806f2b">demo项目：<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/yyt231/updatedemo">https://github.com/yyt231/updatedemo</a></div><div class="notion-text notion-block-8a0fd5a16df5499996cd374dd0349159">巨人的肩膀：
<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://blog.csdn.net/lmj623565791/article/details/52761658">https://blog.csdn.net/lmj623565791/article/details/52761658</a><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.cnblogs.com/lping/p/5833090.html">https://www.cnblogs.com/lping/p/5833090.html</a><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://blog.csdn.net/qq_33750826/article/details/75540738">https://blog.csdn.net/qq_33750826/article/details/75540738</a></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[仿微信地图的可变化高度的列表页]]></title>
            <link>https://bigademo.com/article/169223a5-e6be-46bc-97a7-9d677c41b650</link>
            <guid>https://bigademo.com/article/169223a5-e6be-46bc-97a7-9d677c41b650</guid>
            <pubDate>Wed, 22 May 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-169223a5e6be46bc97a79d677c41b650"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b4ef3e20cc94743877cfaf87bc3cfb5" data-id="3b4ef3e20cc94743877cfaf87bc3cfb5"><span><div id="3b4ef3e20cc94743877cfaf87bc3cfb5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b4ef3e20cc94743877cfaf87bc3cfb5" title="效果"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">效果</span></span></h3><div class="notion-text notion-block-7f4b74850fcf4ba1ab2f3cf097d3e236">点击实现列表的伸缩，拖拽实现列表的伸缩</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6d149b21bfa54781bdae894a998dbc3f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:336px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/map.gif" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3ef603845e1642a7884ffb789f190864" data-id="3ef603845e1642a7884ffb789f190864"><span><div id="3ef603845e1642a7884ffb789f190864" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3ef603845e1642a7884ffb789f190864" title="一句话原理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一句话原理</span></span></h3><div class="notion-text notion-block-c4fc038391bd447b928cd24a9d039aca">通过拖拽事件，改变列表的高度</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6cb87bb2c9ac46c29775302a6d93403c" data-id="6cb87bb2c9ac46c29775302a6d93403c"><span><div id="6cb87bb2c9ac46c29775302a6d93403c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6cb87bb2c9ac46c29775302a6d93403c" title="代码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">代码</span></span></h3><div class="notion-text notion-block-130d45690f4340bb911283a8d5e8fc96"><b>activity_map.xml</b></div><div class="notion-text notion-block-bc84c5fa33e443028f8887694335eed5">&lt;!-- more --&gt;</div><div class="notion-text notion-block-2dc142fcd9a7471aabadf355b92a63ab"><b>关键逻辑代码</b></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android的FloatView]]></title>
            <link>https://bigademo.com/article/16d67514-e3ff-4f1a-8919-be2113412515</link>
            <guid>https://bigademo.com/article/16d67514-e3ff-4f1a-8919-be2113412515</guid>
            <pubDate>Wed, 22 May 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-16d67514e3ff4f1a8919be2113412515"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-4fda8013ade04a039e4a659741504e18" data-id="4fda8013ade04a039e4a659741504e18"><span><div id="4fda8013ade04a039e4a659741504e18" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4fda8013ade04a039e4a659741504e18" title="由来"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">由来</span></span></h3><div class="notion-text notion-block-4a8c9c3e5e3c4c8c9e9a53e3ea62a196">原本我是想在BaseActivity的DecorView层添加一个View，奈何之前同事的Activity继承的五花八门。正好业务需要在<b>手机桌面</b>上显示一个可拖拽的FloatView。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-feb0aa12595949ff8c7a77d2d95bb52a" data-id="feb0aa12595949ff8c7a77d2d95bb52a"><span><div id="feb0aa12595949ff8c7a77d2d95bb52a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#feb0aa12595949ff8c7a77d2d95bb52a" title="使用到的权限"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用到的权限</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-206e83dbb36b4fc083de374da1aa4734" data-id="206e83dbb36b4fc083de374da1aa4734"><span><div id="206e83dbb36b4fc083de374da1aa4734" class="notion-header-anchor"></div><a class="notion-hash-link" href="#206e83dbb36b4fc083de374da1aa4734" title="实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">实现</span></span></h3><div class="notion-text notion-block-575ab1ea3160416a96e1d1f85fb2a879">因为要在手机上显示，所以必须用service来实现</div><div class="notion-text notion-block-0397f56ceb3344a8815fe2391c77c20c">&lt;!-- more --&gt;</div><div class="notion-text notion-block-ebab81e58d5449c5b714008be756abdc"><b>WindowPermissionCheck.java</b></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b8d2c9f63c64846be2df88609a47514" data-id="1b8d2c9f63c64846be2df88609a47514"><span><div id="1b8d2c9f63c64846be2df88609a47514" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b8d2c9f63c64846be2df88609a47514" title="调用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">调用</span></span></h3><div class="notion-text notion-block-6f5b4dd05a464689a6ac22593a7ab6a8">因为要在手机上显示，即需要”在其他APP的上层“显示，在Android6.0以上，需要用户来&quot;允许显示在其他应用的上层&quot;</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a7555fa8ef5445e19b86e4431992cc0b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:240px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/timg.jpeg" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-bfc4f19c384b4931a253f5a783d28db1"><b>调用</b></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AndroidStudio4.1 自定义模板]]></title>
            <link>https://bigademo.com/article/5166a538-1495-44a5-8335-09c8d1da0bf8</link>
            <guid>https://bigademo.com/article/5166a538-1495-44a5-8335-09c8d1da0bf8</guid>
            <pubDate>Sun, 10 Sep 2023 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-5166a538149544a5833509c8d1da0bf8"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-94dab1ab47c545aa81c8a5d98c04d0eb"><b>原创文件，禁止未授权转载</b></div><div class="notion-text notion-block-dce8785435f84c8ab084c3d57462183b">AndroidStudio4.0之前，可以在template的文件夹里使用freemarker的自定义模板，可以在AndroidStudio的文件夹中，随意的添加适合自己的自定义模板，之前鸿洋大神的文章已经有来详细的介绍（<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://blog.csdn.net/lmj623565791/article/details/51592043%EF%BC%89%E3%80%82">https://blog.csdn.net/lmj623565791/article/details/51592043）。</a>
但是从4.1版本开始提供新的方式，Geminio，用Kotlin的形式编写新的template，而且需要使用插件的形式，才能使用自定义的模板，摸索了好几天，终于解决了。</div><div class="notion-text notion-block-9bca72a38a9e437099086405d84dad7d">我的项目是使用MVVM的开发框架，每次在编写一个新的页面的时候，就需要新建四个文件Activity/Fragment, ViewModel, Repository, xml文件,写的多了就会很烦。自从使用了自定义的模板以后，头发掉得都少了。</div><div class="notion-text notion-block-1eebf08ab6554b9b8479a81e6b001675">开工！！！搞起！！！</div><div class="notion-text notion-block-5ae6aa6bad144f51a65b7668410dbb67">#准备</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bfb55afda2e4f93b1717ada4af66450" data-id="1bfb55afda2e4f93b1717ada4af66450"><span><div id="1bfb55afda2e4f93b1717ada4af66450" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bfb55afda2e4f93b1717ada4af66450" title="开发工具 AndroidStudio4.1"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">开发工具 AndroidStudio4.1</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-5b99d61853ec44b490fbc953f92653b4" data-id="5b99d61853ec44b490fbc953f92653b4"><span><div id="5b99d61853ec44b490fbc953f92653b4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5b99d61853ec44b490fbc953f92653b4" title="模板基础代码配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">模板基础代码配置</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-97c56eff54664775b4714247371caa4c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://pic.bigademo.com/16111336710248.jpg" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2a9c501023dd43d3a797065e96db68af">打开https://github.com/JetBrains/intellij-platform-plugin-template，点击绿色的#Use this template#,按步骤在自己的github上创建模板。
然后使用AndroidStudio 将模板下载到本地。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-32682d48dc024c50983f8eecad149b68"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:384px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/16111384836878.jpg" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-c07bb1cec5ae4222a0c72020901f2308"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-96373e8521154733a414b7be5fdc9866" data-id="96373e8521154733a414b7be5fdc9866"><span><div id="96373e8521154733a414b7be5fdc9866" class="notion-header-anchor"></div><a class="notion-hash-link" href="#96373e8521154733a414b7be5fdc9866" title="编码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">编码</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-893da919cffd4ed6be95200c50df7566" data-id="893da919cffd4ed6be95200c50df7566"><span><div id="893da919cffd4ed6be95200c50df7566" class="notion-header-anchor"></div><a class="notion-hash-link" href="#893da919cffd4ed6be95200c50df7566" title="添加wizard-template.jar"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">添加wizard-template.jar</span></span></h3><div class="notion-text notion-block-52a9b3c33dbb4de08703bd73f92b8f7b">在根目录里添加lib文件夹，并添加AndroidStudio安装目录里的wizard-template.jar，位于 /Applications/Android\ Studio.app/Contents/plugins/android/lib/目录下。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-ccaf9694bd674adb9bbb1c2ca8ccf46d" data-id="ccaf9694bd674adb9bbb1c2ca8ccf46d"><span><div id="ccaf9694bd674adb9bbb1c2ca8ccf46d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ccaf9694bd674adb9bbb1c2ca8ccf46d" title="修改build.gradle.kts"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">修改build.gradle.kts</span></span></h3><div class="notion-text notion-block-b090e1aabe364678971c16a300f18fbe">在dependencies里添加wizard-template.jar的依赖</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-f2e2f511919b43d0abf95b838689fc41" data-id="f2e2f511919b43d0abf95b838689fc41"><span><div id="f2e2f511919b43d0abf95b838689fc41" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f2e2f511919b43d0abf95b838689fc41" title="修改gradle.properties"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">修改gradle.properties</span></span></h3><div class="notion-text notion-block-09096dfb6b334de1a9f8afe5aba39e99">修改gradle.properties中的pluginGroup, pluginName_, platformPlugins, platformVersion。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2042153d537145488bd8ab8931a2029a" data-id="2042153d537145488bd8ab8931a2029a"><span><div id="2042153d537145488bd8ab8931a2029a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2042153d537145488bd8ab8931a2029a" title="将默认的listeners的父包名，调整为自己想要的样子，例如com.company.app"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">将默认的listeners的父包名，调整为自己想要的样子，例如com.company.app</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-d4102157403141cfbcf7f513281366c2" data-id="d4102157403141cfbcf7f513281366c2"><span><div id="d4102157403141cfbcf7f513281366c2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d4102157403141cfbcf7f513281366c2" title="修改MyProjectManagerListener"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">修改MyProjectManagerListener</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-73a9247d7da24dabb6cfe13f0a0f7796" data-id="73a9247d7da24dabb6cfe13f0a0f7796"><span><div id="73a9247d7da24dabb6cfe13f0a0f7796" class="notion-header-anchor"></div><a class="notion-hash-link" href="#73a9247d7da24dabb6cfe13f0a0f7796" title="在src/main/kotlin里创建other文件夹用于放置自定义模板"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">在src/main/kotlin里创建other文件夹用于放置自定义模板</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c14d54c4acb349cabcd745bcc45089ce"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/16111388621809.jpg" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-8a647b18e33d4447b48181b3f4f38a96" data-id="8a647b18e33d4447b48181b3f4f38a96"><span><div id="8a647b18e33d4447b48181b3f4f38a96" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8a647b18e33d4447b48181b3f4f38a96" title="正式开始编写自定义模板，以Activity为例。"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">正式开始编写自定义模板，以Activity为例。</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-e04c0e9c7a664414bee00af209508fa2" data-id="e04c0e9c7a664414bee00af209508fa2"><span><div id="e04c0e9c7a664414bee00af209508fa2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e04c0e9c7a664414bee00af209508fa2" title="1. 实现WizardTemplateProvider"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 实现WizardTemplateProvider</span></span></h4><div class="notion-text notion-block-6eebd67c748d442ea523bcb3605c32f3"><b>SamplePluginTemplateProviderImpl</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2111bec1366c4a128626317f256e72a4" data-id="2111bec1366c4a128626317f256e72a4"><span><div id="2111bec1366c4a128626317f256e72a4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2111bec1366c4a128626317f256e72a4" title="2. 创建 mvvmActivityTemplate.kt."><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 创建 mvvmActivityTemplate.kt.</span></span></h4><div class="notion-text notion-block-113ee14e446a412888296996395676a3">这个文件是设置在创建Activity的时候，输入的信息，例如ActivityName，layoutName,packageName以及是否可以为为等
	<b>mvvmActivityTemplate.kt</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-98d3be246ea747a49486b75e58a8a43f" data-id="98d3be246ea747a49486b75e58a8a43f"><span><div id="98d3be246ea747a49486b75e58a8a43f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#98d3be246ea747a49486b75e58a8a43f" title="3. 创建mvvmActivityRecipe.kt。"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 创建mvvmActivityRecipe.kt。</span></span></h4><div class="notion-text notion-block-28c500be3c59472681ccf5166a99e880">这个文件用于将创建的文件保存到文件夹中，例如Activity，布局文件等。<em>原计划将Activity直接添加到AndroidManifest里，但是发现generateManifest有点问题，导致生成的插件不能使用，暂时去掉，只能手动添加了。</em></div><div class="notion-text notion-block-e83276aba70e4ce49a9bee5d0845a282"><b>mvvmActivityRecipe.kt</b></div><div class="notion-text notion-block-4a57aac766fe47bbae5783e054859a8c"></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-956a7658ce174e51bae333a4c4d135c0" data-id="956a7658ce174e51bae333a4c4d135c0"><span><div id="956a7658ce174e51bae333a4c4d135c0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#956a7658ce174e51bae333a4c4d135c0" title="4. 创建mvvmAcitivityKt。"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 创建mvvmAcitivityKt。</span></span></h4><div class="notion-text notion-block-6d89c7076c6144d4a01583a7064c43fe">这个文件用于创建Activity的模板代码，根据自己的情况，自行调整。</div><div class="notion-text notion-block-614c4e5f5a2f4d6daf115bf696512c47"><b>mvvmAcitivityKt.kt</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-c98a4a95b4c5455ebd77939cdcb53b6c" data-id="c98a4a95b4c5455ebd77939cdcb53b6c"><span><div id="c98a4a95b4c5455ebd77939cdcb53b6c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c98a4a95b4c5455ebd77939cdcb53b6c" title="5. 编写mvvmRepository。"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5. 编写mvvmRepository。</span></span></h4><div class="notion-text notion-block-be1dd7a958474c9ea53db86d2afbf46e">这个文件是mvvm的repository层的代码。</div><div class="notion-text notion-block-205d42b2d27b4b1797e8163dcf854100"><b>mvvmRepository.kt</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-a0ccddeb489b41158c9cec602c2b30e5" data-id="a0ccddeb489b41158c9cec602c2b30e5"><span><div id="a0ccddeb489b41158c9cec602c2b30e5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a0ccddeb489b41158c9cec602c2b30e5" title="6. 编写mvvmViewModel。这个是mvvm的viewmodel层"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6. 编写mvvmViewModel。这个是mvvm的viewmodel层</span></span></h4><div class="notion-text notion-block-685ff378581a4f12b7a0666dc0dec91c"><b>mvvmViewModel.kt</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-86b343dfb3fd43499ff13a36387a8788" data-id="86b343dfb3fd43499ff13a36387a8788"><span><div id="86b343dfb3fd43499ff13a36387a8788" class="notion-header-anchor"></div><a class="notion-hash-link" href="#86b343dfb3fd43499ff13a36387a8788" title="7.编写mvvmActivityXml。这个文件是用于生成布局文件的"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.编写mvvmActivityXml。这个文件是用于生成布局文件的</span></span></h4><div class="notion-text notion-block-08789b797f0a48d88ccebd8d0b78e893"><b>mvvmActivityXml.kt</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-b6145620e13e4e6ba7af4fcfcae88be4" data-id="b6145620e13e4e6ba7af4fcfcae88be4"><span><div id="b6145620e13e4e6ba7af4fcfcae88be4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b6145620e13e4e6ba7af4fcfcae88be4" title="8. 修改plugin.xml"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8. 修改plugin.xml</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-1e10256e00734266874919c39e974296"><li>添加org.jetbrains.android，org.jetbrains.kotlin，com.intellij.modules.java的依赖</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-c211e85ee4804b5a92a57fb03650597c"><li>修改applicationService和projectService的值</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-2a22c9eb874c483bb17159f8201a6a1e"><li>修改applicationListenersv中listener的值</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-5e5ccfff3b3d41faadf04ab64d37f410"><li>添加wizardTemplateProvider为刚才添加的类</li></ol><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-bc670aefa2d84a50add838f9eaeec86e" data-id="bc670aefa2d84a50add838f9eaeec86e"><span><div id="bc670aefa2d84a50add838f9eaeec86e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bc670aefa2d84a50add838f9eaeec86e" title="生成jar文件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">生成jar文件</span></span></h2><div class="notion-text notion-block-e2c47cc536ad4dc8be24b98e18cc1a40">在AS最上面选择运行</div><div class="notion-text notion-block-3a24360b711f4dcca806692eb97964ed"><b>Run plugin</b></div><div class="notion-text notion-block-efa031282fb54355b4febfcaa7c2da77">，成功以后即可在build/libs找见对应的jar文件。最后在AS的设置里将这个jar包添加的plugin，重启AS即可。
u</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-fbfc3c16a45a4a3e8e3dd987d319c618"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/image-20210120191030327-1.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6ed8de8cdb3a4be9a9d3c6e39cd3e91b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://pic.bigademo.com/image-20210120191055182-1.png" alt="notion image" loading="lazy" decoding="async"/></div></figure></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>