├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable │ │ │ │ ├── man.png │ │ │ │ ├── girl.jpg │ │ │ │ ├── java.jpg │ │ │ │ ├── woman.png │ │ │ │ ├── android.jpg │ │ │ │ └── javaweb.jpg │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── adapter_book.xml │ │ │ │ ├── adapter_student.xml │ │ │ │ ├── activity_book.xml │ │ │ │ ├── activity_student.xml │ │ │ │ └── activity_login.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── handsome │ │ │ │ └── designmode │ │ │ │ ├── MVP │ │ │ │ ├── View │ │ │ │ │ ├── IStudentView.java │ │ │ │ │ └── StudentActivity.java │ │ │ │ ├── Bean │ │ │ │ │ └── Student.java │ │ │ │ ├── Model │ │ │ │ │ ├── IStudentMode.java │ │ │ │ │ └── StudentMode.java │ │ │ │ ├── Presenter │ │ │ │ │ └── StudentPresenter.java │ │ │ │ └── Adapter │ │ │ │ │ └── StudentAdapter.java │ │ │ │ ├── MVVM │ │ │ │ ├── Bean │ │ │ │ │ └── Student.java │ │ │ │ └── View │ │ │ │ │ └── LoginActivity.java │ │ │ │ └── MVC │ │ │ │ ├── Bean │ │ │ │ └── Book.java │ │ │ │ ├── Model │ │ │ │ └── BookModel.java │ │ │ │ ├── Controller │ │ │ │ └── BookController.java │ │ │ │ ├── View │ │ │ │ └── BookActivity.java │ │ │ │ └── Adapter │ │ │ │ └── BookAdapter.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── handsome │ │ │ └── designmode │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── handsome │ │ └── designmode │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | DesignMode -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DesignMode 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/man.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/drawable/man.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/girl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/drawable/girl.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/java.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/drawable/java.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/woman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/drawable/woman.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/android.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/drawable/android.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/javaweb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/drawable/javaweb.jpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidHensen/Design-Mode/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Design-Mode 2 | MVC、MVP、MVVM设计模式的案例 3 | 4 | * [Android基础——框架模式MVC在安卓中的实践](http://blog.csdn.net/qq_30379689/article/details/52909656) 5 | * [Android基础——框架模式MVP在安卓中的实践](http://blog.csdn.net/qq_30379689/article/details/52910567) 6 | * [Android基础——框架模式MVVM之DataBinding的实践](http://blog.csdn.net/qq_30379689/article/details/53037430) 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/handsome/designmode/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/handsome/designmode/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/handsome/designmode/MVP/View/IStudentView.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode.MVP.View; 2 | 3 | import com.handsome.designmode.MVP.Bean.Student; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 作者:许英俊 9 | * 视图类 10 | * 对视图方法的抽象 11 | */ 12 | public interface IStudentView { 13 | /** 14 | * 展示学生 15 | * @param list 16 | */ 17 | void showStudent(List list); 18 | 19 | /** 20 | * 刷新学生 21 | */ 22 | void refreshStudent(); 23 | } 24 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/adapter_book.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/adapter_student.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/handsome/designmode/MVVM/Bean/Student.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode.MVVM.Bean; 2 | 3 | public class Student { 4 | 5 | private String name; 6 | private String nickName; 7 | 8 | public Student(String name, String nickName) { 9 | this.name = name; 10 | this.nickName = nickName; 11 | } 12 | 13 | public String getNickName() { 14 | 15 | return nickName; 16 | } 17 | 18 | public void setNickName(String nickName) { 19 | this.nickName = nickName; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/handsome/designmode/MVC/Bean/Book.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode.MVC.Bean; 2 | 3 | /** 4 | * 作者:许英俊 5 | * 实体类 6 | * 对数据对象的封装 7 | */ 8 | public class Book { 9 | 10 | //书名 11 | private String name; 12 | //书的图片 13 | private int image; 14 | 15 | public Book(String name, int image) { 16 | this.name = name; 17 | this.image = image; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public int getImage() { 29 | return image; 30 | } 31 | 32 | public void setImage(int image) { 33 | this.image = image; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\Eclipse\android-studio-sdk\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/handsome/designmode/MVP/Bean/Student.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode.MVP.Bean; 2 | 3 | /** 4 | * 作者:许英俊 5 | * 实体类 6 | * 对数据对象的封装 7 | */ 8 | public class Student { 9 | 10 | //学生的名字 11 | private String name; 12 | //学生的图片信息 13 | private int image; 14 | 15 | public Student(String name, int image) { 16 | this.name = name; 17 | this.image = image; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public int getImage() { 29 | return image; 30 | } 31 | 32 | public void setImage(int image) { 33 | this.image = image; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.2" 6 | 7 | dataBinding{ 8 | enabled = true 9 | } 10 | 11 | defaultConfig { 12 | applicationId "com.handsome.designmode" 13 | minSdkVersion 16 14 | targetSdkVersion 24 15 | versionCode 1 16 | versionName "1.0" 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:appcompat-v7:24.2.1' 30 | } 31 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/java/com/handsome/designmode/MVP/Model/IStudentMode.java: -------------------------------------------------------------------------------- 1 | package com.handsome.designmode.MVP.Model; 2 | 3 | import com.handsome.designmode.MVP.Bean.Student; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 作者:许英俊 9 | * 模型抽象类 10 | * 对模型层的抽象 11 | */ 12 | public interface IStudentMode { 13 | 14 | /** 15 | * 查询所有学生 16 | * @param listener 17 | */ 18 | void query(onQueryListener listener); 19 | 20 | /** 21 | * 添加学生 22 | * @param listener 23 | */ 24 | void addStudent(onAddStudentListener listener); 25 | 26 | /** 27 | * 删除学生 28 | * @param listener 29 | */ 30 | void deleteStudent(onDeleteStudentListener listener); 31 | 32 | /** 33 | * 查询学生回调 34 | */ 35 | interface onQueryListener{ 36 | void onComplete(List students); 37 | } 38 | 39 | /** 40 | * 添加学生回调 41 | */ 42 | interface onAddStudentListener{ 43 | void onComplete(); 44 | } 45 | 46 | /** 47 | * 删除学生回调 48 | */ 49 | interface onDeleteStudentListener{ 50 | void onComplete(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_book.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 |