Merge branch 'fix/diverter-timeout' into 'dev'

fix: 修复分流器因为自身原因有一定概率超时的问题

See merge request halo/android/assistant-android!1894
This commit is contained in:
陈君陶
2024-09-14 16:18:36 +08:00
3 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.gh.gamecenter.wrapper
import android.annotation.SuppressLint
import androidx.annotation.WorkerThread
import androidx.lifecycle.MutableLiveData
import com.gh.common.util.HomeBottomBarHelper
import com.gh.common.util.NewFlatLogUtils
@ -152,7 +153,7 @@ class MainWrapperRepository {
fun getBypassList() {
val isInstallFirstAccess = TimeUtils.isToday(SPUtils.getLong(Constants.SP_BRAND_NEW_FIRST_LAUNCH_TIME) / 1000).toString()
mNewApi.getDiverterList(isInstallFirstAccess, BYPASS_TYPE_BOTTOM_TAB)
.subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.computation())
.timeout(BYPASS_TIME_OUT, TimeUnit.MILLISECONDS)
.subscribe(object : BiResponse<List<DiverterEntity>>() {
override fun onSuccess(data: List<DiverterEntity>) {
@ -173,13 +174,13 @@ class MainWrapperRepository {
}
@SuppressLint("CheckResult")
fun getDataUnion() {
@WorkerThread
private fun getDataUnion() {
var diverter = ""
diverterList.forEach {
diverter += "${it.moduleIndex}:${it.diverterData.branchId},"
}
mNewApi.getDataUnion(diverter)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<DataUnionEntity>() {
override fun onSuccess(data: DataUnionEntity) {
processBottomTabData(data.bottomTab)

View File

@ -260,6 +260,7 @@ public class HaloApp extends MultiDexApplication {
});
RxJavaPlugins.setIoSchedulerHandler(scheduler -> AppExecutor.INSTANCE.getCachedScheduler());
RxJavaPlugins.setComputationSchedulerHandler(scheduler -> AppExecutor.INSTANCE.getComputationScheduler());
if (isUserAcceptPrivacyPolicy(this)) {
postInit(false);

View File

@ -64,6 +64,7 @@ object AppExecutor {
}
val cachedScheduler by lazy { Schedulers.from(ioExecutor) }
val computationScheduler by lazy { Schedulers.from(heavyWeightIoExecutor) }
class MainThreadExecutor : Executor {
private val mainThreadHandler = Handler(Looper.getMainLooper())