[Android入门]从零构建Android app之天气——3.配置项目环境

本文介绍了MVP框架模式的实现方式及各组件职责:Model负责业务逻辑与数据处理;View负责界面展示与用户交互;Presenter作为桥梁连接Model与View。文章还列举了包括ButterKnife、Retrofit2、OkHttp3等在内的依赖库配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

框架模式

选用目前比较流行的MVP框架模式。
MVP示意图

  • Model:负责处理业务逻辑,数据加载,算法;
  • View:负责控制视图,处理交互;
  • Presenter:负责链接Model和View,把Model加载好的数据传递到View中展示,把View中的交互数据请求发送给Model进行处理。注意了,Presenter层由于链接了另外两个模块,在开发过程中很容易误把它们的逻辑代码放到这里,特别是Model模块的逻辑!这是应该被禁止的行为,在Presenter中编程时要好好的考虑!

配置依赖库

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'io.reactivex:rxjava:1.1.9'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.android.support:cardview-v7:24.0.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.facebook.fresco:fresco:0.12.0'
    compile 'junit:junit:4.12'
    compile 'com.jakewharton:butterknife:8.2.1'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.squareup.okhttp3:okhttp-ws:3.3.1'
    compile 'com.umeng.analytics:analytics:latest.integration'
}

目前先这么多,后面有需要再更新吧。

配置使用Lambda

配置参考我的这篇教程

规划项目结构

规划项目结构

项目地址GitHub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值