serviceInfoBeans = []
15 | serviceInfoBeans.add(new ServiceInfoBean("test",ctClass))
16 | String s = ComCodeTransform.generateEventManagerInitializeCode(serviceInfoBeans)
17 |
18 | System.out.println(s)
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jimu-core/build-gradle/src/test/groovy/util/StringUtilTest.java:
--------------------------------------------------------------------------------
1 | package util;
2 |
3 | import com.dd.buildgradle.util.StringUtil;
4 |
5 | import static org.junit.Assert.assertFalse;
6 | import static org.junit.Assert.assertTrue;
7 |
8 | public class StringUtilTest {
9 |
10 | @org.junit.Test
11 | public void isMavenArtifact() {
12 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0-rc4@aar"));
13 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0-rc4@jar"));
14 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0-rc4"));
15 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0"));
16 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder"));
17 | }
18 |
19 | @org.junit.Test
20 | public void notMavenArtifact() {
21 | assertFalse(StringUtil.isMavenArtifact("app"));
22 | assertFalse(StringUtil.isMavenArtifact(":app"));
23 | assertFalse(StringUtil.isMavenArtifact(":modules:umeng_bbs"));
24 | assertFalse(StringUtil.isMavenArtifact("modules:umeng_bbs"));
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/jimu-core/build-gradle/src/test/java/com/dd/buildgradle/util/StringUtilTest.java:
--------------------------------------------------------------------------------
1 | package com.dd.buildgradle.util;
2 |
3 | import static org.junit.Assert.assertFalse;
4 | import static org.junit.Assert.assertTrue;
5 |
6 | public class StringUtilTest {
7 |
8 | @org.junit.Test
9 | public void isMavenArtifact() {
10 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0-rc4@aar"));
11 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0-rc4@jar"));
12 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0-rc4"));
13 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder:1.0"));
14 | assertTrue(StringUtil.isMavenArtifact("com.android.databinding:dataBinder"));
15 | }
16 |
17 | @org.junit.Test
18 | public void notMavenArtifact() {
19 | assertFalse(StringUtil.isMavenArtifact("app"));
20 | assertFalse(StringUtil.isMavenArtifact(":app"));
21 | assertFalse(StringUtil.isMavenArtifact(":modules:umeng_bbs"));
22 | assertFalse(StringUtil.isMavenArtifact("modules:umeng_bbs"));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/jimu-core/buildSrc/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "kotlin"
2 |
3 | sourceSets {
4 | main {
5 | java {
6 | srcDirs "../../src_build/main/java"
7 | }
8 | }
9 | }
10 | buildscript {
11 | ext.kotlin_version = "1.4.21"
12 | repositories {
13 | jcenter()
14 | }
15 | dependencies {
16 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17 | gradleApi()
18 | }
19 | }
20 | repositories {
21 | // mavenCentral()
22 | // google()
23 | jcenter()
24 | }
--------------------------------------------------------------------------------
/jimu-core/componentlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/release/component-baselib-0.0.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-core/componentlib/release/component-baselib-0.0.1.1.jar
--------------------------------------------------------------------------------
/jimu-core/componentlib/release/component-baselib-0.0.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-core/componentlib/release/component-baselib-0.0.2.jar
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/IApplicationLike.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.applicationlike;
2 |
3 | /**
4 | * Created by mrzhang on 2017/6/15.
5 | */
6 |
7 | public interface IApplicationLike {
8 |
9 | void onCreate();
10 |
11 | void onStop();
12 | }
13 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.applicationlike;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | /**
7 | * Package: com.dd.buildgradle.exten
8 | * Project: jimu-core
9 | * Classname: RegisterCompManual
10 | * Description: notate the Applike with this annotation
11 | * means that:you will register it manually. the auto register strategy will escape this module
12 | * it will never auto register
13 | * Created by leobert on 2018/5/10.
14 | */
15 | @Retention(RetentionPolicy.CLASS)
16 | public @interface RegisterCompManual {
17 | }
18 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/exceptions/ParamException.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.exceptions;
2 |
3 | /**
4 | * Package: com.luojilab.component.componentlib.exceptions
5 | * Project: DDComponentForAndroid
6 | * Classname: ParamException
7 | * Description: missing required params exception
8 | * Created by leobert on 12/01/2018.
9 | */
10 |
11 | public final class ParamException extends UiRouterException {
12 | public ParamException(String paramName) {
13 | super(paramName + " is required param, but didn't contains in the bundle;");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/exceptions/UiRouterException.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.exceptions;
2 |
3 | /**
4 | * Package: com.luojilab.component.componentlib.exceptions
5 | * Project: DDComponentForAndroid
6 | * Classname: UiRouterException
7 | * Description: none matched node for the target navigation url exception
8 | * Created by leobert on 11/01/2018.
9 | */
10 |
11 | public abstract class UiRouterException extends Exception {
12 | public UiRouterException() {
13 | }
14 |
15 | public UiRouterException(String message) {
16 | super(message);
17 | }
18 |
19 | public UiRouterException(String message, Throwable cause) {
20 | super(message, cause);
21 | }
22 |
23 | public UiRouterException(Throwable cause) {
24 | super(cause);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/log/ILogger.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.log;
2 |
3 | import com.luojilab.component.componentlib.log.impl.DefaultLogger;
4 |
5 | /**
6 | * Package: com.luojilab.component.componentlib.log
7 | * Project: DDComponentForAndroid
8 | * Classname: ILogger
9 | * Description: logger
10 | * Created by leobert on 11/01/2018.
11 | */
12 |
13 | public interface ILogger {
14 | String defaultTag = "[DD-Compo]";
15 |
16 | ILogger logger = new DefaultLogger(defaultTag);
17 |
18 | void showLog(boolean isShowLog);
19 |
20 | void showStackTrace(boolean isShowStackTrace);
21 |
22 | void showMonitor(boolean isShowMonitor);
23 |
24 | void debug(String tag, String message);
25 |
26 | void info(String tag, String message);
27 |
28 | void warning(String tag, String message);
29 |
30 | void error(String tag, String message);
31 |
32 | void monitor(String message);
33 |
34 | boolean isMonitorMode();
35 |
36 | String getDefaultTag();
37 |
38 | void setDefaultTag(String defaultTag);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/router/ISyringe.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.router;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.luojilab.component.componentlib.exceptions.ParamException;
6 |
7 | /**
8 | * Package: com.luojilab.component.componentlib.di.route
9 | * Project: DDComponentForAndroid
10 | * Classname: ISyringe
11 | * Description: desc the function of Syringe, one that used to inject
12 | * sth. to a container
13 | * Created by leobert on 2017/9/18.
14 | */
15 |
16 | public interface ISyringe {
17 | /**
18 | * @param self the container itself, members to be inject into have been annotated
19 | * with one annotation called Autowired
20 | */
21 | void inject(Object self);
22 |
23 | void preCondition(Bundle bundle) throws ParamException;
24 | }
25 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/router/ui/IUIRouter.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.router.ui;
2 |
3 | /**
4 | * router behaviors for component type, sub of {@link IComponentRouter}
5 | * Created by mrzhang on 2017/6/20.
6 | */
7 |
8 | public interface IUIRouter extends IComponentRouter {
9 |
10 | int PRIORITY_NORMAL = 0;
11 | int PRIORITY_LOW = -1000;
12 | int PRIORITY_HEIGHT = 1000;
13 |
14 | void registerUI(IComponentRouter router, int priority);
15 |
16 | void registerUI(IComponentRouter router);
17 |
18 | void registerUI(String host);
19 |
20 | void registerUI(String host, int priority);
21 |
22 | void unregisterUI(IComponentRouter router);
23 |
24 | void unregisterUI(String host);
25 | }
26 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/router/ui/VerifyResult.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.router.ui;
2 |
3 | /**
4 | * Package: com.luojilab.component.componentlib.router.ui
5 | * Project: DDComponentForAndroid
6 | * Classname: VerifyResult
7 | * Description: TODO
8 | * Created by leobert on 23/02/2018.
9 | */
10 |
11 | public class VerifyResult {
12 | private final boolean isSuccess;
13 |
14 | private Throwable throwable;
15 |
16 | public VerifyResult(boolean isSuccess) {
17 | this.isSuccess = isSuccess;
18 | }
19 |
20 | public VerifyResult(boolean isSuccess, Throwable throwable) {
21 | this.isSuccess = isSuccess;
22 | this.throwable = throwable;
23 | }
24 |
25 | public boolean isSuccess() {
26 | return isSuccess;
27 | }
28 |
29 | public Throwable getThrowable() {
30 | return throwable;
31 | }
32 |
33 | public void setThrowable(Throwable throwable) {
34 | this.throwable = throwable;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/service/AutowiredService.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.service;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.luojilab.component.componentlib.exceptions.ParamException;
6 |
7 | /**
8 | * Package: com.luojilab.component.componentlib.di
9 | * Project: DDComponentForAndroid
10 | * Classname: AutowiredService
11 | * Description: Autowired Dependency inject
12 | * Created by leobert on 2017/9/18.
13 | */
14 |
15 | public interface AutowiredService {
16 | boolean THROW_CONFIG = true;
17 |
18 | /**
19 | * Autowired core.
20 | *
21 | * @param instance the instance who need autowired.
22 | */
23 | void autowire(Object instance);
24 |
25 | void preCondition(Class targetActivityClz, Bundle params) throws ParamException;
26 |
27 |
28 | class Factory {
29 | private volatile static AutowiredService autowiredServiceImpl;
30 |
31 | public static AutowiredService getSingletonImpl() {
32 | if (autowiredServiceImpl == null) {
33 | synchronized (AutowiredService.class) {
34 | if (autowiredServiceImpl == null)
35 | autowiredServiceImpl = new AutowiredServiceImpl();
36 | }
37 | }
38 | return autowiredServiceImpl;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonService.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.service;
2 |
3 |
4 | import java.util.List;
5 |
6 | /**
7 | * Package: com.luojilab.component.json
8 | * Project: DDComponentForAndroid
9 | * Classname: JsonService
10 | * Description: APIs provided by the JsonComponent.
11 | * you can implement it via fast-json,gson,jackson etc.
12 | *
13 | * currently only basic functions contains!
14 | *
15 | * Created by leobert on 2017/9/18.
16 | */
17 |
18 | public interface JsonService {
19 |
20 | T parseObject(String text, Class clazz);
21 |
22 | List parseArray(String text, Class clazz);
23 |
24 | String toJsonString(Object instance);
25 |
26 | class Factory {
27 | private volatile static JsonService jsonService;
28 |
29 | public static JsonService getSingletonImpl() {
30 | if (jsonService == null) {
31 | synchronized (Factory.class) {
32 | if (jsonService == null)
33 | jsonService = new JsonServiceImpl();
34 | }
35 | }
36 | return jsonService;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.service;
2 |
3 | /**
4 | * Created by mrzhang on 2017/12/14.
5 | */
6 |
7 | import com.google.gson.Gson;
8 | import com.google.gson.reflect.TypeToken;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Package: com.luojilab.component.json.serviceimpl
14 | * Project: DDComponentForAndroid
15 | * Classname: JsonServiceImpl
16 | * Description: implement of {@link JsonService}, in this,
17 | * base on fast-json
18 | *
19 | * Created by leobert on 2017/9/18.
20 | */
21 |
22 | class JsonServiceImpl implements JsonService {
23 | @Override
24 | public T parseObject(String text, Class clazz) {
25 | Gson gson = new Gson();
26 | return gson.fromJson(text, clazz);
27 | }
28 |
29 | @Override
30 | public List parseArray(String text, Class clazz) {
31 | Gson gson = new Gson();
32 | return gson.fromJson(text, new TypeToken>() {
33 | }.getType());
34 | }
35 |
36 | @Override
37 | public String toJsonString(Object instance) {
38 | Gson gson = new Gson();
39 | return gson.toJson(instance);
40 | }
41 | }
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/AriseAt.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg;
2 |
3 | import com.luojilab.component.componentlib.log.ILogger;
4 |
5 | /**
6 | * Package: org.github.jimu.msg.bean
7 | * Project: JIMU
8 | * Classname: AriseAt
9 | * Description: represent the relationship between the 'poster' and the 'subscriber'
10 | * of their process
11 | * Created by leobert on 2018/4/25.
12 | */
13 | public class AriseAt {
14 |
15 | private String processFullName;
16 | private boolean isLocal;
17 |
18 | private AriseAt(String processFullName, boolean isLocal) {
19 | this.processFullName = processFullName;
20 | this.isLocal = isLocal;
21 | }
22 |
23 | public String getProcessFullName() {
24 | return processFullName;
25 | }
26 |
27 | public static AriseAt local() {
28 | return new AriseAt(Utils.getProcessName(), true);
29 | }
30 |
31 | public static AriseAt remote(String processFullName) {
32 | return new AriseAt(processFullName, false);
33 | }
34 |
35 | public boolean isLocal() {
36 | return isLocal;
37 | }
38 |
39 | public void log() {
40 | ILogger.logger.monitor("AriseAt:{ processFullName:" + processFullName + "}");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/Constants.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg;
2 |
3 | /**
4 | * Package: org.github.jimu.msg
5 | * Project: JIMU
6 | * Classname: Constants
7 | * Description: Constants
8 | * Created by leobert on 2018/4/24.
9 | */
10 | public interface Constants {
11 | int WHAT_SEND_CROSS_PROCESS_EVENT = 10000;
12 | int WHAT_RECEIVE_EVENT_FROM_REMOTE = 2;
13 |
14 | int WHAT_SUBSCRIBE_CROSS_PROCESS_EVENT = 9999;
15 |
16 | String BUNDLE_STR_EVENT_CLZ = "bundle_str_event_clz";
17 | String BUNDLE_PARCEL_EVENT = "bundle_event_parcelable";
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/ConsumeOn.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg;
2 |
3 | /**
4 | * Package: org.github.jimu.msg
5 | * Project: JIMU
6 | * Classname: ConsumeOn
7 | * Description: enum, thread the callback will be invoked
8 | * Created by leobert on 2018/4/26.
9 | */
10 | public enum ConsumeOn {
11 | Main,Background
12 | }
13 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/EventListener.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg;
2 |
3 | import org.github.jimu.msg.bean.EventBean;
4 |
5 | /**
6 | * Package: org.github.jimu.msg
7 | * Project: JIMU
8 | * Classname: EventListener
9 | * Description: callbacks for the event
10 | * Created by leobert on 2018/4/25.
11 | */
12 | public interface EventListener {
13 | void onEvent(T event);
14 |
15 | EventListener NONE_NULL = new EventListener() {
16 | @Override
17 | public void onEvent(EventBean event) {
18 | }
19 | };
20 | }
21 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/MsgBridgeService.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Package: org.github.jimu.msg
10 | * Project: jimu-core
11 | * Classname: MsgBridgeService
12 | * Description: annotation for MessageBridgeService
13 | * Created by leobert on 2018/6/11.
14 | */
15 | @Target(ElementType.TYPE)
16 | @Retention(RetentionPolicy.RUNTIME) // not sure if it is applicable to using CLASS
17 | public @interface MsgBridgeService {
18 | /**
19 | * @return the full name of the process that the service runs in
20 | */
21 | String workProcessName();
22 | }
23 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/Utils.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg;
2 |
3 | import android.os.Looper;
4 | import android.text.TextUtils;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.FileReader;
8 | import java.io.IOException;
9 |
10 | /**
11 | * Package: org.github.jimu.msg
12 | * Project: JIMU
13 | * Classname: Utils
14 | * Description: utilities
15 | * Created by leobert on 2018/4/26.
16 | */
17 | public class Utils {
18 | public static String getProcessName() {
19 | BufferedReader reader = null;
20 | try {
21 | reader = new BufferedReader(new FileReader("/proc/" + android.os.Process.myPid() + "/cmdline"));
22 | String processName = reader.readLine();
23 | if (!TextUtils.isEmpty(processName)) {
24 | processName = processName.trim();
25 | }
26 | return processName;
27 | } catch (Throwable throwable) {
28 | throwable.printStackTrace();
29 | } finally {
30 | try {
31 | if (reader != null) {
32 | reader.close();
33 | }
34 | } catch (IOException exception) {
35 | exception.printStackTrace();
36 | }
37 | }
38 | return null;
39 | }
40 |
41 | public static boolean isMainThread() {
42 | return Looper.myLooper() == Looper.getMainLooper();
43 | }
44 |
45 | static void validateCompoEventManagerInterface(Class service) {
46 | if (!service.isInterface()) {
47 | throw new IllegalArgumentException("CompoEventManagerAPI must be declared as interfaces.");
48 | }
49 | if (service.getInterfaces().length > 0) {
50 | throw new IllegalArgumentException("CompoEventManagerAPI interfaces must not extend any other interfaces.");
51 | }
52 | }
53 |
54 | public static void checkNotNull(Object obj, String msg) {
55 | if (obj == null)
56 | throw new NullPointerException("null check failed; " + msg);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/bean/ConsumerMeta.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.bean;
2 |
3 |
4 | import org.github.jimu.msg.ConsumeOn;
5 | import org.github.jimu.msg.EventListener;
6 | import org.github.jimu.msg.Utils;
7 |
8 | /**
9 | * Package: org.github.jimu.msg.bean
10 | * Project: jimu-core
11 | * Classname: ConsumerMeta
12 | * Description: mate info of the consumer
13 | * Created by leobert on 2018/7/30.
14 | */
15 | public final class ConsumerMeta {
16 | private ConsumeOn consumeOn;
17 | private EventListener eventListener;
18 | private String process;
19 |
20 | public ConsumeOn getConsumeOn() {
21 | return consumeOn;
22 | }
23 |
24 | public EventListener getEventListener() {
25 | return eventListener;
26 | }
27 |
28 | public String getProcess() {
29 | return process;
30 | }
31 |
32 | private ConsumerMeta(Builder builder) {
33 | consumeOn = builder.consumeOn;
34 | eventListener = builder.eventListener;
35 | process = builder.process;
36 | Utils.checkNotNull(eventListener, "eventListener cannot be null," +
37 | "call ConsumerMate.Builder.eventListener before build");
38 |
39 | Utils.checkNotNull(process, "process cannot be null, you can use empty string for the default main process");
40 | }
41 |
42 |
43 | public static Builder newBuilder() {
44 | return new Builder();
45 | }
46 |
47 |
48 | public static final class Builder {
49 | private ConsumeOn consumeOn = ConsumeOn.Main;
50 | private EventListener eventListener;
51 | /**
52 | * "" mean the default process when application is created
53 | */
54 | private String process = "";
55 |
56 | private Builder() {
57 | }
58 |
59 | public Builder consumeOn(ConsumeOn val) {
60 | consumeOn = val;
61 | return this;
62 | }
63 |
64 |
65 | public Builder process(String val) {
66 | process = val;
67 | return this;
68 | }
69 |
70 | public Builder currentProcess() {
71 | process = Utils.getProcessName();
72 | return this;
73 | }
74 |
75 | public Builder eventListener(EventListener val) {
76 | eventListener = val;
77 | return this;
78 | }
79 |
80 | public ConsumerMeta build() {
81 | return new ConsumerMeta<>(this);
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/bean/EventBean.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.bean;
2 |
3 | /**
4 | * Package: org.github.jimu.msg.bean
5 | * Project: JIMU
6 | * Classname: EventBean
7 | * Description:
8 | * Created by leobert on 2018/4/26.
9 | */
10 | public interface EventBean {
11 | }
12 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/bean/RemoteEventBean.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.bean;
2 |
3 | import android.os.Parcelable;
4 |
5 | /**
6 | * Package: org.github.jimu.msg.bean
7 | * Project: JIMU
8 | * Classname: RemoteEventBean
9 | * Description: TODO
10 | * Created by leobert on 2018/4/26.
11 | */
12 | public interface RemoteEventBean extends EventBean, Parcelable {
13 | }
14 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/bean/State.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.bean;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.annotation.Nullable;
5 | import android.support.annotation.VisibleForTesting;
6 |
7 | import org.github.jimu.msg.Utils;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * Package: org.github.jimu.msg.bean
14 | * Project: JIMU
15 | * Classname: State
16 | * Description: TODO
17 | * Created by leobert on 2018/4/25.
18 | */
19 | public class State {
20 | private final List eventQueue = new ArrayList<>();
21 | public boolean onPosting= false;
22 | public final boolean onMainThread;
23 |
24 | public State() {
25 | onMainThread = Utils.isMainThread();
26 | }
27 |
28 | public void addEvent2Queue(@NonNull T event) {
29 | eventQueue.add(event);
30 | }
31 |
32 | public boolean isQueueEmpty() {
33 | return eventQueue.isEmpty();
34 | }
35 |
36 | @VisibleForTesting
37 | public int queneSize() {
38 | return eventQueue.size();
39 | }
40 |
41 | @Nullable
42 | @SuppressWarnings("unchecked")
43 | public T peekFromQueue() {
44 | try {
45 | return (T) eventQueue.remove(0);
46 | } catch (IndexOutOfBoundsException e) {
47 | return null;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/core/MessageBridgeService.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.core;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.os.Messenger;
7 |
8 | import com.luojilab.component.componentlib.log.ILogger;
9 |
10 | import org.github.jimu.msg.EventManager;
11 | import org.github.jimu.msg.Utils;
12 |
13 | /**
14 | * Package: org.github.jimu.msg
15 | * Project: JIMU
16 | * Classname: MessageBridgeService
17 | * Description: service for the binder used in cross process communication.
18 | * define the unique sub-class for the specific process,
19 | * and notate with {@link org.github.jimu.msg.MsgBridgeService}
20 | *
21 | * Created by leobert on 2018/4/25.
22 | *
23 | * @see org.github.jimu.msg.MsgBridgeService MsgBridgeService
24 | */
25 | public abstract class MessageBridgeService extends Service {
26 |
27 | private Messenger currentProcessMessenger = new Messenger(new RemoteObservableHandler());
28 |
29 | @Override
30 | public final IBinder onBind(Intent intent) {
31 | String pn = Utils.getProcessName();
32 | ILogger.logger.monitor("set messenger in order: " + pn);
33 | EventManager.getInstance().updateMessenger(pn, currentProcessMessenger);
34 | return currentProcessMessenger.getBinder();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/core/MessageFactory.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.core;
2 |
3 | import android.os.Bundle;
4 | import android.os.Message;
5 | import android.os.Messenger;
6 | import android.support.annotation.NonNull;
7 |
8 | import org.github.jimu.msg.Constants;
9 | import org.github.jimu.msg.bean.RemoteEventBean;
10 |
11 | /**
12 | * Package: org.github.jimu.msg.core
13 | * Project: JIMU
14 | * Classname: MessageFactory
15 | * Description: factory for message
16 | * Created by leobert on 2018/4/24.
17 | */
18 | public class MessageFactory {
19 | public static final int WHAT_SUBSCRIBE_CROSS_PROCESS_EVENT = Constants.WHAT_SUBSCRIBE_CROSS_PROCESS_EVENT;
20 |
21 | public static final int WHAT_SEND_CROSS_PROCESS_EVENT = Constants.WHAT_SEND_CROSS_PROCESS_EVENT;
22 |
23 | public static final String BUNDLE_STR_EVENT_CLZ = Constants.BUNDLE_STR_EVENT_CLZ;
24 |
25 | public static final String BUNDLE_PARCEL_EVENT = Constants.BUNDLE_PARCEL_EVENT;
26 |
27 |
28 | /**
29 | * obtain subscribe message, contains the key-point information
30 | * of on cross-process subscriber and the event class it subscribes to
31 | *
32 | * @param consumerMessenger Local side Messenger,if the event arise at the remote,
33 | * remote will send it through this
34 | * @param eventClz Class of the event want to subscribe
35 | * @return the subscribe message
36 | */
37 | public static Message obtainSubscribeMsg(Messenger consumerMessenger, Class eventClz) {
38 | Message message = Message.obtain();
39 | message.what = WHAT_SUBSCRIBE_CROSS_PROCESS_EVENT;
40 | message.replyTo = consumerMessenger;
41 | Bundle bundle = new Bundle();
42 | bundle.putString(BUNDLE_STR_EVENT_CLZ, eventClz.getName());
43 | message.setData(bundle);
44 | return message;
45 | }
46 |
47 | public static Message obtainEventMsg(@NonNull T event) {
48 | Message message = Message.obtain();// new Message();
49 | message.what = WHAT_SEND_CROSS_PROCESS_EVENT;
50 | Bundle bundle = new Bundle();
51 | bundle.putString(BUNDLE_STR_EVENT_CLZ, event.getClass().getName());
52 | bundle.putParcelable(BUNDLE_PARCEL_EVENT, event);
53 | message.setData(bundle);
54 | return message;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/core/SubscriberCache.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.core;
2 |
3 | import org.github.jimu.msg.bean.EventBean;
4 |
5 | import java.util.HashMap;
6 |
7 | /**
8 | * Package: org.github.jimu.msg.core
9 | * Project: JIMU
10 | * Classname: SubscriberCache
11 | * Description: just avoid too verbose rawType
12 | * Created by leobert on 2018/4/27.
13 | */
14 | public final class SubscriberCache extends HashMap> {
16 |
17 | public SubscriberCache(int initialCapacity, float loadFactor) {
18 | super(initialCapacity, loadFactor);
19 | }
20 |
21 | public SubscriberCache(int initialCapacity) {
22 | super(initialCapacity);
23 | }
24 |
25 | public SubscriberCache() {
26 | }
27 |
28 | @Override
29 | public SubscriberList get(Object key) {
30 | return super.get(key);
31 | }
32 |
33 | @Override
34 | public SubscriberList put(Class key, SubscriberList value) {
35 | return super.put(key, value);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/core/SubscriberList.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.core;
2 |
3 | import org.github.jimu.msg.EventListener;
4 | import org.github.jimu.msg.bean.EventBean;
5 |
6 | import java.lang.ref.WeakReference;
7 | import java.util.concurrent.CopyOnWriteArrayList;
8 |
9 | /**
10 | * Package: org.github.jimu.msg.core
11 | * Project: JIMU
12 | * Classname: SubscriberList
13 | * Description: just lazy...
14 | * Created by leobert on 2018/4/27.
15 | */
16 | public final class SubscriberList extends CopyOnWriteArrayList>> {
17 |
18 | @Override
19 | public WeakReference> get(int index) {
20 | return super.get(index);
21 | }
22 |
23 | public boolean removeCallback(EventListener listener) {
24 | boolean ret = false;
25 | for (int i = 0;i> ref = get(i);
27 | if (ref == null || ref.get() == null)
28 | continue;
29 |
30 | if (ref.get().equals(listener)) {
31 | ret = true;
32 | remove(ref);
33 | i--;
34 | ref.clear();
35 | }
36 | }
37 | return ret;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/executor/CrossProcessPoster.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.executor;
2 |
3 | import android.os.Messenger;
4 | import android.os.RemoteException;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 |
8 | import com.luojilab.component.componentlib.log.ILogger;
9 | import org.github.jimu.msg.EventListener;
10 | import org.github.jimu.msg.bean.EventBean;
11 | import org.github.jimu.msg.bean.RemoteEventBean;
12 | import org.github.jimu.msg.core.MessageFactory;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * Package: org.github.jimu.msg.executor
19 | * Project: JIMU
20 | * Classname: CrossProcessPoster
21 | * Description: TODO
22 | * Created by leobert on 2018/4/25.
23 | */
24 | public class CrossProcessPoster implements IPoster {
25 |
26 | @Nullable
27 | private Messenger remoteMessenger;
28 |
29 | public void setRemoteMessenger(@Nullable Messenger remoteMessenger) {
30 | this.remoteMessenger = remoteMessenger;
31 | post2Remote();
32 | }
33 |
34 | private final List eventCache = new ArrayList<>();
35 |
36 | private void post(@NonNull T event) {
37 | synchronized (eventCache) {
38 | eventCache.add(event);
39 | post2Remote();
40 | }
41 | }
42 |
43 | private void post2Remote() {
44 | if (remoteMessenger == null) {
45 | ILogger.logger.monitor("remoteMessenger is not in order ");
46 | return;
47 | }
48 |
49 | ILogger.logger.monitor("post to remote process");
50 |
51 | synchronized (eventCache) {
52 | while (!eventCache.isEmpty()) {
53 | RemoteEventBean bean = eventCache.remove(0);
54 | try {
55 | remoteMessenger.send(MessageFactory.obtainEventMsg(bean));
56 | } catch (RemoteException | NullPointerException e) {
57 | e.printStackTrace();
58 | }
59 | }
60 | }
61 | }
62 |
63 |
64 | @Override
65 | public void postEvent(@NonNull T event, @NonNull EventListener target) {
66 | post((RemoteEventBean) event);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/executor/IPoster.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.executor;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import org.github.jimu.msg.EventListener;
6 | import org.github.jimu.msg.bean.EventBean;
7 |
8 | /**
9 | * Package: org.github.jimu.msg.executor
10 | * Project: JIMU
11 | * Classname: IPoster
12 | * Description: TODO
13 | * Created by leobert on 2018/4/25.
14 | */
15 | public interface IPoster {
16 | void postEvent(@NonNull T event, @NonNull EventListener target);
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/executor/LocalProcessBackgroundPoster.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.executor;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v4.util.Pair;
5 |
6 | import org.github.jimu.msg.EventListener;
7 | import org.github.jimu.msg.bean.EventBean;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.concurrent.ExecutorService;
12 |
13 | import osp.leobert.android.reportprinter.notation.Bug;
14 |
15 | /**
16 | * Package: org.github.jimu.msg.executor
17 | * Project: JIMU
18 | * Classname: LocalProcessBackgroundPoster
19 | * Description: TODO
20 | * Created by leobert on 2018/5/3.
21 | */
22 | public class LocalProcessBackgroundPoster implements IPoster, Runnable {
23 | private final List>> cache;
24 |
25 | private boolean started = false;
26 | private final ExecutorService executorService;
27 |
28 | public LocalProcessBackgroundPoster(@NonNull ExecutorService executorService) {
29 | cache = new ArrayList<>();
30 | this.executorService = executorService;
31 | }
32 |
33 | @Override
34 | public void postEvent(@NonNull T event, @NonNull EventListener target) {
35 | synchronized (cache) {
36 | Pair> pair = new Pair<>((EventBean) event, (EventListener) target);
37 | cache.add(pair);
38 | if (!started) {
39 | started = true;
40 | executorService.execute(this);
41 | }
42 | }
43 | }
44 |
45 | /**
46 | * todo consider the waste of cpu performance in the infinite loop
47 | */
48 | @Override
49 | @SuppressWarnings("InfiniteLoopStatement")
50 | @Bug(desc = "consider the waste of cpu performance in the infinite loop")
51 | public void run() {
52 | try {
53 | while (true) {
54 | synchronized (cache) {
55 | if (!cache.isEmpty()) {
56 | Pair> temp = cache.remove(0);
57 | if (temp.second != null)
58 | temp.second.onEvent(temp.first);
59 | }
60 | }
61 | }
62 | } finally { //thread must be interrupted
63 | synchronized (cache) {
64 | started = false;
65 | }
66 | }
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/executor/LocalProcessMainThreadPoster.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.executor;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 | import android.os.Message;
6 | import android.support.annotation.NonNull;
7 | import android.support.v4.util.Pair;
8 |
9 | import org.github.jimu.msg.EventListener;
10 | import org.github.jimu.msg.bean.EventBean;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * Package: org.github.jimu.msg.executor
17 | * Project: JIMU
18 | * Classname: LocalProcessPoster
19 | * Description: TODO
20 | * Created by leobert on 2018/4/25.
21 | */
22 | public class LocalProcessMainThreadPoster extends Handler implements IPoster {
23 |
24 | private final List>> cache;
25 | private boolean started;
26 | private static final long threshold = 10;
27 |
28 | // TODO: 2018/4/27 考虑负载问题
29 |
30 | public LocalProcessMainThreadPoster() {
31 | super(Looper.getMainLooper());
32 | cache = new ArrayList<>();
33 | }
34 |
35 | @Override
36 | public void postEvent(@NonNull T event, @NonNull EventListener target) {
37 | synchronized (cache) {
38 |
39 | Pair> pair = new Pair<>((EventBean) event, (EventListener) target);
40 | cache.add(pair);
41 | if (!started) {
42 | removeMessages(0);
43 | start();
44 | }
45 | }
46 | }
47 |
48 | @Override
49 | public void handleMessage(Message msg) {
50 | // super.handleMessage(msg);
51 | long startStamp = System.currentTimeMillis();
52 | while (true) {
53 | long t = System.currentTimeMillis();
54 | if (t > startStamp + threshold) {
55 | started = false;
56 | resumeLater();
57 | return;
58 | }
59 | synchronized (cache) {
60 | if (cache.size() > 0) {
61 | Pair> temp = cache.remove(0);
62 | try {
63 | if (temp.second != null)
64 | temp.second.onEvent(temp.first);
65 | } finally {
66 | //ignore
67 | }
68 | } else {
69 | started = false;
70 | resumeLater();
71 | break;
72 | }
73 | }
74 | }
75 | }
76 |
77 | private void start() {
78 | sendEmptyMessage(0);
79 | }
80 |
81 | private void resumeLater() {
82 | sendEmptyMessageDelayed(0, 100);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/notation/AriseProcess.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.notation;
2 |
3 | import org.github.jimu.msg.bean.ConsumerMeta;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Package: org.github.jimu.msg.notation
12 | * Project: jimu-core
13 | * Classname: AriseProcess
14 | * Description: all event are created in the process it running at,if the subscriber
15 | * is running in the same process, we call say that the event arises at the local process, otherwise,
16 | * a remote process.
17 | * But, when we code the code, we knows the arise process of event, or said: the component itself knows
18 | * what process the event arise at.
19 | * The sense may be complicated, so we just notate the method to tell what process the event arise at, then
20 | * use {@link ConsumerMeta} and {@link Consumer} to tell what process the consumer
21 | * ran at.
22 | *
23 | * Created by leobert on 2018/7/14.
24 | */
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Target({ElementType.METHOD})
27 | public @interface AriseProcess {
28 |
29 | /**
30 | * maybe we should use a alias when integrate-test the sub component
31 | *
32 | * @return the full process name alias if from remote process, if is the default ""
33 | * means it arise at the default process when application is created.
34 | */
35 | String pa() default "";
36 | }
37 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/notation/Consumer.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.notation;
2 |
3 | import org.github.jimu.msg.bean.ConsumerMeta;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Package: org.github.jimu.msg.notation
12 | * Project: jimu-core
13 | * Classname: Consumer
14 | * Description: notate the parameter {@link ConsumerMeta}
15 | * Created by leobert on 2018/7/14.
16 | */
17 | @Retention(RetentionPolicy.RUNTIME)
18 | @Target(ElementType.PARAMETER)
19 | public @interface Consumer {
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/java/org/github/jimu/msg/notation/Event.java:
--------------------------------------------------------------------------------
1 | package org.github.jimu.msg.notation;
2 |
3 | import org.github.jimu.msg.bean.EventBean;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Package: org.github.jimu.msg.notation
12 | * Project: jimu-core
13 | * Classname: Event
14 | * Description: an notation to notate the event class you subscribe to
15 | * Created by leobert on 2018/7/30.
16 | */
17 | @Retention(RetentionPolicy.RUNTIME)
18 | @Target({ElementType.METHOD})
19 | public @interface Event {
20 | Class extends EventBean> clz();
21 | }
22 |
--------------------------------------------------------------------------------
/jimu-core/componentlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | basiclib
3 |
4 |
--------------------------------------------------------------------------------
/jimu-core/gradle.properties.bak:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | mainmodulename=app
15 | bintrayRepo=maven
16 | publishedGroupId=com.github.jimu
17 | siteUrl=https://github.com/mqzhangw/JIMU
18 | gitUrl=https://github.com/mqzhangw/JIMU.git
19 | developerId=mqzhang,leobert
20 | developerName=mqzhang,leobert
21 | developerEmail=zhmqq0527@gmail.com,leobert.l@hotmail.com
22 |
--------------------------------------------------------------------------------
/jimu-core/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/jimu-core/installv1.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 |
3 | group = publishedGroupId // Maven Group ID for the artifact
4 |
5 | install {
6 | repositories.mavenInstaller {
7 | // This generates POM.xml with proper parameters
8 | pom {
9 | project {
10 | packaging 'aar'
11 | groupId publishedGroupId
12 | artifactId artifact
13 |
14 | // Add your description here
15 | name libraryName
16 | description libraryDescription
17 | url siteUrl
18 |
19 | // Set your license
20 | licenses {
21 | license {
22 | name licenseName
23 | url licenseUrl
24 | }
25 | }
26 | developers {
27 | developer {
28 | id developerId
29 | name developerName
30 | email developerEmail
31 | }
32 | }
33 | scm {
34 | connection gitUrl
35 | developerConnection gitUrl
36 | url siteUrl
37 |
38 | }
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/jimu-core/router-anno-compiler/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-core/router-anno-compiler/src/main/java/com/luojilab/router/compiler/utils/AnnoUtils.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.compiler.utils;
2 |
3 | import com.luojilab.router.compiler.model.MethodInfo;
4 | import com.squareup.javapoet.ParameterSpec;
5 | import com.squareup.javapoet.ParameterizedTypeName;
6 | import com.squareup.javapoet.TypeName;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import javax.lang.model.element.Element;
12 | import javax.lang.model.element.ExecutableElement;
13 | import javax.lang.model.element.Modifier;
14 | import javax.lang.model.element.VariableElement;
15 | import javax.lang.model.type.TypeMirror;
16 |
17 | /**
18 | * Package: com.luojilab.router.compiler.utils
19 | * Project: DDComponentForAndroid
20 | * Classname: AnnoUtils
21 | * Description: AnnoUtils
22 | * Created by leobert on 2017/9/25.
23 | */
24 |
25 | public class AnnoUtils {
26 | public static MethodInfo generateMethodInfo(ExecutableElement methodElement) {
27 | //modifiers
28 | ArrayList methodModifiers = new ArrayList<>();
29 | methodModifiers.add(Modifier.PUBLIC);
30 | //name
31 | String methodName = getSimpleName(methodElement);
32 | //params
33 | List methodParams = new ArrayList<>();
34 | for (VariableElement typeParameterElement : methodElement.getParameters()) {
35 | methodParams.add(typeParameterElement);
36 | }
37 | //return type
38 | TypeMirror methodReturnType = methodElement.getReturnType();
39 | return new MethodInfo().setMethodName(methodName)
40 | .setMethodModifiers(methodModifiers)
41 | .setMethodParameters(methodParams)
42 | .setMethodReturnType(methodReturnType);
43 | }
44 |
45 | public static String getSimpleName(Element element) {
46 | return element.getSimpleName().toString();
47 | }
48 |
49 | public static ParameterSpec generateMethodParameterSpec(TypeMirror typeMirror,
50 | String paramName) {
51 | TypeName tn =
52 | ParameterizedTypeName.get(typeMirror);
53 |
54 | return ParameterSpec.builder(tn, paramName).build();
55 | }
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/jimu-core/router-anno-compiler/src/main/java/com/luojilab/router/compiler/utils/Constants.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.compiler.utils;
2 |
3 | /**
4 | * Package: com.luojilab.router.compiler.utils
5 | * Project: DDComponentForAndroid
6 | * Classname: Constants
7 | * Description: Constants used by apt
8 | * Created by leobert on 2017/9/18.
9 | */
10 |
11 | public interface Constants {
12 |
13 | String ANNO_FACADE_PKG = "com.luojilab.router.facade";
14 |
15 |
16 | ///////////////////////////////////////////////////////////////////////////
17 | // Options of processor
18 | ///////////////////////////////////////////////////////////////////////////
19 | String KEY_HOST_NAME = "host";
20 |
21 | String ANNOTATION_TYPE_ROUTE_NODE = ANNO_FACADE_PKG + ".annotation.RouteNode";
22 | String ANNOTATION_TYPE_ROUTER = ANNO_FACADE_PKG + ".annotation.Router";
23 | String ANNOTATION_TYPE_AUTOWIRED = ANNO_FACADE_PKG + ".annotation.Autowired";
24 |
25 | String PREFIX_OF_LOGGER = "[Router-Anno-Compiler]-- ";
26 |
27 |
28 | // System interface
29 | String ACTIVITY = "android.app.Activity";
30 | String FRAGMENT = "android.app.Fragment";
31 | String FRAGMENT_V4 = "android.support.v4.app.Fragment";
32 | String SERVICE = "android.app.Service";
33 | String PARCELABLE = "android.os.Parcelable";
34 | String SERIALIZABLE = "java.io.Serializable";
35 | String BUNDLE = "android.os.Bundle";
36 |
37 | // Java type
38 | String LANG = "java.lang";
39 | String BYTE = LANG + ".Byte";
40 | String SHORT = LANG + ".Short";
41 | String INTEGER = LANG + ".Integer";
42 | String LONG = LANG + ".Long";
43 | String FLOAT = LANG + ".Float";
44 | String DOUBEL = LANG + ".Double";
45 | String BOOLEAN = LANG + ".Boolean";
46 | String STRING = LANG + ".String";
47 |
48 | String ISYRINGE = "com.luojilab.component.componentlib.router.ISyringe";
49 |
50 | String JSON_SERVICE = "com.luojilab.component.componentlib.service.JsonService";
51 |
52 | String BASECOMPROUTER = "com.luojilab.component.componentlib.router.ui.BaseCompRouter";
53 |
54 | String MISSING_BASECOMPROUTER_MSG = "class BaseCompRouter not found\n确认以下细节:" +
55 | "1.该Module是否使用了componentlib依赖\n" +
56 | "2.确保版本适配,最新的适配版本套件,参考仓库release-note\n" +
57 | "3.使用的componentlib库中BaseCompRouter没有被混淆\n" +
58 | "more detail: https://github.com/mqzhangw/JIMU/issues/26";
59 | }
60 |
--------------------------------------------------------------------------------
/jimu-core/router-anno-compiler/src/main/java/com/luojilab/router/compiler/utils/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.compiler.utils;
2 |
3 | import java.io.BufferedWriter;
4 | import java.io.File;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.OutputStreamWriter;
8 |
9 | /**
10 | * Created by mrzhang on 2017/12/20.
11 | */
12 |
13 | public class FileUtils {
14 |
15 |
16 | /**
17 | * @param fileName
18 | */
19 | public static boolean createFile(String fileName) {
20 | try {
21 | File file = new File(fileName);
22 | if (!file.exists()) {
23 | File dir = new File(file.getParent());
24 | dir.mkdirs();
25 | file.createNewFile();
26 | }
27 | return true;
28 | } catch (Exception e) {
29 | e.printStackTrace();
30 | }
31 | return false;
32 | }
33 |
34 |
35 | /**
36 | * @param fileName
37 | * @param content
38 | */
39 | public static void writeStringToFile(String fileName, String content, boolean append) {
40 | BufferedWriter out = null;
41 | FileOutputStream fileOutputStream = null;
42 | OutputStreamWriter osw = null;
43 | try {
44 | fileOutputStream = new FileOutputStream(fileName, append);
45 | osw = new OutputStreamWriter(fileOutputStream, "UTF-8");
46 | out = new BufferedWriter(osw);
47 | out.write(content);
48 | } catch (Exception e) {
49 | e.printStackTrace();
50 | } finally {
51 | try {
52 | if (out != null)
53 | out.close();
54 | if (osw != null)
55 | osw.close();
56 | if (fileOutputStream != null)
57 | fileOutputStream.close();
58 | } catch (IOException e) {
59 | e.printStackTrace();
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/jimu-core/router-anno-compiler/src/main/java/com/luojilab/router/compiler/utils/Logger.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.compiler.utils;
2 |
3 | import javax.annotation.processing.Messager;
4 | import javax.tools.Diagnostic;
5 |
6 | /**
7 | * Package: com.luojilab.router.compiler.utils
8 | * Project: DDComponentForAndroid
9 | * Classname: Logger
10 | * Description: logger for apt
11 | * Created by leobert on 2017/9/18.
12 | */
13 |
14 | public class Logger {
15 | private Messager msg;
16 |
17 | public Logger(Messager messager) {
18 | msg = messager;
19 | }
20 |
21 | /**
22 | * Print info log.
23 | */
24 | public void info(CharSequence info) {
25 | if (isNotEmpty(info)) {
26 | msg.printMessage(Diagnostic.Kind.NOTE, Constants.PREFIX_OF_LOGGER + info);
27 | }
28 | }
29 |
30 | public void error(CharSequence error) {
31 | if (isNotEmpty(error)) {
32 | msg.printMessage(Diagnostic.Kind.ERROR, Constants.PREFIX_OF_LOGGER + "An exception is encountered, [" + error + "]");
33 | }
34 | }
35 |
36 | public void error(Throwable error) {
37 | if (null != error) {
38 | msg.printMessage(Diagnostic.Kind.ERROR, Constants.PREFIX_OF_LOGGER + "An exception is encountered, [" + error.getMessage() + "]" + "\n" + formatStackTrace(error.getStackTrace()));
39 | }
40 | }
41 |
42 | public void warning(CharSequence warning) {
43 | if (isNotEmpty(warning)) {
44 | msg.printMessage(Diagnostic.Kind.WARNING, Constants.PREFIX_OF_LOGGER + warning);
45 | }
46 | }
47 |
48 | private String formatStackTrace(StackTraceElement[] stackTrace) {
49 | StringBuilder sb = new StringBuilder();
50 | for (StackTraceElement element : stackTrace) {
51 | sb.append(" at ").append(element.toString());
52 | sb.append("\n");
53 | }
54 | return sb.toString();
55 | }
56 |
57 | private static boolean isNotEmpty(final CharSequence cs) {
58 | boolean isEmpty = cs == null || cs.length() == 0;
59 | return !isEmpty;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/jimu-core/router-anno-compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | com.luojilab.router.compiler.processor.AutowiredProcessor
2 | com.luojilab.router.compiler.processor.RouterProcessor
--------------------------------------------------------------------------------
/jimu-core/router-annotation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-core/router-annotation/src/main/java/com/luojilab/router/facade/annotation/Autowired.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.facade.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Package: com.luojilab.router.facade.annotation
10 | * Project: DDComponentForAndroid
11 | * Classname: Autowired
12 | * Description: used to auto-inject dependency
13 | * Created by leobert on 2017/9/18.
14 | */
15 | @Target({ElementType.FIELD})
16 | @Retention(RetentionPolicy.CLASS)
17 | public @interface Autowired {
18 |
19 | /**
20 | * @return param's name or service name.
21 | */
22 | String name() default "";
23 |
24 | /**
25 | * primitive java type check will be ignore
26 | * check the result of DI, if inject failed, the value of
27 | * the field will be null, if required, output log
28 | *
29 | * @return true for required,false otherwise
30 | */
31 | boolean required() default false;
32 |
33 | /**
34 | * throw exception when the required field is null after inject.
35 | *
36 | * It can help developer find most data delivering bugs when developing.
37 | * but not suggest to open this function after release.
38 | *
39 | * I suggest to define a Constant maintained manually
40 | *
41 | * only activated when required = true and throwOnNull = true.
42 | *
43 | * @return true if throwing exception when null is required, false otherwise
44 | */
45 | boolean throwOnNull() default false;
46 |
47 | /**
48 | * @return field description
49 | */
50 | String desc() default "none desc.";
51 | }
52 |
--------------------------------------------------------------------------------
/jimu-core/router-annotation/src/main/java/com/luojilab/router/facade/annotation/RouteNode.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.facade.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | *
Package: com.luojilab.router.facade.annotation
10 | * Project: DDComponentForAndroid
11 | * Classname: RouteDef
12 | * Description: used to decline a route node
13 | * Created by leobert on 2017/9/18.
14 | */
15 | @Target({ElementType.TYPE})
16 | @Retention(RetentionPolicy.CLASS)
17 | public @interface RouteNode {
18 | /**
19 | * path of one route
20 | */
21 | String path();
22 | /**
23 | * The priority of route.
24 | *
25 | * we inspect the path and throw exception when duplicated
26 | * paths were find, thus, it's useless and impossible to use priority
27 | */
28 | @Deprecated
29 | int priority() default -1;
30 |
31 | /**
32 | * description of the activity, user for gen route table
33 | */
34 | String desc() default "";
35 | }
36 |
--------------------------------------------------------------------------------
/jimu-core/router-annotation/src/main/java/com/luojilab/router/facade/enums/NodeType.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.facade.enums;
2 |
3 | /**
4 | * Package: com.luojilab.router.facade.enums
5 | * Project: DDComponentForAndroid
6 | * Classname: NodeType
7 | * Description: TODO
8 | * Created by leobert on 2017/9/19.
9 | */
10 |
11 | public enum NodeType {
12 | ACTIVITY(0, "android.app.Activity"),
13 | INVALID(-1,"invalid node type, currently only activity allowed");
14 |
15 | int id;
16 | String className;
17 |
18 | NodeType(int id, String className) {
19 | this.id = id;
20 | this.className = className;
21 | }
22 |
23 | public int getId() {
24 | return id;
25 | }
26 |
27 | public NodeType setId(int id) {
28 | this.id = id;
29 | return this;
30 | }
31 |
32 | public String getClassName() {
33 | return className;
34 | }
35 |
36 | public NodeType setClassName(String className) {
37 | this.className = className;
38 | return this;
39 | }
40 |
41 | public static NodeType parse(String name) {
42 | for (NodeType nodeType : NodeType.values()) {
43 | if (nodeType.getClassName().equals(name)) {
44 | return nodeType;
45 | }
46 | }
47 |
48 | return INVALID;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/jimu-core/router-annotation/src/main/java/com/luojilab/router/facade/enums/Type.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.facade.enums;
2 |
3 | /**
4 | * Package: com.luojilab.router.facade.enums
5 | * Project: DDComponentForAndroid
6 | * Classname: Type
7 | * Description: enums for java basic types and STRING,PARCELABLE,OBJECT
8 | * Created by leobert on 2017/9/18.
9 | */
10 |
11 | public enum Type {
12 |
13 | ///////////////////////////////////////////////
14 | // Base type
15 | ///////////////////////////////////////////////
16 |
17 | BOOLEAN,
18 | BYTE,
19 | SHORT,
20 | INT,
21 | LONG,
22 | CHAR,
23 | FLOAT,
24 | DOUBLE,
25 |
26 | ///////////////////////////////////////////////
27 | // Other type
28 | ///////////////////////////////////////////////
29 |
30 | STRING,
31 | PARCELABLE,
32 | OBJECT,
33 | SERIALIZABLE
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/jimu-core/router-annotation/src/main/java/com/luojilab/router/facade/model/Node.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.facade.model;
2 |
3 | import com.luojilab.router.facade.enums.NodeType;
4 |
5 | import java.util.Map;
6 |
7 | import javax.lang.model.element.Element;
8 |
9 | /**
10 | * Package: com.luojilab.router.facade.model
11 | * Project: DDComponentForAndroid
12 | * Classname: Node
13 | * Description: TODO
14 | * Created by leobert on 2017/9/19.
15 | */
16 |
17 | public class Node {
18 | private NodeType nodeType;
19 | private Element rawType; // Raw type of route
20 | private Class> destination; // Destination
21 | private String path; // Path of route
22 | private String desc; // Desc of route
23 | private int priority = -1; // The smaller the number, the higher the priority
24 | private Map paramsType;
25 | private Map paramsDesc;
26 |
27 | public NodeType getNodeType() {
28 | return nodeType;
29 | }
30 |
31 | public void setNodeType(NodeType nodeType) {
32 | this.nodeType = nodeType;
33 | }
34 |
35 | public Element getRawType() {
36 | return rawType;
37 | }
38 |
39 | public void setRawType(Element rawType) {
40 | this.rawType = rawType;
41 | }
42 |
43 | public Class> getDestination() {
44 | return destination;
45 | }
46 |
47 | public void setDestination(Class> destination) {
48 | this.destination = destination;
49 | }
50 |
51 | public String getPath() {
52 | return path;
53 | }
54 |
55 | public void setPath(String path) {
56 | this.path = path;
57 | }
58 |
59 | public int getPriority() {
60 | return priority;
61 | }
62 |
63 | public void setPriority(int priority) {
64 | this.priority = priority;
65 | }
66 |
67 | public Map getParamsType() {
68 | return paramsType;
69 | }
70 |
71 | public void setParamsType(Map paramsType) {
72 | this.paramsType = paramsType;
73 | }
74 |
75 | public Map getParamsDesc() {
76 | return paramsDesc;
77 | }
78 |
79 | public void setParamsDesc(Map paramsDesc) {
80 | this.paramsDesc = paramsDesc;
81 | }
82 |
83 | public String getDesc() {
84 | return desc;
85 | }
86 |
87 | public void setDesc(String desc) {
88 | this.desc = desc;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/jimu-core/router-annotation/src/main/java/com/luojilab/router/facade/utils/RouteUtils.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.router.facade.utils;
2 |
3 | /**
4 | * Created by mrzhang on 2017/12/18.
5 | */
6 |
7 | public class RouteUtils {
8 |
9 | private static final String ROUTERIMPL_OUTPUT_PKG = "com.luojilab.gen.router";
10 | private static final String DOT = ".";
11 | private static final String UIROUTER = "UiRouter";
12 |
13 | private static final String ROUTERTABLE = "RouterTable";
14 |
15 | public static String firstCharUpperCase(String str) {
16 | char[] ch = str.toCharArray();
17 | if (ch[0] >= 'a' && ch[0] <= 'z') {
18 | ch[0] = (char) (ch[0] - 32);
19 | }
20 | return new String(ch);
21 | }
22 |
23 | public static String genHostUIRouterClass(String host) {
24 | String claName = ROUTERIMPL_OUTPUT_PKG + DOT + firstCharUpperCase(host) + UIROUTER;
25 | return new String(claName);
26 | }
27 |
28 |
29 | public static String genRouterTable(String host) {
30 | String claName = "./UIRouterTable/" + firstCharUpperCase(host) + ROUTERTABLE + ".txt";
31 | return new String(claName);
32 | }
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/jimu-core/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':build-gradle'
2 | include ':componentlib'
3 | include ':router-annotation'
4 | include ':router-anno-compiler'
5 |
--------------------------------------------------------------------------------
/jimu-sample-project/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | /gradle
9 | /buildSrc/build/
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/AptHotfix/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/jimu-sample-project/AptHotfix/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | }
4 |
5 | java {
6 | sourceCompatibility = JavaVersion.VERSION_1_7
7 | targetCompatibility = JavaVersion.VERSION_1_7
8 | }
9 |
10 | repositories {
11 | mavenCentral()
12 | google()
13 | jcenter()
14 | }
15 | dependencies {
16 |
17 | implementation "io.github.leobert-lan:jimu-router-anno-compiler:1.0.1"
18 | implementation 'com.google.auto.service:auto-service:1.0-rc2'
19 | implementation 'com.squareup:javapoet:1.9.0'
20 |
21 |
22 | implementation 'org.apache.commons:commons-lang3:3.4'
23 | implementation 'org.apache.commons:commons-collections4:4.1'
24 | implementation "io.github.leobert-lan:jimu-router-annotation:1.0.1"
25 | }
--------------------------------------------------------------------------------
/jimu-sample-project/AptHotfix/src/main/java/com/jimu/hotfix/AutowiredProcessorHotfix.java:
--------------------------------------------------------------------------------
1 | package com.jimu.hotfix;
2 |
3 | import com.google.auto.service.AutoService;
4 | import com.luojilab.router.compiler.processor.AutowiredProcessor;
5 | import com.luojilab.router.compiler.utils.Constants;
6 |
7 | import javax.annotation.processing.Processor;
8 | import javax.annotation.processing.SupportedAnnotationTypes;
9 | import javax.annotation.processing.SupportedOptions;
10 | import javax.annotation.processing.SupportedSourceVersion;
11 | import javax.lang.model.SourceVersion;
12 |
13 |
14 | /**
15 | * Package: apt
16 | * Project: jimu-sample-project
17 | * Classname: AutowiredProcessorHotfix
18 | * Description: TODO
19 | * Created by leobert on 2021/6/10.
20 | */
21 | @AutoService(Processor.class)
22 | @SupportedOptions(Constants.KEY_HOST_NAME)
23 | @SupportedSourceVersion(SourceVersion.RELEASE_7)
24 | @SupportedAnnotationTypes({Constants.ANNOTATION_TYPE_AUTOWIRED})
25 | public class AutowiredProcessorHotfix extends AutowiredProcessor {
26 | }
27 |
--------------------------------------------------------------------------------
/jimu-sample-project/AptHotfix/src/main/java/com/jimu/hotfix/RouterProcessorHotfix.java:
--------------------------------------------------------------------------------
1 | package com.jimu.hotfix;
2 |
3 | import com.google.auto.service.AutoService;
4 | import com.luojilab.router.compiler.processor.RouterProcessor;
5 | import com.luojilab.router.compiler.utils.Constants;
6 |
7 | import javax.annotation.processing.Processor;
8 | import javax.annotation.processing.SupportedAnnotationTypes;
9 | import javax.annotation.processing.SupportedOptions;
10 | import javax.annotation.processing.SupportedSourceVersion;
11 | import javax.lang.model.SourceVersion;
12 |
13 | /**
14 | * Package: apt
15 | * Project: jimu-sample-project
16 | * Classname: RouterProcessor
17 | * Description: TODO
18 | * Created by leobert on 2021/6/10.
19 | */
20 | @AutoService(Processor.class)
21 | @SupportedOptions(Constants.KEY_HOST_NAME)
22 | @SupportedSourceVersion(SourceVersion.RELEASE_7)
23 | @SupportedAnnotationTypes({Constants.ANNOTATION_TYPE_ROUTE_NODE, Constants.ANNOTATION_TYPE_ROUTER})
24 | public class RouterProcessorHotfix extends RouterProcessor {
25 | }
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/AptHotfix/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | com.jimu.hotfix.AutowiredProcessorHotfix
2 | com.jimu.hotfix.RouterProcessorHotfix
--------------------------------------------------------------------------------
/jimu-sample-project/UIRouterTable/AppRouterTable.txt:
--------------------------------------------------------------------------------
1 | auto generated, do not change !!!!
2 |
3 | HOST : app
4 |
5 | 主进程页面1
6 | /msg/demo/1
7 |
8 | remote进程页面
9 | /msg/demo/3
10 |
11 | 主进程页面2
12 | /msg/demo/2
13 |
14 | 首页
15 | /main
16 |
17 | 使用Url传参
18 | /uirouter/demo/3
19 | foo:String
20 | EXTRA_STR_BAR:String
21 |
22 | Url和Bundle同时包含参数
23 | /uirouter/demo/4
24 | foo:String
25 | EXTRA_STR_BAR:String
26 |
27 | Parcelable和Serializable
28 | /uirouter/demo/5
29 | foo:parcelable
30 |
31 | 使用bundle传递参数
32 | /uirouter/demo/2
33 | foo:String
34 | EXTRA_STR_BAR:String
35 |
36 | 必须参数2
37 | /uirouter/demo/8
38 | foo:String
39 |
40 | 必须参数
41 | /uirouter/demo/7
42 | foo:String
43 |
44 | 使用json字符串传参
45 | /uirouter/demo/6
46 | EXTRA_OBJ_FOO:com.luojilab.componentdemo.router.cases.Demo6Activity.Foo
47 |
48 | 无参数
49 | /uirouter/demo/1
50 |
51 | UiRouter使用演示页面
52 | /uirouter/demo
53 |
54 |
--------------------------------------------------------------------------------
/jimu-sample-project/UIRouterTable/KotlinRouterTable.txt:
--------------------------------------------------------------------------------
1 | auto generated, do not change !!!!
2 |
3 | HOST : kotlin
4 |
5 | 分享杂志页面
6 | /shareMagazine
7 | author:com.luojilab.componentservice.share.bean.AuthorKt
8 | bookName:String
9 |
10 | test multi java and kotlin in one module
11 | /javatest
12 | author:com.luojilab.componentservice.share.bean.AuthorKt
13 | bookName:String
14 |
15 |
--------------------------------------------------------------------------------
/jimu-sample-project/UIRouterTable/ShareRouterTable.txt:
--------------------------------------------------------------------------------
1 | auto generated, do not change !!!!
2 |
3 | HOST : share
4 |
5 | 分享书籍-内容编辑页面
6 | /share/edit/book
7 | author:com.luojilab.componentservice.share.bean.Author
8 | bookName:String
9 |
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/build.gradle:
--------------------------------------------------------------------------------
1 | import jimu.Consts
2 |
3 | apply plugin: Consts.jimu_plugin_name
4 | //apply plugin: 'JimuHotfix'
5 |
6 | android {
7 | compileSdkVersion versions.compileSdk
8 | buildToolsVersion versions.androidTools
9 |
10 | defaultConfig {
11 | minSdkVersion versions.minSdk
12 | targetSdkVersion versions.targetSdk
13 | versionCode 1
14 | versionName "1.0"
15 | applicationId "com.luojilab.androidcomponent"
16 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
17 |
18 | javaCompileOptions {
19 | annotationProcessorOptions {
20 | arguments = [host: "app"]
21 | }
22 | }
23 |
24 | vectorDrawables.useSupportLibrary = true
25 |
26 | }
27 | buildTypes {
28 | release {
29 | minifyEnabled true
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 |
33 | debug {
34 | signingConfig signingConfigs.debug
35 | minifyEnabled false
36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
37 | }
38 | }
39 |
40 | lintOptions {
41 | checkReleaseBuilds false
42 | // Or, if you prefer, you can continue to check for errors in release builds,
43 | // but continue the build even when errors are found:
44 | abortOnError false
45 | }
46 |
47 |
48 | }
49 |
50 | dependencies {
51 | implementation project(':componentservice')
52 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
53 | implementation 'com.google.android.material:material:1.2.1'
54 | implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
55 |
56 |
57 | annotationProcessor Consts.Deps.JIMU_ROUTER_COMPILER
58 | // annotationProcessor(project(":AptHotfix"))
59 | }
60 |
61 | def projectRoot = project.getRootProject().rootDir.absolutePath
62 |
63 |
64 | combuild {
65 | applicationName = 'com.luojilab.componentdemo.application.AppApplication'
66 | isRegisterCompoAuto = true
67 |
68 | originalManifest = projectRoot + "/app/src/main/AndroidManifest.xml"
69 |
70 | runAloneManifest = projectRoot + "/app/src/main/AndroidManifest.xml"
71 | targetManifest = projectRoot + "/app/src/main/AndroidManifest.xml"
72 | //如果不需要合并,改为false
73 | enableManifestMerge = false
74 | }
75 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | isRunAlone=true
15 | debugComponent=sharecomponent,sharecomponentkotlin,readercomponent
16 | compileComponent=sharecomponent,sharecomponentkotlin,readercomponent
17 |
18 |
19 |
--------------------------------------------------------------------------------
/jimu-sample-project/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 /Users/klee/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 | -ignorewarnings
27 | -dontoptimize
28 | -keep class !android.support.v7.view.menu.*MenuBuilder*, android.support.v7.** { *; }
29 | -keep class android.support.v4.** { *; }
30 | -keep interface android.support.** { *; }
31 | -keepattributes Signature
32 | -keepattributes SourceFile,LineNumberTable
33 | -keep public class * extends android.support.**
34 | -keep public class * extends android.app.Fragment
35 | -keep public class * extends android.app.Activity
36 | -keep public class * extends android.app.Application
37 | -keep public class * extends android.app.Service
38 | -keep public class * extends android.content.BroadcastReceiver
39 | -keep public class * extends android.content.ContentProvider
40 | -keep public class * extends android.app.backup.BackupAgentHelper
41 | -keep public class * extends android.preference.Preference
42 | -keep public class * extends com.netease.ntespmmvp.** {*;}
43 |
44 | -keep enum * { *;}
45 |
46 | -keep interface * {
47 | ;
48 | }
49 | -keep class com.luojilab.component.componentlib.** {*;}
50 | -keep class com.luojilab.router.** {*;}
51 | -keep class com.luojilab.gen.** {*;}
52 | -keep class * implements com.luojilab.component.componentlib.router.ISyringe {*;}
53 | -keep class * implements com.luojilab.component.componentlib.applicationlike.IApplicationLike {*;}
54 | -dontwarn okio.**
55 | -dontwarn okhttp3.**
56 | -dontwarn com.squareup.**
57 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/androidTest/java/com/luojilab/componentdemo/UiRouterTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 |
7 | import com.luojilab.component.componentlib.router.ui.IComponentRouter;
8 | import com.luojilab.component.componentlib.router.ui.UIRouter;
9 |
10 | import org.junit.Assert;
11 | import org.junit.Before;
12 | import org.junit.Test;
13 |
14 | /**
15 | * Package: com.luojilab.componentdemo
16 | * Project: DDComponentForAndroid
17 | * Classname: UiRouterTest
18 | * Description: test cases for {@link UIRouter}
19 | * Created by leobert on 11/01/2018.
20 | */
21 | public class UiRouterTest {
22 |
23 | private UIRouter uiRouter;
24 |
25 | private static final String TARGET_URI = "https://test/UiRouter/target";
26 |
27 | @Before
28 | public void setUp() throws Exception {
29 | uiRouter = UIRouter.getInstance();
30 | // UIRouter.enableDebug();
31 |
32 | uiRouter.registerUI(new IComponentRouter() {
33 | @Override
34 | public boolean openUri(Context context, String url, Bundle bundle) {
35 | return false;
36 | }
37 |
38 | @Override
39 | public boolean openUri(Context context, Uri uri, Bundle bundle) {
40 | return false;
41 | }
42 |
43 | @Override
44 | public boolean openUri(Context context, String url, Bundle bundle, Integer requestCode) {
45 | return false;
46 | }
47 |
48 | @Override
49 | public boolean openUri(Context context, Uri uri, Bundle bundle, Integer requestCode) {
50 | return false;
51 | }
52 |
53 | @Override
54 | public boolean verifyUri(Uri uri) {
55 | if (uri == null)
56 | return false;
57 | return TARGET_URI.equals(uri.toString());
58 | }
59 | });
60 | }
61 |
62 | @Test
63 | public void testVerifyUri() {
64 | Uri[] errorCases = new Uri[]{
65 | Uri.parse("http://error/1"),
66 | Uri.EMPTY,
67 | null
68 | };
69 |
70 | for (Uri uri : errorCases) {
71 | Assert.assertEquals(false, uiRouter.verifyUri(uri));
72 | }
73 |
74 | Assert.assertEquals(true,uiRouter.verifyUri(Uri.parse(TARGET_URI)));
75 | }
76 | }
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/DemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.NonNull;
5 | import com.google.android.material.bottomnavigation.BottomNavigationView;
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import android.view.MenuItem;
8 | import android.widget.TextView;
9 |
10 | public class DemoActivity extends AppCompatActivity {
11 |
12 | private TextView mTextMessage;
13 |
14 | private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
15 | = new BottomNavigationView.OnNavigationItemSelectedListener() {
16 |
17 | @Override
18 | public boolean onNavigationItemSelected(@NonNull MenuItem item) {
19 | switch (item.getItemId()) {
20 | case R.id.navigation_home:
21 | mTextMessage.setText(R.string.title_home);
22 | return true;
23 | case R.id.navigation_dashboard:
24 | mTextMessage.setText(R.string.title_dashboard);
25 | return true;
26 | case R.id.navigation_notifications:
27 | mTextMessage.setText(R.string.title_notifications);
28 | return true;
29 | }
30 | return false;
31 | }
32 | };
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_demo);
38 |
39 | mTextMessage = (TextView) findViewById(R.id.message);
40 | BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
41 | navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/application/AppApplication.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.application;
2 |
3 | import android.util.Log;
4 |
5 | import com.luojilab.component.basicres.BaseApplication;
6 | import com.luojilab.component.componentlib.log.ILogger;
7 | import com.luojilab.component.componentlib.router.Router;
8 | import com.luojilab.component.componentlib.router.ui.UIRouter;
9 | import com.luojilab.componentdemo.msg.AppComponentEventManager;
10 |
11 | import org.github.jimu.msg.EventManager;
12 | import org.jetbrains.annotations.NotNull;
13 | import org.jetbrains.annotations.Nullable;
14 |
15 | import kotlin.Unit;
16 | import kotlin.jvm.functions.Function1;
17 | import kotlin.jvm.functions.Function3;
18 | import osp.leobert.android.maat.JOB;
19 | import osp.leobert.android.maat.Maat;
20 |
21 | /**
22 | * Created by mrzhang on 2017/6/15.
23 | */
24 |
25 | public class AppApplication extends BaseApplication {
26 |
27 | @Override
28 | public void onCreate() {
29 | super.onCreate();
30 | ILogger.logger.setDefaultTag("JIMU");
31 | UIRouter.enableDebug();
32 | Maat.Companion.init(this, 8, new Maat.Logger() {
33 | @Override
34 | public boolean getEnable() {
35 | return true;
36 | }
37 |
38 | @Override
39 | public void log(@NotNull String s, @Nullable Throwable throwable) {
40 | if (throwable != null) {
41 | // ILogger.logger.error("maat", s);
42 | // throwable.printStackTrace();
43 | Log.e("maat",s,throwable);
44 | } else {
45 | // ILogger.logger.debug("maat", s);
46 | Log.d("maat",s);
47 | }
48 | }
49 | }, new Maat.Callback(new Function1() {
50 | @Override
51 | public Unit invoke(Maat maat) {
52 | Maat.Companion.release();
53 | return null;
54 | }
55 | }, new Function3() {
56 | @Override
57 | public Unit invoke(Maat maat, JOB job, Throwable throwable) {
58 | return null;
59 | }
60 | }));
61 |
62 | // EventManager.appendMapper("com.luojilab.componentdemo.application", MainProcessMsgService.class);
63 | // EventManager.appendMapper("com.luojilab.componentdemo.application:remote", RemoteMsgService.class);
64 |
65 | EventManager.init(this);
66 |
67 | UIRouter.getInstance().registerUI("app");
68 |
69 | //如果isRegisterCompoAuto为false,则需要通过反射加载组件
70 | Router.registerComponent("com.luojilab.reader.applike.ReaderAppLike");
71 | // Router.registerComponent("com.luojilab.share.applike.ShareApplike");
72 |
73 | Router.getInstance().addService(AppComponentEventManager.class.getSimpleName(),
74 | EventManager.create(AppComponentEventManager.class));
75 |
76 | }
77 |
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/AppComponentEventManager.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg;
2 |
3 | import com.luojilab.componentdemo.msg.event.EventA;
4 | import com.luojilab.componentdemo.msg.event.EventB;
5 |
6 | import org.github.jimu.msg.bean.ConsumerMeta;
7 | import org.github.jimu.msg.notation.AriseProcess;
8 | import org.github.jimu.msg.notation.Consumer;
9 | import org.github.jimu.msg.notation.Event;
10 |
11 | /**
12 | * Package: com.luojilab.componentdemo.msg
13 | * Project: jimu-sample-project
14 | * Classname: AppComponentEventManager
15 | * Description: TODO
16 | * Created by leobert on 2018/7/30.
17 | */
18 | public interface AppComponentEventManager {
19 | @AriseProcess()
20 | @Event(clz = EventA.class)
21 | void subscribeEventA(@Consumer ConsumerMeta meta);
22 |
23 | @AriseProcess(pa = ":remote")
24 | @Event(clz = EventB.class)
25 | void subscribeEventB(@Consumer ConsumerMeta meta);
26 | }
27 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/Foo.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import androidx.annotation.Nullable;
7 | import android.text.method.LinkMovementMethod;
8 | import android.widget.TextView;
9 |
10 | import com.luojilab.componentdemo.R;
11 |
12 | /**
13 | * Package: com.luojilab.componentdemo.msg
14 | * Project: jimu-sample-project
15 | * Classname: Foo
16 | * Description: TODO
17 | * Created by leobert on 2018/6/7.
18 | */
19 | public abstract class Foo extends Activity {
20 | protected TextView tvMsg;
21 | protected TextView btn;
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_msg);
27 | tvMsg = findViewById(R.id.demo_msg_tv);
28 | btn = findViewById(R.id.demo_msg_btn);
29 | btn.setText(getBtnText());
30 | btn.setMovementMethod(LinkMovementMethod.getInstance());
31 | btn.setHighlightColor(Color.TRANSPARENT);
32 | }
33 |
34 | protected abstract CharSequence getBtnText();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/MainProcessMsgService.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg;
2 |
3 | import org.github.jimu.msg.MsgBridgeService;
4 | import org.github.jimu.msg.core.MessageBridgeService;
5 |
6 | //@MsgBridgeService(workProcessName = "com.luojilab.componentdemo.application")
7 | // empty can represent the default process
8 | @MsgBridgeService(workProcessName = "")
9 | public class MainProcessMsgService extends MessageBridgeService {
10 | public MainProcessMsgService() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/Msg2Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg;
2 |
3 | import android.os.Bundle;
4 | import android.text.SpannableString;
5 | import android.text.Spanned;
6 | import android.text.style.ClickableSpan;
7 | import android.view.View;
8 |
9 | import org.github.jimu.msg.ConsumeOn;
10 | import org.github.jimu.msg.EventListener;
11 | import org.github.jimu.msg.EventManager;
12 | import org.github.jimu.msg.bean.ConsumerMeta;
13 |
14 | import com.luojilab.component.componentlib.router.Router;
15 | import com.luojilab.componentdemo.msg.event.EventA;
16 | import com.luojilab.componentdemo.msg.event.EventB;
17 | import com.luojilab.router.facade.annotation.RouteNode;
18 |
19 | @RouteNode(path = "/msg/demo/2", desc = "主进程页面2")
20 | public class Msg2Activity extends Foo {
21 |
22 | EventListener eventAEventListener;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | eventAEventListener = new EventListener() {
28 | @Override
29 | public void onEvent(EventA event) {
30 | tvMsg.setText("event has been send and received." + event.getMsg());
31 | }
32 | };
33 | // EventManager.getInstance().subscribe(EventA.class, eventAEventListener);
34 |
35 | AppComponentEventManager manager = (AppComponentEventManager) Router.getInstance()
36 | .getService(AppComponentEventManager.class.getSimpleName());
37 |
38 | manager.subscribeEventA(ConsumerMeta.newBuilder()
39 | .consumeOn(ConsumeOn.Main)
40 | .eventListener(eventAEventListener)
41 | .build());
42 | }
43 |
44 | @Override
45 | protected CharSequence getBtnText() {
46 | SpannableString spans1 = new SpannableString("send eventA");
47 | spans1.setSpan(new ClickableSpan() {
48 | @Override
49 | public void onClick(View widget) {
50 | EventManager.getInstance().postEvent(new EventA("event a from Msg2Activity"));
51 | }
52 | }, 0, spans1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
53 |
54 | return spans1;
55 | }
56 |
57 | @Override
58 | protected void onDestroy() {
59 | EventManager.getInstance().unsubscribe(eventAEventListener);
60 | super.onDestroy();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/Msg3Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg;
2 |
3 | import android.os.Bundle;
4 | import android.text.SpannableString;
5 | import android.text.Spanned;
6 | import android.text.style.ClickableSpan;
7 | import android.view.View;
8 |
9 | import org.github.jimu.msg.ConsumeOn;
10 | import org.github.jimu.msg.EventListener;
11 | import org.github.jimu.msg.EventManager;
12 | import org.github.jimu.msg.bean.ConsumerMeta;
13 |
14 | import com.luojilab.component.componentlib.router.Router;
15 | import com.luojilab.componentdemo.msg.event.EventA;
16 | import com.luojilab.componentdemo.msg.event.EventB;
17 | import com.luojilab.router.facade.annotation.RouteNode;
18 |
19 | @RouteNode(path = "/msg/demo/3", desc = "remote进程页面")
20 | public class Msg3Activity extends Foo {
21 |
22 | EventListener eventBEventListener;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | eventBEventListener = new EventListener() {
28 | @Override
29 | public void onEvent(EventB event) {
30 | tvMsg.setText("event has been send and received." + event.getMsg());
31 | }
32 | };
33 | EventManager.getInstance().subscribe(EventB.class, eventBEventListener);
34 |
35 | AppComponentEventManager manager = (AppComponentEventManager) Router.getInstance()
36 | .getService(AppComponentEventManager.class.getSimpleName());
37 |
38 |
39 |
40 | manager.subscribeEventB(ConsumerMeta.newBuilder()
41 | .consumeOn(ConsumeOn.Main)
42 | .process(":remote") // 一般来说,都不需要特地写进程了,我们约定""就代表默认进程,其他新开辟的进程中需要写
43 | .eventListener(eventBEventListener)
44 | .build());
45 | }
46 |
47 | @Override
48 | protected CharSequence getBtnText() {
49 | SpannableString spans1 = new SpannableString("send eventB");
50 | spans1.setSpan(new ClickableSpan() {
51 | @Override
52 | public void onClick(View widget) {
53 | EventManager.getInstance().postEvent(new EventB("event b from Msg3Activity"));
54 | }
55 | }, 0, spans1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
56 |
57 | return spans1;
58 | }
59 |
60 | @Override
61 | protected void onDestroy() {
62 | EventManager.getInstance().unsubscribe(eventBEventListener);
63 | super.onDestroy();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/RemoteMsgService.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg;
2 |
3 | import org.github.jimu.msg.MsgBridgeService;
4 | import org.github.jimu.msg.core.MessageBridgeService;
5 |
6 | @MsgBridgeService(workProcessName = ":remote")
7 | public class RemoteMsgService extends MessageBridgeService {
8 | public RemoteMsgService() {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/event/EventA.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg.event;
2 |
3 | import org.github.jimu.msg.bean.EventBean;
4 |
5 | /**
6 | * Package: com.luojilab.componentdemo.msg.event
7 | * Project: jimu-sample-project
8 | * Classname: EventA
9 | * Description: TODO
10 | * Created by leobert on 2018/6/7.
11 | */
12 | public class EventA implements EventBean {
13 | private String msg;
14 |
15 | public String getMsg() {
16 | return msg;
17 | }
18 |
19 | public EventA(String msg) {
20 | this.msg = msg;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/msg/event/EventB.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.msg.event;
2 |
3 | import android.os.Parcel;
4 |
5 | import org.github.jimu.msg.bean.RemoteEventBean;
6 |
7 | /**
8 | * Package: com.luojilab.componentdemo.msg.event
9 | * Project: jimu-sample-project
10 | * Classname: EventB
11 | * Description: TODO
12 | * Created by leobert on 2018/6/7.
13 | */
14 | public class EventB implements RemoteEventBean{
15 | private String msg;
16 |
17 | public EventB(String msg) {
18 | this.msg = msg;
19 | }
20 |
21 | protected EventB(Parcel in) {
22 | msg = in.readString();
23 | }
24 |
25 | public static final Creator CREATOR = new Creator() {
26 | @Override
27 | public EventB createFromParcel(Parcel in) {
28 | return new EventB(in);
29 | }
30 |
31 | @Override
32 | public EventB[] newArray(int size) {
33 | return new EventB[size];
34 | }
35 | };
36 |
37 | @Override
38 | public int describeContents() {
39 | return 0;
40 | }
41 |
42 | @Override
43 | public void writeToParcel(Parcel dest, int flags) {
44 | dest.writeString(msg);
45 | }
46 |
47 | public String getMsg() {
48 | return msg;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo1Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.widget.TextView;
4 |
5 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
6 | import com.luojilab.router.facade.annotation.RouteNode;
7 |
8 | /**
9 | * Package: com.luojilab.componentdemo.router.cases
10 | * Project: JIMU
11 | * Classname: Demo1Activity
12 | * Description: TODO
13 | * Created by leobert on 28/03/2018.
14 | */
15 | @RouteNode(path = "/uirouter/demo/1", desc = "无参数")
16 | public class Demo1Activity extends TestActivity {
17 | public static final UiRouterDemoActivity.Case aCase
18 | = new UiRouterDemoActivity.Case(false,
19 | "无参数跳转",
20 | "JIMU://app/uirouter/demo/1",
21 | null);
22 |
23 |
24 | @Override
25 | protected void displayInfo(TextView textView) {
26 | textView.setText("无参数跳转成功");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo2Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
7 | import com.luojilab.router.facade.annotation.Autowired;
8 | import com.luojilab.router.facade.annotation.RouteNode;
9 |
10 | /**
11 | * Package: com.luojilab.componentdemo.router.cases
12 | * Project: JIMU
13 | * Classname: Demo2Activity
14 | * Description: TODO
15 | * Created by leobert on 01/04/2018.
16 | */
17 | @RouteNode(path = "/uirouter/demo/2", desc = "使用bundle传递参数")
18 | public class Demo2Activity extends TestActivity {
19 | private static Bundle bundle = new Bundle();
20 |
21 | static {
22 | bundle.putString("foo", "foo string");
23 | bundle.putString("EXTRA_STR_BAR", "bar string");
24 | }
25 |
26 | @Autowired() //不指定名称时将使用变量名,若被混淆可能出现问题,
27 | // 建议使用name指定key,参考bar的使用
28 | String foo;
29 |
30 | @Autowired(name = "EXTRA_STR_BAR")
31 | String bar;
32 |
33 | public static final UiRouterDemoActivity.Case aCase
34 | = new UiRouterDemoActivity.Case(false,
35 | "使用bundle传递参数",
36 | "JIMU://app/uirouter/demo/2",
37 | bundle);
38 |
39 | @Override
40 | protected void displayInfo(TextView textView) {
41 | StringBuilder stringBuilder = new StringBuilder();
42 | stringBuilder.append("使用bundle传递参数成功\r\n");
43 | stringBuilder.append("foo:").append(foo).append("\r\n");
44 | stringBuilder.append("bar:").append(bar).append("\r\n");
45 |
46 | textView.setText(stringBuilder.toString());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo3Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
7 | import com.luojilab.router.facade.annotation.Autowired;
8 | import com.luojilab.router.facade.annotation.RouteNode;
9 |
10 | /**
11 | * Package: com.luojilab.componentdemo.router.cases
12 | * Project: JIMU
13 | * Classname: Demo3Activity
14 | * Description: TODO
15 | * Created by leobert on 01/04/2018.
16 | */
17 | @RouteNode(path = "/uirouter/demo/3" ,desc = "使用Url传参")
18 | public class Demo3Activity extends TestActivity{
19 |
20 | @Autowired() //不指定名称时将使用变量名,若被混淆可能出现问题,
21 | // 建议使用name指定key,参考bar的使用
22 | String foo;
23 |
24 | @Autowired(name = "EXTRA_STR_BAR")
25 | String bar;
26 |
27 | /*注意,仅支持在queryString中设置参数,不支持在path中传递参数*/
28 | public static final UiRouterDemoActivity.Case aCase
29 | = new UiRouterDemoActivity.Case(false,
30 | "使用Url传参",
31 | "JIMU://app/uirouter/demo/3?foo=foo string&EXTRA_STR_BAR=bar string",
32 | null);
33 |
34 | @Override
35 | protected void displayInfo(TextView textView) {
36 | StringBuilder stringBuilder = new StringBuilder();
37 | stringBuilder.append("使用bundle传递参数成功\r\n");
38 | stringBuilder.append("foo:").append(foo).append("\r\n");
39 | stringBuilder.append("bar:").append(bar).append("\r\n");
40 |
41 | textView.setText(stringBuilder.toString());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo4Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
7 | import com.luojilab.router.facade.annotation.Autowired;
8 | import com.luojilab.router.facade.annotation.RouteNode;
9 |
10 | /**
11 | * Package: com.luojilab.componentdemo.router.cases
12 | * Project: JIMU
13 | * Classname: Demo3Activity
14 | * Description: TODO
15 | * Created by leobert on 01/04/2018.
16 | */
17 | @RouteNode(path = "/uirouter/demo/4", desc = "Url和Bundle同时包含参数")
18 | public class Demo4Activity extends TestActivity {
19 | private static Bundle bundle = new Bundle();
20 |
21 | static {
22 | bundle.putString("foo", "foo string in bundle");
23 | bundle.putString("EXTRA_STR_BAR", "bar string in bundle");
24 | }
25 |
26 | @Autowired()
27 | String foo;
28 |
29 | @Autowired(name = "EXTRA_STR_BAR")
30 | String bar;
31 |
32 |
33 | public static final UiRouterDemoActivity.Case aCase
34 | = new UiRouterDemoActivity.Case(false,
35 | "Url和Bundle同时包含参数",
36 | "JIMU://app/uirouter/demo/4?foo=foo string in url&EXTRA_STR_BAR=bar string in url",
37 | null);
38 |
39 | @Override
40 | protected void displayInfo(TextView textView) {
41 | StringBuilder stringBuilder = new StringBuilder();
42 | stringBuilder.append("Url和Bundle同时包含参数,以url为准\r\n");
43 | stringBuilder.append("foo:").append(foo).append("\r\n");
44 | stringBuilder.append("bar:").append(bar).append("\r\n");
45 |
46 | textView.setText(stringBuilder.toString());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo6Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.widget.TextView;
4 |
5 | import com.google.gson.Gson;
6 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
7 | import com.luojilab.router.facade.annotation.Autowired;
8 | import com.luojilab.router.facade.annotation.RouteNode;
9 |
10 |
11 | @RouteNode(path = "/uirouter/demo/6", desc = "使用json字符串传参")
12 | public class Demo6Activity extends TestActivity {
13 |
14 | @Autowired(name = "EXTRA_OBJ_FOO")
15 | Foo foo;
16 | private static Foo test;
17 |
18 | static {
19 | test = new Foo();
20 | test.setFooInt(2);
21 | test.setFooString("foo string");
22 | }
23 |
24 | /*注意,仅支持在queryString中设置参数,不支持在path中传递参数*/
25 | public static final UiRouterDemoActivity.Case aCase
26 | = new UiRouterDemoActivity.Case(false,
27 | "使用json字符串传参",
28 | "JIMU://app/uirouter/demo/6?EXTRA_OBJ_FOO=" + new Gson().toJson(test),
29 | null);
30 |
31 | @Override
32 | protected void displayInfo(TextView textView) {
33 | StringBuilder stringBuilder = new StringBuilder();
34 | stringBuilder.append("使用json字符串传参成功\r\n");
35 | stringBuilder.append("foo:").append(foo).append("\r\n");
36 |
37 | textView.setText(stringBuilder.toString());
38 | }
39 |
40 | public static final class Foo {
41 | private int fooInt;
42 | private String fooString;
43 |
44 | public int getFooInt() {
45 | return fooInt;
46 | }
47 |
48 | public void setFooInt(int fooInt) {
49 | this.fooInt = fooInt;
50 | }
51 |
52 | public String getFooString() {
53 | return fooString;
54 | }
55 |
56 | public void setFooString(String fooString) {
57 | this.fooString = fooString;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "Foo:{" +
63 | "fooInt:" + fooInt + ","
64 | + "fooString:" + fooString +
65 | "}";
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo7Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.widget.TextView;
4 |
5 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
6 | import com.luojilab.router.facade.annotation.Autowired;
7 | import com.luojilab.router.facade.annotation.RouteNode;
8 |
9 | /**
10 | * Package: com.luojilab.componentdemo.router.cases
11 | * Project: JIMU
12 | * Classname: Demo3Activity
13 | * Description: TODO
14 | * Created by leobert on 01/04/2018.
15 | */
16 | @RouteNode(path = "/uirouter/demo/7", desc = "必须参数")
17 | public class Demo7Activity extends TestActivity {
18 |
19 | @Autowired(required = true)
20 | String foo;
21 |
22 | public static final UiRouterDemoActivity.Case aCase
23 | = new UiRouterDemoActivity.Case(false,
24 | "必须参数-log输出",
25 | "JIMU://app/uirouter/demo/7",
26 | null);
27 |
28 | @Override
29 | protected void displayInfo(TextView textView) {
30 | textView.setText("此处Autowired没有使用异常抛出功能,\r\n" +
31 | "通过安全模式可以捕获ParamException\r\n" +
32 | "直接跳转,控制台输出错误日志,通过AutowiredProcessor 进行过滤\r\n" +
33 | "显然,通过异常抛出更容易发现问题");
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/Demo8Activity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.widget.TextView;
4 |
5 | import com.luojilab.componentdemo.router.UiRouterDemoActivity;
6 | import com.luojilab.router.facade.annotation.Autowired;
7 | import com.luojilab.router.facade.annotation.RouteNode;
8 |
9 | /**
10 | * Package: com.luojilab.componentdemo.router.cases
11 | * Project: JIMU
12 | * Classname: Demo3Activity
13 | * Description: TODO
14 | * Created by leobert on 01/04/2018.
15 | */
16 | @RouteNode(path = "/uirouter/demo/8", desc = "必须参数2")
17 | public class Demo8Activity extends TestActivity {
18 |
19 | @Autowired(required = true,throwOnNull = true)
20 | String foo;
21 |
22 | public static final UiRouterDemoActivity.Case aCase
23 | = new UiRouterDemoActivity.Case(true,
24 | "必须参数-空指针校验,primitive无效!",
25 | "JIMU://app/uirouter/demo/8",
26 | null);
27 |
28 | @Override
29 | protected void displayInfo(TextView textView) {
30 | textView.setText("不使用safemode 将直接crash");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/router/cases/TestActivity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.router.cases;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.widget.TextView;
6 |
7 | import com.luojilab.component.componentlib.service.AutowiredService;
8 | import com.luojilab.componentdemo.R;
9 |
10 | abstract class TestActivity extends AppCompatActivity {
11 |
12 | private TextView textView;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_test);
18 | textView = findViewById(R.id.demo_tv_info);
19 | AutowiredService.Factory.getSingletonImpl()
20 | .autowire(this);
21 | displayInfo(textView);
22 | }
23 |
24 | protected abstract void displayInfo(TextView textView);
25 | }
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/java/com/luojilab/componentdemo/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentdemo.utils;
2 |
3 | import android.content.res.Resources;
4 |
5 |
6 | public final class Utils {
7 |
8 | private Utils() {
9 | }
10 |
11 | public static float dp2px(Resources resources, float dp) {
12 | final float scale = resources.getDisplayMetrics().density;
13 | return dp * scale + 0.5f;
14 | }
15 |
16 | public static float sp2px(Resources resources, float sp) {
17 | final float scale = resources.getDisplayMetrics().scaledDensity;
18 | return sp * scale;
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/drawable/ic_dashboard_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/drawable/ic_home_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/drawable/ic_notifications_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/layout/activity_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
14 |
20 |
21 |
28 |
29 |
30 |
34 |
35 |
42 |
43 |
50 |
51 |
52 |
57 |
58 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/layout/activity_msg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/layout/activity_ui_router_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/menu/navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/jimu-sample-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/jimu-sample-project/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidComponent
3 | DemoActivity
4 | Home
5 | Dashboard
6 | Notifications
7 |
8 |
--------------------------------------------------------------------------------
/jimu-sample-project/basiclib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/basiclib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion versions.compileSdk
5 | buildToolsVersion versions.androidTools
6 |
7 | defaultConfig {
8 | minSdkVersion versions.minSdk
9 | targetSdkVersion versions.targetSdk
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | api fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | api deps.support.v7.appcompat
30 | testImplementation deps.junit
31 | api 'com.squareup.picasso:picasso:2.5.2'
32 |
33 | // compile project(":componentlib")
34 | api deps.jimu.componentLib
35 |
36 | api "com.google.code.gson:gson:2.8.2"
37 | api "io.github.leobert-lan:jimu-router-annotation:1.0.1"
38 |
39 | api 'osp.leobert.android:maat:1.0.0'
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/jimu-sample-project/basiclib/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 /Users/mrzhang/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/basiclib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/jimu-sample-project/basiclib/src/main/java/com.luojilab.component.basiclib/ToastManager.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.basiclib;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by mrzhang on 2018/1/16.
8 | */
9 |
10 | public class ToastManager {
11 |
12 | private ToastManager() {
13 | }
14 |
15 | public static void show(Context context, String message) {
16 | Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
17 | }
18 |
19 | public static void show(Context context, int resId) {
20 | show(context, context.getString(resId));
21 | }
22 |
23 | public static void show(Context context, int resId, Object... args) {
24 | show(context, String.format(context.getString(resId), args));
25 | }
26 |
27 | public static void show(Context context, String message, int duration) {
28 | Toast.makeText(context, message, duration).show();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/jimu-sample-project/basiclib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | basiclib
3 |
4 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion versions.compileSdk
5 | buildToolsVersion versions.androidTools
6 |
7 | defaultConfig {
8 | minSdkVersion versions.minSdk
9 | targetSdkVersion versions.targetSdk
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | resourcePrefix "common_"
24 | }
25 |
26 | dependencies {
27 | api project(':basiclib')
28 | testImplementation deps.junit
29 | androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | }
33 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/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 /Users/mrzhang/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/src/main/java/com/luojilab/component/basicres/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.basicres;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.Nullable;
5 | import androidx.appcompat.app.AppCompatActivity;
6 |
7 | import com.luojilab.component.componentlib.service.AutowiredService;
8 |
9 | /**
10 | * Created by mrzhang on 2018/1/16.
11 | */
12 |
13 | public class BaseActivity extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(@Nullable Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | AutowiredService.Factory.getSingletonImpl().autowire(this);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/src/main/java/com/luojilab/component/basicres/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.basicres;
2 |
3 | import android.app.Application;
4 | import androidx.annotation.Nullable;
5 |
6 | /**
7 | * Created by mrzhang on 2018/1/16.
8 | */
9 |
10 | public class BaseApplication extends Application {
11 |
12 | private static BaseApplication mAppCotext;
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | mAppCotext = this;
18 | }
19 |
20 | @Nullable
21 | public static Application getAppContext() {
22 | return mAppCotext;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #ffffffff
5 | #ff000000
6 |
7 | #3F51B5
8 | #303F9F
9 | #FF4081
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | basicres
3 |
4 |
--------------------------------------------------------------------------------
/jimu-sample-project/basicres/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/jimu-sample-project/buildSrc/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | repositories {
3 | mavenCentral()
4 | google()
5 | jcenter()
6 | }
7 | sourceSets {
8 | main {
9 | java {
10 | srcDirs "../../src_build/main/java"
11 | }
12 | }
13 | }
14 | dependencies {
15 | implementation "io.github.leobert-lan:jimu-build-gradle:1.3.5"
16 |
17 | implementation 'com.android.tools.build:gradle:4.1.1'
18 | implementation group: 'org.javassist', name: 'javassist', version: '3.23.1-GA'
19 | //gradle sdk
20 | implementation gradleApi()
21 | //groovy sdk
22 | implementation localGroovy()
23 | }
24 |
25 | java {
26 | sourceCompatibility = JavaVersion.VERSION_1_8
27 | targetCompatibility = JavaVersion.VERSION_1_8
28 | }
--------------------------------------------------------------------------------
/jimu-sample-project/buildSrc/src/main/java/JimuHotfix.java:
--------------------------------------------------------------------------------
1 | import com.dd.buildgradle.ComBuild;
2 |
3 | public class JimuHotfix extends ComBuild {
4 |
5 | }
--------------------------------------------------------------------------------
/jimu-sample-project/buildSrc/src/main/resources/META-INF/gradle-plugins/JimuHotfix.properties:
--------------------------------------------------------------------------------
1 | implementation-class=JimuHotfix
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion versions.compileSdk
6 | buildToolsVersion versions.androidTools
7 |
8 | defaultConfig {
9 | minSdkVersion versions.minSdk
10 | targetSdkVersion versions.targetSdk
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | // compile project(':componentlib')
27 | api project(':basicres')
28 | api fileTree(include: ['*.jar'], dir: 'libs')
29 | androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | testImplementation deps.junit
33 | api deps.kotlin.kotlin_jdk7
34 | }
35 | repositories {
36 | mavenCentral()
37 | }
38 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/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 /Users/klee/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/androidTest/java/com/luojilab/componentservice/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentservice;
2 |
3 | import android.content.Context;
4 | import androidx.test.platform.app.InstrumentationRegistry;
5 | import androidx.test.ext.junit.runners.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.componentservice.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/main/java/com/luojilab/componentservice/readerbook/ReadBookService.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentservice.readerbook;
2 |
3 | import androidx.fragment.app.Fragment;
4 |
5 | /**
6 | * export module services
7 | * Created by mrzhang on 2017/6/15.
8 | */
9 |
10 | public interface ReadBookService {
11 |
12 | Fragment getReadBookFragment();
13 | }
14 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/main/java/com/luojilab/componentservice/share/bean/Author.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentservice.share.bean;
2 |
3 | /**
4 | * Created by mrzhang on 2017/12/14.
5 | */
6 |
7 | public class Author {
8 | private String name;
9 | private int age;
10 | private String county;
11 |
12 | public String getName() {
13 | return name;
14 | }
15 |
16 | public void setName(String name) {
17 | this.name = name;
18 | }
19 |
20 | public int getAge() {
21 | return age;
22 | }
23 |
24 | public void setAge(int age) {
25 | this.age = age;
26 | }
27 |
28 | public String getCounty() {
29 | return county;
30 | }
31 |
32 | public void setCounty(String county) {
33 | this.county = county;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/main/java/com/luojilab/componentservice/share/bean/AuthorKt.kt:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentservice.share.bean
2 |
3 | /**
4 | * Created by mrzhang on 2018/2/26.
5 | */
6 | data class AuthorKt(var name: String, var age: Int, var county: String)
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | componentservice
3 |
4 |
--------------------------------------------------------------------------------
/jimu-sample-project/componentservice/src/test/java/com/luojilab/componentservice/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.componentservice;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/jimu-sample-project/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | mainmodulename=app
15 | bintrayRepo=maven
16 | publishedGroupId=com.github.jimu
17 | siteUrl=https://github.com/mqzhangw/JIMU
18 | gitUrl=https://github.com/mqzhangw/JIMU.git
19 | developerId=mqzhang
20 | developerName=mqzhang
21 | developerEmail=zhmqq0527@gmail.com
22 | android.useAndroidX=true
23 | android.enableJetifier=true
24 |
--------------------------------------------------------------------------------
/jimu-sample-project/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/UIRouterTable/ShareRouterTable.txt:
--------------------------------------------------------------------------------
1 | auto generated, do not change !!!!
2 |
3 | HOST : share
4 |
5 | 分享书籍页面
6 | /shareBook
7 | author:com.luojilab.componentservice.share.bean.Author
8 | bookName:String
9 |
10 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | isRunAlone=true
15 | debugComponent=sharecomponent,sharecomponentkotlin
16 | compileComponent=sharecomponent,sharecomponentkotlin
17 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/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 /Users/klee/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/androidTest/java/com/luojilab/component/componentlib/msg/EventManagerTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.component.componentlib.msg;
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4;
4 |
5 | import org.github.jimu.msg.EventListener;
6 | import org.github.jimu.msg.EventManager;
7 | import org.github.jimu.msg.bean.EventBean;
8 |
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 |
12 | import static org.junit.Assert.*;
13 |
14 | /**
15 | * Package: org.github.jimu.msg
16 | * Project: JIMU
17 | * Classname: EventManagerTest
18 | * Description: TODO
19 | * Created by leobert on 2018/5/2.
20 | */
21 | @RunWith(AndroidJUnit4.class)
22 | public class EventManagerTest {
23 |
24 | private EventManager eventManager = EventManager.getInstance();
25 | private static final class TestClz implements EventBean {
26 | private final String string;
27 |
28 | public TestClz(String string) {
29 | this.string = string;
30 | }
31 | }
32 |
33 |
34 | @Test
35 | public void getInstance() {
36 | EventManager eventManager = EventManager.getInstance();
37 | assertNotNull(eventManager);
38 | }
39 |
40 | @Test
41 | public void subscribe() {
42 | System.out.print("start");
43 | eventManager.subscribe(TestClz.class, new EventListener() {
44 | @Override
45 | public void onEvent(TestClz event) {
46 | System.out.println(event.toString());
47 | }
48 | });
49 | postEvent();
50 |
51 | }
52 |
53 | // @Test
54 | public void postEvent() {
55 |
56 | eventManager.postEvent(new TestClz("a"));
57 | System.out.println("event post called");
58 | }
59 | }
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/ReaderActivity.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.reader;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | public class ReaderActivity extends AppCompatActivity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | setContentView(R.layout.activity_reader);
12 | }
13 | }
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/applike/ReaderAppLike.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.reader.applike;
2 |
3 | import android.util.Log;
4 |
5 | import com.luojilab.component.componentlib.applicationlike.IApplicationLike;
6 | import com.luojilab.component.componentlib.applicationlike.RegisterCompManual;
7 | import com.luojilab.component.componentlib.router.Router;
8 | import com.luojilab.component.componentlib.router.ui.UIRouter;
9 | import com.luojilab.componentservice.readerbook.ReadBookService;
10 | import com.luojilab.reader.serviceimpl.ReadBookServiceImplKotlin;
11 |
12 | import org.jetbrains.annotations.NotNull;
13 |
14 | import java.util.Arrays;
15 | import java.util.Collections;
16 | import java.util.List;
17 |
18 | import kotlinx.coroutines.CoroutineDispatcher;
19 | import kotlinx.coroutines.Dispatchers;
20 | import osp.leobert.android.maat.JOB;
21 | import osp.leobert.android.maat.Maat;
22 |
23 | /**
24 | * Created by mrzhang on 2017/6/15.
25 | */
26 | @RegisterCompManual
27 | public class ReaderAppLike implements IApplicationLike {
28 |
29 | Router router = Router.getInstance();
30 | UIRouter uiRouter = UIRouter.getInstance();
31 |
32 | @Override
33 | public void onCreate() {
34 | Log.e("reader","onCreate");
35 | uiRouter.registerUI("reader");
36 | // router.addService(ReadBookService.class.getSimpleName(), new ReadBookServiceImpl());
37 | router.addService(ReadBookService.class.getSimpleName(), new ReadBookServiceImplKotlin());
38 | Maat.Companion.getDefault().append(new JOB() {
39 | @NotNull
40 | @Override
41 | public String getUniqueKey() {
42 | return "reader";
43 | }
44 |
45 | @NotNull
46 | @Override
47 | public List getDependsOn() {
48 | return Collections.emptyList();
49 | }
50 |
51 | @NotNull
52 | @Override
53 | public CoroutineDispatcher getDispatcher() {
54 | return Dispatchers.getIO();
55 | }
56 |
57 | @Override
58 | public void init(@NotNull Maat maat) {
59 | Log.d("reader", "模拟初始化reader,context:" + maat.getApplication().getClass().getName());
60 | }
61 |
62 | @Override
63 | public String toString() {
64 | return getUniqueKey();
65 | }
66 | });
67 | }
68 |
69 | @Override
70 | public void onStop() {
71 | uiRouter.unregisterUI("reader");
72 | router.removeService(ReadBookService.class.getSimpleName());
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/serviceimpl/ReadBookServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.reader.serviceimpl;
2 |
3 | import androidx.fragment.app.Fragment;
4 |
5 | import com.luojilab.componentservice.readerbook.ReadBookService;
6 | import com.luojilab.reader.ReaderFragment;
7 |
8 | /**
9 | * Created by mrzhang on 2017/6/15.
10 | */
11 |
12 | public class ReadBookServiceImpl implements ReadBookService {
13 | @Override
14 | public Fragment getReadBookFragment() {
15 | return new ReaderFragment();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/serviceimpl/ReadBookServiceImplKotlin.kt:
--------------------------------------------------------------------------------
1 | package com.luojilab.reader.serviceimpl
2 |
3 | import androidx.fragment.app.Fragment
4 | import com.luojilab.componentservice.readerbook.ReadBookService
5 | import com.luojilab.reader.ReaderFragment
6 |
7 | /**
8 | * Created by mrzhang on 2018/2/9.
9 | */
10 | class ReadBookServiceImplKotlin : ReadBookService {
11 | override fun getReadBookFragment(): Fragment {
12 | return ReaderFragment()
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/res/layout/activity_reader.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/res/layout/readerbook_fragment_reader.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
25 |
26 |
36 |
37 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | readerbook
3 |
4 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/runalone/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/application/ReaderApplication.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.reader.runalone.application;
2 |
3 | import android.util.Log;
4 |
5 | import com.luojilab.component.basicres.BaseApplication;
6 | import com.luojilab.component.componentlib.router.Router;
7 |
8 | import org.github.jimu.msg.EventManager;
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | import kotlin.Unit;
13 | import kotlin.jvm.functions.Function1;
14 | import kotlin.jvm.functions.Function3;
15 | import osp.leobert.android.maat.JOB;
16 | import osp.leobert.android.maat.Maat;
17 |
18 | /**
19 | * Created by mrzhang on 2017/6/20.
20 | */
21 |
22 | public class ReaderApplication extends BaseApplication {
23 |
24 | @Override
25 | public void onCreate() {
26 | super.onCreate();
27 | Maat.Companion.init(this, 8, new Maat.Logger() {
28 | @Override
29 | public boolean getEnable() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public void log(@NotNull String s, @Nullable Throwable throwable) {
35 | if (throwable != null) {
36 | // ILogger.logger.error("maat", s);
37 | // throwable.printStackTrace();
38 | Log.e("maat", s, throwable);
39 | } else {
40 | // ILogger.logger.debug("maat", s);
41 | Log.d("maat", s);
42 | }
43 | }
44 | }, new Maat.Callback(new Function1() {
45 | @Override
46 | public Unit invoke(Maat maat) {
47 | Maat.Companion.release();
48 | return null;
49 | }
50 | }, new Function3() {
51 | @Override
52 | public Unit invoke(Maat maat, JOB job, Throwable throwable) {
53 | return null;
54 | }
55 | }));
56 | EventManager.init(this);
57 |
58 | //如果isRegisterCompoAuto为false,则需要通过反射加载组件
59 | Router.registerComponent("com.luojilab.share.applike.ShareApplike");
60 | Router.registerComponent("com.luojilab.share.kotlin.applike.KotlinApplike");
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/runalone/mergedManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/runalone/res/layout/readerbook_activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/jimu-sample-project/readercomponent/src/main/runalone/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/jimu-sample-project/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | include ':sharecomponentkotlin'
3 | include ':readercomponent'
4 | include ':sharecomponent'
5 | include ':componentservice'
6 | include ':basiclib'
7 | include ':basicres'
8 | include ':AptHotfix'
9 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/build.gradle:
--------------------------------------------------------------------------------
1 | import jimu.Consts
2 |
3 | apply plugin: Consts.jimu_plugin_name
4 | //apply plugin: 'JimuHotfix'
5 |
6 | android {
7 | compileSdkVersion versions.compileSdk
8 | buildToolsVersion versions.androidTools
9 |
10 | defaultConfig {
11 | minSdkVersion versions.minSdk
12 | targetSdkVersion versions.targetSdk
13 | versionCode 1
14 | versionName "1.0"
15 |
16 |
17 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
18 |
19 | javaCompileOptions {
20 | annotationProcessorOptions {
21 | arguments = [host: "share"]
22 | }
23 | }
24 |
25 | }
26 | buildTypes {
27 | release {
28 | minifyEnabled false
29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
30 | }
31 | }
32 |
33 | resourcePrefix "share_"
34 |
35 | }
36 |
37 | dependencies {
38 | implementation project(':componentservice')
39 |
40 | annotationProcessor Consts.Deps.JIMU_ROUTER_COMPILER
41 |
42 | // annotationProcessor(project(":AptHotfix"))
43 |
44 | androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
45 | exclude group: 'com.android.support', module: 'support-annotations'
46 | })
47 | testImplementation deps.junit
48 | implementation deps.kotlin.kotlin_jdk7
49 | }
50 |
51 |
52 | def projectRoot = project.getRootProject().rootDir.absolutePath
53 |
54 |
55 | combuild {
56 | applicationName = 'com.luojilab.share.runalone.application.ShareApplication'
57 | isRegisterCompoAuto = true
58 | originalManifest = projectRoot + "/sharecomponent/src/main/AndroidManifest.xml"
59 |
60 | runAloneManifest = projectRoot + "/sharecomponent/src/main/runalone/AndroidManifest.xml"
61 | targetManifest = projectRoot + "/sharecomponent/src/main/runalone/mergedManifest.xml"
62 | //如果不需要合并,改为false
63 | enableManifestMerge = false
64 | useMaat = true
65 | }
66 | repositories {
67 | mavenCentral()
68 | }
69 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 | isRunAlone=true
19 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/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 /Users/klee/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/androidTest/java/com/luojilab/share/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share;
2 |
3 | import android.content.Context;
4 | import androidx.test.platform.app.InstrumentationRegistry;
5 | import androidx.test.ext.junit.runners.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.comp_share.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/java/com/luojilab/share/applike/ShareApplike.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.applike;
2 |
3 | import android.util.Log;
4 |
5 | import com.luojilab.component.componentlib.applicationlike.IApplicationLike;
6 | import com.luojilab.component.componentlib.router.ui.UIRouter;
7 |
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import java.util.Arrays;
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 | import kotlinx.coroutines.CoroutineDispatcher;
15 | import kotlinx.coroutines.Dispatchers;
16 | import osp.leobert.android.maat.JOB;
17 | import osp.leobert.android.maat.Maat;
18 |
19 | /**
20 | * Created by mrzhang on 2017/6/15.
21 | */
22 |
23 | public class ShareApplike implements IApplicationLike {
24 |
25 | UIRouter uiRouter = UIRouter.getInstance();
26 |
27 | @Override
28 | public void onCreate() {
29 | uiRouter.registerUI("share");
30 | Log.e("share","share on create");
31 | Maat.Companion.getDefault().append(new JOB() {
32 | @NotNull
33 | @Override
34 | public String getUniqueKey() {
35 | return "share";
36 | }
37 |
38 | @NotNull
39 | @Override
40 | public List getDependsOn() {
41 | return Collections.singletonList("reader");
42 | }
43 |
44 | @NotNull
45 | @Override
46 | public CoroutineDispatcher getDispatcher() {
47 | return Dispatchers.getMain();
48 | }
49 |
50 | @Override
51 | public void init(@NotNull Maat maat) {
52 | Log.d("share", "模拟初始化share,context:" + maat.getApplication().getClass().getName());
53 | }
54 |
55 | @Override
56 | public String toString() {
57 | return getUniqueKey();
58 | }
59 | });
60 | }
61 |
62 | @Override
63 | public void onStop() {
64 | uiRouter.unregisterUI("share");
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/java/com/luojilab/share/bean/AppShareBean.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.bean;
2 |
3 | import com.luojilab.share.core.AbsShareBean;
4 |
5 | /**
6 | * Package: com.luojilab.share.bean
7 | * Project: jimu-sample-project
8 | * Classname: AppShareBean
9 | * Description: 该Demo演示:大多数情况下我们并不想将一些类下沉如何处理
10 | * Created by leobert on 2018/7/6.
11 | */
12 | public class AppShareBean extends AbsShareBean {
13 | private String content;
14 |
15 | public AppShareBean(int shareVia, String content) {
16 | super(shareVia);
17 | this.content = content;
18 | }
19 |
20 | @Override
21 | protected String getShareContent() {
22 | return content;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/java/com/luojilab/share/bean/BookShareBean.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.bean;
2 |
3 | import com.luojilab.share.core.AbsShareBean;
4 |
5 | /**
6 | * Package: com.luojilab.share.bean
7 | * Project: jimu-sample-project
8 | * Classname: BookShareBean
9 | * Description: TODO
10 | * Created by leobert on 2018/7/6.
11 | */
12 | public class BookShareBean extends AbsShareBean {
13 | private String book;
14 | private String author;
15 | private String county;
16 | private String reason;
17 |
18 |
19 | public BookShareBean(int shareVia, String book, String author, String county, String reason) {
20 | super(shareVia);
21 | this.book = book;
22 | this.author = author;
23 | this.county = county;
24 | this.reason = reason;
25 | }
26 |
27 | @Override
28 | protected String getShareContent() {
29 | return toString();
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return "BookShareBean{" +
35 | "book='" + book + '\'' +
36 | ", author='" + author + '\'' +
37 | ", county='" + county + '\'' +
38 | ", reason='" + reason + '\'' +
39 | '}';
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/java/com/luojilab/share/core/AbsShareBean.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.core;
2 |
3 | import androidx.annotation.IntDef;
4 | import androidx.annotation.NonNull;
5 |
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 |
9 | /**
10 | * Package: com.luojilab.share.core
11 | * Project: jimu-sample-project
12 | * Classname: AbsShareBean
13 | * Description: TODO
14 | * Created by leobert on 2018/7/6.
15 | */
16 | public abstract class AbsShareBean {
17 |
18 | @IntDef({Via.QQ, Via.WECHAT})
19 | @Retention(RetentionPolicy.SOURCE)
20 | public @interface Via {
21 | int QQ = 0;
22 | int WECHAT = 1;
23 | }
24 |
25 | @Via
26 | protected final int shareVia;
27 |
28 | public AbsShareBean(@Via int shareVia) {
29 | this.shareVia = shareVia;
30 | }
31 |
32 | protected final void doShare(@NonNull IShareApi shareCore) {
33 | String content = getShareContent();
34 | switch (shareVia) {
35 | case Via.QQ:
36 | shareCore.share2QQ(content);
37 | break;
38 | default:
39 | case Via.WECHAT:
40 | shareCore.share2Wechat(content);
41 | break;
42 | }
43 | }
44 |
45 | //仅仅是一个demo工程,实际场景比这个复杂的多,按照实际需求妥善处理你的代码
46 | protected abstract String getShareContent();
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/java/com/luojilab/share/core/IShareApi.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.core;
2 |
3 | /**
4 | * Package: com.luojilab.share.bean
5 | * Project: jimu-sample-project
6 | * Classname: IShareApi
7 | * Description: TODO
8 | * Created by leobert on 2018/7/6.
9 | */
10 | public interface IShareApi {
11 | void share(AbsShareBean bean);
12 |
13 | void share2QQ(String content);
14 |
15 | void share2Wechat(String content);
16 | }
17 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/java/com/luojilab/share/core/SampleShareCore.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.core;
2 |
3 | /**
4 | * Package: com.luojilab.share
5 | * Project: jimu-sample-project
6 | * Classname: SampleShareCore
7 | * Description: just a sample to display the share operate
8 | * Created by leobert on 2018/7/6.
9 | */
10 | public class SampleShareCore implements IShareApi {
11 | private static SampleShareCore instance = null;
12 |
13 | private SampleShareCore() {
14 | // single
15 | }
16 |
17 | public static SampleShareCore getInstance() {
18 | if (instance == null)
19 | instance = new SampleShareCore();
20 | return instance;
21 | }
22 |
23 |
24 | public final void share(AbsShareBean bean) {
25 | bean.doShare(this);
26 | }
27 |
28 | public void share2QQ(String content) {
29 | // TODO: 2018/7/6
30 | }
31 |
32 | public void share2Wechat(String content) {
33 | // TODO: 2018/7/6
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/res/layout/share_activity_share.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
16 |
17 |
27 |
28 |
38 |
39 |
49 |
50 |
60 |
61 |
68 |
69 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | share
3 |
4 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/runalone/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/runalone/java/com.luojilab.share.runalone/DispatcherActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | package com.luojilab.share.runalone;
3 |
4 | import android.net.Uri;
5 | import android.support.annotation.Nullable;
6 | import android.text.TextUtils;
7 | import android.util.Log;
8 |
9 | import com.luojilab.component.componentlib.router.ui.AbsDispatcherActivity;
10 | import com.luojilab.component.componentlib.router.ui.UIRouter;
11 | import com.luojilab.component.componentlib.service.JsonService;
12 | import com.luojilab.componentservice.share.bean.Author;
13 |
14 | import java.util.Arrays;
15 | import java.util.List;
16 |
17 | */
18 | /**
19 | * 独立测试模块时可以这样做,并在manifest中声明相应内容
20 | *//*
21 |
22 | public class DispatcherActivity extends AbsDispatcherActivity {
23 |
24 | private static final String TAG = "DispatcherActivity";
25 | */
26 | /*
27 | * use ddcompo://www.luojilab.com/compodemo?target=share/shareBook?bookName=Dummy to display
28 | *
29 | * *//*
30 |
31 |
32 | private static final List transferHost = Arrays.asList(
33 | "www.luojilab.com",
34 | "www.luojilab.cn"
35 | );
36 |
37 | @Override
38 | protected void onBeforeHandle() {
39 | Log.d(TAG, "onBeforeHandle");
40 | }
41 |
42 | @Override
43 | protected boolean needTransferUri(Uri uri) {
44 | if (uri == null)
45 | return false;
46 |
47 | String host = uri.getHost();
48 | return transferHost.contains(host);
49 | }
50 |
51 | @Override
52 | protected Uri transferUri(Uri uri) {
53 | String target = uri.getQueryParameter("target");
54 | if (!TextUtils.isEmpty(target))
55 | return Uri.parse("ddcompo://" + target);
56 | return uri;
57 | }
58 |
59 | @Override
60 | protected void onNullUri() {
61 | Log.e(TAG, "onNullUri");
62 | demo();
63 | }
64 |
65 | @Override
66 | protected void onVerifyFailed(@Nullable Throwable throwable) {
67 | Log.e(TAG, "onVerifyFailed", throwable);
68 | demo();
69 | }
70 |
71 | @Override
72 | protected void onExceptionWhenOpenUri(Uri uri, Exception e) {
73 | Log.e(TAG, e.getMessage());
74 | demo();
75 | }
76 |
77 | @Override
78 | protected void onHandled() {
79 | finish();
80 | }
81 |
82 | private void demo() {
83 |
84 | Author author = new Author();
85 | author.setName("leobert");
86 | author.setCounty("China");
87 | UIRouter.getInstance().openUri(this,
88 | "DDComp://share/shareBook?bookName=Demo&author="
89 | + JsonService.Factory.getSingletonImpl().toJsonString(author), null);
90 | }
91 | }
92 | */
93 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/main/runalone/mergedManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponent/src/test/java/com/luojilab/share/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/build.gradle:
--------------------------------------------------------------------------------
1 | import jimu.Consts
2 |
3 | apply plugin: Consts.jimu_plugin_name
4 | //apply plugin: 'JimuHotfix'
5 | apply plugin: 'kotlin-android'
6 | apply plugin: 'kotlin-kapt'
7 | apply plugin: 'kotlin-android-extensions'
8 |
9 | kapt {
10 | arguments {
11 | arg("host", "kotlin")
12 | }
13 | }
14 |
15 | android {
16 | compileSdkVersion versions.compileSdk
17 | buildToolsVersion versions.androidTools
18 |
19 | defaultConfig {
20 | minSdkVersion versions.minSdk
21 | targetSdkVersion versions.targetSdk
22 | versionCode 1
23 | versionName "1.0"
24 |
25 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
26 |
27 | }
28 |
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 |
36 | resourcePrefix "kotlin_"
37 |
38 | }
39 |
40 | dependencies {
41 | implementation fileTree(dir: 'libs', include: ['*.jar'])
42 | implementation project(':componentservice')
43 |
44 | kapt Consts.Deps.JIMU_ROUTER_COMPILER
45 | // kapt 'com.github.jimu:router-anno-compiler:1.0.1'
46 | implementation deps.kotlin.kotlin_jdk7
47 | }
48 |
49 |
50 | def projectRoot = project.getRootProject().rootDir.absolutePath
51 |
52 |
53 | combuild {
54 | applicationName = 'com.luojilab.share.runalone.application.KotlinApplication'
55 | isRegisterCompoAuto = true
56 |
57 | originalManifest = projectRoot + "/sharecomponentkotlin/src/main/AndroidManifest.xml"
58 |
59 | runAloneManifest = projectRoot + "/sharecomponentkotlin/src/main/runalone/AndroidManifest.xml"
60 | targetManifest = projectRoot + "/sharecomponentkotlin/src/main/runalone/mergedManifest.xml"
61 | //如果不需要合并,改为false
62 | enableManifestMerge = false //如果是true,注意可能需要额外补充一些配置,例如style,
63 | useMaat = false
64 | //先禁用掉,如果runalone时却有需要,可以参考App-module或者sharecomponent,进行初始化并补全所有任务依赖
65 | }
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 | isRunAlone=true
19 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/java/com/luojilab/share/kotlin/JavaTarget.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.kotlin;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.widget.TextView;
6 |
7 | import com.luojilab.component.componentlib.service.AutowiredService;
8 | import com.luojilab.componentservice.share.bean.AuthorKt;
9 | import com.luojilab.router.facade.annotation.Autowired;
10 | import com.luojilab.router.facade.annotation.RouteNode;
11 |
12 | import kotlin.jvm.JvmField;
13 |
14 | /**
15 | * Package: com.luojilab.share.kotlin
16 | * Project: JIMU
17 | * Classname: JavaTarget
18 | * Description: TODO
19 | * Created by leobert on 08/04/2018.
20 | */
21 | @RouteNode(path = "/javatest", desc = "test multi java and kotlin in one module")
22 | public class JavaTarget extends Activity {
23 |
24 | @Autowired(name = "bookName")
25 | String magazineName;
26 |
27 | @Autowired
28 | AuthorKt author;
29 |
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.kotlin_activity_share);
33 | AutowiredService.Factory.getSingletonImpl().autowire(this);
34 |
35 | TextView shareTitle = findViewById(R.id.share_title);
36 |
37 | shareTitle.setText("Java is verbose!");
38 |
39 | ((TextView) findViewById(R.id.share_tv_tag)).setText(magazineName);
40 |
41 | TextView tvAuthor = findViewById(R.id.share_tv_author);
42 |
43 | if (author == null || author.getName() == null)
44 | tvAuthor.setText("leobert");
45 | else
46 | tvAuthor.setText(author.getName());
47 |
48 | // share_tv_county.setText(author?.county ?: "China")
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/java/com/luojilab/share/kotlin/ShareMessageActivity.kt:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.kotlin
2 |
3 | import android.os.Bundle
4 | import com.luojilab.component.basicres.BaseActivity
5 | import com.luojilab.component.componentlib.router.ui.UIRouter
6 | import com.luojilab.component.componentlib.service.JsonService
7 | import com.luojilab.componentservice.share.bean.AuthorKt
8 | import com.luojilab.router.facade.annotation.Autowired
9 | import com.luojilab.router.facade.annotation.RouteNode
10 | import kotlinx.android.synthetic.main.kotlin_activity_share.*
11 |
12 | /**
13 | * Created by mrzhang on 2017/12/29.
14 | */
15 | @RouteNode(path = "/shareMagazine", desc = "分享杂志页面")
16 | open class ShareMessageActivity : BaseActivity() {
17 |
18 | @Autowired(name = "bookName")
19 | @JvmField
20 | var magazineName: String? = null
21 |
22 | @Autowired
23 | @JvmField
24 | var author: AuthorKt? = null
25 |
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | super.onCreate(savedInstanceState)
28 | setContentView(R.layout.kotlin_activity_share)
29 |
30 | share_title.text = "Magazine"
31 | share_tv_tag.setText(magazineName)
32 | share_tv_author.setText(author?.name ?: "zmq")
33 | share_tv_county.setText(author?.county ?: "China")
34 |
35 | share_title.setOnClickListener {
36 |
37 | val author = AuthorKt("Barack Obama", 65, "New York")
38 | UIRouter.getInstance().openUri(this,
39 | "DDComp://kotlin/javatest?bookName=NYTIME&author=" + JsonService.Factory.getSingletonImpl().toJsonString(author), null)
40 | }
41 |
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/java/com/luojilab/share/kotlin/applike/KotlinAppLike.kt:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.kotlin.applike
2 |
3 | import android.util.Log
4 | import com.luojilab.component.componentlib.applicationlike.IApplicationLike
5 | import com.luojilab.component.componentlib.router.ui.UIRouter
6 | import kotlinx.coroutines.CoroutineDispatcher
7 | import kotlinx.coroutines.Dispatchers
8 | import osp.leobert.android.maat.JOB
9 | import osp.leobert.android.maat.Maat
10 |
11 | /**
12 | * Created by mrzhang on 2018/1/3.
13 | */
14 | class KotlinApplike : IApplicationLike {
15 |
16 | val uiRouter = UIRouter.getInstance()
17 |
18 | override fun onCreate() {
19 | uiRouter.registerUI("kotlin")
20 | Log.e("shareKt", "shareKt on create")
21 | Maat.getDefault().append(object : JOB() {
22 | override val uniqueKey: String = "shareKt"
23 |
24 | override val dependsOn: List = arrayListOf("reader")
25 |
26 | override val dispatcher: CoroutineDispatcher = Dispatchers.Main
27 |
28 | override fun init(maat: Maat) {
29 | Log.d("shareKt", "模拟初始化shareKt,context:" + maat.application.javaClass.name)
30 | }
31 |
32 | override fun toString(): String {
33 | return uniqueKey
34 | }
35 | })
36 | }
37 |
38 | override fun onStop() {
39 | uiRouter.unregisterUI("kotlin")
40 | }
41 | }
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/res/layout/kotlin_activity_share.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
22 |
31 |
32 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | sharecomponentkotlin
3 |
4 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/runalone/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
29 |
30 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/runalone/java/com.luojilab.share.runalone/application/KotlinApplication.kt:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.runalone.application
2 |
3 | import android.util.Log
4 | import com.luojilab.component.basicres.BaseApplication
5 | import osp.leobert.android.maat.JOB
6 | import osp.leobert.android.maat.Maat
7 | import osp.leobert.android.maat.Maat.Callback
8 | import osp.leobert.android.maat.Maat.Companion.release
9 |
10 | /**
11 | * Created by mrzhang on 2018/1/5.
12 | */
13 | class KotlinApplication : BaseApplication() {
14 |
15 | override fun onCreate() {
16 | super.onCreate()
17 |
18 | //注意,如果准备使用Maat进行按序初始化,则需要先进行配置:
19 | Maat.init(this, 8, object : Maat.Logger() {
20 | override val enable: Boolean
21 | get() = true
22 |
23 | override fun log(msg: String, throws: Throwable?) {
24 | if (throws != null) {
25 | // ILogger.logger.error("maat", s);
26 | // throwable.printStackTrace();
27 | Log.e("maat", msg, throws)
28 | } else {
29 | // ILogger.logger.debug("maat", s);
30 | Log.d("maat", msg)
31 | }
32 | }
33 | }, Callback({ maat: Maat? ->
34 | release()
35 | }) { maat: Maat?, job: JOB?, throwable: Throwable? -> null })
36 |
37 | //如果真的使用了Maat,而又缺乏相关组件,则说明组件环境依赖不全,会抛出异常,例如
38 | //java.lang.RuntimeException: Unable to create application
39 | // com.luojilab.share.runalone.application.KotlinApplication:
40 | // osp.leobert.android.maat.MaatException: missing jobs:[reader]
41 |
42 | //如果确实有其他组件的初始化依赖,而目前又不方便引入,例如并行开发时,我们可以先把maat禁用或者添加模拟任务,参考sharecomponent
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/runalone/java/com.luojilab.share.runalone/application/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.runalone.application
2 |
3 | import com.luojilab.share.kotlin.ShareMessageActivity
4 |
5 | /**
6 | * Package: com.luojilab.share.runalone.application
7 | * Classname: MainActivity
8 | * Created by leobert on 2021/1/22.
9 | */
10 | class MainActivity: ShareMessageActivity() {
11 | }
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/main/runalone/mergedManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/jimu-sample-project/sharecomponentkotlin/src/test/java/com/luojilab/share/kotlin/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.luojilab.share.kotlin;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/src_build/main/java/jimu/Consts.java:
--------------------------------------------------------------------------------
1 | package jimu;
2 |
3 | public interface Consts {
4 |
5 | String GROUP_ID = "io.github.leobert-lan";
6 |
7 | String jimu_plugin_name = "com.dd.comgradle";
8 |
9 | interface Artifacts {
10 | String router_anno_compiler = "jimu-router-anno-compiler";
11 | }
12 |
13 | interface Versions {
14 | String jimu_plugin = "1.3.6";
15 | String router_anno_compiler = "1.0.2";
16 |
17 | //todo
18 | // def ARTIFACT_ID = 'jimu-router-anno-compiler'
19 | // def VERSION_NAME = '1.0.1'
20 | // def GROUP_ID = 'io.github.leobert-lan'
21 | }
22 |
23 | interface Deps {
24 | String JIMU_PLUGIN = GROUP_ID + ":jimu-build-gradle:" + Versions.jimu_plugin;
25 | String JIMU_ROUTER_COMPILER = GROUP_ID + ":" + Artifacts.router_anno_compiler + ":" + Versions.router_anno_compiler;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/stop_gradle.bat:
--------------------------------------------------------------------------------
1 | gradlew --stop
--------------------------------------------------------------------------------
/得到组件化改造大流程 by leobert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mqzhangw/JIMU/9d573de883f5fe5c0d649699931c1c050341e721/得到组件化改造大流程 by leobert.png
--------------------------------------------------------------------------------