-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
577 lines (366 loc) · 54.7 KB
/
atom.xml
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>willkernel</title>
<subtitle>Lifelong learning</subtitle>
<link href="/atom.xml" rel="self"/>
<link href="http://willkernel.github.io/"/>
<updated>2018-04-19T16:41:06.057Z</updated>
<id>http://willkernel.github.io/</id>
<author>
<name>willkernel</name>
</author>
<generator uri="http://hexo.io/">Hexo</generator>
<entry>
<title>C++(一)</title>
<link href="http://willkernel.github.io/2018/04/08/CPP-%E4%B8%80/"/>
<id>http://willkernel.github.io/2018/04/08/CPP-一/</id>
<published>2018-04-08T00:16:00.000Z</published>
<updated>2018-04-19T16:41:06.057Z</updated>
<summary type="html">
<h4 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h4><blockquote>
<p>C++ 是一种静态类型的、编译式的、通用的、大小写敏感的、不规则的编程语言,支持过程化编程、面向对象编程和泛型编程<br>C++ 被认为是一种中级语言,它综合了高级语言和低级语言的特点<br>C++ 是由 Bjarne Stroustrup 于 1979 年在贝尔实验室开始设计开发的。C++ 进一步扩充和完善C,是 C 的一个超集,事实上,任何合法的 C 程序都是合法的 C++ 程序<br>注意:使用静态类型的编程语言是在编译时执行类型检查,而不是在运行时执行类型检查<br>2014 ISO/IEC 14882:2014 C++14 第四个C++标准</p>
</blockquote>
<blockquote>
<p>C++ 完全支持面向对象的程序设计,包括面向对象开发的四大特性:<br>封装<br>抽象<br>继承<br>多态</p>
</blockquote>
<blockquote>
<p>标准库<br>标准的 C++ 由三个重要部分组成:<br>核心语言,提供了所有构件块,包括变量、数据类型和常量,等等。<br>C++ 标准库,提供了大量的函数,用于操作文件、字符串等。<br>标准模板库(STL),提供了大量的方法,用于操作数据结构等</p>
</blockquote>
<ul>
<li><a href="https://sourceforge.net/projects/mingw/files/" target="_blank" rel="noopener">MinGW</a></li>
</ul>
<h4 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h4><ul>
<li><p>程序结构</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">#include &lt;iostream&gt;</span><br><span class="line">using namespace std;</span><br><span class="line"> </span><br><span class="line">// main() 是程序开始执行的地方 ,单行注释</span><br><span class="line"> </span><br><span class="line">int main()</span><br><span class="line">&#123;</span><br><span class="line"> cout &lt;&lt; &quot;Hello World&quot;; // 输出 Hello World</span><br><span class="line"> return 0;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>包含头文件<code>&lt;iostream&gt;</code></li>
<li><code>using namespace std;</code>使用std命名空间</li>
<li><code>int main()</code>主函数,程序从这里开始执行</li>
<li><code>return 0</code> 终止main()函数,返回0</li>
</ul>
</li>
<li>编译执行<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ touch hello.cpp</span><br><span class="line">$ g++ hello.cpp</span><br><span class="line">$ ./a.exe</span><br><span class="line">Hello World</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="C++" scheme="http://willkernel.github.io/categories/C/"/>
</entry>
<entry>
<title>SQLite(三)</title>
<link href="http://willkernel.github.io/2018/04/08/SQLite-%E4%B8%89/"/>
<id>http://willkernel.github.io/2018/04/08/SQLite-三/</id>
<published>2018-04-07T16:07:00.000Z</published>
<updated>2018-04-07T16:08:11.257Z</updated>
<summary type="html">
<h4 id="SQLite-Java"><a href="#SQLite-Java" class="headerlink" title="SQLite Java"></a>SQLite
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
<category term="SQLite" scheme="http://willkernel.github.io/tags/SQLite/"/>
</entry>
<entry>
<title>Source Insight 使用</title>
<link href="http://willkernel.github.io/2018/04/07/Source-Insight-%E4%BD%BF%E7%94%A8/"/>
<id>http://willkernel.github.io/2018/04/07/Source-Insight-使用/</id>
<published>2018-04-07T13:36:00.000Z</published>
<updated>2018-04-07T14:45:48.622Z</updated>
<summary type="html">
<ul>
<li>New project<img src="http://p4n1d4izv.bkt.clouddn.com/images/srcinsight-1.png"></li>
<li>Add all<img src="http://p4n1d4izv.bkt.clouddn.com/images/srcinsight-2.png">
<img src="http://p4n1d4izv.bkt.clouddn.com/images/srcinsight-3.png"></li>
<li>close<img src="http://p4n1d4izv.bkt.clouddn.com/images/srcinsight-4.png">
</summary>
<category term="Tools" scheme="http://willkernel.github.io/categories/Tools/"/>
<category term="Source Insight" scheme="http://willkernel.github.io/tags/Source-Insight/"/>
</entry>
<entry>
<title>Java 小知识</title>
<link href="http://willkernel.github.io/2018/04/02/Java-%E5%B0%8F%E7%9F%A5%E8%AF%86/"/>
<id>http://willkernel.github.io/2018/04/02/Java-小知识/</id>
<published>2018-04-02T15:53:00.000Z</published>
<updated>2018-04-02T16:31:31.061Z</updated>
<summary type="html">
<ul>
<li><p><code>transient</code> vs
</summary>
<category term="Java" scheme="http://willkernel.github.io/categories/Java/"/>
</entry>
<entry>
<title>Window和WindowManager</title>
<link href="http://willkernel.github.io/2018/04/02/Window%E5%92%8CWindowManager/"/>
<id>http://willkernel.github.io/2018/04/02/Window和WindowManager/</id>
<published>2018-04-02T15:17:00.000Z</published>
<updated>2018-04-02T18:02:20.763Z</updated>
<summary type="html">
<ul>
<li><p>Window和WindowManager<br>Window表示一个窗口,可以实现在桌面上显示悬浮窗,Window是一个抽象类,具体实现是PhoneWindow。通过WindowManager创建Window,WindowManager是外界访问Windo
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
</entry>
<entry>
<title>SQLite(二)</title>
<link href="http://willkernel.github.io/2018/04/02/SQLite-%E4%BA%8C/"/>
<id>http://willkernel.github.io/2018/04/02/SQLite-二/</id>
<published>2018-04-02T04:08:00.000Z</published>
<updated>2018-04-07T16:07:56.843Z</updated>
<summary type="html">
<h4 id="数据库操作"><a href="#数据库操作" class="headerlink" title="数据库操作"></a>数据库操作</h4><ul>
<li><p>创建</p>
<figure class="highlight
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
<category term="SQLite" scheme="http://willkernel.github.io/tags/SQLite/"/>
</entry>
<entry>
<title>SQLite(一)</title>
<link href="http://willkernel.github.io/2018/03/30/SQLite-%E4%B8%80/"/>
<id>http://willkernel.github.io/2018/03/30/SQLite-一/</id>
<published>2018-03-30T07:56:00.000Z</published>
<updated>2018-04-02T04:06:25.882Z</updated>
<summary type="html">
<h4 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h4><p>SQLite特点:无服务器、零配置、事务性的 SQL 数据库引擎,SQLite 引擎不是一个独立的进程,可以按应用程序需求进行静态或动态连接;非常小轻量级,兼容ACID原则,是进程或线程安全的</p>
<blockquote>
<p>ACID是一组强调高可靠性的数据库系统设计原则,在软件崩溃甚至是硬件故障的情况下,数据也不会损坏。当你需要依赖兼容ACID原则的业务时,你不必重复造轮子去实现一致性检查和崩溃恢复机制。如果你有额外的安全保证机制,可以调整牺牲掉ACID的一些可靠性换取更高的性能和数据吞吐量<br>A: atomicity (原子性)<br>C: consistency (一致性)<br>I: isolation (隔离性)<br>D: durability (持久性)</p>
</blockquote>
<blockquote>
<p>SQL92 不支持的特性如下<br>RIGHT OUTER JOIN 只实现了 LEFT OUTER JOIN<br>FULL OUTER JOIN 只实现了 LEFT OUTER JOIN<br>ALTER TABLE 支持 RENAME TABLE 和 ALTER TABLE 的 ADD COLUMN variants 命令,不支持 DROP COLUMN、ALTER COLUMN、ADD CONSTRAINT<br>Trigger 支持 FOR EACH ROW 触发器,但不支持 FOR EACH STATEMENT 触发器<br>VIEWs 在 SQLite 中,视图是只读的,不可以在视图上执行 DELETE、INSERT 或 UPDATE 语句<br>GRANT 和 REVOKE 可以应用的唯一的访问权限是底层操作系统的正常文件访问权限</p>
</blockquote>
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
<category term="SQLite" scheme="http://willkernel.github.io/tags/SQLite/"/>
</entry>
<entry>
<title>Kotlin for Android(七)</title>
<link href="http://willkernel.github.io/2018/03/25/Kotlin-for-Android-%E4%B8%83/"/>
<id>http://willkernel.github.io/2018/03/25/Kotlin-for-Android-七/</id>
<published>2018-03-25T04:08:00.000Z</published>
<updated>2018-03-25T13:46:28.638Z</updated>
<summary type="html">
<h4 id="创建业务逻辑访问数据"><a href="#创建业务逻辑访问数据" class="headerlink" title="创建业务逻辑访问数据"></a>创建业务逻辑访问数据</h4><blockquote>
<p>从数据库获取数据<br>检查是否存在对应星期的数据<br>如果有,返回UI并且渲染<br>如果没有,请求服务器获取数据<br>结果被保存在数据库中并且返回UI渲染</p>
</blockquote>
<ul>
<li><p>数据源应该是一个具体的实现,这样就可以被容易地修改,所以增加一些额外的代码,然后把 command 从数据访问中抽象出来听</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">interface ForecastDataSource &#123;</span><br><span class="line">fun requestForecastByZipCode(zipCode: Long, date: Long): For</span><br><span class="line">ecastList?</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>使用数据库的数据源和服务端数据源。顺序是很重要的,因为它会根据顺序去遍历这个sources,然后一旦获取到有效的返回值就会停止查询。逻辑顺序是先在本地查询(本地数据库中),然后再通过API查询</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">class ForecastProvider(private val source: List&lt;ForecastDataSource&gt; = ForecastProvider.SOURCES) &#123;</span><br><span class="line"> companion object &#123;</span><br><span class="line"> val DAY_IN_MILLIS = 1000 * 60 * 60 * 24</span><br><span class="line"> val SOURCES = listOf(ForecastDb(), ForecastServer())</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> fun requestByZipCode(zipCode: Long, days: Int): ForecastList = source.firstResult &#123;</span><br><span class="line"> requestSource(it, days, zipCode)</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> private fun requestSource(source: ForecastDataSource, days: Int, zipCode: Long): ForecastList? &#123;</span><br><span class="line"> val res = source.requestForecastByZipCode(zipCode, todayTimeSpan())</span><br><span class="line"> return if (res != null &amp;&amp; res.size &gt;= days) res else null</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> private fun todayTimeSpan() = System.currentTimeMillis() / DAY_IN_MILLIS * DAY_IN_MILLIS</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Kotlin" scheme="http://willkernel.github.io/categories/Kotlin/"/>
<category term="Android" scheme="http://willkernel.github.io/tags/Android/"/>
<category term="Kotlin" scheme="http://willkernel.github.io/tags/Kotlin/"/>
</entry>
<entry>
<title>Kotlin for Android(六)</title>
<link href="http://willkernel.github.io/2018/03/24/Kotlin-for-Android-%E5%85%AD/"/>
<id>http://willkernel.github.io/2018/03/24/Kotlin-for-Android-六/</id>
<published>2018-03-24T05:45:00.000Z</published>
<updated>2018-03-25T03:48:57.586Z</updated>
<summary type="html">
<h4 id="Kotlin中的null安全"><a href="#Kotlin中的null安全" class="headerlink"
</summary>
<category term="Kotlin" scheme="http://willkernel.github.io/categories/Kotlin/"/>
<category term="Android" scheme="http://willkernel.github.io/tags/Android/"/>
<category term="Kotlin" scheme="http://willkernel.github.io/tags/Kotlin/"/>
</entry>
<entry>
<title>Kotlin for Android (五)</title>
<link href="http://willkernel.github.io/2018/03/24/Kotlin-for-Android-%E4%BA%94/"/>
<id>http://willkernel.github.io/2018/03/24/Kotlin-for-Android-五/</id>
<published>2018-03-23T17:18:00.000Z</published>
<updated>2018-04-03T01:56:24.193Z</updated>
<summary type="html">
<h4 id="创建SQLiteHelper"><a href="#创建SQLiteHelper" class="headerlink" title="创建SQLiteHelper"></a>创建SQLiteHelper</h4><p>一般使用SqliteOpenHelper
</summary>
<category term="Kotlin" scheme="http://willkernel.github.io/categories/Kotlin/"/>
<category term="Android" scheme="http://willkernel.github.io/tags/Android/"/>
<category term="Kotlin" scheme="http://willkernel.github.io/tags/Kotlin/"/>
</entry>
<entry>
<title>Kotlin for Android (四)</title>
<link href="http://willkernel.github.io/2018/03/23/kotlin-for-Android-%E5%9B%9B/"/>
<id>http://willkernel.github.io/2018/03/23/kotlin-for-Android-四/</id>
<published>2018-03-23T12:08:00.000Z</published>
<updated>2018-03-23T17:18:10.630Z</updated>
<summary type="html">
<h4 id="Application单例化和属性的Delegated"><a href="#Application单例化和属性的Delegated" class="headerlink"
</summary>
<category term="Kotlin" scheme="http://willkernel.github.io/categories/Kotlin/"/>
<category term="Android" scheme="http://willkernel.github.io/tags/Android/"/>
<category term="Kotlin" scheme="http://willkernel.github.io/tags/Kotlin/"/>
</entry>
<entry>
<title>Kotlin for Android (三)</title>
<link href="http://willkernel.github.io/2018/03/23/Kotlin-for-Android-%E4%B8%89/"/>
<id>http://willkernel.github.io/2018/03/23/Kotlin-for-Android-三/</id>
<published>2018-03-23T08:34:27.000Z</published>
<updated>2018-03-23T12:06:54.135Z</updated>
<summary type="html">
<h4 id="操作符"><a href="#操作符" class="headerlink" title="操作符"></a>操作符</h4><img
</summary>
</entry>
<entry>
<title>Kotlin for Android (二)</title>
<link href="http://willkernel.github.io/2018/03/23/Kotlin-for-Android-%E4%BA%8C/"/>
<id>http://willkernel.github.io/2018/03/23/Kotlin-for-Android-二/</id>
<published>2018-03-23T02:47:00.000Z</published>
<updated>2018-03-23T08:33:33.257Z</updated>
<summary type="html">
<h4 id="Anko"><a href="#Anko" class="headerlink" title="Anko"></a><a href="https://github.com/Kotlin/anko" target="_blank" rel="noopener">Anko</a></h4><ul>
<li>Anko Commons:一个轻量级的库,里面包含了intents,对话框,日志等帮助类</li>
<li>Anko Layouts:用于编写动态Android布局的快速且类型安全的方法</li>
<li>Anko SQLite:查询适用于Android SQLite的DSL和分析器集合</li>
<li>Anko Coroutines:基于kotlinx.coroutines库的实用程序</li>
<li>简化获取RecyclerView<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">val forecastList: RecyclerView = find(R.id.recyclerView)</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h4 id="扩展函数"><a href="#扩展函数" class="headerlink" title="扩展函数"></a>扩展函数</h4><p>扩展函数数是指在一个类上增加一种新的行为,甚至我们没有这个类代码的访问权<br>限。这是一个在缺少有用函数的类上扩展的方法。在Java中,通常会实现很多带有<br>static方法的工具类。Kotlin中扩展函数的一个优势是我们不需要在调用方法的时候<br>把整个对象当作参数传入。扩展函数表现得就像是属于这个类的一样,而且我们可<br>以使用 this 关键字和调用所有public方法<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">fun Context.toastF(message: CharSequence,duration: Int=Toast.LENGTH_SHORT)&#123;</span><br><span class="line"> Toast.makeText(this, &quot;$message&quot;, duration).show()</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<ul>
<li><p>Anko已经扩展toast函数,提供了CharSequence,(resource id)Int的函数</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">toast(R.string.app_name)</span><br><span class="line">longToast(&quot;longToast&quot;)</span><br></pre></td></tr></table></figure>
</li>
<li><p>扩展函数并不是真正地修改了原来的类,它是以静态导入的方式来实现的。扩展函数可以被声明在任何文件中,通用的实践是把一系列有关的函数放在一个新建的文件里</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">var TextView.text: CharSequence</span><br><span class="line"> get() = getText()</span><br><span class="line"> set(v) = setText(v)</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Kotlin" scheme="http://willkernel.github.io/categories/Kotlin/"/>
<category term="Android" scheme="http://willkernel.github.io/tags/Android/"/>
<category term="Kotlin" scheme="http://willkernel.github.io/tags/Kotlin/"/>
</entry>
<entry>
<title>Kotlin for Android (一)</title>
<link href="http://willkernel.github.io/2018/03/22/Kotlin-for-Android-%E4%B8%80/"/>
<id>http://willkernel.github.io/2018/03/22/Kotlin-for-Android-一/</id>
<published>2018-03-22T15:43:00.000Z</published>
<updated>2018-03-23T02:49:12.143Z</updated>
<summary type="html">
<h4 id="介绍Kotlin"><a href="#介绍Kotlin" class="headerlink" title="介绍Kotlin"></a>介绍Kotlin</h4><ul>
<li>编写代码量少</li>
<li>更加安全:Kotlin编译时期就处理了各种null的情况,避免了执行时异常。如果一个对象可以是null,则我们需要明确地指定它,然后在使用它之前检查它是否是null</li>
<li>它是函数式的:Kotlin是基于面向对象的语言,它使用了很多函数式编程的概念,比如,使用lambda表达式来更方便地解决问题。其中一个很棒的特性就是Collections的处理方式</li>
<li>它可以扩展函数:可以扩展类的更多的特性,甚至我们没有权限去访问这个类中的代码</li>
<li>它是高度互操作性的:你可以继续使用所有的你用Java写的代码和库,因为两个语言之间的互操作性是完美的。可以在一个项目中使用Kotlin和Java两种语言混合编程</li>
</ul>
<h4 id="特性"><a href="#特性" class="headerlink" title="特性"></a>特性</h4><h5 id="Expresiveness-可读性"><a href="#Expresiveness-可读性" class="headerlink" title="Expresiveness 可读性"></a>Expresiveness 可读性</h5><ul>
<li><p>POJO</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">public class Artist &#123;</span><br><span class="line">private long id;</span><br><span class="line">private String name;</span><br><span class="line">private String url;</span><br><span class="line">private String mbid;</span><br><span class="line">public long getId() &#123;</span><br><span class="line">return id;</span><br><span class="line">&#125;</span><br><span class="line">public void setId(long id) &#123;</span><br><span class="line">this.id = id;</span><br><span class="line">&#125;</span><br><span class="line">···</span><br></pre></td></tr></table></figure>
</li>
<li><p>Kotlin中创建数据类Artist.kt,自动生成所有属性和访问器</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">data class Artist(var id: Long, var name: String, var url: String, var mbid: String)</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h5 id="空安全"><a href="#空安全" class="headerlink" title="空安全"></a>空安全</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"> //编译不通过,非空类不能为null</span><br><span class="line"> var artist:Artist=null</span><br><span class="line"> </span><br><span class="line"> //安全调用操作符? 明确地指定一个对象是否能为空</span><br><span class="line"> var artist: Artist? = null</span><br><span class="line"> </span><br><span class="line">// 无法编译, artist可能是null,需要进行处理</span><br><span class="line">// artist.hashCode()</span><br><span class="line"></span><br><span class="line">//在artist!=null时调用</span><br><span class="line">artist?.hashCode()</span><br><span class="line"></span><br><span class="line">// 判空</span><br><span class="line">if(artist!=null)&#123;</span><br><span class="line"> artist.hashCode()</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">//给定在null时的替代者</span><br><span class="line">val name=artist?.name?:&quot;empty&quot;</span><br><span class="line"></span><br><span class="line">//确保artist不是null的情况下调用,否在抛异常KotlinNullPointerException</span><br><span class="line">artist!!.hashCode()</span><br></pre></td></tr></table></figure>
</summary>
<category term="Kotlin" scheme="http://willkernel.github.io/categories/Kotlin/"/>
<category term="Android" scheme="http://willkernel.github.io/tags/Android/"/>
<category term="Kotlin" scheme="http://willkernel.github.io/tags/Kotlin/"/>
</entry>
<entry>
<title>RxJava2</title>
<link href="http://willkernel.github.io/2018/03/20/RxJava2/"/>
<id>http://willkernel.github.io/2018/03/20/RxJava2/</id>
<published>2018-03-20T07:14:00.000Z</published>
<updated>2018-03-21T18:07:17.577Z</updated>
<summary type="html">
<h5 id="RxJava2"><a href="#RxJava2" class="headerlink" title="RxJava2"></a>RxJava2</h5><p>RxJava是Java VM响应式编程扩展的实现,扩展了观察者模式,通过操作符对数据事件流操作,来编写异步和基于事件的程序,从而不用关心同步,线程安全并发等问题</p>
<ul>
<li>app/build.gradle<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">implementation &apos;io.reactivex.rxjava2:rxjava:2.1.9&apos;</span><br><span class="line">implementation &apos;io.reactivex.rxjava2:rxandroid:2.0.2&apos;</span><br><span class="line"></span><br><span class="line">//retrofit</span><br><span class="line">implementation &apos;com.squareup.retrofit2:retrofit:2.3.0&apos;</span><br><span class="line">//Gson converter</span><br><span class="line">implementation &apos;com.squareup.retrofit2:converter-gson:2.3.0&apos;</span><br><span class="line">//RxJava2 Adapter</span><br><span class="line">implementation &apos;com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0&apos;</span><br><span class="line">//okhttp</span><br><span class="line">implementation &apos;com.squareup.okhttp3:okhttp:3.8.1&apos;</span><br><span class="line">implementation &apos;com.squareup.okhttp3:logging-interceptor:3.6.0&apos;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
<category term="RxJava2" scheme="http://willkernel.github.io/tags/RxJava2/"/>
</entry>
<entry>
<title>Data Binding</title>
<link href="http://willkernel.github.io/2018/03/16/Data-Binding/"/>
<id>http://willkernel.github.io/2018/03/16/Data-Binding/</id>
<published>2018-03-16T05:38:00.000Z</published>
<updated>2018-03-21T18:10:19.922Z</updated>
<summary type="html">
<h5 id="Data-Binding-Library"><a href="#Data-Binding-Library" class="headerlink" title="Data Binding Library"></a>Data Binding Library</h5><p>数据绑定库编写声明式布局,尽量减少绑定应用程序逻辑和布局所需的代码,减少布局绑定相关代码</p>
<ul>
<li><p>build environment</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">android&#123;</span><br><span class="line">...</span><br><span class="line"> dataBinding &#123;</span><br><span class="line"> enabled = true</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>Data Binding Compiler V2</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">android.databinding.enableV2=true</span><br><span class="line">向后不兼容</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
</entry>
<entry>
<title>Dagger</title>
<link href="http://willkernel.github.io/2018/03/13/Dagger/"/>
<id>http://willkernel.github.io/2018/03/13/Dagger/</id>
<published>2018-03-12T16:12:00.000Z</published>
<updated>2018-03-21T18:11:03.531Z</updated>
<summary type="html">
<h5 id="Dagger"><a href="#Dagger" class="headerlink" title="Dagger"></a>Dagger</h5><p>依赖注入(Dependency Injection),简称DI,又叫控制反转(Inversion of Control),简称IOC<br>当一个类的实例需要另一个类的实例,在传统的设计中,通常由调用者来创建被调用者的实例,然而依赖注入的方式,创建被调用者不再由调用者创建实例,创建被调用者的实例的工作由IOC容器来完成,然后注入到调用者。因此也被称为依赖注入</p>
<ul>
<li>API<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">public @interface Component &#123;</span><br><span class="line"> Class&lt;?&gt;[] modules() default &#123;&#125;;</span><br><span class="line"> Class&lt;?&gt;[] dependencies() default &#123;&#125;;</span><br><span class="line"> @Target(TYPE)</span><br><span class="line"> @Documented</span><br><span class="line"> @interface Builder &#123;&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public @interface Subcomponent &#123;</span><br><span class="line"> Class&lt;?&gt;[] modules() default &#123;&#125;;</span><br><span class="line"> @Target(TYPE)</span><br><span class="line"> @Documented</span><br><span class="line"> @interface Builder &#123;&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public @interface Module &#123;</span><br><span class="line"> Class&lt;?&gt;[] includes() default &#123;&#125;;</span><br><span class="line"> @Beta</span><br><span class="line"> Class&lt;?&gt;[] subcomponents() default &#123;&#125;;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public @interface Provides &#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public @interface MapKey &#123;</span><br><span class="line"> boolean unwrapValue() default true;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public interface Lazy&lt;T&gt; &#123;</span><br><span class="line"> T get();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
</entry>
<entry>
<title>ConstraintLayout</title>
<link href="http://willkernel.github.io/2018/03/10/ConstraintLayout/"/>
<id>http://willkernel.github.io/2018/03/10/ConstraintLayout/</id>
<published>2018-03-09T18:16:00.000Z</published>
<updated>2018-03-20T07:12:15.997Z</updated>
<summary type="html">
<ul>
<li><p>引入constraint-layout</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">allprojects &#123;</span><br><span class="line"> repositories &#123;</span><br><span class="line"> jcenter()</span><br><span class="line"> maven &#123;</span><br><span class="line"> url &apos;https://maven.google.com&apos;</span><br><span class="line"> &#125;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">compile &apos;com.android.support.constraint:constraint-layout:1.1.0-beta5&apos;</span><br></pre></td></tr></table></figure>
</li>
<li><p>属性</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">layout_constraintLeft_toLeftOf</span><br><span class="line">左对齐</span><br><span class="line">layout_constraintLeft_toRightOf</span><br><span class="line">左边和约束控件的右边对齐</span><br><span class="line">layout_constraintRight_toLeftOf</span><br><span class="line">右边在某组件的左边</span><br><span class="line">layout_constraintRight_toRightOf</span><br><span class="line">右边在某组件的右边</span><br><span class="line">layout_constraintTop_toTopOf</span><br><span class="line">上边和某组件的上边对其</span><br><span class="line">layout_constraintTop_toBottomOf</span><br><span class="line">上边在某组件的下边</span><br><span class="line">layout_constraintBottom_toTopOf</span><br><span class="line">下边在某组件的上边</span><br><span class="line">layout_constraintBottom_toBottomOf</span><br><span class="line">下边在某组件的下边</span><br><span class="line">layout_constraintBaseline_toBaselineOf</span><br><span class="line">组件的基线位置和某组件的基线位置对其(很少用)</span><br><span class="line">layout_constraintStart_toEndOf</span><br><span class="line">layout_constraintStart_toStartOf</span><br><span class="line">layout_constraintEnd_toStartOf</span><br><span class="line">layout_constraintEnd_toEndOf</span><br><span class="line">属性的值有两种,一种是同层级组件ID,还有就是parent,当值为parent时即是相对于父布局进行定位</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
</entry>
<entry>
<title>CoordinatorLayout</title>
<link href="http://willkernel.github.io/2018/03/09/CoordinatorLayout/"/>
<id>http://willkernel.github.io/2018/03/09/CoordinatorLayout/</id>
<published>2018-03-09T02:33:00.000Z</published>
<updated>2018-03-21T18:13:30.692Z</updated>
<summary type="html">
<h4 id="CoordinatorLayout"><a href="#CoordinatorLayout" class="headerlink" title="CoordinatorLayout"></a>CoordinatorLayout</h4><p>Material风格布局,包含在support Library中,结合AppbarLayout,CollapsingToolbarLayout等可达到MD设计风格布局</p>
<ul>
<li>build.gradle<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">def SUPPORT = &quot;26.1.0&quot;</span><br><span class="line">dependencies &#123;</span><br><span class="line"> implementation &apos;com.android.support:appcompat-v7:26.1.0&apos;</span><br><span class="line"> implementation &apos;com.android.support.constraint:constraint-layout:1.0.2&apos;</span><br><span class="line"> implementation &quot;com.android.support:design:$SUPPORT&quot;</span><br><span class="line"> implementation &quot;com.android.support:cardview-v7:$SUPPORT&quot;</span><br><span class="line"> implementation &quot;com.android.support:recyclerview-v7:$SUPPORT&quot;</span><br><span class="line"> implementation &apos;de.hdodenhof:circleimageview:1.3.0&apos;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</summary>
<category term="Android" scheme="http://willkernel.github.io/categories/Android/"/>
</entry>
<entry>
<title>Git</title>
<link href="http://willkernel.github.io/2018/03/09/Git/"/>
<id>http://willkernel.github.io/2018/03/09/Git/</id>
<published>2018-03-08T17:04:00.000Z</published>
<updated>2018-03-22T09:08:53.194Z</updated>
<summary type="html">
<h4 id="入门"><a href="#入门" class="headerlink" title="入门"></a>入门</h4><ul>
<li>.git 的隐藏目录是你的本地仓库(Local Repository)</li>
<li><code>git log</code> 查看历史 <img src="http://p4n1d4izv.bkt.clouddn.com/images/gitlog.png"></li>
<li><code>git log -p</code>查看详细历史</li>
<li><code>git log --stat</code> 查看简要统计</li>
<li><code>git show e66666/branch</code>查看指定commit,加文件名看指定文件</li>
<li><code>git diff --staged/--cached</code>查看当前工作目录与暂存区的不同,可以看到即将添加到暂存区的改动内容,<code>git diff HEAD</code>看到当前工作目录与上一个commit的不同<ul>
<li>commit 的 SHA-1 校验和<br><code>commit 8cf88cf35ce40cb91488e7d9b12cf46463fedc2f</code></li>
</ul>
</li>
<li><code>git status</code><img src="http://p4n1d4izv.bkt.clouddn.com/images/gitstatus.png">
</summary>
<category term="Git" scheme="http://willkernel.github.io/categories/Git/"/>
<category term="Git" scheme="http://willkernel.github.io/tags/Git/"/>
</entry>
</feed>