将部分数据库操作移动到工作线程

This commit is contained in:
juntao
2020-12-23 18:11:27 +08:00
parent 324aaa5056
commit 9374fc5264
2 changed files with 10 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package com.gh.gamecenter.manager;
import android.content.Context;
import com.gh.common.AppExecutor;
import com.gh.common.exposure.meta.MetaUtil;
import com.gh.common.loghub.LoghubUtils;
import com.gh.common.util.Installation;
@ -37,12 +38,14 @@ public class DataCollectionManager {
}
public static void onEvent(Context context, String type, Map<String, Object> map, boolean isUpload) {
map.put("createdOn", Utils.getTime(context));
if (isUpload) {
DataCollectionManager.getInstance(context).realTimeUpload(type, map);
} else {
onEvent(context, type, new JSONObject(map).toString(), false);
}
AppExecutor.getLightWeightIoExecutor().execute(() -> {
map.put("createdOn", Utils.getTime(context));
if (isUpload) {
DataCollectionManager.getInstance(context).realTimeUpload(type, map);
} else {
onEvent(context, type, new JSONObject(map).toString(), false);
}
});
}
/*

View File

@ -91,7 +91,7 @@ public class FilterManager {
}
RetrofitManager.getInstance(mContext).getApi().getPackageUsed(UrlFilterUtils.getFilterQuery("since", String.valueOf(since)), skip)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.observeOn(Schedulers.io())
.subscribe(new Response<List<PackageEntity>>() {
@Override
public void onResponse(List<PackageEntity> response) {