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),還有和所涉及的類。