-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
28 lines (28 loc) · 9.69 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!doctype html><html class="scroll-pt-16 scroll-smooth" lang=zh><head><meta name=generator content="Hugo 0.127.0"><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1"><link rel=icon href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'> <text x='0' y='14'>🧑💻</text> </svg>"><link rel=stylesheet href=https://blog.io01.xyz/css/style.css><script type=text/javascript src=https://blog.io01.xyz/js/main.js></script><title>IO01 Blog</title></head><body><header class="sticky top-0 z-10 bg-white backdrop-filter backdrop-blur-lg bg-opacity-70 border-b border-gray-200"><nav class="max-w-5xl mx-auto px-4"><div class="flex items-center justify-between h-16"><a href=/ class="text-2xl text-gray-900 font-semibold">IO01 Blog</a><ul class="flex space-x-4 text-gray-900"><li><a href=https://blog.io01.xyz/posts>归档</a></li><li><a href=https://blog.io01.xyz/about>关于</a></li></ul></div></nav></header><div id=content><main class="flex flex-col justify-center"><div class="flex flex-col mx-auto w-5/6 lg:w-3/4 xl:w-3/5 my-4"><h2 class="text-2xl font-semibold hover:underline hover:underline-offset-4 hover:decoration-2"><a href=https://blog.io01.xyz/posts/6fn7/>深入源码排查 FLAG_ACTIVITY_NEW_TASK 导致的 Activity 无法正常启动</a></h2><div class="inline-flex my-1"><div class="inline-flex items-center"><svg viewBox="0 0 1 1" class="h-4 mr-1"><use href="#calendar"/></svg>
<span class=text-gray-500>2021-09-16</span></div><div class="inline-flex items-center ml-2"><svg viewBox="0 0 1 1" class="h-4 mx-1"><use href="#tags"/></svg>
<a href=https://blog.io01.xyz/tags/android/ class="text-gray-500 mr-1">Android
</a><a href=https://blog.io01.xyz/tags/%E6%BA%90%E7%A0%81/ class="text-gray-500 mr-1">源码</a></div></div><div class="summary-item prose max-w-none"><h2 id=引言>引言</h2><p>众所周知 Android 中 Activity 有四种启动模式,决定了是否创建新的 Activity 实例或复用当前实例。但是实际上 Activity 的启动十分复杂,不单单是 <code>android:launchMode</code> 就能决定的,多个 Intent Flag 都能改变启动的行为模式,除此之外还会根据 <code>android:taskAffinity</code> 的值来判断对应任务栈是否存在。</p></div><div class="bg-gray-200 w-full h-px mt-3"></div></div><div class="flex flex-col mx-auto w-5/6 lg:w-3/4 xl:w-3/5 my-4"><h2 class="text-2xl font-semibold hover:underline hover:underline-offset-4 hover:decoration-2"><a href=https://blog.io01.xyz/posts/2aa2/>遵循 Google 应用指南的 Retrofit + Coroutine 封装</a></h2><div class="inline-flex my-1"><div class="inline-flex items-center"><svg viewBox="0 0 1 1" class="h-4 mr-1"><use href="#calendar"/></svg>
<span class=text-gray-500>2021-06-18</span></div><div class="inline-flex items-center ml-2"><svg viewBox="0 0 1 1" class="h-4 mx-1"><use href="#tags"/></svg>
<a href=https://blog.io01.xyz/tags/kotlin/ class="text-gray-500 mr-1">Kotlin
</a><a href=https://blog.io01.xyz/tags/android/ class="text-gray-500 mr-1">Android</a></div></div><div class="summary-item prose max-w-none"><h2 id=前言>前言</h2><p>Retrofit 从 2.6.0 以后对 Kotlin 协程提供了原生支持,使得异步请求从写法上更像同步调用,配合 Google 出的 Jetpack 全家桶可以使得网络请求更加优雅简单,而且可以完全遵循 Google 给出的应用架构指南。</p><p>另外我们有一个更加多样的需求:我们的应用使用了多套服务接口,每套接口返回的参数模板不同,baseUrl 则更多样化,因此带来了更复杂的封装逻辑。</p></div><div class="bg-gray-200 w-full h-px mt-3"></div></div><div class="flex flex-col mx-auto w-5/6 lg:w-3/4 xl:w-3/5 my-4"><h2 class="text-2xl font-semibold hover:underline hover:underline-offset-4 hover:decoration-2"><a href=https://blog.io01.xyz/posts/53aj/>时间格式化的趣事:YYYY 示年</a></h2><div class="inline-flex my-1"><div class="inline-flex items-center"><svg viewBox="0 0 1 1" class="h-4 mr-1"><use href="#calendar"/></svg>
<span class=text-gray-500>2020-02-27</span></div><div class="inline-flex items-center ml-2"><svg viewBox="0 0 1 1" class="h-4 mx-1"><use href="#tags"/></svg>
<a href=https://blog.io01.xyz/tags/java/ class="text-gray-500 mr-1">Java</a></div></div><div class="summary-item prose max-w-none"><h2 id=引言>引言</h2><p>2019 年 12 月 29 到 31 日在格式化时间时出现了一个有趣的小 bug:比如 2019 年 12 月 31 日时间戳有可能会被格式化成:2020-12-31。</p></div><div class="bg-gray-200 w-full h-px mt-3"></div></div><div class="flex flex-col mx-auto w-5/6 lg:w-3/4 xl:w-3/5 my-4"><h2 class="text-2xl font-semibold hover:underline hover:underline-offset-4 hover:decoration-2"><a href=https://blog.io01.xyz/posts/33dn/>MD5 计算前导 0 丢失问题</a></h2><div class="inline-flex my-1"><div class="inline-flex items-center"><svg viewBox="0 0 1 1" class="h-4 mr-1"><use href="#calendar"/></svg>
<span class=text-gray-500>2020-01-20</span></div><div class="inline-flex items-center ml-2"><svg viewBox="0 0 1 1" class="h-4 mx-1"><use href="#tags"/></svg>
<a href=https://blog.io01.xyz/tags/java/ class="text-gray-500 mr-1">Java</a></div></div><div class="summary-item prose max-w-none"><h2 id=现象>现象</h2><p>我们使用 Java 生成 MD5 时常用的写法如下:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java><span style=display:flex><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1</span><span><span style=color:#8be9fd;font-style:italic>private</span> <span style=color:#8be9fd;font-style:italic>static</span> String <span style=color:#50fa7b>md5</span>(String data) <span style=color:#8be9fd;font-style:italic>throws</span> NoSuchAlgorithmException {
</span></span><span style=display:flex><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">2</span><span> MessageDigest md <span style=color:#ff79c6>=</span> MessageDigest.<span style=color:#50fa7b>getInstance</span>(<span style=color:#f1fa8c>"MD5"</span>);
</span></span><span style=display:flex><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">3</span><span> md.<span style=color:#50fa7b>update</span>(data.<span style=color:#50fa7b>getBytes</span>());
</span></span><span style=display:flex><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">4</span><span> <span style=color:#ff79c6>return</span> <span style=color:#ff79c6>new</span> BigInteger(1, md.<span style=color:#50fa7b>digest</span>()).<span style=color:#50fa7b>toString</span>(16);
</span></span><span style=display:flex><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">5</span><span>}
</span></span></code></pre></div><p>如果计算 <code>a</code> 的 MD5 会发现结果为 <code>cc175b9c0f1b6a831c399e269772661</code>,只有 31 位,正确的值应该是 <code>0cc175b9c0f1b6a831c399e269772661</code>,仔细观察可以发现我们的计算方法把第一位 <code>0</code> 丢失了。</p></div><div class="bg-gray-200 w-full h-px mt-3"></div></div><div class="flex flex-col mx-auto w-5/6 lg:w-3/4 xl:w-3/5 my-4"><h2 class="text-2xl font-semibold hover:underline hover:underline-offset-4 hover:decoration-2"><a href=https://blog.io01.xyz/posts/57fb/>从阿里规约谈起 - 包装类的值比较注意事项</a></h2><div class="inline-flex my-1"><div class="inline-flex items-center"><svg viewBox="0 0 1 1" class="h-4 mr-1"><use href="#calendar"/></svg>
<span class=text-gray-500>2019-11-29</span></div><div class="inline-flex items-center ml-2"><svg viewBox="0 0 1 1" class="h-4 mx-1"><use href="#series"/></svg>
<a href=https://blog.io01.xyz/series/%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6/ class=text-gray-500>阿里规约</a></div><div class="inline-flex items-center ml-2"><svg viewBox="0 0 1 1" class="h-4 mx-1"><use href="#tags"/></svg>
<a href=https://blog.io01.xyz/tags/java/ class="text-gray-500 mr-1">Java
</a><a href=https://blog.io01.xyz/tags/%E6%BA%90%E7%A0%81/ class="text-gray-500 mr-1">源码</a></div></div><div class="summary-item prose max-w-none"><h2 id=前言>前言</h2><p><code>int</code>、<code>long</code> 等基本数据类型值比较可以直接使用 <code>==</code> 比较,其包装类型:<code>Integer</code>、<code>Long</code> 如果直接使用 <code>==</code> 比较大小我们会发现一个神奇的现象。当然,阿里规约也对此做出强制规定:</p><blockquote><p><strong>【强制】</strong> 所有的相同类型的包装类对象之间值的比较,全部使用 <code>equals</code> 方法比较。</p></blockquote></div><div class="bg-gray-200 w-full h-px mt-3"></div></div><div class="my-2 flex w-screen justify-center"><a href=/ class="mx-3 sm:mx-4 font-semibold text-gray-400 hover:text-sky-400 hover:underline hover:underline-offset-4 hover:decoration-2">1
</a><span class="mx-3 sm:mx-4 font-semibold text-sky-400 underline underline-offset-4 decoration-2">2
</span><a href=/page/3/ class="mx-3 sm:mx-4 font-semibold text-gray-400 hover:text-sky-400 hover:underline hover:underline-offset-4 hover:decoration-2">3</a></div></main></div><footer><div class="flex justify-center mt-6 mb-2 text-gray-500"><span>©2024
<span class=ml-2><a class=hover:text-sky-400 href=https://blog.io01.xyz>IO01</a>
</span></span><span class=mx-2>|</span>
<span>Powered by
<a class=hover:text-sky-400 href=https://gohugo.io>Hugo</a>
</span><span class=mx-1>&</span>
<span><a class=hover:text-sky-400 href=#>FullMoon</a></span></div></footer></body></html>