-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
653 lines (356 loc) · 21.8 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
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
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>xudshen's blog</title>
<meta name="author" content="Xudong Shen">
<meta property="og:site_name" content="xudshen's blog"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:image" content="undefined"/>
<link rel="apple-touch-icon" href="/icon.png" />
<link rel="shortcut icon" href="/favicon.png" >
<link rel="alternate" href="/atom.xml" title="xudshen's blog" type="application/atom+xml">
<link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="//ajax.useso.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<meta name="theme-color" content="#d00">
<link href="http://fonts.useso.com/css?family=Pacifico" rel="stylesheet" type="text/css">
</head>
<body>
<div id="content" class="inner">
<aside id="sidebar" class="alignleft">
<div class="navigationBar">
<a href="/">xudshen's blog</a>
</div>
<nav class="widget" id="menu">
<ul>
<li class="cell"><a class="next" href="/">Home</a><li>
<li class="cell"><a class="next" href="/archives/">Archives</a><li>
<li class="cell"><a class="next" href="/about/">About</a><li>
<li class="cell"><a class="next" href="/atom.xml">Subscribe</a><li>
</ul>
</nav>
<div class="widget tagcloud">
<h3 class="title">Tags</h3>
<div class="entry">
<a href="/tags/65K/" style="font-size: 10px;">65K</a> <a href="/tags/Android/" style="font-size: 15px;">Android</a> <a href="/tags/DataBinding/" style="font-size: 10px;">DataBinding</a> <a href="/tags/GreenDao/" style="font-size: 10px;">GreenDao</a> <a href="/tags/Gson/" style="font-size: 10px;">Gson</a> <a href="/tags/HTML/" style="font-size: 10px;">HTML</a> <a href="/tags/Homebrew/" style="font-size: 10px;">Homebrew</a> <a href="/tags/JS/" style="font-size: 10px;">JS</a> <a href="/tags/Java/" style="font-size: 10px;">Java</a> <a href="/tags/MQTT/" style="font-size: 10px;">MQTT</a> <a href="/tags/MVVM/" style="font-size: 10px;">MVVM</a> <a href="/tags/Multidex/" style="font-size: 10px;">Multidex</a> <a href="/tags/RxJava/" style="font-size: 10px;">RxJava</a> <a href="/tags/RxMqtt/" style="font-size: 10px;">RxMqtt</a> <a href="/tags/Spring-MVC/" style="font-size: 10px;">Spring MVC</a> <a href="/tags/VPS/" style="font-size: 10px;">VPS</a> <a href="/tags/WinRT/" style="font-size: 15px;">WinRT</a> <a href="/tags/Xcode/" style="font-size: 10px;">Xcode</a> <a href="/tags/Yosemite/" style="font-size: 10px;">Yosemite</a> <a href="/tags/安全/" style="font-size: 10px;">安全</a> <a href="/tags/日常/" style="font-size: 20px;">日常</a> <a href="/tags/视差滚动/" style="font-size: 10px;">视差滚动</a> <a href="/tags/设计/" style="font-size: 15px;">设计</a> <a href="/tags/软工/" style="font-size: 10px;">软工</a> <a href="/tags/音乐/" style="font-size: 10px;">音乐</a>
</div>
</div>
<nav class="widget" id="menu">
<ul>
<li class="cell"><a class="next" href="//t.xudshen.info">Gallery</a><li>
</ul>
</nav>
<div class="widget search">
<form accept-charset="utf-8">
<input id="st-search-input" type="text" name="q" placeholder="Search">
</form>
</div>
<script type="text/javascript">
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
})(window,document,'script','//s.swiftypecdn.com/install/v1/st.js','_st');
_st('install','XEKS2jHDgy4uUCKWmcLA');
</script>
<footer id="footer" class="inner"><div class="copyright">
© 2016 Xudong Shen
</div>
<div style="position:relative; bottom: 23px">
<script src="http://s95.cnzz.com/stat.php?id=1253420162&web_id=1253420162&show=pic1" language="JavaScript">
</script>
</div>
</footer>
</aside>
<div id="hidden-navigationBar" class="navigationBar">
<a href="/">xudshen's blog</a>
</div>
<div id="main-col" class="alignright">
<div id="wrapper">
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2016/03/07/introducing-droiddata/">Introducing DroidData (Preliminary)</a></h1>
<time datetime="2016-03-07T07:34:24.000Z"><a href="/2016/03/07/introducing-droiddata/">2016-03-07</a></time>
</header>
<div class="entry">
<p>There are already lots of discussions about the architecture of a quality android application, such as <a href="https://github.com/pedrovgs/EffectiveAndroidUI/">EffectiveAndroidUI</a>, <a href="http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/">Android-CleanArchitecture</a>, which use some common patterns like MVC, MVP or MVVM. However, what we are going to talk about in this post is not which one of these architectures is the best, but some kind solution while implementing these architectures.</p>
</div>
<footer>
<div class="alignleft">
<a href="/2016/03/07/introducing-droiddata/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/11/12/list-all-classes-after-multidex/">List All Classes after Multidex</a></h1>
<time datetime="2014-11-12T11:02:29.000Z"><a href="/2014/11/12/list-all-classes-after-multidex/">2014-11-12</a></time>
</header>
<div class="entry">
<h2 id="Intro"><a href="#Intro" class="headerlink" title="Intro"></a>Intro</h2><p>Google recently posted an <a href="http://developer.android.com/tools/building/multidex.html">article</a> to solve the <code>65K Reference Limit</code> problem.<br>It is such a relief that we will not need to worry about the following errors any more.</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></pre></td><td class="code"><pre><span class="line">Conversion to Dalvik format failed:</span><br><span class="line">Unable to execute dex: method ID not in [<span class="number">0</span>, <span class="number">0xffff</span>]: <span class="number">65536</span></span><br><span class="line"><span class="comment">//--or--</span></span><br><span class="line">trouble writing output:</span><br><span class="line">Too many field references: <span class="number">131000</span>; max is <span class="number">65536</span>.</span><br><span class="line">You may <span class="keyword">try</span> using --multi-dex option.</span><br></pre></td></tr></table></figure>
<h2 id="Problem"><a href="#Problem" class="headerlink" title="Problem"></a>Problem</h2><p>After configuring multidex in the module, some projects may encounter the loss of part of the the classes when using reflection to list all the classes in the apk.<br>The usual code may like this:</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></pre></td><td class="code"><pre><span class="line"><span class="comment">//get the apk path</span></span><br><span class="line">String path = context.getPackageManager().getApplicationInfo(context.getPackageName(), <span class="number">0</span>).sourceDir;</span><br><span class="line"><span class="comment">//use DexFile the unzip the apk, find the *classes.dex* in the apk</span></span><br><span class="line">DexFile dexfile = <span class="keyword">new</span> DexFile(path);</span><br><span class="line"><span class="comment">//get all the classes in this dex</span></span><br><span class="line">Enumeration<String> dexEntries = dexfile.entries();</span><br><span class="line"><span class="keyword">while</span> (dexEntries.hasMoreElements()) {</span><br><span class="line"> classNames.add(dexEntries.nextElement());</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
</div>
<footer>
<div class="alignleft">
<a href="/2014/11/12/list-all-classes-after-multidex/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/10/21/good-music-awsome/">令人惊叹的电音</a></h1>
<time datetime="2014-10-21T10:50:28.000Z"><a href="/2014/10/21/good-music-awsome/">2014-10-21</a></time>
</header>
<div class="entry">
<blockquote><p>不是摇滚,而是电音。<br>不是躁杂,而是节奏。<br>生命和心脏一起律动,<br>思维完全沉浸入音乐中,<br>是未来,是科学,是电子,是光,是电,是宇宙的文明在歌唱。</p>
</blockquote>
<p>闹了好久的音乐荒,今天终于发现了新大陆。</p>
</div>
<footer>
<div class="alignleft">
<a href="/2014/10/21/good-music-awsome/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/10/18/fix-package-with-Yosemite-update/">Yosemite:安装和修复开发环境</a></h1>
<time datetime="2014-10-18T03:10:52.000Z"><a href="/2014/10/18/fix-package-with-Yosemite-update/">2014-10-18</a></time>
</header>
<div class="entry">
<p>OS X Yosemite昨天如期而至,更新自不待说。有了上次升级OS X Yosemite Beta失败的经验,这次在按下那个大大的<code>继续</code>之前,先用Time Machine做了一个备份。</p>
<p>等待的过程尤其漫长,论坛上看到很多人都卡在<a href="http://www.v2ex.com/t/139538">大约剩余2分钟</a>。我倒是没有出现这种情况,我只是卡在<a href="http://www.v2ex.com/t/139538">大约剩余1分钟</a>而已(._.)。在安装界面使用<code>CMD</code>+<code>L</code>可以看到系统在不断拷贝<code>texlive</code>的文件,也算是蛮拼的了。</p>
<p>大约一个半小时后,锵锵,全新的OS X长这样。 </p>
<p><img src="/2014/10/18/fix-package-with-Yosemite-update/osx.jpg" alt="OS X Yosemite"></p>
<p>然后就是修复我的开发环境,毕竟还要靠它赚钱吃饭呐。</p>
</div>
<footer>
<div class="alignleft">
<a href="/2014/10/18/fix-package-with-Yosemite-update/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/10/15/securing-vps-with-iptables/">Bandwagon 被黑小记</a></h1>
<time datetime="2014-10-15T14:33:02.000Z"><a href="/2014/10/15/securing-vps-with-iptables/">2014-10-15</a></time>
</header>
<div class="entry">
<p>最近使用Azure和Bandwagon搭建了一个APNP梯子,顺畅无比。可惜好景不长,昨天下午突然就不能用了,心想不会那么快没流量吧。结果登上KiviVM一看,我的VPS居然被Suspend了,原因是Spam Email,顿时感到不妙,花了个擦,我的小梯子居然成了肉鸡?</p>
</div>
<footer>
<div class="alignleft">
<a href="/2014/10/15/securing-vps-with-iptables/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/08/13/parallax-scrolling-start/">视差滚动:初探</a></h1>
<time datetime="2014-08-13T10:21:00.000Z"><a href="/2014/08/13/parallax-scrolling-start/">2014-08-13</a></time>
</header>
<div class="entry">
<p><a href="http://en.wikipedia.org/wiki/Parallax_scrolling#Parallax_scrolling_in_Web_design" target="_blank" rel="external">视差滚动</a>已经火了很久了,但一直没有空去尝试。</p>
<p>下面是利用<code>$(window).scroll</code>来控制<code>div</code>位置的尝试,重点在于各种高度的计算。</p>
<iframe scrolling="no" width="100%" height="300" src="http://jsfiddle.net/n3e50sze/embedded/result,js,html,css/light" frameborder="0" allowfullscreen></iframe>
<p style="margin-bottom: 20px"></p>
</div>
<footer>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/07/21/rxmqtt-rxjava-with-mqtt/">RxMqtt:Reactive Extensions for the Mqtt</a></h1>
<time datetime="2014-07-21T06:30:48.000Z"><a href="/2014/07/21/rxmqtt-rxjava-with-mqtt/">2014-07-21</a></time>
</header>
<div class="entry">
<p style="margin-bottom: 20px"></p>
</div>
<footer>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2014/07/14/gson-with-spring-mvc/">Gson在Spring MVC中的使用</a></h1>
<time datetime="2014-07-14T11:14:13.000Z"><a href="/2014/07/14/gson-with-spring-mvc/">2014-07-14</a></time>
</header>
<div class="entry">
<p>最近在用Spring MVC搭建一套Restful API,整个过程的最后一步就是数据序列化。Spring MVC默认使用<a href="http://jackson.codehaus.org">Jackson</a>,但在使用过程中并不如想象中的顺手。因而尝试转向<a href="https://code.google.com/p/google-gson/">Gson</a>。</p>
<p>Gson是Google出品的用来进行Java Object和JSON转换的类库。有人曾对Gson和Jackson的性能做过<a href="http://tuhrig.de/jaxb-vs-gson-and-jackson/">比较</a>,Gson在读取和写入方面的速度都要逊于Jackson。不过现前并不需要在性能上作过多要求,容易上手和提高开发效率才是这个项目的重中之重。</p>
<h1 id="基本"><a href="#基本" class="headerlink" title="基本"></a>基本</h1><p>使用Gson来反序列化JSON十分简单,如下:</p>
<figure class="highlight java"><figcaption><span>User</span></figcaption><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></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">User</span></span>{</span><br><span class="line"> <span class="keyword">private</span> String name;</span><br><span class="line"> <span class="keyword">private</span> String password;</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="title">User</span><span class="params">(String name, String password)</span></span>{...}</span><br><span class="line"> ...</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<figure class="highlight java"><figcaption><span>Gson反序列化User</span></figcaption><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></pre></td><td class="code"><pre><span class="line">Gson gson = <span class="keyword">new</span> Gson();</span><br><span class="line">gson.toJson(<span class="keyword">new</span> User(<span class="string">"hello"</span>, <span class="string">"world"</span>), User.class);</span><br><span class="line"></span><br><span class="line"><span class="comment">// Result:</span></span><br><span class="line"><span class="comment">// {"name": "hello", "password": "world"}</span></span><br></pre></td></tr></table></figure>
<p>但Gson的优点不仅仅在于这点,而是在自定义序列化方面。<br>
</div>
<footer>
<div class="alignleft">
<a href="/2014/07/14/gson-with-spring-mvc/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2013/06/08/why-are-button-list-the-basic-ui-control/">[知乎]答:为什么现在的 GUI 设计仍跳不出 button、list、icon,没有这些元素的 GUI 会是什么样子?</a></h1>
<time datetime="2013-06-07T16:48:00.000Z"><a href="/2013/06/08/why-are-button-list-the-basic-ui-control/">2013-06-08</a></time>
</header>
<div class="entry">
<p>此为知乎上的一个提问,<a href="http://www.zhihu.com/question/20269253">原文在这里</a>。</p>
<p>button,list等作为一些基础控件,从较高的层面讲,他们阐释了<strong>基本的交互语言,从而实现界面交互</strong>;就像在研究素描时,大多也就可以由三角形、圆形、矩形等构成(图一)。</p>
<p><img src="/2013/06/08/why-are-button-list-the-basic-ui-control/sketch.jpg" alt="图一:素描"></p>
</div>
<footer>
<div class="alignleft">
<a href="/2013/06/08/why-are-button-list-the-basic-ui-control/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content" data-swiftype-index='true'>
<header>
<h1 class="title"><a href="/2013/04/19/se-api-define/">软工_API定义</a></h1>
<time datetime="2013-04-19T02:12:00.000Z"><a href="/2013/04/19/se-api-define/">2013-04-19</a></time>
</header>
<div class="entry">
<p>软件工程课程项目API</p>
<p>为了进行更好的分工合作,将API罗列如下…</p>
</div>
<footer>
<div class="alignleft">
<a href="/2013/04/19/se-api-define/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<nav id="pagination">
<a href="/page/2/" class="alignright next">Next</a>
</nav></div>
</div>
<div class="tabbar" onload="divideTabBar()">
<div class="tabbaritem"><a class="next" href="/">Home</a></div>
<div class="tabbaritem"><a class="next" href="/archives/">Archives</a></div>
<div class="tabbaritem"><a class="next" href="/about/">About</a></div>
<div class="tabbaritem"><a class="next" href="/atom.xml">Subscribe</a></div>
</div>
</div>
</body>
</html>