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
9b4a5f15
Commit
9b4a5f15
authored
Sep 30, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
f3db2a9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
src/main/java/tech/starwin/LibConfig.java
+118
-0
No files found.
src/main/java/tech/starwin/LibConfig.java
0 → 100644
View file @
9b4a5f15
package
tech
.
starwin
;
import
android.app.Application
;
import
android.content.Context
;
import
android.view.View
;
import
com.scwang.smartrefresh.layout.SmartRefreshLayout
;
import
com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator
;
import
com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator
;
import
com.scwang.smartrefresh.layout.api.RefreshFooter
;
import
com.scwang.smartrefresh.layout.api.RefreshHeader
;
import
com.scwang.smartrefresh.layout.api.RefreshLayout
;
import
com.scwang.smartrefresh.layout.footer.ClassicsFooter
;
import
com.scwang.smartrefresh.layout.header.ClassicsHeader
;
import
tech.starwin.R
;
import
tech.starwin.network.Gateway
;
import
tech.starwin.utils.PreferencesManager
;
/**
* Created by SiKang on 2018/9/30.
*/
public
class
LibConfig
{
private
static
Context
CONTEXT
;
public
static
boolean
DEBUG
;
public
static
String
APPLICATION_ID
;
public
static
String
BUILD_TYPE
;
public
static
String
FLAVOR
;
public
static
int
VERSION_CODE
;
public
static
String
VERSION_NAME
;
public
static
String
FLAVOR_default
;
public
static
String
FLAVOR_server
;
public
static
String
AGREEMENT_URL
;
public
static
String
APP_URL
;
public
static
String
BUGLY_APP_ID
;
public
static
String
CONTRACT_URL
;
public
static
String
HOTLINE
;
public
static
String
LOAN_AGREEMENT
;
public
static
String
LOGIN_ACTIVITY_ACTION
;
public
static
String
ROOT_DIR
;
public
static
String
ADMIN_HOST
;
public
static
String
API_BASE_URL
;
public
static
String
GATEWAY_HOST_G0
;
public
static
String
GATEWAY_HOST_G1
;
public
static
String
HARVESTER_IP
;
public
static
int
HARVESTER_PORT
;
public
static
ButterKnifeBinder
butterKnifeBinder
;
public
static
Context
getContext
()
{
if
(
CONTEXT
==
null
)
throw
new
RuntimeException
(
"context is null ! you must execute LibConfig.bindApplication(application) in your Appliaction"
);
return
CONTEXT
;
}
/**
* 为Library绑定一个Context
*/
public
static
void
initLib
(
Application
application
)
{
if
(
application
!=
null
)
{
CONTEXT
=
application
;
PreferencesManager
.
get
().
init
(
application
);
Gateway
.
init
(
PreferencesManager
.
get
().
getGatewayInfo
());
}
}
/**
* 用于在Base 中 实现Butterknife.bind()的功能
*
* @param binder 实现 ButterKnifeBinder.bindView() 方法,在其中做Butterknife.bind() ,功能
*/
public
static
void
setButterKnifeBinder
(
ButterKnifeBinder
binder
)
{
butterKnifeBinder
=
binder
;
}
public
static
Object
bindView
(
Object
obj
,
View
view
)
{
if
(
butterKnifeBinder
!=
null
)
{
return
butterKnifeBinder
.
bindView
(
obj
,
view
);
}
return
null
;
}
public
static
void
unBindView
(
Object
unBinder
)
{
if
(
butterKnifeBinder
!=
null
)
{
butterKnifeBinder
.
unBind
(
unBinder
);
}
}
public
interface
ButterKnifeBinder
{
Object
bindView
(
Object
obj
,
View
view
);
void
unBind
(
Object
obj
);
}
/**
* SmartRefresh 默认风格
* */
static
{
//设置全局的Header构建器
SmartRefreshLayout
.
setDefaultRefreshHeaderCreator
(
new
DefaultRefreshHeaderCreator
()
{
@Override
public
RefreshHeader
createRefreshHeader
(
Context
context
,
RefreshLayout
layout
)
{
layout
.
setPrimaryColorsId
(
R
.
color
.
color_main
,
android
.
R
.
color
.
white
);
//全局设置主题颜色
return
new
ClassicsHeader
(
context
);
//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header
}
});
//设置全局的Footer构建器
SmartRefreshLayout
.
setDefaultRefreshFooterCreator
(
new
DefaultRefreshFooterCreator
()
{
@Override
public
RefreshFooter
createRefreshFooter
(
Context
context
,
RefreshLayout
layout
)
{
//指定为经典Footer,默认是 BallPulseFooter
return
new
ClassicsFooter
(
context
).
setDrawableSize
(
20
);
}
});
}
}
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