Kotlin搭建基礎(chǔ)框架

Android 開發(fā)中一邊向高級靠攏,一邊整理高級開發(fā)這方面資料。同時(shí)一邊使用Java語言和kotlin語言重新搭建APP原生開發(fā)基礎(chǔ)架構(gòu)。

我將要運(yùn)用到:Retroft2網(wǎng)絡(luò)框架 + Glide圖片加載 + Gson數(shù)據(jù)解析 + Logger開源等優(yōu)秀的第三方庫,當(dāng)然為了避免64K限制肯定是不會濫用第三方庫的

首先介紹使用Kotlin進(jìn)行搭建

使用kotlin中自我感覺的優(yōu)點(diǎn):

代碼量少了
非空安全
這兩個(gè)是給我最直接的體驗(yàn),其他的好處真心沒有感受到呢。應(yīng)該是我還不夠級。

和我一樣是kotlin菜鳥的可以看一下這個(gè),我剛開始也是這樣看的,哈哈哈
kotlin教程:
http://www.runoob.com/kotlin/kotlin-tutorial.html
kotlin中文文檔:
http://www.kotlindoc.cn/GettingStarted/Basic-Syntax.html

那么使用kotlin一步步搭建一個(gè)基礎(chǔ)框架:
Kotlin+MVP+Retrofit2+RxJava2

首先我添加的依賴

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//攔截器
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
//gson
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//    1、升級自己的版本到27.0.2
//    2、使用exclue排除沖突 (我使用的方法)
//    3、降級Glide到 4.3.1
implementation('com.github.bumptech.glide:glide:4.7.1') {
    exclude group: "com.android.support"
}
implementation 'com.orhanobut:logger:2.2.0'
}

介紹一下我的開發(fā)環(huán)境和目錄

QQ圖片20181011172552.png
QQ圖片20181011172845.png
QQ圖片20181011172733.png

這是我的項(xiàng)目的目錄結(jié)構(gòu),還有和所涉及的類。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容