Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf8cb5c

Browse files
1:修改ClassUtils方法,增加多个路径下寻找类的方法;
1 parent 1483376 commit cf8cb5c

File tree

5 files changed

+156
-82
lines changed

5 files changed

+156
-82
lines changed

‎lib_common/src/main/java/com/guiying/module/common/base/BaseActivity.java‎

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@
1919
*/
2020
public abstract class BaseActivity extends AppCompatActivity {
2121

22-
/**
23-
* Setup the toolbar.
24-
*
25-
* @param toolbar toolbar
26-
* @param hideTitle 是否隐藏Title
27-
*/
28-
protected void setupToolBar(Toolbar toolbar, boolean hideTitle) {
29-
setSupportActionBar(toolbar);
30-
ActionBar actionBar = getSupportActionBar();
31-
if (actionBar != null) {
32-
actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
33-
actionBar.setDisplayHomeAsUpEnabled(true);
34-
actionBar.setDisplayShowHomeEnabled(true);
35-
if (hideTitle) {
36-
//隐藏Title
37-
actionBar.setDisplayShowTitleEnabled(false);
38-
}
39-
}
40-
}
41-
4222

4323
/**
4424
* 封装的findViewByID方法
@@ -48,6 +28,7 @@ protected void setupToolBar(Toolbar toolbar, boolean hideTitle) {
4828
return (T) super.findViewById(id);
4929
}
5030

31+
5132
@Override
5233
protected void onCreate(Bundle savedInstanceState) {
5334
super.onCreate(savedInstanceState);
@@ -67,7 +48,34 @@ public boolean onSupportNavigateUp() {
6748
return true;
6849
}
6950

70-
//添加fragment
51+
52+
/**
53+
* Setup the toolbar.
54+
*
55+
* @param toolbar toolbar
56+
* @param hideTitle 是否隐藏Title
57+
*/
58+
protected void setupToolBar(Toolbar toolbar, boolean hideTitle) {
59+
setSupportActionBar(toolbar);
60+
ActionBar actionBar = getSupportActionBar();
61+
if (actionBar != null) {
62+
actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
63+
actionBar.setDisplayHomeAsUpEnabled(true);
64+
actionBar.setDisplayShowHomeEnabled(true);
65+
if (hideTitle) {
66+
//隐藏Title
67+
actionBar.setDisplayShowTitleEnabled(false);
68+
}
69+
}
70+
}
71+
72+
73+
/**
74+
* 添加fragment
75+
*
76+
* @param fragment
77+
* @param frameId
78+
*/
7179
protected void addFragment(BaseFragment fragment, @IdRes int frameId) {
7280
Utils.checkNotNull(fragment);
7381
getSupportFragmentManager().beginTransaction()
@@ -77,7 +85,12 @@ protected void addFragment(BaseFragment fragment, @IdRes int frameId) {
7785

7886
}
7987

80-
//替换fragment
88+
89+
/**
90+
* 替换fragment
91+
* @param fragment
92+
* @param frameId
93+
*/
8194
protected void replaceFragment(BaseFragment fragment, @IdRes int frameId) {
8295
Utils.checkNotNull(fragment);
8396
getSupportFragmentManager().beginTransaction()
@@ -87,7 +100,11 @@ protected void replaceFragment(BaseFragment fragment, @IdRes int frameId) {
87100

88101
}
89102

90-
//隐藏fragment
103+
104+
/**
105+
* 隐藏fragment
106+
* @param fragment
107+
*/
91108
protected void hideFragment(BaseFragment fragment) {
92109
Utils.checkNotNull(fragment);
93110
getSupportFragmentManager().beginTransaction()
@@ -97,7 +114,10 @@ protected void hideFragment(BaseFragment fragment) {
97114
}
98115

99116

100-
//显示fragment
117+
/**
118+
* 显示fragment
119+
* @param fragment
120+
*/
101121
protected void showFragment(BaseFragment fragment) {
102122
Utils.checkNotNull(fragment);
103123
getSupportFragmentManager().beginTransaction()
@@ -107,6 +127,10 @@ protected void showFragment(BaseFragment fragment) {
107127
}
108128

109129

130+
/**
131+
* 移除fragment
132+
* @param fragment
133+
*/
110134
protected void removeFragment(BaseFragment fragment) {
111135
Utils.checkNotNull(fragment);
112136
getSupportFragmentManager().beginTransaction()
@@ -116,7 +140,9 @@ protected void removeFragment(BaseFragment fragment) {
116140
}
117141

118142

119-
//移除fragment
143+
/**
144+
* 弹出栈顶部的Fragment
145+
*/
120146
protected void popFragment() {
121147
if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
122148
getSupportFragmentManager().popBackStack();

‎lib_common/src/main/java/com/guiying/module/common/base/BaseApplication.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* 组件中实现的Application必须在debug包中的AndroidManifest.xml中注册,否则无法使用;
1414
* 组件的Application需置于java/debug文件夹中,不得放于主代码;
1515
* 组件中获取Context的方法必须为:Utils.getContext(),不允许其他写法;
16-
* BaseApplication主要用来管理全局Activity;
1716
*
1817
* @author 2016年12月2日 17:02
1918
* @version V1.0.0
@@ -25,7 +24,7 @@ public class BaseApplication extends Application {
2524

2625
private static BaseApplication sInstance;
2726

28-
private List<ApplicationDelegate> delegateList;
27+
private List<ApplicationDelegate> mAppDelegateList;
2928

3029

3130
public static BaseApplication getIns() {
@@ -36,12 +35,13 @@ public static BaseApplication getIns() {
3635
public void onCreate() {
3736
super.onCreate();
3837
sInstance = this;
38+
Logger.init("pattern").logLevel(LogLevel.FULL);
3939
Utils.init(this);
40-
delegateList = ClassUtils.getObjectsWithInterface(this, ApplicationDelegate.class, ROOT_PACKAGE);
41-
for (ApplicationDelegate delegate : delegateList) {
40+
mAppDelegateList = ClassUtils.getObjectsWithInterface(this, ApplicationDelegate.class, ROOT_PACKAGE);
41+
for (ApplicationDelegate delegate : mAppDelegateList) {
4242
delegate.onCreate();
4343
}
44-
Logger.init("pattern").logLevel(LogLevel.FULL);
44+
4545
}
4646

4747

‎lib_common/src/main/java/com/guiying/module/common/base/BaseFragment.java‎

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,85 @@ public abstract class BaseFragment extends Fragment {
1010

1111
protected BaseActivity mActivity;
1212

13-
14-
//获取宿主Activity
15-
protected BaseActivity getHoldingActivity() {
16-
return mActivity;
17-
}
18-
1913
@Override
2014
public void onAttach(Context context) {
2115
super.onAttach(context);
2216
this.mActivity = (BaseActivity) context;
2317
}
2418

2519

26-
//添加fragment
20+
/**
21+
* 获取宿主Activity
22+
*
23+
* @return BaseActivity
24+
*/
25+
protected BaseActivity getHoldingActivity() {
26+
return mActivity;
27+
}
28+
29+
30+
/**
31+
* 添加fragment
32+
*
33+
* @param fragment
34+
* @param frameId
35+
*/
2736
protected void addFragment(BaseFragment fragment, @IdRes int frameId) {
2837
Utils.checkNotNull(fragment);
2938
getHoldingActivity().addFragment(fragment, frameId);
3039

3140
}
3241

33-
//替换fragment
42+
43+
/**
44+
* 替换fragment
45+
*
46+
* @param fragment
47+
* @param frameId
48+
*/
3449
protected void replaceFragment(BaseFragment fragment, @IdRes int frameId) {
3550
Utils.checkNotNull(fragment);
3651
getHoldingActivity().replaceFragment(fragment, frameId);
3752
}
3853

39-
//隐藏fragment
54+
55+
/**
56+
* 隐藏fragment
57+
*
58+
* @param fragment
59+
*/
4060
protected void hideFragment(BaseFragment fragment) {
4161
Utils.checkNotNull(fragment);
4262
getHoldingActivity().hideFragment(fragment);
4363
}
4464

4565

46-
//显示fragment
66+
/**
67+
* 显示fragment
68+
*
69+
* @param fragment
70+
*/
4771
protected void showFragment(BaseFragment fragment) {
4872
Utils.checkNotNull(fragment);
4973
getHoldingActivity().showFragment(fragment);
5074
}
5175

5276

77+
/**
78+
* 移除Fragment
79+
*
80+
* @param fragment
81+
*/
5382
protected void removeFragment(BaseFragment fragment) {
5483
Utils.checkNotNull(fragment);
5584
getHoldingActivity().removeFragment(fragment);
5685

5786
}
5887

5988

60-
//移除fragment
89+
/**
90+
* 弹出栈顶部的Fragment
91+
*/
6192
protected void popFragment() {
6293
getHoldingActivity().popFragment();
6394
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /