Skip to content

Commit

Permalink
测试 Service 注入两次是否有问题, 看起来不会有问题.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojinzi123 committed Oct 9, 2019
1 parent b81577b commit 2616c9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public static <T> T unregister(@NonNull Class<T> tClass) {

@Nullable
public static <T> T get(@NonNull Class<T> tClass) {
if (map.get(tClass) == null) {
IServiceLoad<?> serviceLoad = map.get(tClass);
if (serviceLoad == null) {
return null;
} else {
return (T) map.get(tClass).get();
return (T) serviceLoad.get();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import android.widget.TextView;

import com.xiaojinzi.base.ModuleConfig;
import com.xiaojinzi.base.service.inter.user.UserService;
import com.xiaojinzi.base.view.BaseAct;
import com.xiaojinzi.component.Component;
import com.xiaojinzi.component.anno.FiledAutowiredAnno;
import com.xiaojinzi.component.anno.RouterAnno;
import com.xiaojinzi.component.anno.ServiceAutowiredAnno;
import com.xiaojinzi.component1.R;

/**
Expand All @@ -27,6 +29,9 @@ public class TestInjectAct4 extends BaseAct {
@FiledAutowiredAnno("name")
String name = compareStr;

@ServiceAutowiredAnno
UserService userService;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down

0 comments on commit 2616c9e

Please sign in to comment.