Skip to content

Commit

Permalink
Merge branch 'master-androidx' into master-androidx-java8
Browse files Browse the repository at this point in the history
  • Loading branch information
keepactive committed Sep 15, 2020
2 parents 3c4e700 + 7e58629 commit 30db907
Show file tree
Hide file tree
Showing 77 changed files with 301 additions and 299 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaojinzi.component.anno;

import com.xiaojinzi.component.anno.support.MainThreadCreateAnno;
import com.xiaojinzi.component.anno.support.UiThreadCreateAnno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +10,7 @@
/**
* 标记一个 Fragment, 方便路由到此注解标记的 Fragment
*/
@MainThreadCreateAnno
@UiThreadCreateAnno
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface FragmentAnno {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaojinzi.component.anno;

import com.xiaojinzi.component.anno.support.MainThreadCreateAnno;
import com.xiaojinzi.component.anno.support.UiThreadCreateAnno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +10,7 @@
/**
* 拦截器的注解,用这个注解标记的不是全局的拦截器,但是你可以使用特定的字符串访问到这个拦截器
*/
@MainThreadCreateAnno
@UiThreadCreateAnno
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface InterceptorAnno {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaojinzi.component.anno;

import com.xiaojinzi.component.anno.support.MainThreadCreateAnno;
import com.xiaojinzi.component.anno.support.UiThreadCreateAnno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +10,7 @@
/**
* 标记一个接口
*/
@MainThreadCreateAnno
@UiThreadCreateAnno
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface ServiceAnno {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaojinzi.component.anno;

import com.xiaojinzi.component.anno.support.MainThreadCreateAnno;
import com.xiaojinzi.component.anno.support.UiThreadCreateAnno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +10,7 @@
/**
* 标记一个 Service 服务接口的方法是暴露的
*/
@MainThreadCreateAnno
@UiThreadCreateAnno
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface ServiceMethodAnno {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaojinzi.component.anno;

import com.xiaojinzi.component.anno.support.MainThreadCreateAnno;
import com.xiaojinzi.component.anno.support.UiThreadCreateAnno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +10,7 @@
/**
* 标记一个 Service 服务接口的方法的参数是暴露的
*/
@MainThreadCreateAnno
@UiThreadCreateAnno
@Target({ElementType.TYPE, ElementType.PARAMETER})
@Retention(RetentionPolicy.CLASS)
public @interface ServiceParameterAnno {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
*/
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface MainThreadCreateAnno {
public @interface UiThreadCreateAnno {
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ public void accept(String key, RouterAnnoBean routerBean) {

// 声明一个拦截器的集合.
String interceptorListName = "interceptorList" + atomicInteger.incrementAndGet();
initMapMethodSpecBuilder.addStatement("$N<$T> $N = new $T($L)",
initMapMethodSpecBuilder.addStatement("$N<$T> $N = new $N<$T>($L)",
ComponentConstants.JAVA_LIST, pageInterceptorBeanTypeElement, interceptorListName,
ArrayList.class, routerBean.getTotalInterceptorSize());
ComponentConstants.JAVA_ARRAYLIST, pageInterceptorBeanTypeElement, routerBean.getTotalInterceptorSize());
initMapMethodSpecBuilder.addStatement("$N.setPageInterceptors($N)", routerBeanName, interceptorListName);

// 拦截器的代码的生成
Expand Down
32 changes: 18 additions & 14 deletions ComponentImpl/src/main/java/com/xiaojinzi/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.impl.application.ModuleManager;
import com.xiaojinzi.component.support.Inject;
Expand All @@ -22,6 +23,11 @@
*/
public class Component {

public static final String GITHUB_URL = "https://github.com/xiaojinzi123/Component";
public static final String DOC_URL = "https://github.com/xiaojinzi123/Component/wiki";
public static final String COMMON_ERROR_ISSUE = "https://github.com/xiaojinzi123/Component/issues/21";
public static final String ROUTER_UES_NOTE = "https://github.com/xiaojinzi123/Component/wiki/%E4%B8%BB%E9%A1%B5#%E7%89%B9%E5%88%AB%E6%B3%A8%E6%84%8F";

/**
* 是否初始化过了
*/
Expand All @@ -45,28 +51,25 @@ private Component() {
*
* @see Config 初始化的配置对象
*/
@MainThread
@UiThread
public static void init(boolean isDebug, @NonNull Config config) {

// 做必要的检查
if (isInit) {
throw new RuntimeException("you have init Component already!");
}
Utils.checkMainThread();
Utils.checkNullPointer(config, "config");

Component.isDebug = isDebug;
mConfig = config;
if (isDebug) {
printComponent();
}
// 注册
mConfig.getApplication().registerActivityLifecycleCallbacks(new ComponentLifecycleCallback());
if (mConfig.isOptimizeInit() && mConfig.isAutoRegisterModule()) {
ModuleManager.getInstance().autoRegister();
}
isInit = true;
if (isDebug) {
printComponent();
}

}

/**
Expand All @@ -92,8 +95,9 @@ private static void printComponent() {
sb.append(" *********\n");

sb.append("感谢您选择 Component 组件化框架. \n有任何问题欢迎提 issue 或者扫描 github 上的二维码进入群聊@群主\n")
.append("Github 地址:https://github.com/xiaojinzi123/Component")
.append("\n文档地址:https://github.com/xiaojinzi123/Component/wiki")
.append("Github 地址:" + GITHUB_URL)
.append("\n文档地址:" + DOC_URL)
.append("\n错误排查指南:" + COMMON_ERROR_ISSUE)
.append("\n ");

LogUtil.logw(sb.toString());
Expand Down Expand Up @@ -132,22 +136,22 @@ private static void checkInit() {
}
}

@MainThread
@UiThread
public static void inject(@NonNull Object target) {
inject(target, null, true, true);
}

@MainThread
@UiThread
public static void injectAttrValueFromIntent(@NonNull Object target, @Nullable Intent intent) {
injectAttrValueFromBundle(target, intent == null ? null : intent.getExtras());
}

@MainThread
@UiThread
public static void injectAttrValueFromBundle(@NonNull Object target, @Nullable Bundle bundle) {
inject(target, bundle, true, false);
}

@MainThread
@UiThread
public static void injectService(@NonNull Object target) {
inject(target, null, false, true);
}
Expand All @@ -160,7 +164,7 @@ public static void injectService(@NonNull Object target) {
* @param isAutoWireAttrValue 是否注入属性值
* @param isAutoWireService 是否注入 Service
*/
@MainThread
@UiThread
private static void inject(@NonNull Object target, @Nullable Bundle bundle,
boolean isAutoWireAttrValue,
boolean isAutoWireService) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.xiaojinzi.component;

import android.app.Activity;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.support.Utils;

Expand All @@ -28,7 +28,7 @@ private static class Holder {
private static ComponentActivityStack INSTANCE = new ComponentActivityStack();
}

@MainThread
@UiThread
public static ComponentActivityStack getInstance() {
return Holder.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaojinzi.component.application;

import androidx.annotation.MainThread;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.anno.ModuleAppAnno;
import com.xiaojinzi.component.anno.support.CheckClassNameAnno;
Expand All @@ -13,7 +13,7 @@
* 你可以实现此接口或者{@link IComponentApplication} 接口, 但是建议实现此接口.
* 老接口 {@link IComponentApplication} 会在将来某个版本删除
*/
@MainThread
@UiThread
@CheckClassNameAnno
public interface IApplicationLifecycle extends IBaseLifecycle {
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.xiaojinzi.component.application;

import androidx.annotation.MainThread;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.anno.support.CheckClassNameAnno;
import com.xiaojinzi.component.support.IBaseLifecycle;

/**
* @see IApplicationLifecycle
*/
@MainThread
@UiThread
@CheckClassNameAnno
public interface IComponentApplication extends IApplicationLifecycle {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.xiaojinzi.component.fragment;


import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.support.IBaseLifecycle;
import com.xiaojinzi.component.support.IHost;
Expand All @@ -21,7 +21,7 @@ public interface IComponentHostFragment extends IBaseLifecycle, IHost {
* 第二:在注解驱动器中, 做了避免重复的操作
*/
@NonNull
@MainThread
@UiThread
Set<String> getFragmentNameSet();

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.xiaojinzi.component.impl;

import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.anno.support.CheckClassNameAnno;
import com.xiaojinzi.component.support.Function;
Expand All @@ -26,7 +26,7 @@ public interface BiCallback<T> extends OnRouterCancel, OnRouterError {
* @param result 路由成功的对象
* @param t 返回的对象
*/
@MainThread
@UiThread
void onSuccess(@NonNull RouterResult result, @NonNull T t);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.xiaojinzi.component.impl;

import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import com.xiaojinzi.component.anno.support.CheckClassNameAnno;
import com.xiaojinzi.component.support.OnRouterCancel;
Expand Down Expand Up @@ -31,7 +31,7 @@ public interface Callback extends OnRouterError, OnRouterCancel {
* @see Navigator#navigate(Callback)
* @see Navigator#navigateForResultCodeMatch(Callback, int)
*/
@MainThread
@UiThread
void onSuccess(@NonNull RouterResult result);

/**
Expand All @@ -40,7 +40,7 @@ public interface Callback extends OnRouterError, OnRouterCancel {
* @param successResult 路由成功时候的返回对象,成功的对象
* @param errorResult 发生的错误对象
*/
@MainThread
@UiThread
void onEvent(@Nullable RouterResult successResult, @Nullable RouterErrorResult errorResult);

}
Loading

0 comments on commit 30db907

Please sign in to comment.