Skip to content

Commit

Permalink
修改api库
Browse files Browse the repository at this point in the history
  • Loading branch information
ktdynamic committed Jun 18, 2020
1 parent 9d5f59d commit 82b7f3e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion litedb-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ publish {
userOrg = rootProject.userOrg//bintray.com用户名
groupId = rootProject.groupId//jcenter上的路径
uploadName = artifactId//项目名称
publishVersion = "1.0.2"//版本号
publishVersion = "1.0.3"//版本号
desc = "a easy db api to use for Android X "//项目介绍
website = rootProject.website//项目主页
licences = rootProject.licences
Expand Down
2 changes: 1 addition & 1 deletion litedb-api/src/main/java/com/jy/litedb/api/BaseDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open class BaseDao<T : Any> constructor(private var subClass: Class<T>) : BaseSu
private var hashMap: HashMap<String, FieldInfo> = LoaderFieldInfo.getFieldMapInfo(subClass)

init {
// dbConfig = DBConfig.beginBuilder().build()
dbConfig = LoaderFieldInfo.dbConfig
}

override val tableName: String
Expand Down
3 changes: 2 additions & 1 deletion litedb-api/src/main/java/com/jy/litedb/api/DBManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ class DBManager {
private var mDatabaseHelper: BaseOpenHelper? = null

@Synchronized
fun init(helper: BaseOpenHelper) {
fun init(helper: BaseOpenHelper, dbConfig: DBConfig) {
if (instance == null) {
instance = DBManager()
mDatabaseHelper = helper
//多线程读写
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mDatabaseHelper!!.setWriteAheadLoggingEnabled(true)
}
LoaderFieldInfo.dbConfig = dbConfig
}
}

Expand Down
10 changes: 10 additions & 0 deletions litedb-api/src/main/java/com/jy/litedb/api/LoaderFieldInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class LoaderFieldInfo {
public static HashMap<String, HashMap<String, FieldInfo>> hashMap = new HashMap<>();

public static String dexFileName = null;
public static DBConfig dbConfig = null;

private static final LazyInitHelper sInitHelper = new LazyInitHelper("LoaderFieldInfo") {
@Override
Expand Down Expand Up @@ -66,6 +67,15 @@ public static void openDexFileLoaderService(Context context) {
dexFileName = context.getPackageCodePath();
}

/**
* 设置配置文件
*
* @param config
*/
public static void setDbConfig(DBConfig config) {
dbConfig = config;
}

public static HashMap<String, FieldInfo> getFieldMapInfo(Class cls) {
HashMap<String, FieldInfo> map = hashMap.get(cls.getSimpleName());
if (map == null) {
Expand Down

0 comments on commit 82b7f3e

Please sign in to comment.