-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathandroid-design-pattern-singleton.html
599 lines (388 loc) · 31 KB
/
android-design-pattern-singleton.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
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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
<!DOCTYPE html>
<html lang="en">
<!-- Head tag -->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
<meta name="baidu-site-verification" content="093lY4ziMu" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="一个有内涵的技术分享平台">
<meta name="keyword" content="meizu,kernel,魅族">
<link rel="shortcut icon" href="/img/ironman-draw.png">
<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
<!--<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>-->
<title>
Android 中的设计模式 —— 单例模式 - 魅族内核团队
</title>
<link rel="canonical" href="https://kernel.meizu.com//./android-design-pattern-singleton.html">
<!-- Bootstrap Core CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="../css/dusign-light.css">
<link rel="stylesheet" href="../css/dusign-common-light.css">
<link rel="stylesheet" href="../css/font-awesome.css">
<link rel="stylesheet" href="../css/toc.css">
<!-- background effects end -->
<!-- Pygments Highlight CSS -->
<link rel="stylesheet" href="../css/highlight.css">
<link rel="stylesheet" href="../css/widget.css">
<link rel="stylesheet" href="../css/rocket.css">
<link rel="stylesheet" href="../css/signature.css">
<link rel="stylesheet" href="../css/fonts.googleapis.css">
<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
<!-- photography -->
<link rel="stylesheet" href="../css/photography.css">
<!-- ga & ba script hoook -->
<script></script>
<meta name="generator" content="Hexo 7.3.0"></head>
<!-- hack iOS CSS :active style -->
<body ontouchstart="">
<!-- background effects start -->
<!-- background effects end -->
<!-- Modified by Yu-Hsuan Yen -->
<!-- Post Header -->
<style type="text/css">
header.intro-header{
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('')
/*post*/
}
</style>
<header class="intro-header" >
<!-- Signature -->
<div id="signature">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-heading">
<div class="tags">
<a class="tag" href="/tags/#Android" title="Android">Android</a>
<a class="tag" href="/tags/#Framework" title="Framework">Framework</a>
<a class="tag" href="/tags/#设计模式" title="设计模式">设计模式</a>
<a class="tag" href="/tags/#Singleton" title="Singleton">Singleton</a>
</div>
<h1>Android 中的设计模式 —— 单例模式</h1>
<h2 class="subheading"></h2>
<span class="meta">
Posted by Zhang Xing on
2016-09-19
</span>
</div>
</div>
</div>
</div>
</div>
<div class="waveWrapper">
<div class="wave wave_before" style="background-image: url('/img/wave-light.png')"></div>
<div class="wave wave_after" style="background-image: url('/img/wave-light.png')"></div>
</div>
</header>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">魅族内核团队</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<!-- Known Issue, found by Hux:
<nav>'s height woule be hold on by its content.
so, when navbar scale out, the <nav> will cover tags.
also mask any touch event of tags, unfortunately.
-->
<div id="huxblog_navbar">
<div class="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/about/">About</a>
</li>
<li>
<a href="/archive/">Archives</a>
</li>
<li>
<a href="/categories/">Categories</a>
</li>
<li>
<a href="/tags/">Tags</a>
</li>
</ul>
</div>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<script>
// Drop Bootstarp low-performance Navbar
// Use customize navbar with high-quality material design animation
// in high-perf jank-free CSS3 implementation
var $body = document.body;
var $toggle = document.querySelector('.navbar-toggle');
var $navbar = document.querySelector('#huxblog_navbar');
var $collapse = document.querySelector('.navbar-collapse');
$toggle.addEventListener('click', handleMagic)
function handleMagic(e){
if ($navbar.className.indexOf('in') > 0) {
// CLOSE
$navbar.className = " ";
// wait until animation end.
setTimeout(function(){
// prevent frequently toggle
if($navbar.className.indexOf('in') < 0) {
$collapse.style.height = "0px"
}
},400)
}else{
// OPEN
$collapse.style.height = "auto"
$navbar.className += " in";
}
}
</script>
<!-- Main Content -->
<!-- Post Content -->
<article>
<div class="container">
<div class="row">
<!-- Post Container -->
<div class="
col-lg-8 col-lg-offset-2
col-md-10 col-md-offset-1
post-container">
<h2 id="设计模式简介"><a href="#设计模式简介" class="headerlink" title="设计模式简介"></a>设计模式简介</h2><p>当我们讨论设计模式的时候,其实我们在讨论面向对象的设计问题。</p>
<p>软件设计中很多问题都会一次又一次的重复出现,而经过一定的总结之后会有一些优秀的解法沉淀下来,可以用于以后出现的类似问题,我们把这些解法叫做设计模式。</p>
<p>软件的生命周期决定了其设计要尽可能地面对(需求)改变,所以在开发和维护过程中,面临的较大问题,除了解决问题的关键点,另一个就是解决需求变更和扩展所带来的代码结构变化问题。而设计模式刚好可以让我们的设计更加灵活,在解决问题的基础上,也使得后期的功能扩展对原有结构的影响尽可能小。</p>
<p><strong>推荐书籍:</strong></p>
<ol>
<li>[ 设计模式:可复用面向对象软件的基础 ] <a href="http://item.jd.com/10057319.html" title=" 设计模式:可复用面向对象软件的基础 "> 推荐书籍 1</a></li>
<li>[Head First 设计模式 ] <a href="http://item.jd.com/10100236.html" title="Head First 设计模式 "> 推荐书籍 2</a></li>
</ol>
<h2 id="面向对象软件设计原则"><a href="#面向对象软件设计原则" class="headerlink" title="面向对象软件设计原则"></a>面向对象软件设计原则</h2><p>[《Head First 设计模式》] <a href="http://item.jd.com/10100236.html" title="Head First 设计模式 "> 推荐书籍 2</a> 一书里面提炼了很多 OO 设计的原则,在这里分析其中的一些。</p>
<ol>
<li><strong>找出需求中“可能变化”之处,把它们独立出来。</strong> 这样,新需求对原架构的影响就会减小很多。这个是程序设计最基本的原则,也可以说成,让每次的变化,尽可能地影响最少的代码。</li>
<li><strong>针对接口编程,而不是针对实现编程。</strong> 这里的接口,可以是 Interface,也可以是 base class,最关键的是,当行为改变时,对使用该接口的地方来讲是透明的。也就是说,要有效利用多态的特性。</li>
<li><strong>多用组合、少用继承。</strong> 为什么要少用继承?个人的理解是,继承都需要用在能表现多态的地方。</li>
<li><strong>为了交互对象之间的松耦合设计而努力。</strong> 这个好像不用解释。</li>
<li><strong>要依赖抽象,不要依赖具体类。</strong> 一旦依赖了具体类,就没办法低耦合了。</li>
<li><strong>一个类只应该有一个引起变化的原因。</strong> 这是我们奋斗的目标,但是有时候需要综合其他的原则一起考虑。</li>
</ol>
<p>还有一些其他原则,有待在实践中不断深化,这里不一一列举了。</p>
<h2 id="设计模式举例"><a href="#设计模式举例" class="headerlink" title="设计模式举例"></a>设计模式举例</h2><h3 id="单例模式"><a href="#单例模式" class="headerlink" title="单例模式"></a>单例模式</h3><p>单例模式应该是最简单的一个模式,因为它不涉及和其他类交互的问题。但是写好单例模式并不容易,特别是在多线程环境下,单例模式有时候并不好写。</p>
<p>当确定系统只需要某个对象的唯一实例时,就需要使用单例模式。</p>
<p>先看看关系图如下:</p>
<p><img src="http://i.imgur.com/qAjcNLz.jpg" alt=" 单例模式 UML 类图 "></p>
<p>最简单的写法就是只提供一个 private 的构造方法,一个 static 的对象和获取这个对象的函数,如下所示:</p>
<figure class="highlight csharp"><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"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title">Singleton</span>{</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">static</span> Singleton singleton = <span class="literal">null</span>;</span><br><span class="line"> <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span>()</span>{}</span><br><span class="line"> <span class="function"><span class="keyword">public</span> Singleton <span class="title">getInstance</span>()</span>{</span><br><span class="line"> <span class="keyword">if</span>(singleton == <span class="literal">null</span>){</span><br><span class="line"> singleton = <span class="keyword">new</span> Singleton();</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> singleton;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>不过这种写法即使是在笔试的时候,也的不了多少分的。</p>
<h4 id="实际应用举例"><a href="#实际应用举例" class="headerlink" title="实际应用举例"></a>实际应用举例</h4><p>一个比较过关的写法是考虑多线程的情况下能够正常运行,并且尽可能推迟生成实例(在生成实例代价较大的情况下比较有用)。以下是一个具体的场景:要根据手机屏幕的亮灭来控制手机 LED 灯的亮灭,这样可以在无屏幕的状态下根据 LED 的情况判断手机是否处于开机状态。</p>
<p>因为 Framework 中 <code>DisplayPowerState</code> 这个类有在 <code>PowerManagerService</code> 里面更新屏幕的状态,如果不用单例模式,会出现生成多个控制 LED 灯的对象,导致 LED 在指定状态下是一闪一闪的状态,无法达到指定需求。所以考虑使用单例模式来写 LED 对象。</p>
<figure class="highlight java"><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></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> <span class="title class_">LightHandler</span> <span class="keyword">extends</span> <span class="title class_">Handler</span>{</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">Object</span> <span class="variable">mLock</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Object</span>();</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">volatile</span> <span class="keyword">static</span> <span class="type">LightHandler</span> <span class="variable">mlightHandler</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line"> <span class="keyword">private</span> <span class="title function_">LightHandler</span><span class="params">()</span>{</span><br><span class="line"> <span class="built_in">super</span>();</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">private</span> <span class="title function_">LightHandler</span><span class="params">(Looper looper)</span>{</span><br><span class="line"> <span class="built_in">super</span>(looper);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> LightHandler <span class="title function_">getInstance</span><span class="params">(Looper looper)</span>{</span><br><span class="line"> <span class="keyword">if</span>(mlightHandler == <span class="literal">null</span>){</span><br><span class="line"> <span class="keyword">synchronized</span>(mLock){</span><br><span class="line"> <span class="keyword">if</span>(mlightHandler == <span class="literal">null</span>)</span><br><span class="line"> mlightHandler = <span class="keyword">new</span> <span class="title class_">LightHandler</span>(looper);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> mlightHandler;</span><br><span class="line"> }</span><br><span class="line"> ...</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>考虑目前的 Android 版本使用的 java 都在 1.6 以上,所以 <code>volatile</code> 关键字可以有效使用。实测该方法可以有效控制 LED 灯不再闪烁。</p>
<h4 id="Framework-层代码使用单例模式的例子"><a href="#Framework-层代码使用单例模式的例子" class="headerlink" title="Framework 层代码使用单例模式的例子"></a>Framework 层代码使用单例模式的例子</h4><p>github 上有一个很完整的例子:<a href="https://github.com/simple-Android-framework/android_design_patterns_analysis/tree/master/singleton/mr.simple" title="Framework 中的单例模式 ">Framework 中的单例模式</a></p>
<p>这个例子里面解释了 <code>LayoutInflater</code> 使用单例的情况,写得非常详细。里面也提到了 Framework 层的很多 Serivce 都是单例模式,那这里就去看看源代码吧。</p>
<p><code>.frameworks/base/core/java/com/Android/server/LocalServices.java</code> 这个文件就是典型的例子。</p>
<figure class="highlight typescript"><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"><span class="keyword">import</span> android.<span class="property">util</span>.<span class="property">ArrayMap</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> final <span class="keyword">class</span> <span class="title class_">LocalServices</span> {</span><br><span class="line"> <span class="keyword">private</span> <span class="title class_">LocalServices</span>() {}</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">static</span> final <span class="title class_">ArrayMap</span><<span class="title class_">Class</span><?>, <span class="title class_">Object</span>> sLocalServiceObjects =</span><br><span class="line"> <span class="keyword">new</span> <span class="title class_">ArrayMap</span><<span class="title class_">Class</span><?>, <span class="title class_">Object</span>>();</span><br><span class="line"></span><br><span class="line"> <span class="meta">@SuppressWarnings</span>(<span class="string">"unchecked"</span>)</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <T> T <span class="title function_">getService</span>(<span class="params"><span class="title class_">Class</span><T> <span class="keyword">type</span></span>) {</span><br><span class="line"> <span class="title function_">synchronized</span> (sLocalServiceObjects) {</span><br><span class="line"> <span class="keyword">return</span> (T) sLocalServiceObjects.<span class="title function_">get</span>(<span class="keyword">type</span>);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <T> <span class="built_in">void</span> <span class="title function_">addService</span>(<span class="params"><span class="title class_">Class</span><T> <span class="keyword">type</span>, T service</span>) {</span><br><span class="line"> <span class="title function_">synchronized</span> (sLocalServiceObjects) {</span><br><span class="line"> <span class="keyword">if</span> (sLocalServiceObjects.<span class="title function_">containsKey</span>(<span class="keyword">type</span>)) {</span><br><span class="line"> <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">IllegalStateException</span>(<span class="string">"Overriding service registration"</span>);</span><br><span class="line"> }</span><br><span class="line"> sLocalServiceObjects.<span class="title function_">put</span>(<span class="keyword">type</span>, service);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>每次添加 Service 的时候,都是往 <code>ArrayMap</code> 里面添加一个 <code>key-value</code> 对,通过控制这个数据结构来达到单例的要求。所有的 <code>LoacalServices</code> 在系统中都保持只有一个实例,需要用到的时候,使用 <code>getService()</code> 函数获取即可。可以看到以下一些使用的例子:</p>
<figure class="highlight gradle"><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">.<span class="regexp">/services/</span>core<span class="regexp">/java/</span>com<span class="regexp">/android/</span>server/VibratorService.java:<span class="number">230</span>: mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.<span class="keyword">class</span>);</span><br><span class="line">.<span class="regexp">/services/</span>core<span class="regexp">/java/</span>com<span class="regexp">/android/</span>server<span class="regexp">/power/</span>Notifier.java:<span class="number">141</span>: mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.<span class="keyword">class</span>);</span><br><span class="line">.<span class="regexp">/services/</span>core<span class="regexp">/java/</span>com<span class="regexp">/android/</span>server/SystemService.java:<span class="number">197</span>: <span class="keyword">return</span> LocalServices.getService(SystemServiceManager.<span class="keyword">class</span>);</span><br></pre></td></tr></table></figure>
<p>这些都是需要使用 <code>LoacalServices</code> 的例子。</p>
<hr>
<!-- Pager -->
<ul class="pager">
<li class="previous">
<a href="//configure-jenkins-guide.html" data-toggle="tooltip" data-placement="top" title=" 搭建 Jenkins 服务指南 ">← Previous Post</a>
</li>
<li class="next">
<a href="//android-m-external-storage.html" data-toggle="tooltip" data-placement="top" title="Android M 外部存储剖析 ">Next Post →</a>
</li>
</ul>
<!-- tip start -->
<div class="comment_notes">
<p>
This is copyright.
</p>
</div>
<!-- tip end -->
<!-- Music start-->
<!-- Music end -->
<!-- Sharing -->
<div class="social-share" data-wechat-qrcode-helper="" align="center"></div>
<!-- css & js -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js"></script>
<!-- Sharing -->
<!-- gitment start -->
<!-- gitment end -->
<!-- 来必力City版安装代码 -->
<!-- City版安装代码已完成 -->
<!-- disqus comment start -->
<!-- disqus comment end -->
</div>
<!-- Tabe of Content -->
<!-- Table of Contents -->
<!-- Sidebar Container -->
<div class="
col-lg-8 col-lg-offset-2
col-md-10 col-md-offset-1
sidebar-container">
<!-- Featured Tags -->
<section>
<!-- no hr -->
<h5><a href="/tags/">FEATURED TAGS</a></h5>
<div class="tags">
<a class="tag" href="/tags/#Android" title="Android">Android</a>
<a class="tag" href="/tags/#Framework" title="Framework">Framework</a>
<a class="tag" href="/tags/#设计模式" title="设计模式">设计模式</a>
<a class="tag" href="/tags/#Singleton" title="Singleton">Singleton</a>
</div>
</section>
<!-- Friends Blog -->
<hr>
<h5>FRIENDS</h5>
<ul class="list-inline">
<li><a href="#" target="_blank">Other</a></li>
</ul>
</div>
</div>
</div>
</article>
<!-- async load function -->
<script>
function async(u, c) {
var d = document, t = 'script',
o = d.createElement(t),
s = d.getElementsByTagName(t)[0];
o.src = u;
if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
s.parentNode.insertBefore(o, s);
}
</script>
<!-- anchor-js, Doc:http://bryanbraun.github.io/anchorjs/ -->
<script>
async("https://cdn.bootcss.com/anchor-js/1.1.1/anchor.min.js",function(){
anchors.options = {
visible: 'hover',
placement: 'left',
icon: 'ℬ'
};
anchors.add().remove('.intro-header h1').remove('.subheading').remove('.sidebar-container h5');
})
</script>
<style type="text/css">
/* place left on bigger screen */
@media all and (min-width: 800px) {
.anchorjs-link{
position: absolute;
left: -0.75em;
font-size: 1.1em;
margin-top : -0.1em;
}
}
</style>
<!-- Footer -->
<!-- Footer -->
<footer>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<ul class="list-inline text-center">
</ul>
<p class="copyright text-muted">
Copyright © meizu 2024
<br>
Powered by
<a href="https://github.com/dusign/hexo-theme-snail">
<i>hexo-theme-snail</i>
</a> |
<iframe name="star" style="margin-left: 2px; margin-bottom:-5px;" frameborder="0" scrolling="0"
width="100px" height="20px"
src="https://ghbtns.com/github-btn.html?user=dusign&repo=hexo-theme-snail&type=star&count=true">
</iframe>
</p>
</div>
</div>
</div>
</footer>
<!-- jQuery -->
<script src="../js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="../js/bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="../js/hux-blog.min.js"></script>
<!-- Search -->
<script src="../js/search.js"></script>
<!-- async load function -->
<script>
function async(u, c) {
var d = document, t = 'script',
o = d.createElement(t),
s = d.getElementsByTagName(t)[0];
o.src = u;
if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
s.parentNode.insertBefore(o, s);
}
</script>
<!-- jquery.tagcloud.js -->
<script>
// only load tagcloud.js in tag.html
if($('#tag_cloud').length !== 0){
async("https://kernel.meizu.com/js/jquery.tagcloud.js",function(){
$.fn.tagcloud.defaults = {
//size: {start: 1, end: 1, unit: 'em'},
color: {start: '#bbbbee', end: '#0085a1'},
};
$('#tag_cloud a').tagcloud();
})
}
</script>
<!--fastClick.js -->
<script>
async("https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js", function(){
var $nav = document.querySelector("nav");
if($nav) FastClick.attach($nav);
})
</script>
<!-- Google Analytics -->
<script>
// dynamic User by Hux
var _gaId = 'UA-XXXXXXXX-X';
var _gaDomain = 'yoursite';
// Originial
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', _gaId, _gaDomain);
ga('send', 'pageview');
</script>
<!-- Baidu Tongji -->
<!-- Search -->
<script type="text/javascript">
var search_path = "search.xml";
if (search_path.length == 0) {
search_path = "search.xml";
}
var path = "/" + search_path;
searchFunc(path, 'local-search-input', 'local-search-result');
</script>
<!-- busuanzi -->
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<a id="rocket" href="#top" class=""></a>
<script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
<script type="text/javascript" src="/js/toc.js?v=1.0.0" async=""></script>
<!-- background effects line -->
<script type="text/javascript" src="/js/mouse-click.js" content='["🌱","just do it","🍀"]' color='["rgb(121,93,179)" ,"rgb(76,180,231)" ,"rgb(184,90,154)"]'></script>
<!-- background effects end -->
<!--<script size="50" alpha='0.3' zIndex="-999" src="/js/ribbonStatic.js"></script>-->
<script src="/js/ribbonDynamic.js"></script>
</body>
</html>