Skip to content

Commit

Permalink
1.更新 DevEngine 部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
afkT committed Sep 1, 2021
1 parent a694e75 commit 013bf3e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 27 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/afkt/project/base/BaseApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ class BaseApplication : MultiDexApplication() {
*/
private fun initEngine() {
// 使用内部默认实现 Engine
DevEngine.defaultEngine()
DevEngine.defaultMMKVInitialize(this)
.defaultEngine(DevEngine.getMMKVConfig())
}

/**
Expand Down
12 changes: 12 additions & 0 deletions lib/DevEngine/src/main/java/dev/engine/DevEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import dev.engine.storage.DevMediaStoreEngineImpl
import dev.engine.storage.DevStorageEngine
import dev.utils.app.cache.DevCache
import dev.utils.app.logger.LogConfig
import dev.utils.common.cipher.Cipher

/**
* detail: DevEngine
Expand Down Expand Up @@ -102,6 +103,17 @@ object DevEngine {
return MMKVUtils.defaultHolder().mmkv
}

/**
* 获取 MMKV Config
* @param cipher 加解密中间层
* @return [MMKVConfig]
* <p></p>
* 需先调用 [defaultMMKVInitialize]
*/
fun getMMKVConfig(cipher: Cipher? = null): MMKVConfig {
return MMKVConfig(cipher, getMMKVByHolder()!!)
}

// ============
// = 初始化方法 =
// ============
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class DevCacheEngineImpl(
) : ICacheEngine<CacheConfig?, DataItem?> {

// JSON Engine
private var mJSONEngine: IJSONEngine<in IJSONEngine.EngineConfig>? = DevJSONEngine.getEngine()
private var mJSONEngine: IJSONEngine<out IJSONEngine.EngineConfig>? = DevJSONEngine.getEngine()

fun setJSONEngine(engine: IJSONEngine<in IJSONEngine.EngineConfig>) {
fun setJSONEngine(engine: IJSONEngine<out IJSONEngine.EngineConfig>) {
this.mJSONEngine = engine
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class MMKVKeyValueEngineImpl(
}

// JSON Engine
private var mJSONEngine: IJSONEngine<in IJSONEngine.EngineConfig>? = DevJSONEngine.getEngine()
private var mJSONEngine: IJSONEngine<out IJSONEngine.EngineConfig>? = DevJSONEngine.getEngine()

fun setJSONEngine(engine: IJSONEngine<in IJSONEngine.EngineConfig>) {
fun setJSONEngine(engine: IJSONEngine<out IJSONEngine.EngineConfig>) {
this.mJSONEngine = engine
}

Expand Down
4 changes: 2 additions & 2 deletions lib/DevEngine/src/main/java/dev/engine/keyvalue/engine_sp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class SPKeyValueEngineImpl(
}

// JSON Engine
private var mJSONEngine: IJSONEngine<in IJSONEngine.EngineConfig>? = DevJSONEngine.getEngine()
private var mJSONEngine: IJSONEngine<out IJSONEngine.EngineConfig>? = DevJSONEngine.getEngine()

fun setJSONEngine(engine: IJSONEngine<in IJSONEngine.EngineConfig>) {
fun setJSONEngine(engine: IJSONEngine<out IJSONEngine.EngineConfig>) {
this.mJSONEngine = engine
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class BaseApplication : MultiDexApplication(),
}

// 使用内部默认实现 Engine
DevEngine.defaultEngine()
DevEngine.defaultMMKVInitialize(this)
.defaultEngine(DevEngine.getMMKVConfig())

// 全局状态布局配置
val global = StateLayout.Global(object : StateLayout.Listener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ class BaseApplication : MultiDexApplication() {
)
}

// 个推推送 Engine 实现
DevPushEngine.setEngine(GTPushEngineImpl())
// 个推推送初始化
DevPushEngine.getEngine()?.initialize(
this, PushConfig(
isDebugMode = BuildConfig.DEBUG
)
// 个推推送 Engine 实现并初始化
DevPushEngine.setEngine(GTPushEngineImpl()).initialize(
this, PushConfig(isDebugMode = BuildConfig.DEBUG)
)

// =============
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ class BaseApplication : MultiDexApplication() {
)
}

// 极光推送 Engine 实现
DevPushEngine.setEngine(JPushEngineImpl())
// 极光推送初始化
DevPushEngine.getEngine()?.initialize(
this, PushConfig(
isDebugMode = BuildConfig.DEBUG
)
// 极光推送 Engine 实现并初始化
DevPushEngine.setEngine(JPushEngineImpl()).initialize(
this, PushConfig(isDebugMode = BuildConfig.DEBUG)
)

// =============
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class BaseApplication : MultiDexApplication() {

// 使用内部默认实现 Engine
DevEngine.defaultMMKVInitialize(this)
.defaultEngine()
.defaultEngine(DevEngine.getMMKVConfig())

// 友盟分享 Engine 实现
DevShareEngine.setEngine(UMShareEngine())
// 初始化分享配置
DevShareEngine.getEngine()?.initialize(this, shareConfig)
// 友盟分享 Engine 实现并初始化
DevShareEngine.setEngine(UMShareEngine()).initialize(
this, shareConfig
)
}
}

0 comments on commit 013bf3e

Please sign in to comment.