diff --git a/accountcache/consumer-rules.pro b/accountcache/consumer-rules.pro index fef86b6..8a5c795 100644 --- a/accountcache/consumer-rules.pro +++ b/accountcache/consumer-rules.pro @@ -14,3 +14,4 @@ public static java.lang.String TABLENAME; -keep class rx.** { *; } -keep class com.facebook.flipper.** { *; } -keep class com.facebook.jni.** { *; } +-keep @org.greenrobot.greendao.annotation.Entity class * {*;} diff --git a/accountcache/src/main/java/com/hss01248/accountcache/AccountCacher.java b/accountcache/src/main/java/com/hss01248/accountcache/AccountCacher.java index 8d6b4b2..4568b67 100644 --- a/accountcache/src/main/java/com/hss01248/accountcache/AccountCacher.java +++ b/accountcache/src/main/java/com/hss01248/accountcache/AccountCacher.java @@ -4,6 +4,8 @@ import android.app.AlertDialog; import android.app.Application; import android.content.DialogInterface; +import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Base64; import android.widget.Toast; @@ -95,9 +97,19 @@ public static void selectAccount(int hostType, FragmentActivity activity, String @Override public void onGranted(List permissions, boolean all) { - List accounts = MyDbUtil.getAll(hostType, countryCode); + new Thread(new Runnable() { + @Override + public void run() { + List accounts = MyDbUtil.getAll(hostType, countryCode); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + showSelectAccountDialog(hostType, activity, countryCode, accounts, callback); + } + }); + } + }).start(); - showSelectAccountDialog(hostType, activity, countryCode, accounts, callback); } @Override @@ -207,29 +219,32 @@ public static void saveAccount(Activity activity, int currentHostType, final Str @Override public void onGranted(List permissions, boolean all) { - - - List list = MyDbUtil.getDaoSession().getDebugAccountDao() - .queryBuilder().where(DebugAccountDao.Properties.Account.eq(account) - , DebugAccountDao.Properties.CountryCode.eq(countryCode) - , DebugAccountDao.Properties.HostType.eq(currentHostType)).list(); - if (list == null || list.isEmpty()) { - DebugAccount debugAccount = new DebugAccount(); - debugAccount.account = account; - debugAccount.pw = pw; - debugAccount.updateTime = System.currentTimeMillis(); - debugAccount.position = 0; - debugAccount.countryCode = countryCode; - debugAccount.hostType = currentHostType; - debugAccount.usedNum = 1; - MyDbUtil.getDaoSession().getDebugAccountDao().insert(debugAccount); - } else { - DebugAccount debugAccount = list.get(0); - debugAccount.usedNum = debugAccount.usedNum + 1; - debugAccount.pw = pw; - debugAccount.updateTime = System.currentTimeMillis(); - MyDbUtil.getDaoSession().getDebugAccountDao().update(debugAccount); - } + new Thread(new Runnable() { + @Override + public void run() { + List list = MyDbUtil.getDaoSession().getDebugAccountDao() + .queryBuilder().where(DebugAccountDao.Properties.Account.eq(account) + , DebugAccountDao.Properties.CountryCode.eq(countryCode) + , DebugAccountDao.Properties.HostType.eq(currentHostType)).list(); + if (list == null || list.isEmpty()) { + DebugAccount debugAccount = new DebugAccount(); + debugAccount.account = account; + debugAccount.pw = pw; + debugAccount.updateTime = System.currentTimeMillis(); + debugAccount.position = 0; + debugAccount.countryCode = countryCode; + debugAccount.hostType = currentHostType; + debugAccount.usedNum = 1; + MyDbUtil.getDaoSession().getDebugAccountDao().insert(debugAccount); + } else { + DebugAccount debugAccount = list.get(0); + debugAccount.usedNum = debugAccount.usedNum + 1; + debugAccount.pw = pw; + debugAccount.updateTime = System.currentTimeMillis(); + MyDbUtil.getDaoSession().getDebugAccountDao().update(debugAccount); + } + } + }).start(); } @Override diff --git a/accountcache/src/main/java/com/hss01248/accountcache/MyDbUtil.java b/accountcache/src/main/java/com/hss01248/accountcache/MyDbUtil.java index bed3c0c..6484eef 100644 --- a/accountcache/src/main/java/com/hss01248/accountcache/MyDbUtil.java +++ b/accountcache/src/main/java/com/hss01248/accountcache/MyDbUtil.java @@ -27,7 +27,13 @@ private static void initGreenDao(Application context) { DaoMaster daoMaster = new DaoMaster(db); daoSession = daoMaster.newSession(); //兼容旧数据迁移情况 - moveOldData(context); + new Thread(new Runnable() { + @Override + public void run() { + moveOldData(context); + } + }).start(); + } private static void moveOldData(Application context) { diff --git a/app/build.gradle b/app/build.gradle index c5196e1..a74d910 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation project(path: ':accountcache') + //debugImplementation 'com.github.hss01248.accountCacher:accountcache:1.1.1' //implementation project(path: ':no-op') testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.2'