Skip to content

Commit

Permalink
增加base模块用于存放公共的东西
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhijun committed Jun 8, 2017
1 parent bcfb2f7 commit 9820788
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 5 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//主工程依赖所有的module
compile project(':bussiness-module-a')
compile project(':lrouter-api')
compile project(':bussiness-module-b')
compile project(':basemodel')
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/lenovohit/lrouter/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.widget.Button;
import android.widget.Toast;

import com.lenovohit.basemodel.User;
import com.lenovohit.lrouter_api.base.LRouterAppcation;
import com.lenovohit.lrouter_api.core.LRouterRequest;
import com.lenovohit.lrouter_api.core.LRouterResponse;
Expand Down Expand Up @@ -102,7 +103,8 @@ public void onClick(View v) {
.provider("ModuleBProvider")
.action("ModuleBAction")
.param("1", "Hello")
.param("2", "Annotation"));
.param("2", "Annotation")
.reqeustObject(new User("yuzhijun","123456")));

new Thread(new Runnable() {
@Override
Expand Down
1 change: 1 addition & 0 deletions basemodel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
32 changes: 32 additions & 0 deletions basemodel/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"

defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:25.1.0'
testCompile 'junit:junit:4.12'
compile project(':lrouter-api')
}
25 changes: 25 additions & 0 deletions basemodel/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\AndroidSdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.lenovohit.basemodel;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.lenovohit.aidlmodel.test", appContext.getPackageName());
}
}
13 changes: 13 additions & 0 deletions basemodel/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.lenovohit.basemodel"
>

<application android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>

</application>

</manifest>
63 changes: 63 additions & 0 deletions basemodel/src/main/java/com/lenovohit/basemodel/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.lenovohit.basemodel;

import android.os.Parcel;
import android.os.Parcelable;

/**
* Created by yuzhijun on 2017/6/8.
*/

public class User implements Parcelable {
private String userName;
private String passWord;

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getPassWord() {
return passWord;
}

public void setPassWord(String passWord) {
this.passWord = passWord;
}


@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.userName);
dest.writeString(this.passWord);
}

public User(String userName,String passWord) {
this.userName = userName;
this.passWord = passWord;
}

protected User(Parcel in) {
this.userName = in.readString();
this.passWord = in.readString();
}

public static final Creator<User> CREATOR = new Creator<User>() {
@Override
public User createFromParcel(Parcel source) {
return new User(source);
}

@Override
public User[] newArray(int size) {
return new User[size];
}
};
}
3 changes: 3 additions & 0 deletions basemodel/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">AIDLModel</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.lenovohit.basemodel;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
2 changes: 1 addition & 1 deletion bussiness-module-a/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
//module依赖路由module
compile project(':lrouter-api')
compile project(':basemodel')
}
2 changes: 1 addition & 1 deletion bussiness-module-b/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile project(':lrouter-api')
compile project(':basemodel')
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.text.TextUtils;

import com.lenovohit.basemodel.User;
import com.lenovohit.lrouter_api.annotation.ioc.Action;
import com.lenovohit.lrouter_api.core.LRAction;
import com.lenovohit.lrouter_api.core.LRActionResult;
Expand All @@ -28,6 +29,10 @@ public LRActionResult invoke(Context context, LRouterRequest requestData) {
if(!TextUtils.isEmpty((CharSequence) requestData.getParams().get("2"))){
temp+=requestData.getParams().get("2");
}
User user = (User) requestData.getRequestObject();
if (!TextUtils.isEmpty(user.getUserName()+user.getPassWord())){
temp+=user.getUserName()+"-"+user.getPassWord();
}
LRActionResult result = new LRActionResult.Builder()
.code(LRActionResult.RESULT_SUCESS)
.msg("success")
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app', ':lrouter-api', ':bussiness-module-a', ':bussiness-module-b'
include ':app', ':lrouter-api', ':bussiness-module-a', ':bussiness-module-b', ':basemodel'

0 comments on commit 9820788

Please sign in to comment.