-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
159 lines (118 loc) · 9.3 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<!-- Begin Jekyll SEO tag v2.4.0 -->
<title>Ban | 【Kotlin + MVP + OkHttp + Retrofit】This city is too lonely, we need a friend.</title>
<meta name="generator" content="Jekyll v3.7.3" />
<meta property="og:title" content="Ban" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="【Kotlin + MVP + OkHttp + Retrofit】This city is too lonely, we need a friend." />
<meta property="og:description" content="【Kotlin + MVP + OkHttp + Retrofit】This city is too lonely, we need a friend." />
<link rel="canonical" href="https://chenbingx.github.io/Ban/" />
<meta property="og:url" content="https://chenbingx.github.io/Ban/" />
<meta property="og:site_name" content="Ban" />
<script type="application/ld+json">
{"name":"Ban","description":"【Kotlin + MVP + OkHttp + Retrofit】This city is too lonely, we need a friend.","@type":"WebSite","url":"https://chenbingx.github.io/Ban/","headline":"Ban","@context":"http://schema.org"}</script>
<!-- End Jekyll SEO tag -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#157878">
<link rel="stylesheet" href="/Ban/assets/css/style.css?v=d6b5ec6c34750e8a153869dba9a346dcaaf23bd3">
</head>
<body>
<section class="page-header">
<h1 class="project-name">Ban</h1>
<h2 class="project-tagline">【Kotlin + MVP + OkHttp + Retrofit】This city is too lonely, we need a friend.</h2>
<a href="https://github.com/chenBingX/Ban" class="btn">View on GitHub</a>
</section>
<section class="main-content">
<p><img src="http://ogemdlrap.bkt.clouddn.com/ban_cover.png" alt="image" /></p>
<blockquote>
<h2 id="这城市太寂寞伴在你身边">这城市太寂寞,《伴》在你身边</h2>
</blockquote>
<h1 id="伴之序">《伴》之序</h1>
<p><strong>《伴》</strong> 是一款完全的Kotlin项目,她展示了部分<strong>Kotlin</strong> 的知识。诸如类、函数、变量、流程控制语句等基础知识点,以及单例、伴生、数据类、延迟注入、转型、扩展方法、扩展属性等进阶知识点。随着项目的发展,CoorChice期待加入更多有趣实用的特性进去。</p>
<p>在 <strong>《伴》</strong> 中,CoorChice向你展示了如何使用Kotlin快速的构建一个App,以及如何轻松愉悦的、持续的进行迭代。如果你忍受够了Java各种冗余的、反人类的语法,如果你被Java圈住太久,想要尝尝自由的味道,那么你可以在 <strong>《伴》</strong> 中看到Kotlin是如何来解放一个程序员的。</p>
<p>CoorChice在这里准备一些Kotlin的入门知识,顺利的话你将能很快的上手Kotlin。<a href="http://www.jianshu.com/nb/12698208">秘术Kotlin【http://www.jianshu.com/nb/12698208】</a>。如果你想了解更多的进阶知识,可以在网上找到很多不错的资料。</p>
<p>下面,CoorChice将会简单的介绍一下《伴》。如果你希望获得更多的信息和讨论,可以进入我的主页关注我。</p>
<h1 id="伴之形">《伴》之形</h1>
<p>《伴》使用了纯Kotlin进行开发,总体架构选用了时下流行的、稳定的MVP架构。关于MVP已经有很多资料在网络中流传了,建议大家可以先查找相关资料熟悉一下。什么?怎么查找?这会是对你有用的一篇文章:<a href="http://www.jianshu.com/p/a2f0f5a39cc3">这十个搜索技巧至少价值100万!【http://www.jianshu.com/p/a2f0f5a39cc3】</a>。</p>
<h2 id="使用到的库">使用到的库</h2>
<p>下面是一些《伴》中用到的流行库:</p>
<ul>
<li><strong>Gson</strong>,解析Json数据。</li>
<li><strong>OkHttp3 + Retrofit2</strong>,处理网络请求。</li>
<li><strong>Fresco</strong>,展示图片。</li>
<li><strong>SuperTextView</strong>,这是<strong>CoorChice</strong>喜爱的控件,他真是可以无处不在啊!如果你感兴趣的话,这是地址<a href="http://www.jianshu.com/p/1b91e11e441d">从未如此惊艳!你好,SuperTextView (v1.3)【http://www.jianshu.com/p/1b91e11e441d】</a>。</li>
</ul>
<p>CoorChice想说的是,Kotlin完全可以兼容现有的流行库。你还在为Kotlin的生态不够全面而害怕尝试吗?Java能用的,Kotlin也能有办法使用。</p>
<h2 id="听说kotlin和anko更配哦">听说Kotlin和Anko更配哦</h2>
<p>《伴》还使用Kotlin的专属扩展库<strong>Anko</strong>。</p>
<p>Anko是Kotlin的一个扩展库,它包含了很多使用的工具和强大的特性。比如用DSL语言来在代码中创建布局,虽然CoorChice对它没什么好感,但它确实是一个有意思的东西。比起在xml中写布局,这个在代码中写布局的特性实在差太多了。</p>
<p>但是,Anko有一个十分让人爱不释手的特性,就是布局id就可以直接操作控件实例。强烈建议大家尝试一下,真的是爱不释手。<code class="highlighter-rouge">findViewById()</code>,<code class="highlighter-rouge">ButterKnife</code>等等你都可以停止了。</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>fragment_joke.xml
<!--这是一个xml中的控件-->
<com.coorchice.library.SuperTextView
android:id="@+id/btn_picture"
android:layout_width="44.65dp"
android:layout_height="44.65dp"
app:corner="24dp"
app:solid="@color/md_blue_200"
android:text="@string/picture"
android:gravity="center"
android:textSize="@dimen/title"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="24.18dp"
android:layout_marginRight="8dp"
/>
</code></pre></div></div>
<p>通过import在Activity或Fragment中导入布局文件:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>import kotlinx.android.synthetic.main.fragment_joke.*
</code></pre></div></div>
<p>就是【<code class="highlighter-rouge">kotlinx.android.synthetic.main</code> + 布局文件 + *】的格式。</p>
<p>然后,你可以这样来使用:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>btn_picture.solid = ***
</code></pre></div></div>
<p>看到没,不用<strong>findViewById()</strong>,不用<strong>ButterKnife</strong> 。真是太棒了!</p>
<p>当然,Anko还有许多有趣的特性,比如可以通过这个函数<code class="highlighter-rouge">dip()</code>,来快速的将dp转为px,你都不用自己去封装。相关资料可以到这里查看:<a href="https://github.com/Kotlin/anko#which-anko-libraries-are-available-and-1which-do-i-need">Kotlin/anko【https://github.com/Kotlin/anko#which-anko-libraries-are-available-and-1which-do-i-need】</a>。</p>
<h1 id="遇见伴">遇见《伴》</h1>
<p>目前,<strong>《伴》</strong> 共有4个模块:新闻头条,微信精选,轻松一刻,星座运势。她们被打造来陪伴寂寞的你(如果你寂寞的话)。下面CoorChice展示一下《伴》的大致面貌吧。</p>
<h2 id="新闻头条">新闻头条</h2>
<p>将世界收入你的口袋中!足不出户而知天下事,大概说的就是这样吧。</p>
<p><img src="http://ogemdlrap.bkt.clouddn.com/%E4%BC%B4-00.gif" alt="0" /></p>
<h2 id="微信精选">微信精选</h2>
<p>每日微信精选文章让你看到微信中不一样的世界。</p>
<p><img src="http://ogemdlrap.bkt.clouddn.com/%E4%BC%B4-1.gif" alt="1" /></p>
<h2 id="轻松一刻">轻松一刻</h2>
<p>随身的图文笑话,让你走到哪都是最有幽默感的那一个。</p>
<p><img src="http://ogemdlrap.bkt.clouddn.com/%E4%BC%B4-2.gif" alt="image" /></p>
<h2 id="星座运势">星座运势</h2>
<p>让你每天都可以了解自己的星座动态。</p>
<p><img src="http://ogemdlrap.bkt.clouddn.com/%E4%BC%B4-3.gif" alt="image" /></p>
<h1 id="总结">总结</h1>
<blockquote>
<ul>
<li>抽出空余时间写文章分享需要动力,还请各位看官动动小手 <strong>【点个赞】</strong>,给CoorChice点鼓励</li>
<li>CoorChice一直在不定期的创作新的干货,想要上车只需进到【个人主页】点个关注就好了哦。发车喽~</li>
</ul>
</blockquote>
<p>本篇CoorChice分享了自己的Kotlin项目《伴》,如果你现在任然感谢兴趣的话,下面是项目的地址:</p>
<blockquote>
<p><a href="https://github.com/chenBingX/Ban">《伴》【https://github.com/chenBingX/Ban】</a></p>
</blockquote>
<p>或者,你可以在这个地址下载解压安装体验《伴》。</p>
<blockquote>
<p><a href="http://ogemdlrap.bkt.clouddn.com/app-debug.apk.zip">《伴》http://ogemdlrap.bkt.clouddn.com/app-debug.apk.zip</a></p>
</blockquote>
<h2 id="喜欢的话记得顺手给个star点个赞鼓励下coorchice哦">喜欢的话,记得顺手给个star,点个赞,鼓励下CoorChice哦!</h2>
<footer class="site-footer">
<span class="site-footer-owner"><a href="https://github.com/chenBingX/Ban">Ban</a> is maintained by <a href="https://github.com/chenBingX">chenBingX</a>.</span>
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a>.</span>
</footer>
<h2 id="框架预警">框架预警</h2>
</section>
</body>
</html>