Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
bcdc2b6a
Commit
bcdc2b6a
authored
Sep 30, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
7fc4b04a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
src/main/java/tech/starwin/base/BaseActivity.java
+1
-0
src/main/java/tech/starwin/base/BaseFragment.java
+1
-0
src/main/java/tech/starwin/base/LibConfig.java
+29
-0
No files found.
src/main/java/tech/starwin/base/BaseActivity.java
View file @
bcdc2b6a
...
@@ -150,6 +150,7 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
...
@@ -150,6 +150,7 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
//填充Activity -> bindLayout();
//填充Activity -> bindLayout();
if
(
bindLayout
()
!=
0
)
{
if
(
bindLayout
()
!=
0
)
{
LayoutInflater
.
from
(
this
).
inflate
(
bindLayout
(),
rootLayout
,
true
);
LayoutInflater
.
from
(
this
).
inflate
(
bindLayout
(),
rootLayout
,
true
);
LibConfig
.
bindView
(
this
,
rootLayout
);
initView
();
initView
();
}
else
{
}
else
{
throw
new
RuntimeException
(
"找不到布局文件 bindLayout() -> "
+
bindLayout
());
throw
new
RuntimeException
(
"找不到布局文件 bindLayout() -> "
+
bindLayout
());
...
...
src/main/java/tech/starwin/base/BaseFragment.java
View file @
bcdc2b6a
...
@@ -62,6 +62,7 @@ public abstract class BaseFragment extends Fragment implements IView {
...
@@ -62,6 +62,7 @@ public abstract class BaseFragment extends Fragment implements IView {
initTopBar
(
mTopBar
);
initTopBar
(
mTopBar
);
}
}
mContentView
=
(
ViewGroup
)
LayoutInflater
.
from
(
getActivity
()).
inflate
(
bindLayout
(),
mContentView
);
mContentView
=
(
ViewGroup
)
LayoutInflater
.
from
(
getActivity
()).
inflate
(
bindLayout
(),
mContentView
);
LibConfig
.
bindView
(
this
,
mContentView
);
initView
();
initView
();
return
mContentView
;
return
mContentView
;
}
}
...
...
src/main/java/tech/starwin/base/LibConfig.java
View file @
bcdc2b6a
...
@@ -2,6 +2,7 @@ package tech.starwin.base;
...
@@ -2,6 +2,7 @@ package tech.starwin.base;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
android.view.View
;
import
com.scwang.smartrefresh.layout.SmartRefreshLayout
;
import
com.scwang.smartrefresh.layout.SmartRefreshLayout
;
import
com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator
;
import
com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator
;
...
@@ -43,16 +44,44 @@ public class LibConfig {
...
@@ -43,16 +44,44 @@ public class LibConfig {
public
static
String
HARVESTER_IP
;
public
static
String
HARVESTER_IP
;
public
static
int
HARVESTER_PORT
;
public
static
int
HARVESTER_PORT
;
public
static
ButterKnifeBinder
butterKnifeBinder
;
public
static
Context
getContext
()
{
public
static
Context
getContext
()
{
if
(
CONTEXT
==
null
)
if
(
CONTEXT
==
null
)
throw
new
RuntimeException
(
"context is null ! you must execute LibConfig.bindApplication(application) in your Appliaction"
);
throw
new
RuntimeException
(
"context is null ! you must execute LibConfig.bindApplication(application) in your Appliaction"
);
return
CONTEXT
;
return
CONTEXT
;
}
}
/**
* 为Library绑定一个Context
*/
public
static
void
bindApplication
(
Application
application
)
{
public
static
void
bindApplication
(
Application
application
)
{
CONTEXT
=
application
;
CONTEXT
=
application
;
}
}
/**
* 用于在Base 中 实现Butterknife.bind()的功能
*
* @param binder 实现 ButterKnifeBinder.bindView() 方法,在其中做Butterknife.bind() ,功能
*/
public
static
void
setButterKnifeBinder
(
ButterKnifeBinder
binder
)
{
butterKnifeBinder
=
binder
;
}
public
static
void
bindView
(
Object
obj
,
View
view
)
{
if
(
butterKnifeBinder
!=
null
)
{
butterKnifeBinder
.
bindView
(
obj
,
view
);
}
}
public
interface
ButterKnifeBinder
{
void
bindView
(
Object
obj
,
View
view
);
}
/**
* SmartRefresh 默认风格
* */
static
{
static
{
//设置全局的Header构建器
//设置全局的Header构建器
SmartRefreshLayout
.
setDefaultRefreshHeaderCreator
(
new
DefaultRefreshHeaderCreator
()
{
SmartRefreshLayout
.
setDefaultRefreshHeaderCreator
(
new
DefaultRefreshHeaderCreator
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment