Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhi1ong committed Jan 4, 2017
1 parent dc043fc commit 57b46dc
Show file tree
Hide file tree
Showing 91 changed files with 5,213 additions and 27 deletions.
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
/*/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# IDEA Files
.idea
*.iml
/*.ipr
/*.iws

# Eclipse Files
/target
*.classpath
*.project
*.settings

app/src/main/res/values/config.xml
app/src/main/res/drawable/yw_1222.jpg

# OS X Files
.DS_Store

map.txt
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
4. Generate mapping-relationship document automatically.

#### Ⅲ. The Basic
1. Add dependencies
1. Add dependencies and configuration

apply plugin: 'com.neenbedankt.android-apt'

Expand All @@ -38,9 +38,15 @@
}
}

apt {
arguments {
moduleName project.getName();
}
}

dependencies {
apt 'com.alibaba.android:arouter-compiler:x.x.x'
compile 'com.alibaba.android:arouter-api:x.x.x'
apt 'com.alibaba:arouter-compiler:x.x.x'
compile 'com.alibaba:arouter-api:x.x.x'
...
}

Expand Down Expand Up @@ -284,6 +290,12 @@

2. 注意:推荐使用ByName方式获取Service,ByType这种方式写起来比较方便,但如果存在多实现的情况时,SDK不保证能获取到你想要的实现

10. Service management - resolve dependencies through services

可以通过ARouter service包装您的业务逻辑或者sdk,在service的init方法中初始化您的sdk,不同的sdk使用ARouter的service进行调用,
每一个service在第一次使用的时候会被初始化,即调用init方法。
这样就可以告别各种乱七八糟的依赖关系的梳理,只要能调用到这个service,那么这个service中所包含的sdk等就已经被初始化过了,完全不需要
关心各个sdk的初始化顺序。

#### Ⅴ. More function

Expand Down Expand Up @@ -347,15 +359,4 @@

- They need to implement different interface
- Interceptors will take effect in every navigation. Interceptors will initialize asynchronously at initialization of ARouter. If the initialization is not finished yet when first navigation execute, the navigation will block and wait.
- Services will do the initialization only when they are invoked. If a service has never been invoked in whole lifecycle, it won’t initialize.

3. Support Jack-Complier tool chain

- ARouter hide the messy params handling dependent on some javac APIs. As a result, when you use Jack to compile your project, some special work is needed.

// 在使用了Jack的模块的build.gradle中加入如下参数即可,moduleName保证和其他模块不重复,使用标准字符,不要使用各种特殊字符
apt {
arguments {
moduleName 'lalala'
}
}
- Services will do the initialization only when they are invoked. If a service has never been invoked in whole lifecycle, it won’t initialize.
29 changes: 17 additions & 12 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
4. 生成映射关系文档(考虑支持)

#### 三、基础功能
1. 添加依赖
1. 添加依赖和配置

apply plugin: 'com.neenbedankt.android-apt'
Expand All @@ -37,9 +37,15 @@
}
}
apt {
arguments {
moduleName project.getName();
}
}
dependencies {
apt 'com.alibaba.android:arouter-compiler:x.x.x'
compile 'com.alibaba.android:arouter-api:x.x.x'
apt 'com.alibaba:arouter-compiler:x.x.x'
compile 'com.alibaba:arouter-api:x.x.x'
...
}

Expand Down Expand Up @@ -283,7 +289,12 @@
2. 注意:推荐使用ByName方式获取Service,ByType这种方式写起来比较方便,但如果存在多实现的情况时,SDK不保证能获取到你想要的实现


10. 使用ARouter管理服务(三) 管理依赖

可以通过ARouter service包装您的业务逻辑或者sdk,在service的init方法中初始化您的sdk,不同的sdk使用ARouter的service进行调用,
每一个service在第一次使用的时候会被初始化,即调用init方法。
这样就可以告别各种乱七八糟的依赖关系的梳理,只要能调用到这个service,那么这个service中所包含的sdk等就已经被初始化过了,完全不需要
关心各个sdk的初始化顺序。

#### 五、更多功能

Expand Down Expand Up @@ -351,11 +362,5 @@

3. Jack 编译链的支持

- 因为不想让用户主动设置一堆乱七八糟的参数,在获取模块名的时候使用javac的api,使用了Jack之后没有了javac,只能让用户稍稍动动手了
// 在使用了Jack的模块的build.gradle中加入如下参数即可,moduleName保证和其他模块不重复,使用标准字符,不要使用各种特殊字符
apt {
arguments {
moduleName 'lalala'
}
}
- ~~因为不想让用户主动设置一堆乱七八糟的参数,在获取模块名的时候使用javac的api,使用了Jack之后没有了javac,只能让用户稍稍动动手了~~
- 因为一些其他原因,现在任何情况下都需要在build.gradle中配置moduleName了。。。。
61 changes: 61 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
buildToolsVersion BUILDTOOLS_VERSION

defaultConfig {
minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(TARGET_SDK_VERSION)
versionName "0.0.1"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

signingConfigs {
debug {
storeFile file("./doc/debug/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}

buildTypes {
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}

release {
minifyEnabled false
signingConfig null
}
}

lintOptions {
abortOnError false
}
}

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

apt 'com.alibaba:arouter-compiler:1.0.1'
compile 'com.alibaba:arouter-api:1.0.1'

compile project(':test-module-1')
compile project(':test-module-2')

compile 'com.android.support:appcompat-v7:22.2.0'
}

apt {
arguments {
moduleName project.getName();
}
}
Binary file added app/doc/debug/debug.keystore
Binary file not shown.
63 changes: 63 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alibaba.android.arouter.demo">

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>

<application
android:name=".AppContext"
android:allowBackup="false"
android:label="ARouter demo"
android:theme="@style/Base.Theme.AppCompat">
<activity android:name=".SchameFilterActivity">

<!-- Schame -->
<intent-filter>
<data
android:host="m.aliyun.com"
android:scheme="arouter"/>

<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>

<!-- App Links -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<data
android:host="m.aliyun.com"
android:scheme="http"/>
<data
android:host="m.aliyun.com"
android:scheme="https"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".TestWebview">
</activity>
<activity android:name=".testactivity.Test1Activity">
</activity>
<activity android:name=".testactivity.Test2Activity">
</activity>
<activity android:name=".testactivity.Test3Activity">
</activity>
<activity android:name=".testactivity.Test4Activity">
</activity>
</application>

</manifest>
25 changes: 25 additions & 0 deletions app/src/main/assets/schame-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>

<body>

<h2>跳转测试</h2>

<h2>自定义Schame[通常来说都是这样的]</h2>
<p><a href="arouter://m.aliyun.com/test/activity1">arouter://m.aliyun.com/test/activity1</a></p>
<p><a href="arouter://m.aliyun.com/test/activity1?url=https%3a%2f%2fm.abc.com%3fa%3db%26c%3dd">测试URL Encode情况</a></p>
<p><a href="arouter://m.aliyun.com/test/activity1?name=alex&age=18&boy=true&high=180">arouter://m.aliyun.com/test/activity1?name=alex&age=18&boy=true&high=180</a></p>
<p><a href="arouter://m.aliyun.com/test/activity2">arouter://m.aliyun.com/test/activity2</a></p>
<p><a href="arouter://m.aliyun.com/test/activity2?key1=value1">arouter://m.aliyun.com/test/activity2?key1=value1</a></p>
<p><a href="arouter://m.aliyun.com/test/activity3?name=alex&age=18&boy=true&high=180">(需要开启自动注入)arouter://m.aliyun.com/test/activity3?name=alex&age=18&boy=true&high=180</a></p>

<h2>App Links[防止被App屏蔽]</h2>
<p><a href="http://m.aliyun.com/test/activity1">http://m.aliyun.com/test/activity1</a></p>
<p><a href="http://m.aliyun.com/test/activity2">http://m.aliyun.com/test/activity2</a></p>

</body>
</html>
44 changes: 44 additions & 0 deletions app/src/main/java/com/alibaba/android/arouter/demo/AppContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.alibaba.android.arouter.demo;

import android.app.Application;
import android.content.Context;

import com.alibaba.android.arouter.launcher.ARouter;

/**
* TODO feature
*
* @author Alex <a href="mailto:[email protected]">Contact me.</a>
* @version 1.0
* @since 16/8/23 11:54
*/
public class AppContext extends Application {

private static Application mInstance;

@Override
public void onCreate() {
super.onCreate();

mInstance = this;
}

public static Application getInstance() {
return mInstance;
}

/**
* Set the base context for this ContextWrapper. All calls will then be
* delegated to the base context. Throws
* IllegalStateException if a base context has already been set.
*
* @param base The new base context for this wrapper.
*/
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);

// 实验性功能,不推荐使用
ARouter.attachBaseContext();
}
}
Loading

0 comments on commit 57b46dc

Please sign in to comment.