Skip to content

Commit

Permalink
Merge pull request alibaba#533 from alibaba/develop
Browse files Browse the repository at this point in the history
Update demo and tips
  • Loading branch information
zhi1ong authored Oct 26, 2018
2 parents 53c951a + 9eaac35 commit 38d087d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public class Test1Activity extends Activity {
}

// If you need to pass a custom object, Create a new class(Not the custom object class),implement the SerializationService, And use the @Route annotation annotation, E.g:
@Route(path = "/service/json")
@Route(path = "/yourservicegroupname/json")
public class JsonServiceImpl implements SerializationService {
@Override
public void init(Context context) {
Expand Down Expand Up @@ -269,7 +269,7 @@ public interface HelloService extends IProvider {
String sayHello(String name);
}

@Route(path = "/service/hello", name = "test service")
@Route(path = "/yourservicegroupname/hello", name = "test service")
public class HelloServiceImpl implements HelloService {

@Override
Expand All @@ -290,7 +290,7 @@ public class Test {
@Autowired
HelloService helloService;

@Autowired(name = "/service/hello")
@Autowired(name = "/yourservicegroupname/hello")
HelloService helloService2;

HelloService helloService3;
Expand All @@ -308,7 +308,7 @@ public class Test {

// 2. Discovering services using dependency lookup, the following two methods are byName and byType
helloService3 = ARouter.getInstance().navigation(HelloService.class);
helloService4 = (HelloService) ARouter.getInstance().build("/service/hello").navigation();
helloService4 = (HelloService) ARouter.getInstance().build("/yourservicegroupname/hello").navigation();
helloService3.sayHello("Vergil");
helloService4.sayHello("Vergil");
}
Expand Down
8 changes: 4 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public class Test1Activity extends Activity {


// 如果需要传递自定义对象,新建一个类(并非自定义对象类),然后实现 SerializationService,并使用@Route注解标注(方便用户自行选择序列化方式),例如:
@Route(path = "/service/json")
@Route(path = "/yourservicegroupname/json")
public class JsonServiceImpl implements SerializationService {
@Override
public void init(Context context) {
Expand Down Expand Up @@ -279,7 +279,7 @@ public interface HelloService extends IProvider {
}

// 实现接口
@Route(path = "/service/hello", name = "测试服务")
@Route(path = "/yourservicegroupname/hello", name = "测试服务")
public class HelloServiceImpl implements HelloService {

@Override
Expand All @@ -300,7 +300,7 @@ public class Test {
@Autowired
HelloService helloService;

@Autowired(name = "/service/hello")
@Autowired(name = "/yourservicegroupname/hello")
HelloService helloService2;

HelloService helloService3;
Expand All @@ -319,7 +319,7 @@ public class Test {

// 2. 使用依赖查找的方式发现服务,主动去发现服务并使用,下面两种方式分别是byName和byType
helloService3 = ARouter.getInstance().navigation(HelloService.class);
helloService4 = (HelloService) ARouter.getInstance().build("/service/hello").navigation();
helloService4 = (HelloService) ARouter.getInstance().build("/yourservicegroupname/hello").navigation();
helloService3.sayHello("Vergil");
helloService4.sayHello("Vergil");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void onInterrupt(Postcard postcard) {
.navigation();
break;
case R.id.navByName:
((HelloService) ARouter.getInstance().build("/service/hello").navigation()).sayHello("mike");
((HelloService) ARouter.getInstance().build("/yourservicegroupname/hello").navigation()).sayHello("mike");
break;
case R.id.navByType:
ARouter.getInstance().navigation(HelloService.class).sayHello("mike");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @version 1.0
* @since 2017/1/3 10:26
*/
@Route(path = "/service/hello")
@Route(path = "/yourservicegroupname/hello")
public class HelloServiceImpl implements HelloService {
Context mContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @version 1.0
* @since 2017/4/10 下午2:10
*/
@Route(path = "/service/json")
@Route(path = "/yourservicegroupname/json")
public class JsonServiceImpl implements SerializationService {
@Override
public void init(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @version 1.0
* @since 2017/4/24 下午9:04
*/
@Route(path = "/service/single")
@Route(path = "/yourservicegroupname/single")
public class SingleService implements IProvider {

Context mContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static com.alibaba.android.arouter.compiler.utils.Consts.KEY_MODULE_NAME;
import static com.alibaba.android.arouter.compiler.utils.Consts.METHOD_LOAD_INTO;
import static com.alibaba.android.arouter.compiler.utils.Consts.NAME_OF_INTERCEPTOR;
import static com.alibaba.android.arouter.compiler.utils.Consts.NO_MODULE_NAME_TIPS;
import static com.alibaba.android.arouter.compiler.utils.Consts.PACKAGE_OF_GENERATE_FILE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SEPARATOR;
import static com.alibaba.android.arouter.compiler.utils.Consts.WARNING_TIPS;
Expand Down Expand Up @@ -95,12 +96,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
moduleName = moduleName.replaceAll("[^0-9a-zA-Z_]+", "");
logger.info("The user has configuration the module name, it was [" + moduleName + "]");
} else {
logger.error("These no module name, at 'build.gradle', like :\n" +
"apt {\n" +
" arguments {\n" +
" moduleName project.getName();\n" +
" }\n" +
"}\n");
logger.error(NO_MODULE_NAME_TIPS);
throw new RuntimeException("ARouter::Compiler >>> No module name, for more information, look at gradle log.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import static com.alibaba.android.arouter.compiler.utils.Consts.NAME_OF_GROUP;
import static com.alibaba.android.arouter.compiler.utils.Consts.NAME_OF_PROVIDER;
import static com.alibaba.android.arouter.compiler.utils.Consts.NAME_OF_ROOT;
import static com.alibaba.android.arouter.compiler.utils.Consts.NO_MODULE_NAME_TIPS;
import static com.alibaba.android.arouter.compiler.utils.Consts.PACKAGE_OF_GENERATE_DOCS;
import static com.alibaba.android.arouter.compiler.utils.Consts.PACKAGE_OF_GENERATE_FILE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SEPARATOR;
Expand Down Expand Up @@ -130,17 +131,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) {

logger.info("The user has configuration the module name, it was [" + moduleName + "]");
} else {
logger.error("These no module name, at 'build.gradle', like :\n" +
"android {\n" +
" defaultConfig {\n" +
" ...\n" +
" javaCompileOptions {\n" +
" annotationProcessorOptions {\n" +
" arguments = [AROUTER_MODULE_NAME: project.getName()]\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n");
logger.error(NO_MODULE_NAME_TIPS);
throw new RuntimeException("ARouter::Compiler >>> No module name, for more information, look at gradle log.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ public class Consts {

// Log
static final String PREFIX_OF_LOGGER = PROJECT + "::Compiler ";
public static final String NO_MODULE_NAME_TIPS = "These no module name, at 'build.gradle', like :\n" +
"android {\n" +
" defaultConfig {\n" +
" ...\n" +
" javaCompileOptions {\n" +
" annotationProcessorOptions {\n" +
" arguments = [AROUTER_MODULE_NAME: project.getName()]\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n";

// Options of processor
public static final String KEY_MODULE_NAME = "AROUTER_MODULE_NAME";
Expand Down

0 comments on commit 38d087d

Please sign in to comment.