不跟你多BB,先上效果图了
写这篇文章在于总结一下自己当前使用的快速开发的框架,然后欢迎大家批评指正。
MVP实现大框架+rxjava响应式拉取+retrofit okhttp实现网络请求+joup实现网页解析
第一章就先介绍我的MVP的封装好了
MVP就不再赘述了,只提一点:
为什么使用MVP模式?因为在Android中,Activity严重耦合了界面和数据获取层。这样不仅导致了Activity的类越来越庞大,而且,如果修改数据获取层,可能也导致整个View都要重写。也非常不利于模块和自动化测试。MVP使View独立于数据,把大量的逻辑从Activity中提取出来。把应用分层,每层都可以独立测试和变动。
先把gradle依赖贴出来
//项目创建时自动添加的依赖+recyclerview implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support:recyclerview-v7:27.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' //RxJava依赖 implementation "io.reactivex.rxjava2:rxjava:2.1.12" implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' //Retrofit依赖 implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' //Glide依赖 implementation 'com.github.bumptech.glide:glide:4.6.1' annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1' //框架中baseActivity的子类的依赖 implementation 'me.yokeyword:fragmentation:1.3.3' //Butter Knife依赖 implementation 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' </