Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fastcoding
/
wdkitcore
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
张波
2024-10-14 19:04:56 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c7c83a66361012d62cf06855f5742c8a1d1b6349
c7c83a66
1 parent
b6da39db
更新代码,更新版本
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
4376 additions
and
57 deletions
wdkitcore/build.gradle
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/BusMutableLiveData.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/LiveDataBus.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/ObserverWrapper.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/SingleLiveData.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/router/ArouterServiceManager.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/ConfigBase.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/MemMgr.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/MemStoreUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/SpMgr.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/SpStoreUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/AppContext.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/AssertUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/CloseUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/DeviceUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/FileUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/JsonUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/ResUtils.java
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/SpUtils.java
wdkitcore/build.gradle
View file @
c7c83a6
...
...
@@ -4,6 +4,12 @@ plugins {
id
'maven'
}
private
static
String
getBuildTime
()
{
Date
date
=
new
Date
()
String
dateStr
=
date
.
format
(
"yyyyMMddHHmm"
)
return
"\"${dateStr}\""
}
android
{
compileSdkVersion
var
.
compileSdkVersion
...
...
@@ -17,6 +23,8 @@ android {
consumerProguardFiles
"consumer-rules.pro"
buildConfigField
"String"
,
"API_VERSION"
,
"\"${requestVersion}\""
//添加build 时间
buildConfigField
"String"
,
"build_version"
,
getBuildTime
()
}
buildTypes
{
...
...
@@ -44,6 +52,8 @@ android {
dependencies
{
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'com.wd:log:1.0.0'
implementation
'com.alibaba:fastjson:1.2.62'
api
'com.alibaba:arouter-api:1.5.2'
}
uploadArchives
{
...
...
@@ -54,7 +64,7 @@ uploadArchives {
}
pom
.
project
{
artifactId
'wdkitcore'
version
'1.0.
0
'
version
'1.0.
5
'
groupId
'com.wd'
packaging
'aar'
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/BusMutableLiveData.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
livedata
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
import
androidx.annotation.NonNull
;
import
androidx.lifecycle.LifecycleOwner
;
import
androidx.lifecycle.LiveData
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.Observer
;
/**
* @author : ouyang
* @description :BusMutableLiveData
* @since : 2022/7/4
*/
public
class
BusMutableLiveData
<
T
>
extends
MutableLiveData
<
T
>
{
private
Map
<
Observer
,
Observer
>
observerMap
=
new
HashMap
<>();
@Override
public
void
observe
(
@NonNull
LifecycleOwner
owner
,
@NonNull
Observer
<?
super
T
>
observer
)
{
super
.
observe
(
owner
,
observer
);
try
{
hook
(
observer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
observeForever
(
@NonNull
Observer
<?
super
T
>
observer
)
{
if
(!
observerMap
.
containsKey
(
observer
))
{
observerMap
.
put
(
observer
,
new
ObserverWrapper
(
observer
));
}
super
.
observeForever
(
observerMap
.
get
(
observer
));
}
@Override
public
void
removeObserver
(
@NonNull
final
Observer
<?
super
T
>
observer
)
{
Observer
realObserver
=
null
;
if
(
observerMap
.
containsKey
(
observer
))
{
realObserver
=
observerMap
.
remove
(
observer
);
}
else
{
realObserver
=
observer
;
}
super
.
removeObserver
(
realObserver
);
}
private
void
hook
(
@NonNull
Observer
<?
super
T
>
observer
)
throws
Exception
{
// get wrapper's version
Class
<
LiveData
>
classLiveData
=
LiveData
.
class
;
Field
fieldObservers
=
classLiveData
.
getDeclaredField
(
"mObservers"
);
fieldObservers
.
setAccessible
(
true
);
Object
objectObservers
=
fieldObservers
.
get
(
this
);
Class
<?>
classObservers
=
objectObservers
.
getClass
();
Method
methodGet
=
classObservers
.
getDeclaredMethod
(
"get"
,
Object
.
class
);
methodGet
.
setAccessible
(
true
);
Object
objectWrapperEntry
=
methodGet
.
invoke
(
objectObservers
,
observer
);
Object
objectWrapper
=
null
;
if
(
objectWrapperEntry
instanceof
Map
.
Entry
)
{
objectWrapper
=
((
Map
.
Entry
)
objectWrapperEntry
).
getValue
();
}
if
(
objectWrapper
==
null
)
{
// throw new NullPointerException("Wrapper can not be bull!");
return
;
}
Class
<?>
classObserverWrapper
=
objectWrapper
.
getClass
().
getSuperclass
();
Field
fieldLastVersion
=
classObserverWrapper
.
getDeclaredField
(
"mLastVersion"
);
fieldLastVersion
.
setAccessible
(
true
);
// get livedata's version
Field
fieldVersion
=
classLiveData
.
getDeclaredField
(
"mVersion"
);
fieldVersion
.
setAccessible
(
true
);
Object
objectVersion
=
fieldVersion
.
get
(
this
);
// set wrapper's version
fieldLastVersion
.
set
(
objectWrapper
,
objectVersion
);
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/LiveDataBus.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
livedata
;
import
java.util.HashMap
;
import
java.util.Map
;
import
androidx.lifecycle.MutableLiveData
;
/**
* @author : ouyang
* @description :LiveDataBus
* @since : 2022/7/4
*/
public
final
class
LiveDataBus
{
private
static
class
SingletonHolder
{
private
static
final
LiveDataBus
DEFAULT_BUS
=
new
LiveDataBus
();
}
private
final
Map
<
String
,
BusMutableLiveData
<
Object
>>
bus
;
private
LiveDataBus
()
{
bus
=
new
HashMap
<>();
}
public
static
LiveDataBus
getInstance
()
{
return
SingletonHolder
.
DEFAULT_BUS
;
}
public
<
T
>
MutableLiveData
<
T
>
with
(
String
key
,
Class
<
T
>
type
)
{
if
(!
bus
.
containsKey
(
key
))
{
bus
.
put
(
key
,
new
BusMutableLiveData
<>());
}
return
(
MutableLiveData
<
T
>)
bus
.
get
(
key
);
}
public
MutableLiveData
<
Object
>
with
(
String
key
)
{
return
with
(
key
,
Object
.
class
);
}
}
\ No newline at end of file
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/ObserverWrapper.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
livedata
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.Observer
;
/**
* @author : ouyang
* @description :ObserverWrapper
* @since : 2022/7/4
*/
public
class
ObserverWrapper
<
T
>
implements
Observer
<
T
>
{
private
Observer
<
T
>
observer
;
public
ObserverWrapper
(
Observer
<
T
>
observer
)
{
this
.
observer
=
observer
;
}
@Override
public
void
onChanged
(
@Nullable
T
t
)
{
if
(
observer
!=
null
)
{
if
(
isCallOnObserve
())
{
return
;
}
observer
.
onChanged
(
t
);
}
}
private
boolean
isCallOnObserve
()
{
StackTraceElement
[]
stackTrace
=
Thread
.
currentThread
().
getStackTrace
();
if
(
stackTrace
!=
null
&&
stackTrace
.
length
>
0
)
{
for
(
StackTraceElement
element
:
stackTrace
)
{
if
(
"android.arch.lifecycle.LiveData"
.
equals
(
element
.
getClassName
())
&&
"observeForever"
.
equals
(
element
.
getMethodName
()))
{
return
true
;
}
}
}
return
false
;
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/livedata/SingleLiveData.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
livedata
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
android.util.Log
;
import
androidx.annotation.MainThread
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.LifecycleOwner
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.Observer
;
//1.一部分原因是LiveData的机制,就是向所有前台Fragment或者Activity发送数据。只要注册的观察者在前台就必定会收到这个数据。
//2.另一部分的原因是对ViewModel理解不深刻,理论上只有在Activity保存的ViewModel它没被销毁过就会一直给新的前台Fragment观察者发送数据。
// 我们需要管理好ViewModel的使用范围。 比如只需要在Fragment里使用的ViewModel就不要给Activity保管。
// 而根Activity的ViewModel只需要做一下数据共享与看情况使用LiveData。
public
class
SingleLiveData
<
T
>
extends
MutableLiveData
<
T
>
{
private
static
final
String
TAG
=
SingleLiveData
.
class
.
getSimpleName
();
private
final
AtomicBoolean
mPending
=
new
AtomicBoolean
(
false
);
@Override
@MainThread
public
void
observe
(
LifecycleOwner
owner
,
final
Observer
<?
super
T
>
observer
)
{
if
(
hasActiveObservers
())
{
Log
.
w
(
TAG
,
"Multiple observers registered but only one will be notified of changes."
);
}
// Observe the internal MutableLiveData
super
.
observe
(
owner
,
new
Observer
<
T
>()
{
@Override
public
void
onChanged
(
@Nullable
T
t
)
{
if
(
mPending
.
compareAndSet
(
true
,
false
))
{
observer
.
onChanged
(
t
);
}
}
});
}
@Override
@MainThread
public
void
setValue
(
@Nullable
T
t
)
{
mPending
.
set
(
true
);
super
.
setValue
(
t
);
}
/**
* Used for cases where T is Void, to make calls cleaner.
*/
@MainThread
public
void
call
()
{
setValue
(
null
);
}
}
\ No newline at end of file
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/router/ArouterServiceManager.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
router
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
com.alibaba.android.arouter.facade.template.IProvider
;
import
com.alibaba.android.arouter.launcher.ARouter
;
import
com.alibaba.android.arouter.utils.TextUtils
;
import
com.wd.foundation.wdkitcore.tools.AppContext
;
/**
* @ProjectName: 路由
* @Description: 服务提供类
*/
public
class
ArouterServiceManager
{
public
static
final
String
TAG
=
"ArouterServiceManager"
;
@Nullable
public
static
<
T
extends
IProvider
>
T
provide
(
Class
<
T
>
clz
,
String
path
)
{
if
(
TextUtils
.
isEmpty
(
path
))
{
return
null
;
}
IProvider
provider
=
null
;
try
{
provider
=
(
IProvider
)
ARouter
.
getInstance
().
build
(
path
).
navigation
();
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"没有获取到需要的服务,请检查"
);
}
return
(
T
)
provider
;
}
@Nullable
public
static
<
T
extends
IProvider
>
T
provide
(
Class
<
T
>
clz
)
{
IProvider
provider
=
null
;
try
{
provider
=
ARouter
.
getInstance
().
navigation
(
clz
);
}
catch
(
Exception
e
)
{
Log
.
i
(
TAG
,
"没有获取到需要的服务,请检查"
);
}
if
(
AppContext
.
DEBUG
&&
null
==
provider
)
{
if
(
Looper
.
getMainLooper
().
getThread
()
==
Thread
.
currentThread
())
{
Toast
.
makeText
(
AppContext
.
getContext
(),
"没有获取到需要的服务,请检查--->"
+
clz
.
getSimpleName
(),
Toast
.
LENGTH_LONG
)
.
show
();
}
Log
.
e
(
TAG
,
"没有获取到需要的服务,请检查-->"
+
clz
.
getSimpleName
());
}
return
(
T
)
provider
;
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/ConfigBase.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
storage
;
/**
* sp保存基类<BR>
*
* @author zhangbo
* @version [V1.0.0, 2020/8/11]
* @since V1.0.0
*/
public
class
ConfigBase
{
private
String
mFileName
=
"default_sp_file"
;
public
ConfigBase
(
String
fileName
)
{
mFileName
=
fileName
;
}
private
String
getConfigName
()
{
return
this
.
mFileName
;
}
public
void
put
(
String
key
,
String
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
put
(
String
key
,
int
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
put
(
String
key
,
long
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
put
(
String
key
,
double
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
put
(
String
key
,
float
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
put
(
String
key
,
boolean
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
put
(
String
key
,
Object
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
remove
(
String
key
)
{
MemStoreUtils
.
remove
(
this
.
getConfigName
(),
key
);
}
public
void
removeWithSP
(
String
key
)
{
MemStoreUtils
.
remove
(
this
.
getConfigName
(),
key
);
SpStoreUtils
.
remove
(
this
.
getConfigName
(),
key
);
}
public
Object
getObj
(
String
key
)
{
return
MemStoreUtils
.
getObj
(
this
.
getConfigName
(),
key
);
}
public
String
getStringWithSP
(
String
key
)
{
return
this
.
getStringWithSP
(
key
,
(
String
)
null
);
}
public
int
getIntWithSP
(
String
key
)
{
return
this
.
getIntWithSP
(
key
,
-
2147483648
);
}
public
long
getLongWithSP
(
String
key
)
{
return
this
.
getLongWithSP
(
key
,
-
9223372036854775808L
);
}
public
float
getFloatWithSP
(
String
key
)
{
return
this
.
getFloatWithSP
(
key
,
1.4
E
-
45
F
);
}
public
boolean
getBooleanWithSP
(
String
key
)
{
return
this
.
getBooleanWithSP
(
key
,
false
);
}
public
boolean
getBoolean
(
String
key
)
{
return
MemStoreUtils
.
getBoolean
(
this
.
getConfigName
(),
key
);
}
public
boolean
getBoolean
(
String
key
,
boolean
defValue
)
{
return
MemStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
)
?
MemStoreUtils
.
getBoolean
(
this
.
getConfigName
(),
key
)
:
defValue
;
}
public
void
putWithSP
(
String
key
,
String
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
SpStoreUtils
.
putString
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
putWithSP
(
String
key
,
int
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
SpStoreUtils
.
putInt
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
putWithSP
(
String
key
,
long
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
SpStoreUtils
.
putLong
(
this
.
getConfigName
(),
key
,
value
);
}
public
void
putWithSP
(
String
key
,
float
value
)
{
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
SpStoreUtils
.
putFloat
(
this
.
getConfigName
(),
key
,
value
);
}
/**
* 保存布尔类型设置项
*
* @param key 保存key
* @param value 保存值
*/
public
void
putWithSP
(
String
key
,
boolean
value
)
{
MemStoreUtils
.
put
(
getConfigName
(),
key
,
value
);
SpStoreUtils
.
putBoolean
(
getConfigName
(),
key
,
value
);
}
public
int
getInt
(
String
key
)
{
return
MemStoreUtils
.
getInt
(
this
.
getConfigName
(),
key
);
}
public
String
getStringWithSP
(
String
key
,
String
defValue
)
{
if
(
MemStoreUtils
.
isContains
(
key
))
{
return
MemStoreUtils
.
getString
(
this
.
getConfigName
(),
key
);
}
else
if
(
SpStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
String
value
=
SpStoreUtils
.
getString
(
this
.
getConfigName
(),
key
,
defValue
);
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
return
value
;
}
else
{
return
defValue
;
}
}
public
int
getIntWithSP
(
String
key
,
int
defValue
)
{
if
(
MemStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
return
MemStoreUtils
.
getInt
(
this
.
getConfigName
(),
key
);
}
else
if
(
SpStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
int
value
=
SpStoreUtils
.
getInt
(
this
.
getConfigName
(),
key
,
defValue
);
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
return
value
;
}
else
{
return
defValue
;
}
}
public
long
getLongWithSP
(
String
key
,
long
defValue
)
{
if
(
MemStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
return
MemStoreUtils
.
getLong
(
this
.
getConfigName
(),
key
);
}
else
if
(
SpStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
long
value
=
SpStoreUtils
.
getLong
(
this
.
getConfigName
(),
key
,
defValue
);
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
return
value
;
}
else
{
return
defValue
;
}
}
public
float
getFloatWithSP
(
String
key
,
float
defValue
)
{
if
(
MemStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
return
MemStoreUtils
.
getFloat
(
this
.
getConfigName
(),
key
);
}
else
if
(
SpStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
float
value
=
SpStoreUtils
.
getFloat
(
this
.
getConfigName
(),
key
,
defValue
);
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
return
value
;
}
else
{
return
defValue
;
}
}
/**
* 获取保存的布尔类型值
*
* @param key 键值
* @param defValue 默认值
*/
public
boolean
getBooleanWithSP
(
String
key
,
boolean
defValue
)
{
if
(
MemStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
return
MemStoreUtils
.
getBoolean
(
this
.
getConfigName
(),
key
);
}
else
if
(
SpStoreUtils
.
isContains
(
this
.
getConfigName
(),
key
))
{
boolean
value
=
SpStoreUtils
.
getBoolean
(
this
.
getConfigName
(),
key
,
defValue
);
MemStoreUtils
.
put
(
this
.
getConfigName
(),
key
,
value
);
return
value
;
}
else
{
return
defValue
;
}
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/MemMgr.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
storage
;
import
java.util.HashMap
;
import
com.wd.foundation.wdkitcore.tools.StringUtils
;
/**
* 内存存储类<BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/5/28]
* @since V1.0.0.0
*/
public
class
MemMgr
{
private
static
final
MemMgr
INSTANCE
=
new
MemMgr
();
private
static
final
String
DEFAULT_MAP_GROUP
=
"default_map_group"
;
/**
* 缓存数据容器
*/
private
HashMap
<
String
,
Object
>
mMemHashMapGroup
=
new
HashMap
<>();
/**
* 锁
*/
private
final
byte
[]
lock
=
new
byte
[
0
];
private
MemMgr
()
{
}
protected
static
MemMgr
getInstance
()
{
return
INSTANCE
;
}
public
boolean
isContains
(
String
key
)
{
return
this
.
isContains
((
String
)
null
,
key
);
}
public
boolean
isContains
(
String
mapName
,
String
key
)
{
if
(
StringUtils
.
isEmpty
(
key
))
{
return
false
;
}
else
{
synchronized
(
this
.
lock
)
{
HashMap
<
String
,
Object
>
map
=
this
.
getHashMapGroup
(
mapName
);
return
map
.
containsKey
(
key
);
}
}
}
protected
void
put
(
String
key
,
Object
value
)
{
put
(
DEFAULT_MAP_GROUP
,
key
,
value
);
}
protected
void
put
(
String
mapGroupName
,
String
key
,
Object
value
)
{
synchronized
(
lock
)
{
getHashMapGroup
(
mapGroupName
).
put
(
key
,
value
);
}
}
protected
int
getInt
(
String
key
)
{
return
getInt
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
int
getInt
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
Object
object
=
get
(
mapGroupName
,
key
);
if
(
object
instanceof
Integer
)
{
return
(
Integer
)
object
;
}
return
-
1
;
}
}
protected
Long
getLong
(
String
key
)
{
return
getLong
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
Long
getLong
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
Object
object
=
get
(
mapGroupName
,
key
);
if
(
object
instanceof
Long
)
{
return
(
Long
)
object
;
}
return
Long
.
MIN_VALUE
;
}
}
protected
String
getString
(
String
key
)
{
return
getString
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
String
getString
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
Object
object
=
get
(
mapGroupName
,
key
);
if
(
object
instanceof
String
)
{
return
(
String
)
object
;
}
return
null
;
}
}
protected
Float
getFloat
(
String
key
)
{
return
getFloat
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
Float
getFloat
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
Object
object
=
get
(
mapGroupName
,
key
);
if
(
object
instanceof
Float
)
{
return
(
Float
)
object
;
}
return
Float
.
MIN_VALUE
;
}
}
protected
Double
getDouble
(
String
key
)
{
return
getDouble
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
Double
getDouble
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
Object
object
=
get
(
mapGroupName
,
key
);
if
(
object
instanceof
Double
)
{
return
(
Double
)
object
;
}
return
Double
.
MIN_VALUE
;
}
}
public
boolean
getBoolean
(
String
key
)
{
return
this
.
getBoolean
((
String
)
null
,
key
);
}
public
boolean
getBoolean
(
String
mapName
,
String
key
)
{
Object
value
=
this
.
getObj
(
mapName
,
key
);
if
(
null
==
value
)
{
return
false
;
}
else
if
(
value
instanceof
Boolean
)
{
return
(
Boolean
)
value
;
}
else
if
(
value
instanceof
String
)
{
try
{
return
Boolean
.
parseBoolean
((
String
)
value
);
}
catch
(
Exception
var5
)
{
return
false
;
}
}
else
{
return
false
;
}
}
public
Object
getObj
(
String
key
)
{
return
this
.
getObj
((
String
)
null
,
key
);
}
public
Object
getObj
(
String
mapName
,
String
key
)
{
if
(
StringUtils
.
isEmpty
(
key
))
{
return
null
;
}
else
{
synchronized
(
this
.
lock
)
{
HashMap
<
String
,
Object
>
map
=
getHashMapGroup
(
mapName
);
return
map
.
get
(
key
);
}
}
}
protected
Object
get
(
String
key
)
{
return
get
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
Object
get
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
return
getHashMapGroup
(
mapGroupName
).
get
(
key
);
}
}
protected
void
clear
(
String
mapGroupName
)
{
synchronized
(
lock
)
{
getHashMapGroup
(
mapGroupName
).
clear
();
}
}
protected
void
remove
(
String
key
)
{
remove
(
DEFAULT_MAP_GROUP
,
key
);
}
protected
void
remove
(
String
mapGroupName
,
String
key
)
{
synchronized
(
lock
)
{
getHashMapGroup
(
mapGroupName
).
remove
(
key
);
}
}
private
HashMap
<
String
,
Object
>
getHashMapGroup
(
String
groupName
)
{
Object
object
=
mMemHashMapGroup
.
get
(
groupName
);
if
(
object
==
null
)
{
return
createMapGroup
(
groupName
);
}
return
(
HashMap
<
String
,
Object
>)
object
;
}
private
HashMap
<
String
,
Object
>
createMapGroup
(
String
hashMapName
)
{
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
mMemHashMapGroup
.
put
(
hashMapName
,
hashMap
);
return
hashMap
;
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/MemStoreUtils.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
storage
;
/**
* 内存存储工具类BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/5/28]
* @since V1.0.0.0
*/
public
final
class
MemStoreUtils
{
/**
* 存储
*
* @param key 键值
* @param value 存储值
*/
public
static
void
put
(
String
key
,
Object
value
)
{
MemMgr
.
getInstance
().
put
(
key
,
value
);
}
/**
* 存储
*
* @param mapGroupName 组名
* @param key 键值
* @param value 存储值
*/
public
static
void
put
(
String
mapGroupName
,
String
key
,
Object
value
)
{
MemMgr
.
getInstance
().
put
(
mapGroupName
,
key
,
value
);
}
public
static
Object
getObj
(
String
key
)
{
return
MemMgr
.
getInstance
().
getObj
(
key
);
}
public
static
Object
getObj
(
String
mapName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getObj
(
mapName
,
key
);
}
/**
* 获取数据
*
* @param key 键值
* @return 存储值
*/
public
static
int
getInt
(
String
key
)
{
return
MemMgr
.
getInstance
().
getInt
(
key
);
}
/**
* 获取数据
*
* @param mapGroupName 组名
* @param key 键值
* @return 存储值
*/
public
static
int
getInt
(
String
mapGroupName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getInt
(
mapGroupName
,
key
);
}
/**
* 获取数据
*
* @param key 键值
* @return 存储值
*/
public
static
Long
getLong
(
String
key
)
{
return
MemMgr
.
getInstance
().
getLong
(
key
);
}
/**
* 获取数据
*
* @param mapGroupName 组名
* @param key 键值
* @return 存储值
*/
public
static
Long
getLong
(
String
mapGroupName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getLong
(
mapGroupName
,
key
);
}
/**
* 获取数据
*
* @param key 键值
* @return 存储值
*/
public
static
String
getString
(
String
key
)
{
return
MemMgr
.
getInstance
().
getString
(
key
);
}
/**
* 获取数据
*
* @param mapGroupName 组名
* @param key 键值
* @return 存储值
*/
public
static
String
getString
(
String
mapGroupName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getString
(
mapGroupName
,
key
);
}
/**
* 获取数据
*
* @param key 键值
* @return 存储值
*/
public
static
Float
getFloat
(
String
key
)
{
return
MemMgr
.
getInstance
().
getFloat
(
key
);
}
/**
* 获取数据
*
* @param mapGroupName 组名
* @param key 键值
* @return 存储值
*/
public
static
Float
getFloat
(
String
mapGroupName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getFloat
(
mapGroupName
,
key
);
}
/**
* 获取数据
*
* @param key 键值
* @return 存储值
*/
public
static
Double
getDouble
(
String
key
)
{
return
MemMgr
.
getInstance
().
getDouble
(
key
);
}
/**
* 获取数据
*
* @param mapGroupName 组名
* @param key 键值
* @return 存储值
*/
public
static
Double
getDouble
(
String
mapGroupName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getDouble
(
mapGroupName
,
key
);
}
public
static
boolean
getBoolean
(
String
key
)
{
return
MemMgr
.
getInstance
().
getBoolean
(
key
);
}
public
static
boolean
getBoolean
(
String
mapName
,
String
key
)
{
return
MemMgr
.
getInstance
().
getBoolean
(
mapName
,
key
);
}
/**
* 清除某一组数据
*
* @param mapGroupName 组名
*/
public
static
void
clear
(
String
mapGroupName
)
{
MemMgr
.
getInstance
().
clear
(
mapGroupName
);
}
/**
* 移除某一个数据
*
* @param key 键值
*/
public
static
void
remove
(
String
key
)
{
MemMgr
.
getInstance
().
remove
(
key
);
}
/**
* 移除某一个数据
*
* @param mapGroupName 组名
* @param key 键值
*/
public
static
void
remove
(
String
mapGroupName
,
String
key
)
{
MemMgr
.
getInstance
().
remove
(
mapGroupName
,
key
);
}
public
static
boolean
isContains
(
String
key
)
{
return
MemMgr
.
getInstance
().
isContains
(
key
);
}
/**
* 是否包含
*
* @param key 键值
*/
public
static
boolean
isContains
(
String
mapName
,
String
key
)
{
return
MemMgr
.
getInstance
().
isContains
(
mapName
,
key
);
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/SpMgr.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
storage
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
com.wd.foundation.wdkitcore.tools.AppContext
;
/**
* SP 存储管理类<BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/4/7]
* @since V1.0.0.0
*/
public
class
SpMgr
{
private
static
final
String
DEFAULT_SP_NAME
=
"default_sp_name"
;
private
static
SpMgr
INSTANCE
=
new
SpMgr
();
private
SpMgr
()
{
}
protected
static
SpMgr
getInstance
()
{
return
INSTANCE
;
}
protected
boolean
isContains
(
String
key
)
{
return
isContains
(
DEFAULT_SP_NAME
,
key
);
}
protected
boolean
isContains
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
return
sp
!=
null
&&
sp
.
contains
(
key
);
}
protected
void
putString
(
String
key
,
String
value
)
{
putString
(
DEFAULT_SP_NAME
,
key
,
value
);
}
protected
void
putString
(
String
spName
,
String
key
,
String
value
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
putString
(
key
,
value
);
editor
.
apply
();
}
protected
void
putInt
(
String
key
,
int
value
)
{
putInt
(
DEFAULT_SP_NAME
,
key
,
value
);
}
protected
void
putInt
(
String
spName
,
String
key
,
int
value
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
putInt
(
key
,
value
);
editor
.
apply
();
}
protected
void
putLong
(
String
key
,
long
value
)
{
putLong
(
DEFAULT_SP_NAME
,
key
,
value
);
}
protected
void
putLong
(
String
spName
,
String
key
,
long
value
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
putLong
(
key
,
value
);
editor
.
apply
();
}
protected
void
putFloat
(
String
key
,
float
value
)
{
putFloat
(
DEFAULT_SP_NAME
,
key
,
value
);
}
protected
void
putFloat
(
String
spName
,
String
key
,
float
value
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
putFloat
(
key
,
value
);
editor
.
apply
();
}
protected
void
putBoolean
(
String
key
,
boolean
value
)
{
putBoolean
(
DEFAULT_SP_NAME
,
key
,
value
);
}
protected
void
putBoolean
(
String
spName
,
String
key
,
boolean
value
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
putBoolean
(
key
,
value
);
editor
.
apply
();
}
protected
void
remove
(
String
key
)
{
remove
(
DEFAULT_SP_NAME
,
key
);
}
protected
void
remove
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
sp
.
edit
();
editor
.
remove
(
key
);
editor
.
apply
();
}
protected
int
getInt
(
String
key
)
{
return
getInt
(
DEFAULT_SP_NAME
,
key
);
}
protected
int
getInt
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
0
;
}
return
sp
.
getInt
(
key
,
0
);
}
protected
long
getLong
(
String
key
)
{
return
getLong
(
DEFAULT_SP_NAME
,
key
);
}
protected
long
getLong
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
0
;
}
return
sp
.
getLong
(
key
,
0
);
}
protected
float
getFloat
(
String
key
)
{
return
getFloat
(
DEFAULT_SP_NAME
,
key
);
}
protected
float
getFloat
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
0
.
f
;
}
return
sp
.
getFloat
(
key
,
0
.
f
);
}
protected
boolean
getBoolean
(
String
key
)
{
return
getBoolean
(
DEFAULT_SP_NAME
,
key
);
}
protected
boolean
getBoolean
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
false
;
}
return
sp
.
getBoolean
(
key
,
false
);
}
protected
String
getString
(
String
key
)
{
return
getString
(
DEFAULT_SP_NAME
,
key
);
}
protected
String
getString
(
String
spName
,
String
key
)
{
SharedPreferences
sp
=
getSp
(
spName
);
if
(
sp
==
null
)
{
return
""
;
}
return
sp
.
getString
(
key
,
""
);
}
protected
String
getString
(
String
spName
,
String
key
,
String
defValue
)
{
SharedPreferences
sp
=
getSp
(
spName
);
return
null
==
sp
?
null
:
sp
.
getString
(
key
,
defValue
);
}
protected
boolean
getBoolean
(
String
spName
,
String
key
,
boolean
defValue
)
{
SharedPreferences
sp
=
getSp
(
spName
);
return
null
==
sp
?
defValue
:
sp
.
getBoolean
(
key
,
defValue
);
}
protected
long
getLong
(
String
spName
,
String
key
,
long
defValue
)
{
SharedPreferences
sp
=
getSp
(
spName
);
return
null
==
sp
?
defValue
:
sp
.
getLong
(
key
,
defValue
);
}
protected
int
getInt
(
String
spName
,
String
key
,
int
defValue
)
{
SharedPreferences
sp
=
getSp
(
spName
);
return
null
==
sp
?
defValue
:
sp
.
getInt
(
key
,
defValue
);
}
protected
float
getFloat
(
String
spName
,
String
key
,
float
defValue
)
{
SharedPreferences
sp
=
getSp
(
spName
);
return
null
==
sp
?
defValue
:
sp
.
getFloat
(
key
,
defValue
);
}
private
SharedPreferences
getSp
(
String
spName
)
{
Context
context
=
AppContext
.
getContext
();
if
(
context
==
null
)
{
return
null
;
}
return
context
.
getSharedPreferences
(
spName
,
Context
.
MODE_PRIVATE
);
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/storage/SpStoreUtils.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
storage
;
import
com.wd.base.log.Logger
;
/**
* sp 存储<BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/4/7]
* @since V1.0.0.0
*/
public
class
SpStoreUtils
{
public
static
boolean
isContains
(
String
spName
,
String
key
)
{
return
SpMgr
.
getInstance
().
isContains
(
spName
,
key
);
}
public
static
void
putInt
(
String
key
,
int
value
)
{
SpMgr
.
getInstance
().
putInt
(
key
,
value
);
}
public
static
void
putInt
(
String
spName
,
String
key
,
int
value
)
{
SpMgr
.
getInstance
().
putInt
(
spName
,
key
,
value
);
}
public
static
void
putLong
(
String
key
,
long
value
)
{
SpMgr
.
getInstance
().
putLong
(
key
,
value
);
}
public
static
void
putLong
(
String
spName
,
String
key
,
long
value
)
{
SpMgr
.
getInstance
().
putLong
(
spName
,
key
,
value
);
}
public
static
void
putString
(
String
key
,
String
value
)
{
SpMgr
.
getInstance
().
putString
(
key
,
value
);
}
public
static
void
putString
(
String
spName
,
String
key
,
String
value
)
{
SpMgr
.
getInstance
().
putString
(
spName
,
key
,
value
);
}
public
static
void
putBoolean
(
String
key
,
boolean
value
)
{
SpMgr
.
getInstance
().
putBoolean
(
key
,
value
);
}
public
static
void
putBoolean
(
String
spName
,
String
key
,
boolean
value
)
{
SpMgr
.
getInstance
().
putBoolean
(
spName
,
key
,
value
);
}
public
static
void
putFloat
(
String
key
,
float
value
)
{
SpMgr
.
getInstance
().
putFloat
(
key
,
value
);
}
public
static
void
putFloat
(
String
spName
,
String
key
,
float
value
)
{
SpMgr
.
getInstance
().
putFloat
(
spName
,
key
,
value
);
}
public
static
void
remove
(
String
key
)
{
SpMgr
.
getInstance
().
remove
(
key
);
}
public
static
void
remove
(
String
spName
,
String
key
)
{
SpMgr
.
getInstance
().
remove
(
spName
,
key
);
}
public
static
int
getInt
(
String
key
)
{
return
SpMgr
.
getInstance
().
getInt
(
key
);
}
public
static
int
getInt
(
String
spName
,
String
key
)
{
return
SpMgr
.
getInstance
().
getInt
(
spName
,
key
);
}
public
static
int
getInt
(
String
spName
,
String
key
,
int
defValue
)
{
String
value
=
null
;
try
{
value
=
SpMgr
.
getInstance
().
getString
(
spName
,
key
,
String
.
valueOf
(
defValue
));
return
Integer
.
parseInt
(
value
);
}
catch
(
ClassCastException
var5
)
{
return
getIntInSP
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var6
)
{
Logger
.
d
(
"SPStoreApi"
,
"getInt failed, invalid value. <"
+
spName
+
", "
+
key
+
", "
+
value
+
">"
);
return
defValue
;
}
}
public
static
long
getLong
(
String
key
)
{
return
SpMgr
.
getInstance
().
getLong
(
key
);
}
public
static
long
getLong
(
String
spName
,
String
key
)
{
return
SpMgr
.
getInstance
().
getInt
(
spName
,
key
);
}
public
static
long
getLong
(
String
spName
,
String
key
,
long
defValue
)
{
String
value
=
null
;
try
{
value
=
SpMgr
.
getInstance
().
getString
(
spName
,
key
,
String
.
valueOf
(
defValue
));
return
Long
.
parseLong
(
value
);
}
catch
(
ClassCastException
var6
)
{
return
getLongInSP
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var7
)
{
Logger
.
d
(
"SPStoreApi"
,
"getLong failed, invalid value. <"
+
spName
+
", "
+
key
+
", "
+
value
+
">"
);
return
defValue
;
}
}
public
static
boolean
getBoolean
(
String
key
)
{
return
SpMgr
.
getInstance
().
getBoolean
(
key
);
}
public
static
boolean
getBoolean
(
String
spName
,
String
key
)
{
return
SpMgr
.
getInstance
().
getBoolean
(
spName
,
key
);
}
public
static
boolean
getBoolean
(
String
spName
,
String
key
,
boolean
defValue
)
{
String
value
=
null
;
try
{
value
=
SpMgr
.
getInstance
().
getString
(
spName
,
key
,
String
.
valueOf
(
defValue
));
return
Boolean
.
valueOf
(
value
);
}
catch
(
ClassCastException
var5
)
{
return
getBooleanInSP
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var6
)
{
Logger
.
d
(
"SPStoreApi"
,
"getBoolean failed, invalid value. <"
+
spName
+
", "
+
key
+
", "
+
value
+
">"
);
return
defValue
;
}
}
public
static
String
getString
(
String
key
)
{
return
SpMgr
.
getInstance
().
getString
(
key
);
}
public
static
String
getString
(
String
spName
,
String
key
)
{
return
SpMgr
.
getInstance
().
getString
(
spName
,
key
);
}
public
static
String
getString
(
String
spName
,
String
key
,
String
defValue
)
{
return
getStringInSP
(
spName
,
key
,
defValue
);
}
public
static
float
getFloat
(
String
key
)
{
return
SpMgr
.
getInstance
().
getFloat
(
key
);
}
public
static
float
getFloat
(
String
spName
,
String
key
)
{
return
SpMgr
.
getInstance
().
getFloat
(
spName
,
key
);
}
public
static
float
getFloat
(
String
spName
,
String
key
,
float
defValue
)
{
String
value
=
null
;
try
{
value
=
SpMgr
.
getInstance
().
getString
(
spName
,
key
,
String
.
valueOf
(
defValue
));
return
Float
.
valueOf
(
value
);
}
catch
(
ClassCastException
var5
)
{
return
getFloatInSP
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var6
)
{
Logger
.
d
(
"SPStoreApi"
,
"getFloat failed, invalid value. <"
+
spName
+
", "
+
key
+
", "
+
value
+
">"
);
return
defValue
;
}
}
private
static
int
getIntInSP
(
String
spName
,
String
key
,
int
defValue
)
{
try
{
return
SpMgr
.
getInstance
().
getInt
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var4
)
{
Logger
.
d
(
"SPStoreApi"
,
"getIntInSp failed, invalid value. <"
+
spName
+
", "
+
key
+
">"
);
return
defValue
;
}
}
private
static
long
getLongInSP
(
String
spName
,
String
key
,
long
defValue
)
{
try
{
return
SpMgr
.
getInstance
().
getLong
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var5
)
{
Logger
.
d
(
"SPStoreApi"
,
"getLongInSP failed, invalid value. <"
+
spName
+
", "
+
key
+
">"
);
return
defValue
;
}
}
private
static
boolean
getBooleanInSP
(
String
spName
,
String
key
,
boolean
defValue
)
{
try
{
return
SpMgr
.
getInstance
().
getBoolean
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var4
)
{
Logger
.
d
(
"SPStoreApi"
,
"getBooleanInSP failed, invalid value. <"
+
spName
+
", "
+
key
+
">"
);
return
defValue
;
}
}
private
static
float
getFloatInSP
(
String
spName
,
String
key
,
float
defValue
)
{
try
{
return
SpMgr
.
getInstance
().
getFloat
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var4
)
{
Logger
.
d
(
"SPStoreApi"
,
"getFloatInSP failed, invalid value. <"
+
spName
+
", "
+
key
+
">"
);
return
defValue
;
}
}
private
static
String
getStringInSP
(
String
spName
,
String
key
,
String
defValue
)
{
try
{
return
SpMgr
.
getInstance
().
getString
(
spName
,
key
,
defValue
);
}
catch
(
Exception
var4
)
{
Logger
.
d
(
"SPStoreApi"
,
"getStringInSP failed, invalid value. <"
+
spName
+
", "
+
key
+
">"
);
return
defValue
;
}
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/AppContext.java
View file @
c7c83a6
...
...
@@ -25,6 +25,11 @@ public final class AppContext {
public
static
boolean
mPause
=
false
;
/**
* 开发环境、正式环境
*/
public
static
boolean
DEBUG
;
public
AppContext
()
{
}
...
...
@@ -32,7 +37,8 @@ public final class AppContext {
public
static
HashMap
<
String
,
Boolean
>
mSet
=
new
HashMap
<>();
public
static
void
init
(
Context
context
)
{
public
static
void
init
(
Context
context
,
boolean
debug
)
{
DEBUG
=
debug
;
mContext
=
context
;
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/AssertUtils.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
/**
* 读取本地assert 工具类
*
* @author lvjinhui
*/
public
class
AssertUtils
{
public
static
String
readJsonFile
(
String
file
){
StringBuilder
newstringBuilder
=
new
StringBuilder
();
try
{
InputStream
inputStream
=
AppContext
.
getContext
().
getResources
().
getAssets
().
open
(
file
);
InputStreamReader
isr
=
new
InputStreamReader
(
inputStream
);
BufferedReader
reader
=
new
BufferedReader
(
isr
);
String
jsonLine
;
while
((
jsonLine
=
reader
.
readLine
())
!=
null
)
{
newstringBuilder
.
append
(
jsonLine
);
}
reader
.
close
();
isr
.
close
();
inputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
data
=
newstringBuilder
.
toString
();
return
data
;
}
public
static
String
getLocalGroupJson
(
String
fileName
)
{
try
{
InputStream
is
=
AppContext
.
getContext
().
getAssets
().
open
(
fileName
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
int
len
=
-
1
;
byte
[]
buffer
=
new
byte
[
1024
];
while
((
len
=
is
.
read
(
buffer
))
!=
-
1
)
{
baos
.
write
(
buffer
,
0
,
len
);
}
String
rel
=
baos
.
toString
();
is
.
close
();
return
rel
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/CloseUtils.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
java.io.Closeable
;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
com.wd.base.log.Logger
;
/**
* 数据关闭工具类<BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/5/16]
* @since V1.0.0.0
*/
public
class
CloseUtils
{
private
static
final
String
TAG
=
"CloseUtils"
;
private
CloseUtils
()
{
}
/**
* 关闭索引
*
* @param cursor 索引
*/
public
static
void
close
(
Cursor
cursor
)
{
if
(
null
==
cursor
)
{
Logger
.
t
(
TAG
).
e
(
"cursor is empty"
);
}
else
{
try
{
cursor
.
close
();
}
catch
(
Exception
var2
)
{
Logger
.
t
(
TAG
).
e
(
"close cursor has exception:"
,
var2
);
}
}
}
/**
* 关闭数据库
*
* @param db 数据库
*/
public
static
void
close
(
SQLiteDatabase
db
)
{
if
(
null
!=
db
)
{
try
{
db
.
close
();
}
catch
(
Exception
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
}
}
}
/**
* 关闭资源
*
* @param closed 可关闭的资源
*/
public
static
void
close
(
Closeable
closed
)
{
if
(
null
!=
closed
)
{
try
{
closed
.
close
();
}
catch
(
IOException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
}
catch
(
Exception
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
}
}
}
/**
* 关闭 http 连接
*
* @param conn 连接
*/
public
static
void
close
(
HttpURLConnection
conn
)
{
if
(
null
!=
conn
)
{
try
{
conn
.
disconnect
();
}
catch
(
Exception
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
}
}
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/DeviceUtils.java
deleted
100644 → 0
View file @
b6da39d
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
android.content.Context
;
import
android.os.Build
;
/**
* 设备相关工具类<BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/4/7]
* @since V1.0.0.0
*/
public
class
DeviceUtils
{
/**
* 设备屏幕宽度
*
* @return 屏幕宽度
*/
public
static
int
getDeviceWidth
()
{
Context
context
=
AppContext
.
getContext
();
if
(
context
==
null
)
{
return
0
;
}
return
Math
.
min
(
context
.
getResources
().
getDisplayMetrics
().
widthPixels
,
context
.
getResources
().
getDisplayMetrics
().
heightPixels
);
}
/**
* 设备屏幕高度
*
* @return 屏幕高度
*/
public
static
int
getDeviceHeight
()
{
Context
context
=
AppContext
.
getContext
();
if
(
context
==
null
)
{
return
0
;
}
return
Math
.
max
(
context
.
getResources
().
getDisplayMetrics
().
widthPixels
,
context
.
getResources
().
getDisplayMetrics
().
heightPixels
);
}
/**
* 获得版本 Model
*
* @return 版本 Model
*/
public
static
String
getModel
()
{
return
Build
.
MODEL
;
}
}
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/FileUtils.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.nio.channels.FileChannel
;
import
java.util.Locale
;
import
android.content.Context
;
import
android.content.res.AssetManager
;
import
android.text.TextUtils
;
import
android.webkit.MimeTypeMap
;
import
com.wd.base.log.Logger
;
/**
* 文件操作工具类
*
* @author huweixiong
* @version [V1.0.0.1, 2020/8/27]
* @since V1.0.0.1
*/
public
class
FileUtils
{
private
static
final
String
TAG
=
"FileUtils"
;
private
FileUtils
()
{
}
/**
* 判断文件是否存在,且不是空文件
*
* @param filePath 文件路径
* @return 文件是否存在
*/
public
static
boolean
isFileExists
(
String
filePath
)
{
if
(
TextUtils
.
isEmpty
(
filePath
))
{
return
false
;
}
else
{
try
{
File
f
=
new
File
(
filePath
);
return
f
.
exists
()
&&
f
.
isFile
()
&&
f
.
length
()
>
0L
;
}
catch
(
Exception
var2
)
{
Logger
.
t
(
TAG
).
e
(
"isFileExists:"
,
var2
);
return
false
;
}
}
}
/**
* 判断目录是否存在,且不是空目录
*
* @param folderPath 目录路径
* @return 目录是否存在
*/
public
static
boolean
isFolderExists
(
String
folderPath
)
{
if
(
TextUtils
.
isEmpty
(
folderPath
))
{
return
false
;
}
else
{
try
{
File
f
=
new
File
(
folderPath
);
boolean
isFolderExist
=
f
.
exists
()
&&
f
.
isDirectory
();
if
(!
isFolderExist
)
{
return
false
;
}
else
{
String
[]
files
=
f
.
list
();
return
files
!=
null
&&
files
.
length
>
0
;
}
}
catch
(
Exception
var4
)
{
Logger
.
t
(
TAG
).
e
(
"isFolderExists:"
,
var4
);
return
false
;
}
}
}
/**
* 删除文件
*
* @param path 文件路径
* @return 是否删除成功
*/
public
static
boolean
deleteFile
(
String
path
)
{
boolean
result
=
false
;
if
(!
TextUtils
.
isEmpty
(
path
))
{
File
file
=
new
File
(
path
);
if
(
file
.
exists
())
{
result
=
file
.
delete
();
if
(!
result
)
{
Logger
.
t
(
TAG
).
w
(
"delete file failed, file path="
+
path
);
}
}
}
return
result
;
}
/**
* 删除文件
*
* @param file 文件对象
* @return 是否删除成功
*/
public
static
boolean
deleteFile
(
File
file
)
{
if
(
file
!=
null
&&
file
.
exists
())
{
if
(
file
.
isFile
())
{
boolean
result
=
file
.
delete
();
if
(!
result
)
{
Logger
.
t
(
TAG
).
w
(
"delete file failed, file path="
+
getCanonicalPath
(
file
));
}
return
result
;
}
else
{
File
[]
files
=
file
.
listFiles
();
if
(
files
!=
null
&&
files
.
length
>
0
)
{
int
len
=
files
.
length
;
for
(
int
i
=
0
;
i
<
len
;
++
i
)
{
deleteFile
(
files
[
i
]);
}
}
return
file
.
delete
();
}
}
else
{
return
true
;
}
}
/**
* 获取文件扩展名
*
* @param filename 文件路径
* @return 返回扩展名
*/
public
static
String
extension
(
String
filename
)
{
if
(
TextUtils
.
isEmpty
(
filename
))
{
return
""
;
}
else
{
int
start
=
filename
.
lastIndexOf
(
"/"
);
int
stop
=
filename
.
lastIndexOf
(
"."
);
return
stop
>=
start
&&
stop
<
filename
.
length
()
-
1
?
StringUtils
.
cutString
(
filename
,
stop
+
1
,
filename
.
length
())
:
""
;
}
}
/**
* 获取文件的MIME_type
*
* @param filename 文件路径
* @return 返回文件的MIME_type
*/
public
static
String
mimeType
(
String
filename
)
{
String
ext
=
extension
(
filename
);
String
mime
=
MimeTypeMap
.
getSingleton
().
getMimeTypeFromExtension
(
ext
);
return
mime
==
null
?
"*.*"
:
mime
;
}
/**
* 移动文件并修改文件名或修改文件
*
* @param newPath 新文件路径
* @param oldPath 旧文件路径
* @return 是否移动成功
*/
public
static
boolean
renameFile
(
String
newPath
,
String
oldPath
)
{
if
(!
TextUtils
.
isEmpty
(
newPath
)
&&
!
TextUtils
.
isEmpty
(
oldPath
))
{
File
file
=
new
File
(
oldPath
);
Logger
.
t
(
TAG
).
d
(
"renameFile:"
+
oldPath
+
" to "
+
newPath
);
return
file
.
renameTo
(
new
File
(
newPath
));
}
else
{
return
false
;
}
}
/**
* 复制文件
*
* @param orgPath 原文件路径
* @param srcPath 新文件路径
* @return 是否复制文件成功
*/
public
static
boolean
copyFile
(
String
orgPath
,
String
srcPath
)
{
if
(!
TextUtils
.
isEmpty
(
orgPath
)
&&
!
TextUtils
.
isEmpty
(
srcPath
))
{
File
from
=
new
File
(
orgPath
);
File
to
=
new
File
(
srcPath
);
Logger
.
t
(
TAG
).
d
(
"copyFile:"
+
orgPath
+
" to "
+
srcPath
);
if
(!
from
.
exists
())
{
Logger
.
t
(
TAG
).
w
(
"copyFile from File isnot exists!"
);
return
false
;
}
FileChannel
input
=
null
;
FileChannel
output
=
null
;
try
{
input
=
(
new
FileInputStream
(
from
)).
getChannel
();
output
=
(
new
FileOutputStream
(
to
)).
getChannel
();
output
.
transferFrom
(
input
,
0L
,
input
.
size
());
}
catch
(
FileNotFoundException
var11
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var11
);
}
catch
(
IOException
var12
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var12
);
}
finally
{
CloseUtils
.
close
(
input
);
CloseUtils
.
close
(
output
);
}
}
return
isFileExists
(
srcPath
);
}
/**
* 文件的绝对路径
*
* @param file 文件对象
* @return 返回文件的绝对路径
*/
public
static
String
getCanonicalPath
(
File
file
)
{
if
(
null
==
file
)
{
return
null
;
}
else
{
try
{
return
file
.
getCanonicalPath
();
}
catch
(
IOException
var2
)
{
Logger
.
t
(
TAG
).
w
(
"CanonicalPath is not avaliable."
);
return
file
.
getAbsolutePath
();
}
}
}
/**
* 获取Assets目录下面文件内容,去掉头尾空字符串
*
* @param fileName 文件名称,相当Assets目录的文件名称
* @return 返回文件的绝对路径
*/
public
static
String
getJsonFromFile
(
Context
mContext
,
String
fileName
)
{
InputStreamReader
ips
=
null
;
BufferedReader
br
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
AssetManager
am
=
mContext
.
getAssets
();
try
{
ips
=
new
InputStreamReader
(
am
.
open
(
fileName
),
"UTF-8"
);
br
=
new
BufferedReader
(
ips
);
String
next
=
""
;
while
(
null
!=
(
next
=
br
.
readLine
()))
{
sb
.
append
(
next
);
}
}
catch
(
IOException
var10
)
{
Logger
.
t
(
TAG
).
e
(
"assets read exception"
,
var10
);
sb
.
delete
(
0
,
sb
.
length
());
}
finally
{
CloseUtils
.
close
(
br
);
CloseUtils
.
close
(
ips
);
}
return
sb
.
toString
().
trim
();
}
public
static
boolean
deleteFileInDataFileDir
(
String
fileName
)
{
return
AppContext
.
getContext
().
deleteFile
(
fileName
);
}
public
static
String
mirrorDirection
(
String
path
,
String
dSign
)
{
return
TextUtils
.
getLayoutDirectionFromLocale
(
Locale
.
getDefault
())
==
1
?
path
.
replaceAll
(
dSign
,
"\u200f"
+
dSign
)
:
path
;
}
public
static
void
makeSureFullDirExist
(
File
dir
)
{
if
(!
dir
.
exists
()
&&
!
dir
.
mkdirs
())
{
Logger
.
t
(
TAG
).
i
(
"Create dir failed: "
+
getCanonicalPath
(
dir
));
}
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/JsonUtils.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONException
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.wd.base.log.Logger
;
/**
* JSON工具类<BR>
*
* @author zhengyin
* @version [V1.0.0.0, 2020/6/3]
* @since V1.0.0.0
*/
public
class
JsonUtils
{
private
static
final
String
TAG
=
"JsonUtils"
;
/***
* 功能描述: object 转成json
*
* @param root root
* @return json字符串
*/
public
static
String
convertObjectToJson
(
Object
root
)
{
String
resultString
=
""
;
try
{
resultString
=
JSON
.
toJSONString
(
root
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
resultString
;
}
/***
* 功能描述: json转成object(需要注意泛型类必须提供无参构造函数)
*
* @param json json字符串
* @param clazz 泛型类
* @return 泛型对象
*/
public
static
<
T
>
T
convertJsonToObject
(
String
json
,
Class
<
T
>
clazz
)
{
T
object
=
null
;
try
{
object
=
JSON
.
parseObject
(
json
,
clazz
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Logger
.
i
(
TAG
,
"ex:"
+
e
.
getMessage
());
}
return
object
;
}
/**
* 将json字串解析为JSONArray
*
* @param json json字符串
* @return JSONArray
*/
public
static
JSONArray
convertJsonArray
(
String
json
)
throws
JSONException
{
if
(
StringUtils
.
isEmpty
(
json
))
{
Logger
.
w
(
TAG
,
"convertJsonArray json is null"
);
return
null
;
}
return
JSON
.
parseArray
(
json
);
}
/**
* 获取JSONArray
*
* @param jsonObject json数据对象
* @param key key
* @return JSONArray
*/
public
static
JSONArray
getJsonArray
(
JSONObject
jsonObject
,
String
key
)
throws
JSONException
{
if
(
jsonObject
==
null
)
{
return
null
;
}
if
(!
jsonObject
.
containsKey
(
key
))
{
Logger
.
w
(
TAG
,
"getJsonArray no this key"
);
return
null
;
}
return
jsonObject
.
getJSONArray
(
key
);
}
/**
* 功能描述:把JSON数据转换成jsonObject
*
* @param jsonData JSON数据
* @return
* @throws Exception
*/
public
static
JSONObject
convertJsonToJsonObject
(
String
jsonData
)
throws
Exception
{
return
JSON
.
parseObject
(
jsonData
);
}
/**
* 获取JSONObject
*
* @param jsonObject jsonObject
* @param key key
* @return JSONObject
*/
public
static
JSONObject
getJsonObject
(
JSONObject
jsonObject
,
String
key
)
throws
JSONException
{
if
(
jsonObject
==
null
)
{
return
null
;
}
if
(!
jsonObject
.
containsKey
(
key
))
{
Logger
.
w
(
TAG
,
"getJsonObject no this key"
);
return
null
;
}
return
jsonObject
.
getJSONObject
(
key
);
}
/**
* 获取指定位置的JSONObject
*
* @param jsonArray jsonArray
* @param index index
* @return JSONObject
*/
public
static
JSONObject
getJsonObject
(
JSONArray
jsonArray
,
int
index
)
throws
JSONException
{
if
(
jsonArray
==
null
)
{
return
null
;
}
if
(
jsonArray
.
size
()
<
index
)
{
return
null
;
}
return
jsonArray
.
getJSONObject
(
index
);
}
/**
* 功能描述:把JsonArray数据转换成泛型对象列表 (需要注意泛型类必须提供无参构造函数)
*
* @param jsonArrayString JsonArray字符串
* @param clazz 泛型类型
* @return 泛型列表
* @throws Exception
*/
public
static
<
T
>
List
<
T
>
convertJsonArrayToObjList
(
String
jsonArrayString
,
Class
<
T
>
clazz
)
throws
Exception
{
return
JSON
.
parseArray
(
jsonArrayString
,
clazz
);
}
/**
* 功能描述:把JSON字符串转换成较为复杂的java对象列表
*
* @param json JSON数据
* @return
* @throws Exception
*/
public
static
List
<
Map
<
String
,
Object
>>
convertJsonToObjectMapList
(
String
json
)
throws
Exception
{
return
JSON
.
parseObject
(
json
,
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{});
}
/**
* 功能描述:把JSON字符串的部分转换成目标Java对象
*
* @param json JSON字符串
* @param targetPath 目标路径
* @param clazz 需要转换成的Java对象类
* @return Object对象
*/
public
static
Object
getJsonObjectFromTargetPath
(
String
json
,
String
targetPath
,
Class
clazz
)
throws
JSONException
{
JSON
targetJson
=
getJsonFromTargetPath
(
json
,
targetPath
);
if
(
targetJson
==
null
)
{
Logger
.
d
(
TAG
,
"getJsonObjectFromTargetPath, targetJson is null"
);
throw
new
JSONException
(
"getJsonObjectFromTargetPath, targetJson is null"
);
}
return
JSON
.
toJavaObject
(
targetJson
,
clazz
);
}
/**
* 功能描述:把JSON字符串的部分转换成目标Java对象列表
*
* @param json JSON字符串
* @param targetPath 目标路径
* @param clazz 需要转换成的Java对象类
* @return Object对象
*/
public
static
List
getJsonObjectListFromTargetPath
(
String
json
,
String
targetPath
,
Class
clazz
)
throws
JSONException
{
JSON
targetJson
=
getJsonFromTargetPath
(
json
,
targetPath
);
JSONArray
targetJsonArray
=
CastUtils
.
cast
(
targetJson
,
JSONArray
.
class
);
if
(
ArrayUtils
.
isEmpty
(
targetJsonArray
))
{
Logger
.
d
(
TAG
,
"getJsonObjectListFromTargetPath, targetJsonArray is empty"
);
throw
new
JSONException
(
"getJsonObjectListFromTargetPath, targetJsonArray is empty"
);
}
return
JSONObject
.
parseArray
(
targetJsonArray
.
toJSONString
(),
clazz
);
}
private
static
JSON
getJsonFromTargetPath
(
String
json
,
String
targetPath
)
throws
JSONException
{
if
(
StringUtils
.
isEmpty
(
json
))
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, json is null"
);
throw
new
JSONException
(
"getJsonFromTargetPath, json is null"
);
}
if
(
StringUtils
.
isEmpty
(
targetPath
))
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, targetPath is null"
);
throw
new
JSONException
(
"getJsonFromTargetPath, targetPath is null"
);
}
String
[]
pathList
=
targetPath
.
split
(
"\\."
);
JSON
tmp
=
JSON
.
parseObject
(
json
);
Pattern
pat
=
Pattern
.
compile
(
"(\\w+)\\[(\\d*)]"
);
for
(
String
path
:
pathList
)
{
Matcher
matcher
=
pat
.
matcher
(
path
);
if
(
matcher
.
find
())
{
if
(
StringUtils
.
isNotEmpty
(
matcher
.
group
(
2
)))
{
JSONObject
tmpObj
=
CastUtils
.
cast
(
tmp
,
JSONObject
.
class
);
if
(
tmpObj
==
null
)
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, tmpObj is null, matcher has index"
);
throw
new
JSONException
(
"getJsonFromTargetPath, tmpObj is null, matcher has index"
);
}
JSONArray
tmpArray
=
tmpObj
.
getJSONArray
(
matcher
.
group
(
1
));
if
(
ArrayUtils
.
isEmpty
(
tmpArray
))
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, tmpArray is null, matcher has index"
);
throw
new
JSONException
(
"getJsonFromTargetPath, tmpArray is null, matcher has index"
);
}
int
index
=
MathUtils
.
parseInt
(
matcher
.
group
(
2
),
0
);
if
(
index
<
tmpArray
.
size
())
{
tmp
=
tmpArray
.
getJSONObject
(
index
);
}
else
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, matcher has index, index out of bounds"
);
throw
new
JSONException
(
"getJsonFromTargetPath, matcher has index, index out of bounds"
);
}
}
else
{
JSONObject
tmpObj
=
CastUtils
.
cast
(
tmp
,
JSONObject
.
class
);
if
(
tmpObj
==
null
)
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, tmpObj is null, matcher with no index"
);
throw
new
JSONException
(
"getJsonFromTargetPath, tmpObj is null, matcher with no index"
);
}
tmp
=
tmpObj
.
getJSONArray
(
matcher
.
group
(
1
));
}
}
else
{
JSONObject
tmpObj
=
CastUtils
.
cast
(
tmp
,
JSONObject
.
class
);
if
(
tmpObj
==
null
)
{
Logger
.
d
(
TAG
,
"getJsonFromTargetPath, tmpObj is null, matcher not find"
);
throw
new
JSONException
(
"getJsonFromTargetPath, tmpObj is null, matcher not find"
);
}
tmp
=
tmpObj
.
getJSONObject
(
path
);
}
}
return
tmp
;
}
}
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/ResUtils.java
0 → 100644
View file @
c7c83a6
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
*/
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
android.content.Context
;
import
android.content.res.ColorStateList
;
import
android.content.res.Configuration
;
import
android.content.res.Resources
;
import
android.graphics.drawable.Drawable
;
import
android.util.DisplayMetrics
;
import
android.util.TypedValue
;
import
androidx.annotation.NonNull
;
import
com.wd.base.log.Logger
;
/**
* <BR>
*
* @author wangnaiwen
* @version [V1.0.0.0, 2020/4/7]
* @since V1.0.0.0
*/
public
final
class
ResUtils
{
private
static
final
String
TAG
=
"ResUtils"
;
private
static
final
float
ROUNDING
=
0.5
F
;
private
ResUtils
()
{
}
public
static
Resources
getResources
()
{
return
AppContext
.
getContext
().
getResources
();
}
@NonNull
public
static
Resources
getResources
(
Context
context
)
{
if
(
null
!=
context
)
{
Resources
resources
=
context
.
getResources
();
if
(
null
!=
resources
)
{
return
resources
;
}
}
return
AppContext
.
getContext
().
getResources
();
}
public
static
String
getString
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getString
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
null
;
}
}
public
static
String
getString
(
Context
context
,
int
resId
)
{
if
(
context
!=
null
)
{
try
{
return
context
.
getString
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
}
}
return
null
;
}
public
static
String
getString
(
int
resId
,
Object
...
formatArgs
)
{
try
{
return
AppContext
.
getContext
().
getString
(
resId
,
formatArgs
);
}
catch
(
Resources
.
NotFoundException
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
return
null
;
}
}
public
static
String
getQuantityString
(
int
resId
,
int
quantity
,
Object
...
formatArgs
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getQuantityString
(
resId
,
quantity
,
formatArgs
);
}
catch
(
Resources
.
NotFoundException
var4
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var4
);
return
null
;
}
}
@Deprecated
public
static
int
getDimensionPixelSize
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getDimensionPixelSize
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0
;
}
}
public
static
int
getDimensionPixelSize
(
Context
context
,
int
resId
)
{
try
{
return
getResources
(
context
).
getDimensionPixelSize
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0
;
}
}
public
static
int
getIdentifier
(
String
name
,
String
defType
,
String
defPackTAGe
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getIdentifier
(
name
,
defType
,
defPackTAGe
);
}
catch
(
Resources
.
NotFoundException
var4
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var4
);
return
0
;
}
}
public
static
float
getDimension
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getDimension
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0.0
F
;
}
}
public
static
float
getFloat
(
int
resId
)
{
try
{
TypedValue
outValue
=
new
TypedValue
();
AppContext
.
getContext
().
getResources
().
getValue
(
resId
,
outValue
,
true
);
return
outValue
.
getFloat
();
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0.0
F
;
}
}
public
static
int
getColor
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getColor
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0
;
}
}
public
static
int
getInt
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getInteger
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0
;
}
}
public
static
Drawable
getDrawable
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getDrawable
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
null
;
}
}
public
static
String
[]
getStringArray
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getStringArray
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
new
String
[
0
];
}
}
public
static
int
[]
getIntegerArray
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getIntArray
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
new
int
[
0
];
}
}
public
static
ColorStateList
getColorStateList
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getColorStateList
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
null
;
}
}
public
static
boolean
getBoolean
(
int
resId
)
{
try
{
return
AppContext
.
getContext
().
getResources
().
getBoolean
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
false
;
}
}
public
static
int
dp2Px
(
float
dp
)
{
float
scale
=
AppContext
.
getContext
().
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
dp
*
scale
+
ROUNDING
);
}
public
static
int
sp2Px
(
float
sp
)
{
float
scale
=
AppContext
.
getContext
().
getResources
().
getDisplayMetrics
().
scaledDensity
;
return
(
int
)
(
sp
*
scale
+
ROUNDING
);
}
public
static
int
px2Dp
(
float
px
)
{
float
scale
=
AppContext
.
getContext
().
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
px
/
scale
+
ROUNDING
);
}
public
static
boolean
isDirectionLTR
()
{
return
getResources
().
getConfiguration
().
getLayoutDirection
()
==
0
;
}
public
static
int
getIdentifier
(
Context
context
,
String
name
,
String
defType
,
String
defPackTAGe
)
{
try
{
return
getResources
(
context
).
getIdentifier
(
name
,
defType
,
defPackTAGe
);
}
catch
(
Resources
.
NotFoundException
var5
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var5
);
return
0
;
}
}
public
static
int
getColor
(
Context
context
,
int
resId
)
{
try
{
return
getResources
(
context
).
getColor
(
resId
);
}
catch
(
Resources
.
NotFoundException
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
return
0
;
}
}
public
static
Drawable
getDrawable
(
Context
context
,
int
resId
)
{
try
{
return
getResources
(
context
).
getDrawable
(
resId
);
}
catch
(
Resources
.
NotFoundException
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
return
null
;
}
}
public
static
String
[]
getStringArray
(
Context
context
,
int
resId
)
{
try
{
return
getResources
(
context
).
getStringArray
(
resId
);
}
catch
(
Resources
.
NotFoundException
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
return
new
String
[
0
];
}
}
public
static
ColorStateList
getColorStateList
(
Context
context
,
int
resId
)
{
try
{
return
getResources
(
context
).
getColorStateList
(
resId
);
}
catch
(
Resources
.
NotFoundException
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
return
null
;
}
}
public
static
boolean
getBoolean
(
Context
context
,
int
resId
)
{
try
{
return
getResources
(
context
).
getBoolean
(
resId
);
}
catch
(
Resources
.
NotFoundException
var3
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var3
);
return
false
;
}
}
public
static
DisplayMetrics
getDisplayMetrics
()
{
return
getResources
().
getDisplayMetrics
();
}
public
static
Configuration
getConfiguration
()
{
return
getResources
().
getConfiguration
();
}
public
static
int
getDimensionPixelOffset
(
int
resId
)
{
try
{
return
getResources
().
getDimensionPixelOffset
(
resId
);
}
catch
(
Resources
.
NotFoundException
var2
)
{
Logger
.
t
(
TAG
).
e
(
""
+
var2
);
return
0
;
}
}
}
\ No newline at end of file
...
...
wdkitcore/src/main/java/com/wd/foundation/wdkitcore/tools/SpUtils.java
0 → 100644
View file @
c7c83a6
package
com
.
wd
.
foundation
.
wdkitcore
.
tools
;
import
android.text.TextUtils
;
import
com.wd.foundation.wdkitcore.storage.ConfigBase
;
/**
* 描述:key-value存储
* TODO 待梳理,考虑上移
*
* @author : lvjinhui
* @since: 2022/12/15
*/
public
class
SpUtils
{
/**
* tag
*/
private
static
final
String
TAG
=
"SpUtils"
;
/**
* 默认环境变量
*/
private
static
String
BASE_URL_VALUE
=
""
;
/**
* 接口服务器默认地址
*/
private
static
final
String
KEY_BASE_URL_TAG
=
"key_base_url_tag"
;
private
static
final
String
BASE_URL_TAG
=
"base_url_tag"
;
/**
* http收到406的情况
*/
private
static
final
String
HTTP_406
=
"http_406"
;
/**
* http收到377的情况
*/
private
static
final
String
HTTP_377
=
"http_377"
;
/**
* 用户token
*/
private
static
final
String
USER_TOKE
=
"user_token"
;
/**
* 用户 融云token
*/
private
static
final
String
USER_RONGYUN_TOKE
=
"user_rongyun_token"
;
/**
* 用户refreshToken
*/
private
static
final
String
REFRE_TOKEN
=
"refer_token"
;
/**
* 用户信息
*/
private
static
final
String
USER_ID
=
"user_id"
;
/**
* 用户创作者名称
*/
private
static
final
String
USER_CREATOR_NAME
=
"user_creator_name"
;
/**
* 用户id值
*/
private
static
String
USER_ID_VALUE
=
""
;
/**
* 缓存的key保存起来,用来清理缓存
*/
private
static
final
String
NETWORK_CACHE_DATA_KEY
=
"network_cache_data_key"
;
/**
*
*/
private
static
final
String
PROVINCE
=
"province"
;
/**
* 城市
*/
private
static
final
String
CITY
=
"city"
;
/**
* 城市值
*/
private
static
String
CITY_VALUE
=
""
;
/**
* 首次打开app 用户协议提示
*/
private
static
final
String
APP_FIRST_AGREEMENT_TIP
=
"app_first_agreement_tip"
;
/**
* 播放时间
*/
private
static
final
String
LIVE_LOADING_TIME
=
"live_loading_time"
;
/**
* 缓存网络数据
*/
private
static
final
String
NETWORK_CACHE_DATA_SP
=
"network_cache_data_sp"
;
/**
* 彩蛋id 存储
*/
private
static
final
String
POPUPS_SAVE_FILE
=
"popups_save_file"
;
/**
* 页面彩蛋
*/
public
static
final
String
POPUP_PAGE
=
"popup_page"
;
/**
* 展示的广告记录
*/
private
static
final
String
ADS_RECORD
=
"ads_record"
;
/**
* 广告类型-开屏
*/
private
static
final
String
TYPE_LAUNCH
=
"type_launch"
;
/**
* 广告类型-挂角
*/
private
static
final
String
TYPE_CORNERS
=
"type_corners"
;
/**
* 启动相关,非启动不要使用
*/
public
static
final
String
LAUNCH
=
"launch"
;
/**
* 首次开启引导页
*/
private
static
final
String
APP_FIRST_GUIDE
=
"app_first_guide"
;
/**
* 数据存储的XML名称 存储置顶应用用
**/
private
static
final
String
FILENAME_RMRB
=
"rmrb_config"
;
/**
* 数据存储的音频数据
**/
// private static final String USER_MUSIC = "user_music";
/**
* 用户协议H5
*/
private
static
final
String
USER_AGREE_URL
=
"user_agree_url"
;
/**
* 用户协议版本
*/
private
static
final
String
USER_AGREE_VERSION
=
"user_agree_version"
;
/**
* 创作者资质认证状态,
* 0:未认证,1:机审中、2:认证中 3.:认证不通过 4:已认证 5:已认证变更中 6:认证驳回
*/
private
static
final
String
USER_STATUS
=
"user_status"
;
/**
* 注销协议
*/
private
static
final
String
LOG_OUT_AGREE_URL
=
"log_out_agreee_url"
;
/**
* 隐私政策H5
*/
private
static
final
String
PRIVATE_AGREE_URL
=
"private_agree_url"
;
/**
* 隐私政策版本
*/
private
static
final
String
PRIVATE_AGREE_VERSION
=
"private_agree_version"
;
/**
* 隐私政策中相机权限
*/
private
static
final
String
PRIVATE_CAMERA_URL
=
"private_camera_url"
;
/**
* 直播规范
*/
private
static
final
String
PRIVATE_LIVEBROADCAST_URL
=
"private_livebroadcast_url"
;
/**
* 直播协议
*/
private
static
final
String
PRIVATE_LIVEPROTOCAL_URL
=
"private_liveprotocal_url"
;
/**
* 实名认证服务协议
*/
private
static
final
String
PRIVATE_CERTIFICATION_URL
=
"private_certification_url"
;
/**
* 留言板-隐私协议
*/
private
static
final
String
MESSAGE_BOARD_PRIVATE_URL
=
"message_board_private_url"
;
/**
* 留言板-用户协议
*/
private
static
final
String
MESSAGE_BOARD_USER_URL
=
"message_board_user_url"
;
/**
* 留言板-发布提问规定
*/
private
static
final
String
MESSAGE_BOARD_PULISH_URL
=
"message_board_publish_url"
;
/**
* 地区编码
*/
private
static
String
CITY_DISTRICTCODE_VALUE
=
""
;
/**
* 区、县编码编码
*/
private
static
final
String
DISTRICT_CODE
=
"district_code"
;
/**
* 问政频道地理编码
*/
private
static
final
String
WENZHEN_CHANNEL_AREA
=
"wenzhen_channel_area"
;
/**
* 问政频道地理名称
*/
private
static
final
String
WENZHEN_CHANNEL_AREA_NAME
=
"wenzhen_channel_area_name"
;
/**
* 直播红点数据
*/
private
static
final
String
LIVE_RED_POINT_DATA
=
"live_red_point_data"
;
/**
* 问政红点数据
*/
private
static
final
String
ASK_RED_POINT_DATA
=
"ask_red_point_data"
;
/**
* 广告id 存储
*/
public
static
final
String
ADV_SAVE_FILE
=
"adv_save_file"
;
/**
* 展示的广告
*/
public
static
final
String
ADV_
=
"adv_"
;
/**
* 配置config 存储
*/
private
static
final
String
CONFIG_SAVE_FILE
=
"config_save_file"
;
/**
* 保存 是否 拒绝 定位权限
*/
private
static
final
String
LOCATION_PERMISSION
=
"location_permission"
;
/**
* 覆盖安装,保存的上个版本号
*/
private
static
final
String
LAST_APP_VERSION
=
"last_app_version"
;
/**
* 邀请码
*/
private
static
final
String
INVITER_CODE
=
"inviter_code"
;
/**
* 推送开关
*/
private
static
final
String
UM_PUSH_SWITCH
=
"um_push_switch"
;
/**
* 仅wifi下加载图片
*/
private
static
final
String
WIFI_LOAD_IMG_SWITCH
=
"wifi_load_img_switch"
;
/**
* 仅wifi下播放视频
*/
private
static
final
String
WIFI_PLAY_VIDEO_SWITCH
=
"wifi_play_video_switch"
;
/**
* 视频悬浮窗
*/
private
static
final
String
PLAY_VIDEO_WINDOW_SWITCH
=
"play_video_window_switch"
;
/**
* token时间节点
*/
private
static
final
String
END_POINT
=
"end_point"
;
/**
* 头像
*/
private
static
final
String
RMRB_HEAD_IMG
=
"rmrb_head_img"
;
/**
* 用户类型userType
*/
private
static
final
String
USER_TYPE
=
"user_type"
;
/**
* 创作者id
*/
private
static
final
String
CREATOR_ID
=
"creator_id"
;
/**
* 头像Url
*/
private
static
final
String
AVATAR_URL
=
"avatar_url"
;
/**
* 用户号码
*/
private
static
final
String
USER_PHONE
=
"user_phone"
;
/**
* 直播过期token 时间
*/
private
static
final
String
LIVE_TOKEN_TIME
=
"live_token_time"
;
/**
* 直播过accessToken
*/
private
static
final
String
LIVE_ACCESSTOKEN
=
"live_accesstoken"
;
/**
* 直播refreshToken
*/
private
static
final
String
LIVE_REFRESHTOKEN
=
"live_refreshToken"
;
/**
* 用户名称
*/
private
static
final
String
USER_NAME
=
"user_name"
;
/**
* 用户是否听过次音乐 存储id
*/
private
static
final
String
USER_MUSIC_OLD_ID
=
"user_music_old_id"
;
/**
* 性别
*/
private
static
final
String
SEX
=
"sex"
;
/**
* 出生年月日
*/
private
static
final
String
BIRTHDAY
=
"BIRTHDAY"
;
/**
* 阿里 直播 APPID
*/
private
static
final
String
LIVE_IM_APPID
=
"im_appId"
;
/**
* 阿里 直播 APPKEY
*/
private
static
final
String
LIVE_IM_APPKEY
=
"im_appKey"
;
/**
* 用户成长值等级
*/
private
static
int
USER_LEVEL_VALUE
=
-
1
;
/**
* 用户成长值等级
*/
private
static
final
String
USER_LEVEL
=
"user_level"
;
/**
* push数据
*/
private
static
final
String
PUSH_DATA
=
"push_data"
;
/**
* push数据
*/
private
static
final
String
PUSH_MESSAGEID
=
"push_messageid"
;
/**
* 设置-夜间模式标识
*/
private
static
final
String
SET_NIGHTMODE
=
"set_nightmode"
;
/**
* 设置-夜间模式-日间模式值
*/
public
static
final
String
LIGHT_MODE
=
"Light Mode"
;
/**
* 设置-夜间模式-夜间模式值
*/
public
static
final
String
NIGHT_MODE
=
"Night Mode"
;
/**
* 设置-夜间模式-跟随系统模式值
*/
public
static
final
String
FOLLOWUP_SYSTEM
=
"System Default"
;
/**
* 是否已经非wifi弹窗一次,VIDEO
*/
private
static
final
String
NO_USER_WIFI_FOR_VIDEO
=
"no_user_wifi_for_video"
;
/**
* 启动页数据
*/
private
static
final
String
SPLASHINFO
=
"splashinfo"
;
/**
* 启动页数据
* 0:没有,1:展现广告,2:广告中心开机屏
*/
private
static
final
String
SPLASH_CACHE_TYPE
=
"splash_cache_type"
;
/**
* 启动页数据md5
*/
private
static
final
String
SPLASH_CACHE_MD5
=
"splash_cache_md5"
;
/**
* 设备id
*/
private
static
final
String
DEVICE_ID
=
"device_id"
;
/**
* 邮件订阅曝光时间
*/
private
static
final
String
SUB_EMAIL_EXPORE
=
"sub_email_expore"
;
/**
* 设置-夜间模式标识
*/
private
static
final
String
UPDATE_ID
=
"update_id"
;
private
static
final
String
KEY_DEFAULT_CHANNEL_ID
=
"key_default_channel_id"
;
// 默认频道
/**
* 语音播放标识
*/
private
static
final
String
ARTICLE_DETAIL_SP
=
"article_detail_sp"
;
/**
* 语音播放图文内容参数
*/
private
static
final
String
CONTENT_ID
=
"content_id"
;
private
static
final
String
CONTENT_TYPE
=
"content_type"
;
private
static
final
String
TOPIC_ID
=
"topic_id"
;
private
static
final
String
CHANNEL_ID
=
"channel_id"
;
private
static
final
String
COMP_ID
=
"compId"
;
private
static
final
String
SOURCE_PAGE
=
"sourcePage"
;
private
static
final
String
CONTENT_REL_TYPE
=
"contentRelType"
;
private
static
final
String
CONTENT_REL_ID
=
"contentRelId"
;
private
static
final
String
SCROLL_TO_BOTTOM
=
"scrollToBottom"
;
/**
* 数据存储的XML名称 存储置顶应用用
**/
private
static
final
String
FILENAME_PLAY_UTILS
=
"mgtv_player_config"
;
/**
* 经度
*/
private
static
String
LOCATION_LONGITUDE
=
"longitude"
;
/**
* 纬度
*/
private
static
String
LOCATION_LATITUDE
=
"latitude"
;
/**
* 地址
*/
private
static
String
LOCATION_ADDRESS
=
"location_address"
;
/**
* 视频播放环境设置 0:Mobile data and Wi-Fi / 默认 1:Wi-Fi only
*/
private
static
final
String
VIDEO_PLAYBACK
=
"video_playback"
;
/**
* 用户活动权限:0:有权限 1:无权限
*/
private
static
final
String
USER_ACTIVITY_CONTROL
=
"user_activity_control"
;
/**
* 是否点过分享海报
*/
private
static
final
String
SHARE_ICON_NEW_TAG
=
"share_icon_new_tag"
;
/**
* 推送消息数目
*/
private
static
final
String
PUSH_MESSAGE_COUNT
=
"push_message_count"
;
/**
* client
*/
private
static
final
String
CLIENT_ID
=
"client_id"
;
/**
* client
*/
private
static
final
String
ONCE_UPDATE
=
"once_update"
;
/**
* 获取用户name
*/
public
static
String
getUserName
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_NAME
,
""
);
}
/**
* 保存用户name
*/
public
static
void
saveUserName
(
String
name
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_NAME
,
name
);
}
/**
* 获取用户性别
*/
public
static
String
getSex
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
SEX
,
""
);
}
/**
* 保存用户性别
*/
public
static
void
saveSex
(
String
sex
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
SEX
,
sex
);
}
/**
* 获取用户生日
*/
public
static
String
getBirthday
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
BIRTHDAY
,
""
);
}
/**
* 保存用户生日
*/
public
static
void
saveBirthday
(
String
birthday
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
BIRTHDAY
,
birthday
);
}
/**
* 设置使用哪个默认请求地址
*
* @param tag
*/
public
static
void
saveBaseUrlTag
(
String
tag
)
{
if
(!
TextUtils
.
isEmpty
(
tag
))
{
BASE_URL_VALUE
=
tag
;
new
ConfigBase
(
KEY_BASE_URL_TAG
).
putWithSP
(
BASE_URL_TAG
,
tag
);
}
}
/**
* 获取服务器默认地址 是哪个
*
* @return
*/
public
static
String
getBaseUrlTag
()
{
if
(!
TextUtils
.
isEmpty
(
BASE_URL_VALUE
))
{
return
BASE_URL_VALUE
;
}
return
new
ConfigBase
(
KEY_BASE_URL_TAG
).
getStringWithSP
(
BASE_URL_TAG
);
}
/**
* 获取http状态406的情况
*/
public
static
boolean
getHttp406
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getBooleanWithSP
(
HTTP_406
,
false
);
}
/**
* 保存http状态406的情况
*/
public
static
void
saveHttp406
(
boolean
isTrue
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
HTTP_406
,
isTrue
);
}
/**
* 保存用户token
*/
public
static
void
saveUserToken
(
String
token
)
{
if
(!
"null"
.
equals
(
token
)
&&
token
!=
null
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_TOKE
,
token
);
}
}
/**
* 获取融云token
*/
public
static
String
getUserRongYunToken
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_RONGYUN_TOKE
,
""
);
}
/**
* 保存融云token
*/
public
static
void
saveUserRongYunToken
(
String
token
)
{
if
(!
"null"
.
equals
(
token
)
&&
token
!=
null
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_RONGYUN_TOKE
,
token
);
}
}
/**
* 获取用户token
*/
public
static
String
getUserToken
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_TOKE
,
""
);
}
/**
* 存userid
*/
public
static
void
saveUserId
(
String
userId
)
{
if
(
StringUtils
.
isEmpty
(
getUserId
())
||
!
StringUtils
.
isEqual
(
userId
,
getUserId
()))
{
// 登录状态变化,清除广告数据
clearNormalRecordAdvBeanList
();
}
USER_ID_VALUE
=
userId
;
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_ID
,
userId
);
}
/**
* get userid
*/
public
static
String
getUserId
()
{
if
(!
TextUtils
.
isEmpty
(
USER_ID_VALUE
))
{
return
USER_ID_VALUE
;
}
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_ID
,
""
);
}
/**
* 保存用户传作者name
*/
public
static
void
saveUserCreatorName
(
String
name
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_CREATOR_NAME
,
name
);
}
/**
* 获取r用户传作者name
*/
public
static
String
getUserCreatorName
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_CREATOR_NAME
,
getUserName
());
}
/**
* 保存refreshToken
*/
public
static
void
saveRefreshToken
(
String
token
)
{
if
(!
"null"
.
equals
(
token
)
&&
token
!=
null
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
REFRE_TOKEN
,
token
);
}
}
/**
* 获取refreshToken
*/
public
static
String
getRefreshToken
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
REFRE_TOKEN
);
}
/**
* 保存用户类型 userType,默认普通用户
*/
public
static
void
saveUserType
(
int
userType
)
{
if
(
0
==
userType
)
{
userType
=
1
;
}
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_TYPE
,
userType
);
}
/**
* 获取userType
* 1:普通用户 2:视频号 3:矩阵号 4内容子账号 5内容号
*/
public
static
int
getUserType
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getIntWithSP
(
USER_TYPE
,
1
);
}
/**
* 保存endPoint
*/
public
static
void
saveEndPoint
(
String
endPoint
)
{
if
(!
"null"
.
equals
(
endPoint
)
&&
endPoint
!=
null
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
END_POINT
,
endPoint
);
}
}
/**
* 获取endPoint
*/
public
static
String
getEndPoint
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
END_POINT
);
}
/**
* 保存rmrbHeadImg
*/
public
static
void
saveRmrbHeadImg
(
String
rmrbHeadImg
)
{
if
(!
"null"
.
equals
(
rmrbHeadImg
)
&&
rmrbHeadImg
!=
null
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
RMRB_HEAD_IMG
,
rmrbHeadImg
);
}
}
/**
* 获取头像
*/
public
static
String
getRmrbHeadImg
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
RMRB_HEAD_IMG
);
}
/**
* creatorId
*/
public
static
void
saveCreatorId
(
String
creatorId
)
{
if
(
"0"
.
equals
(
creatorId
))
{
creatorId
=
""
;
}
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
CREATOR_ID
,
creatorId
);
}
/**
* get creatorId
*/
public
static
String
getCreatorId
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
CREATOR_ID
,
""
);
}
/**
* 头像headPhotoUrl
*/
public
static
void
saveHeadPhotoUrl
(
String
url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
AVATAR_URL
,
url
);
}
/**
* 头像地址headPhotoUrl
*/
public
static
String
getHeadPhotoUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
AVATAR_URL
,
""
);
}
/**
* 保存手机号码
*/
public
static
void
saveUserPhone
(
String
key
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_PHONE
,
key
);
}
/**
* 获取手机号码
*/
public
static
String
getUserPhone
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_PHONE
);
}
/**
* 保存用户等级
*/
public
static
void
saveUserLevel
(
String
userLevel
)
{
try
{
USER_LEVEL_VALUE
=
Integer
.
parseInt
(
userLevel
);
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_LEVEL
,
USER_LEVEL_VALUE
);
}
catch
(
NumberFormatException
e
)
{
}
}
/**
* 获取用户等级
*/
public
static
int
getUserLevel
()
{
if
(
USER_LEVEL_VALUE
!=
-
1
)
{
return
USER_LEVEL_VALUE
;
}
return
new
ConfigBase
(
FILENAME_RMRB
).
getIntWithSP
(
USER_LEVEL
,
-
1
);
}
/**
* 获取http状态377的情况
*/
public
static
boolean
getHttp377
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getBooleanWithSP
(
HTTP_377
,
false
);
}
/**
* 保存http状态377的情况
*/
public
static
void
saveHttp377
(
boolean
isTrue
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
HTTP_377
,
isTrue
);
}
/**
* 保存城市
*/
public
static
void
saveCity
(
String
cityCode
)
{
CITY_VALUE
=
cityCode
;
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
CITY
,
cityCode
);
}
/**
* 获取城市
*
* @return
*/
public
static
String
getCity
()
{
if
(!
TextUtils
.
isEmpty
(
CITY_VALUE
))
{
return
CITY_VALUE
;
}
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
CITY
,
""
);
}
/**
* 省份编码
*
* @return
*/
public
static
String
getProvinceCode
()
{
if
(!
TextUtils
.
isEmpty
(
getDistrictCode
())
&&
getDistrictCode
().
length
()
>
1
)
{
return
getDistrictCode
().
substring
(
0
,
2
)
+
"0000"
;
}
else
{
return
""
;
}
}
/**
* 获取城市编码
*
* @return
*/
public
static
String
getCityCode
()
{
if
(!
TextUtils
.
isEmpty
(
getDistrictCode
())
&&
getDistrictCode
().
length
()
>
3
)
{
return
getDistrictCode
().
substring
(
0
,
4
)
+
"00"
;
}
else
{
return
""
;
}
}
/**
* 是否首次使用协议
*
* @return 默认true
*/
public
static
boolean
isFirstAgreementFlag
()
{
// 默认首次为true
return
new
ConfigBase
(
LAUNCH
).
getBooleanWithSP
(
APP_FIRST_AGREEMENT_TIP
,
true
);
}
/**
* 修改首次使用协议
*/
public
static
void
editFirstAgreementFlag
()
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
APP_FIRST_AGREEMENT_TIP
,
false
);
}
// 记录直播加载时间
public
static
long
getLiveLoadTime
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getLongWithSP
(
LIVE_LOADING_TIME
,
0
);
}
public
static
void
saveLiveLoadTime
(
long
time
)
{
new
ConfigBase
(
FILENAME_RMRB
).
put
(
LIVE_LOADING_TIME
,
time
);
}
/**
* 保存网络数据
*/
public
static
void
saveNetworkDataCache
(
String
spKey
,
String
data
)
{
// 保存数据
ConfigBase
configBase
=
new
ConfigBase
(
NETWORK_CACHE_DATA_SP
);
configBase
.
putWithSP
(
spKey
,
data
);
// 保存key,重复key不保存
String
cacheDataKeys
=
configBase
.
getStringWithSP
(
NETWORK_CACHE_DATA_KEY
);
if
(
isContainKey
(
cacheDataKeys
,
spKey
))
{
return
;
}
if
(
StringUtils
.
isBlank
(
cacheDataKeys
))
{
configBase
.
putWithSP
(
NETWORK_CACHE_DATA_KEY
,
spKey
+
";"
);
}
else
{
configBase
.
putWithSP
(
NETWORK_CACHE_DATA_KEY
,
cacheDataKeys
+
spKey
+
";"
);
}
}
/**
* 是否包含了该key
*
* @param key
* @return
*/
private
static
boolean
isContainKey
(
String
cacheDataKeys
,
String
key
)
{
if
(
cacheDataKeys
==
null
)
{
return
false
;
}
String
[]
keys
=
cacheDataKeys
.
split
(
";"
);
if
(
keys
!=
null
&&
keys
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
if
(
keys
[
i
].
equals
(
key
))
{
return
true
;
}
}
}
return
false
;
}
/**
* 清除接口缓存
*/
public
static
void
cleanNetworkDataCache
()
{
ConfigBase
configBase
=
new
ConfigBase
(
NETWORK_CACHE_DATA_SP
);
String
cacheDataKeys
=
configBase
.
getStringWithSP
(
NETWORK_CACHE_DATA_KEY
);
if
(
cacheDataKeys
==
null
)
{
return
;
}
String
[]
keys
=
cacheDataKeys
.
split
(
";"
);
if
(
keys
!=
null
&&
keys
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
configBase
.
removeWithSP
(
keys
[
i
]);
}
}
// 把key清空
configBase
.
putWithSP
(
NETWORK_CACHE_DATA_KEY
,
""
);
}
/**
* 获取网络缓存数据
*
* @param spKey
* @return
*/
public
static
String
getNetworkDataCache
(
String
spKey
)
{
return
new
ConfigBase
(
NETWORK_CACHE_DATA_SP
).
getStringWithSP
(
spKey
);
}
/**
* 保存展示的彩蛋
*
* @param type 彩蛋类型
* @param id 彩蛋id
*/
public
static
void
savePopUpIsShow
(
String
type
,
String
id
)
{
new
ConfigBase
(
POPUPS_SAVE_FILE
).
putWithSP
(
type
+
"_"
+
id
+
"_"
+
getUserId
(),
true
);
}
/**
* 获取彩蛋是否展示过
*
* @param type 彩蛋类型
* @param id 彩蛋id
* @return
*/
public
static
Boolean
getPopUpIsShow
(
String
type
,
String
id
)
{
return
new
ConfigBase
(
POPUPS_SAVE_FILE
).
getBooleanWithSP
(
type
+
"_"
+
id
+
"_"
+
getUserId
(),
false
);
}
//
// /**
// * 存储或更新 广告
// *
// * @param type 0:开屏
// * 1:挂角
// * @param bean
// */
// public static void saveOrUpdateNormalAdvInfor(int type, RecordNormalAdvBean bean) {
//
// StringBuilder fileName = new StringBuilder();
// fileName.append(ADS_RECORD);
// if (type == 0) {
// fileName.append("_");
// fileName.append(TYPE_LAUNCH);
// } else if (type == 1) {
// fileName.append("_");
// fileName.append(TYPE_CORNERS);
// }
//
// List<RecordNormalAdvBean> list = getRecordNormalAdvBeanList(type);
//
// if (list == null || list.size() == 0) {
// bean.setShowCount(1);
// List<RecordNormalAdvBean> aList = new ArrayList<>();
// aList.add(bean);
// String jsonArray = JsonUtils.convertObjectToJson(aList);
// Logger.t(TAG).d("saveOrUpdateNormalAdvInfor====>" + jsonArray);
// new ConfigBase(fileName.toString()).putWithSP(ADS_RECORD, jsonArray);
// } else {
// boolean addNewAdsId = true;
// int showCount = getRecordNormalAdvCount(type, bean.getAdvId());
// for (int i = 0; i < list.size(); i++) {
// if (StringUtils.isEqual(bean.getAdvId(), list.get(i).getAdvId())) {
// // id一样,不添加
// list.get(i).setShowCount(1);
// addNewAdsId = false;
// } else if (showCount == 1) {
// // 新循环开始,将其他缓存的数据展示次数置为0
// list.get(i).setShowCount(0);
// }
// }
// if (addNewAdsId) {
// // 需要添加
// bean.setShowCount(1);
// list.add(bean);
// }
// String jsonArray = JsonUtils.convertObjectToJson(list);
// new ConfigBase(fileName.toString()).putWithSP(ADS_RECORD, jsonArray);
// Logger.t(TAG).d("saveOrUpdateNormalAdvInfor====>" + jsonArray);
// }
// }
// /**
// * 获取展示的次数 -1:未展示过,0:已展示过,但当前循环未展示,1:当前循环已展示
// *
// * @param type 0:开屏
// * 1:挂角
// * @param id
// * @return
// */
// public static int getRecordNormalAdvCount(int type, String id) {
// int count = -1;
// List<RecordNormalAdvBean> list = getRecordNormalAdvBeanList(type);
// if (list == null || list.size() == 0) {
// return count;
// } else {
// for (RecordNormalAdvBean bean : list) {
// if (StringUtils.isEqual(id, bean.getAdvId())) {
// // id一样,不添加
// count = bean.getShowCount();
// break;
// }
// }
// return count;
// }
// }
// /**
// * 获取普通广告的记录信息
// *
// * @param type 0:开屏
// * 1:挂角
// * @return
// */
// private static List<RecordNormalAdvBean> getRecordNormalAdvBeanList(int type) {
//
// StringBuilder fileName = new StringBuilder();
// fileName.append(ADS_RECORD);
// if (type == 0) {
// fileName.append("_");
// fileName.append(TYPE_LAUNCH);
// } else if (type == 1) {
// fileName.append("_");
// fileName.append(TYPE_CORNERS);
// }
//
// String jsonArrayStr = new ConfigBase(fileName.toString()).getStringWithSP(ADS_RECORD, "");
// List<RecordNormalAdvBean> idList = null;
// try {
// idList = JsonUtils.convertJsonArrayToObjList(jsonArrayStr, RecordNormalAdvBean.class);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return idList;
// }
/**
* 清理广告数据
*/
public
static
void
clearNormalRecordAdvBeanList
()
{
// 清理开屏广告数据
clearNormalRecordAdvBeanList
(
0
);
// 清理挂角广告数据
clearNormalRecordAdvBeanList
(
1
);
}
/**
* 清理普通广告记录
*
* @param type 0:开屏
* 1:挂角
*/
public
static
void
clearNormalRecordAdvBeanList
(
int
type
)
{
// 切换账号清理广告数据
StringBuilder
fileName
=
new
StringBuilder
();
fileName
.
append
(
ADS_RECORD
);
if
(
type
==
0
)
{
fileName
.
append
(
"_"
);
fileName
.
append
(
TYPE_LAUNCH
);
}
else
if
(
type
==
1
)
{
fileName
.
append
(
"_"
);
fileName
.
append
(
TYPE_CORNERS
);
}
// 清理未登录的广告数据
new
ConfigBase
(
fileName
.
toString
()).
removeWithSP
(
ADS_RECORD
);
}
/**
* 是否首次使用引导页
*
* @return 默认true
*/
public
static
boolean
isFirstGuideFlag
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getBooleanWithSP
(
APP_FIRST_GUIDE
,
true
);
}
/**
* 修改首次使用引导页
*/
public
static
void
editFirstGuideFlag
()
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
APP_FIRST_GUIDE
,
false
);
}
/**
* 保存用户协议版本
*/
public
static
void
saveUserAgreeVersion
(
String
version
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_AGREE_VERSION
,
version
);
}
/**
* 获取用户协议版本
*
* @return
*/
public
static
String
getUserAgreeVersion
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_AGREE_VERSION
);
}
public
static
void
saveUserStatus
(
String
userStatus
)
{
try
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
USER_STATUS
,
userStatus
);
}
catch
(
NumberFormatException
e
)
{
}
}
/**
* 获取用户活动展示权限:0:有权限 1:无权限, 默认有权限(普通用户)
*/
public
static
String
getUserStatus
()
{
return
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
getStringWithSP
(
USER_STATUS
);
}
/**
* 保存隐私政策版本号
*/
public
static
void
savePrivateAgreeVersion
(
String
version
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PRIVATE_AGREE_VERSION
,
version
);
}
/**
* 获取隐私政策版本号
*
* @return
*/
public
static
String
getPrivateAgreeVersion
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PRIVATE_AGREE_VERSION
);
}
/**
* 保存用户协议
*/
public
static
void
saveUserAgreeUrl
(
String
h5url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_AGREE_URL
,
h5url
);
}
public
static
String
getUserAgreeUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_AGREE_URL
);
}
/**
* 保存隐私政策
*/
public
static
void
savePrivateAgreeUrl
(
String
h5url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PRIVATE_AGREE_URL
,
h5url
);
}
public
static
String
getPrivateAgreeUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PRIVATE_AGREE_URL
);
}
/**
* 保存隐私政策中相应权限
*/
public
static
void
saveCameraPermissionUrl
(
String
url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PRIVATE_CAMERA_URL
,
url
);
}
/**
* 获取隐私政策中相应权限
*
* @return
*/
public
static
String
getCameraPermissionUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PRIVATE_CERTIFICATION_URL
,
""
);
}
/**
* 保存留言板隐私协议
*/
public
static
void
saveMessageBoardPrivateUrl
(
String
url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
MESSAGE_BOARD_PRIVATE_URL
,
url
);
}
/**
* 获取留言板隐私协议
*
* @return
*/
public
static
String
getMessageBoardPrivateUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
MESSAGE_BOARD_PRIVATE_URL
,
""
);
}
/**
* 保存留言板用户协议
*/
public
static
void
saveMessageBoardUserUrl
(
String
url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
MESSAGE_BOARD_USER_URL
,
url
);
}
/**
* 获取留言板用户协议
*
* @return
*/
public
static
String
getMessageBoardUserUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
MESSAGE_BOARD_USER_URL
,
""
);
}
/**
* 保存留言板发布提问规定
*/
public
static
void
saveMessageBoardPublishUrl
(
String
url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
MESSAGE_BOARD_PULISH_URL
,
url
);
}
/**
* 获取留言板发布提问规定
*
* @return
*/
public
static
String
getMessageBoardPublishUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
MESSAGE_BOARD_PULISH_URL
,
""
);
}
/**
* 保存注销协议
*/
public
static
void
saveLogoutAgreeUrl
(
String
h5url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
LOG_OUT_AGREE_URL
,
h5url
);
}
public
static
String
getLogoutAgreeUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
LOG_OUT_AGREE_URL
);
}
/**
* 保存实名认证服务协议
*/
public
static
void
saveCertificationUrl
(
String
url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PRIVATE_CERTIFICATION_URL
,
url
);
}
/**
* 获取实名认证服务协议
*
* @return
*/
public
static
String
getCertificationionUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PRIVATE_CERTIFICATION_URL
,
""
);
}
/**
* 保存直播规范
*/
public
static
void
saveLiveBroadcastUrl
(
String
h5url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PRIVATE_LIVEBROADCAST_URL
,
h5url
);
}
/**
* 获取直播规范
*/
public
static
String
getLiveBroadcastUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PRIVATE_LIVEBROADCAST_URL
);
}
/**
* 保存直播协议
*/
public
static
void
saveLiveProtocalUrl
(
String
h5url
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PRIVATE_LIVEPROTOCAL_URL
,
h5url
);
}
/**
* 获取直播协议
*/
public
static
String
getLiveProtocalUrl
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PRIVATE_LIVEPROTOCAL_URL
);
}
/**
* 保存区、县编码
*/
public
static
void
saveDistrictCode
(
String
districtCode
)
{
CITY_DISTRICTCODE_VALUE
=
districtCode
;
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
DISTRICT_CODE
,
districtCode
);
}
/**
* 存储问政频道地理信息
*
* @param fullCode
*/
public
static
void
saveWenZhenChannelAreaCode
(
String
fullCode
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
WENZHEN_CHANNEL_AREA
,
fullCode
);
}
/**
* 获取问政频道地理信息code
*
* @return
*/
public
static
String
getWenZhenChannelAreaCode
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
WENZHEN_CHANNEL_AREA
,
""
);
}
/**
* 存储问政频道地理信息名称
*
* @param fullCode
*/
public
static
void
saveWenZhenChannelAreaName
(
String
fullCode
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
WENZHEN_CHANNEL_AREA_NAME
,
fullCode
);
}
/**
* 获取问政频道地理信息名称
*
* @return
*/
public
static
String
getWenZhenChannelAreaName
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
WENZHEN_CHANNEL_AREA_NAME
,
""
);
}
public
static
String
getUserLocalProviceName
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PROVINCE
,
""
);
}
public
static
void
saveUserLocalProviceName
(
String
proviceName
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PROVINCE
,
proviceName
);
}
/**
* 存储直播红点提示的md5值
*
* @param liveMd5
*/
public
static
void
saveLiveIdMD5
(
String
liveMd5
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
LIVE_RED_POINT_DATA
,
liveMd5
);
}
/**
* 获取直播红点提示的md5值
*
* @return
*/
public
static
String
getLiveIdMD5
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
LIVE_RED_POINT_DATA
,
""
);
}
/**
* 存储个人中心红点提示的md5值
*
* @param askMd5
*/
public
static
void
saveAskMarkMD5
(
String
askMd5
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
ASK_RED_POINT_DATA
,
askMd5
);
}
/**
* 获取个人中心问政红点提示的md5值
*
* @return
*/
public
static
String
getAskMarkMD5
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
ASK_RED_POINT_DATA
,
""
);
}
/**
* 获取区、县编码
*/
public
static
String
getDistrictCode
()
{
if
(!
TextUtils
.
isEmpty
(
CITY_DISTRICTCODE_VALUE
))
{
return
CITY_DISTRICTCODE_VALUE
;
}
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
DISTRICT_CODE
);
}
/**
* 获取是否拒绝过定位权限
*/
public
static
boolean
getRefusedLocation
()
{
return
new
ConfigBase
(
CONFIG_SAVE_FILE
).
getBooleanWithSP
(
LOCATION_PERMISSION
,
false
);
}
/**
* 保存是否拒绝过定位权限
*/
public
static
void
saveRefusedLocation
(
boolean
b
)
{
new
ConfigBase
(
CONFIG_SAVE_FILE
).
putWithSP
(
LOCATION_PERMISSION
,
b
);
}
/**
* 设置广告展示的次数
*
* @param type 广告类型
* @param id 广告id
* @return
*/
public
static
void
setAdvShowCount
(
String
type
,
String
id
)
{
int
count
=
getAdvShowCount
(
type
,
id
);
count
=
count
+
1
;
new
ConfigBase
(
SpUtils
.
ADV_SAVE_FILE
).
putWithSP
(
SpUtils
.
ADV_
+
type
+
"_"
+
id
+
"_"
+
SpUtils
.
getUserId
(),
count
);
}
/**
* 获取广告展示的次数
*
* @param type 广告类型
* @param id 广告id
* @return
*/
public
static
Integer
getAdvShowCount
(
String
type
,
String
id
)
{
return
new
ConfigBase
(
SpUtils
.
ADV_SAVE_FILE
)
.
getIntWithSP
(
SpUtils
.
ADV_
+
type
+
"_"
+
id
+
"_"
+
SpUtils
.
getUserId
(),
0
);
}
/**
* 获取覆盖安装前的版本号
*/
public
static
String
getLastAppVersion
()
{
return
new
ConfigBase
(
CONFIG_SAVE_FILE
).
getStringWithSP
(
LAST_APP_VERSION
,
""
);
}
/**
* 保存覆盖安装前的版本号
*/
public
static
void
saveLastAppVersion
(
String
version
)
{
new
ConfigBase
(
CONFIG_SAVE_FILE
).
putWithSP
(
LAST_APP_VERSION
,
version
);
}
/**
* 获取邀请码
*/
public
static
String
getInviterCode
()
{
return
new
ConfigBase
(
CONFIG_SAVE_FILE
).
getStringWithSP
(
INVITER_CODE
,
""
);
}
/**
* 保存邀请码
*/
public
static
void
saveInviterCode
(
String
inviterCode
)
{
new
ConfigBase
(
CONFIG_SAVE_FILE
).
putWithSP
(
INVITER_CODE
,
inviterCode
);
}
/**
* 保存推送开关
*
* @param tag
*/
public
static
void
savePushSwitchTag
(
String
tag
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
UM_PUSH_SWITCH
,
tag
);
}
/**
* 获取推送开关状态
*
* @return
*/
public
static
String
getPushSwitchTag
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
UM_PUSH_SWITCH
);
}
public
static
void
saveWifiLoadImgTag
(
String
tag
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
WIFI_LOAD_IMG_SWITCH
,
tag
);
}
/**
* 默认关闭
* 仅wifi网络加载图片:默认关闭
*
* @return
*/
public
static
String
getWifiLoadImgSwitchTag
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
WIFI_LOAD_IMG_SWITCH
,
"0"
);
}
public
static
void
saveWifiPlayVideoTag
(
String
tag
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
WIFI_PLAY_VIDEO_SWITCH
,
tag
);
}
/**
* 默认开启
* wifi网络下自动播放视频:默认打开
*
* @return
*/
public
static
String
getWifiPlayVideoSwitchTag
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
WIFI_PLAY_VIDEO_SWITCH
,
"1"
);
}
public
static
void
savePlayVideoWindowTag
(
String
tag
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PLAY_VIDEO_WINDOW_SWITCH
,
tag
);
}
/**
* 默认关闭画中画
*
* @return 1 是开启 0 是关闭
*/
public
static
String
getPlayVideoWindowSwitchTag
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PLAY_VIDEO_WINDOW_SWITCH
,
"0"
);
}
// 记录token有效期加载加载时间
public
static
long
getLiveTokenTime
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getLongWithSP
(
LIVE_TOKEN_TIME
,
0
);
}
public
static
void
saveLiveTokeTime
(
long
time
)
{
new
ConfigBase
(
FILENAME_RMRB
).
put
(
LIVE_TOKEN_TIME
,
time
);
}
// 记录accessToken
public
static
String
getLiveAccessToken
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
LIVE_ACCESSTOKEN
,
""
);
}
public
static
void
saveLiveAccessToken
(
String
accessToken
)
{
new
ConfigBase
(
FILENAME_RMRB
).
put
(
LIVE_ACCESSTOKEN
,
accessToken
);
}
// 记录refreshToken
public
static
String
getLiveRefreshToken
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
LIVE_REFRESHTOKEN
,
""
);
}
public
static
void
saveLiveRefreshToken
(
String
refreshToken
)
{
new
ConfigBase
(
FILENAME_RMRB
).
put
(
LIVE_REFRESHTOKEN
,
refreshToken
);
}
/**
* 保存IMAPPID
*/
public
static
void
saveIMAppId
(
String
appid
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
LIVE_IM_APPID
,
appid
);
}
/**
* 保存IMAPPKEY
*/
public
static
void
saveIMAppkey
(
String
appKey
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
LIVE_IM_APPKEY
,
appKey
);
}
/**
* 获取IMAPPKEY
*
* @return
*/
public
static
String
getIMAppKey
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
LIVE_IM_APPKEY
);
}
/**
* 清理用户信息
*/
public
static
void
clearUserInfo
()
{
saveUserToken
(
""
);
saveUserId
(
""
);
saveUserName
(
""
);
saveCreatorId
(
""
);
saveRefreshToken
(
""
);
saveUserType
(-
1
);
saveHeadPhotoUrl
(
""
);
saveUserLevel
(
""
);
saveIMAppId
(
""
);
saveIMAppkey
(
""
);
saveLiveTokeTime
(
3600000L
);
saveLiveAccessToken
(
""
);
saveLiveRefreshToken
(
""
);
saveSex
(
""
);
saveBirthday
(
""
);
}
/**
* 获取推送数据
*/
public
static
String
getpushData
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PUSH_DATA
,
""
);
}
/**
* 保存推送数据
*/
public
static
void
savePushData
(
String
strData
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PUSH_DATA
,
strData
);
}
/**
* 保存推送数据
*/
public
static
void
savePushMessageId
(
String
strData
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PUSH_MESSAGEID
,
strData
);
}
/**
* 获取推送数据
*/
public
static
String
getPushMessageId
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
PUSH_MESSAGEID
,
""
);
}
/**
* 保存夜间模式状态
*
* @param mode 日间模式(默认)、夜间模式、跟随系统
* Light Mode 、Night Mode 、Follow-up System
**/
public
static
void
saveNightMode
(
String
mode
)
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
SET_NIGHTMODE
,
mode
);
}
/**
* 获取本地配置的夜间模式状态
* 日间模式
* 夜间模式
* 跟随系统
*
* @return
*/
public
static
String
getNightMode
()
{
return
new
ConfigBase
(
LAUNCH
).
getStringWithSP
(
SET_NIGHTMODE
,
LIGHT_MODE
);
}
/**
* 获取实时的夜间模式状态
* 日间模式 false
* 夜间模式 true
*/
public
static
boolean
isNightMode
()
{
// 获取夜间模式状态
String
nightModeState
=
SpUtils
.
getNightMode
();
// 注释系统设置来改变夜间模式
/*
* if (SpUtils.FOLLOWUP_SYSTEM.equals(nightModeState)) {
* //获取系统深浅色
* switch (AppContext.getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK)
* {
* case Configuration.UI_MODE_NIGHT_YES:
* //深色夜间模式
* nightModeState = SpUtils.NIGHT_MODE;
* break;
* case Configuration.UI_MODE_NIGHT_NO:
* // 浅色日间模式
* nightModeState = SpUtils.LIGHT_MODE;
* break;
* default:
* break;
* }
* }
*/
return
SpUtils
.
NIGHT_MODE
.
equals
(
nightModeState
);
}
/**
* 视频播放使用wifi
*
* @param isWifi
*/
public
static
void
saveNoUseWifiForVideo
(
boolean
isWifi
)
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
NO_USER_WIFI_FOR_VIDEO
,
isWifi
);
}
public
static
boolean
getNoUseWifiForVideo
()
{
return
new
ConfigBase
(
LAUNCH
).
getBooleanWithSP
(
NO_USER_WIFI_FOR_VIDEO
,
false
);
}
/**
* 开屏数据
*/
public
static
void
saveSplashCache
(
String
json
)
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
SPLASHINFO
,
json
);
}
public
static
String
getSplashCache
()
{
return
new
ConfigBase
(
LAUNCH
).
getStringWithSP
(
SPLASHINFO
,
""
);
}
public
static
void
setSplashCacheType
(
int
type
)
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
SPLASH_CACHE_TYPE
,
type
);
}
public
static
int
getSplashCacheType
()
{
return
new
ConfigBase
(
LAUNCH
).
getIntWithSP
(
SPLASH_CACHE_TYPE
,
0
);
}
public
static
void
setSplashCacheMd5
(
String
md5
)
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
SPLASH_CACHE_MD5
,
md5
);
}
public
static
String
getSplashCacheMd5
()
{
return
new
ConfigBase
(
LAUNCH
).
getStringWithSP
(
SPLASH_CACHE_MD5
,
""
);
}
/**
* 保存设备id
*/
public
static
void
saveDeviceId
(
String
deviceId
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
DEVICE_ID
,
deviceId
);
}
/**
* 获取设备id
*
* @return
*/
public
static
String
getDeviceId
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
DEVICE_ID
,
""
);
}
/**
* 记录邮件订阅曝光时间
*
* @param exporeTime
*/
public
static
void
saveSubEmailExporeTime
(
long
exporeTime
)
{
//
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
SUB_EMAIL_EXPORE
,
exporeTime
);
}
/**
* 获取邮件订阅曝光时间
*
* @return
*/
public
static
long
getSubEmailExporeTime
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getLongWithSP
(
SUB_EMAIL_EXPORE
,
0
);
}
/**
* 更新单次升级id
**/
public
static
void
saveUpdateOnceState
(
String
mode
)
{
new
ConfigBase
(
LAUNCH
).
putWithSP
(
UPDATE_ID
,
mode
);
}
/**
* 上次单次升级id
*
* @return
*/
public
static
String
getUpdateOnceState
()
{
return
new
ConfigBase
(
LAUNCH
).
getStringWithSP
(
UPDATE_ID
,
""
);
}
/**
* 保存语音播报图文详情页参数
*/
public
static
void
saveContentId
(
String
mContentId
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
CONTENT_ID
,
mContentId
);
}
public
static
void
saveContentType
(
String
mContentType
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
CONTENT_TYPE
,
mContentType
);
}
public
static
void
saveTopicId
(
String
mTopicId
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
TOPIC_ID
,
mTopicId
);
}
public
static
void
saveChannelId
(
String
mChannelId
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
CHANNEL_ID
,
mChannelId
);
}
public
static
void
saveCompId
(
String
mCompId
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
COMP_ID
,
mCompId
);
}
public
static
void
saveSourcePage
(
String
mSourcePage
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
SOURCE_PAGE
,
mSourcePage
);
}
public
static
void
saveContentRelType
(
String
contentRelType
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
CONTENT_REL_TYPE
,
contentRelType
);
}
public
static
void
saveContentRelId
(
String
contentRelId
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
CONTENT_REL_ID
,
contentRelId
);
}
public
static
void
saveScrollToBottom
(
boolean
scrollToBottom
)
{
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
putWithSP
(
SCROLL_TO_BOTTOM
,
scrollToBottom
);
}
/**
* 获取语音播报图文详情页参数
*
* @return
*/
public
static
String
getContentId
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
CONTENT_ID
);
}
public
static
String
getContentType
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
CONTENT_TYPE
);
}
public
static
String
getTopicId
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
TOPIC_ID
);
}
public
static
String
getChannelId
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
CHANNEL_ID
);
}
public
static
String
getCompId
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
COMP_ID
);
}
public
static
String
getSourcePage
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
SOURCE_PAGE
);
}
public
static
String
getRelID
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
CONTENT_REL_ID
);
}
public
static
String
getRelType
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getStringWithSP
(
CONTENT_REL_TYPE
);
}
public
static
boolean
getScrollToBottom
()
{
return
new
ConfigBase
(
ARTICLE_DETAIL_SP
).
getBooleanWithSP
(
SCROLL_TO_BOTTOM
);
}
/**
* 首页默认选中项
*/
public
static
String
getKeyDefaultChannelId
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
KEY_DEFAULT_CHANNEL_ID
,
""
);
}
public
static
void
setKeyDefaultChannelId
(
String
keyRecommend
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
KEY_DEFAULT_CHANNEL_ID
,
keyRecommend
);
}
/**
* 获取经度
*/
public
static
String
getLongitude
()
{
return
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
getStringWithSP
(
LOCATION_LONGITUDE
);
}
/**
* 保存经度
*
* @param longitude
*/
public
static
void
saveLongitude
(
String
longitude
)
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
LOCATION_LONGITUDE
,
longitude
);
}
/**
* 获取纬度
*/
public
static
String
getLatitude
()
{
return
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
getStringWithSP
(
LOCATION_LATITUDE
);
}
/**
* 保存纬度
*
* @param latitude
*/
public
static
void
saveLatitude
(
String
latitude
)
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
LOCATION_LATITUDE
,
latitude
);
}
/**
* 获取地址
*
* @return
*/
public
static
String
getAddress
()
{
return
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
getStringWithSP
(
LOCATION_ADDRESS
);
}
/**
* 保存地址
*
* @param address
*/
public
static
void
saveAddress
(
String
address
)
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
LOCATION_ADDRESS
,
address
);
}
/**
* 是否拉起
*/
public
static
boolean
isPullup
=
false
;
/**
* 拉起是否经过appmain oncreate方法
*/
public
static
boolean
isAppMainCreate
=
false
;
/**
* 拉起数据缓存
*/
public
static
String
pulldata
=
""
;
/**
* 获取视频播放环境设置
*/
public
static
int
getVideoPlayback
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getIntWithSP
(
VIDEO_PLAYBACK
,
0
);
}
/**
* 保存用户活动权限
*/
public
static
void
saveUserActivityControl
(
int
activityControl
)
{
try
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
USER_ACTIVITY_CONTROL
,
activityControl
);
}
catch
(
NumberFormatException
e
)
{
}
}
/**
* 获取用户活动展示权限:0:有权限 1:无权限, 默认有权限(普通用户)
*/
public
static
int
getUserActivityControl
()
{
return
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
getIntWithSP
(
USER_ACTIVITY_CONTROL
,
0
);
}
/**
* 发布本地的上传状态
*/
private
static
final
String
PUBLISH_UPLOAD_STATUS
=
"publish_upload_status"
;
/**
* 是否正在上传视频
*
* @return 默认true
*/
public
static
boolean
isPublishUploading
()
{
return
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
getBooleanWithSP
(
PUBLISH_UPLOAD_STATUS
,
false
);
}
/**
* 修改发布视频本地的上传状态为上传中
*/
public
static
void
setPublishUploadStatusIsRunning
()
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
PUBLISH_UPLOAD_STATUS
,
true
);
}
/**
* 修改发布视频本地的上传状态为上传完成
*/
public
static
void
setPublishUploadStatusIsComplete
()
{
new
ConfigBase
(
FILENAME_PLAY_UTILS
).
putWithSP
(
PUBLISH_UPLOAD_STATUS
,
false
);
}
/**
* 保存用户是否点过分享海报
*/
public
static
void
saveShareIconNewClick
(
int
click
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
SHARE_ICON_NEW_TAG
,
click
);
}
/**
* 获取用户是否点过分享海报
*/
public
static
int
getShareIconNewClick
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getIntWithSP
(
SHARE_ICON_NEW_TAG
,
0
);
}
/**
* 用户是否听过次音乐
*/
public
static
void
saveUserMusicOldId
(
String
name
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
USER_MUSIC_OLD_ID
,
name
);
}
/**
* 用户是否听过次音乐
*/
public
static
String
getUserMusicOldId
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
USER_MUSIC_OLD_ID
,
""
);
}
/**
* 保存推送历史数目
*
* @param count
*/
public
static
void
savePushMsgCount
(
int
count
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
PUSH_MESSAGE_COUNT
,
count
);
}
public
static
int
getPushMsgCount
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getIntWithSP
(
PUSH_MESSAGE_COUNT
,
0
);
}
/**
* 存clientId
*/
public
static
void
saveClientId
(
String
clientId
)
{
new
ConfigBase
(
FILENAME_RMRB
).
putWithSP
(
CLIENT_ID
,
clientId
);
}
/**
* get clientId
*/
public
static
String
getClientId
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
CLIENT_ID
,
""
);
}
public
static
void
saveUpGrade
(
String
version
)
{
new
ConfigBase
(
FILENAME_RMRB
).
put
(
ONCE_UPDATE
,
version
);
}
public
static
String
getUpGrade
()
{
return
new
ConfigBase
(
FILENAME_RMRB
).
getStringWithSP
(
ONCE_UPDATE
,
""
);
}
}
...
...
Please
register
or
login
to post a comment