优化搜索展示过程,离开搜索页暂停搜索线程池,回到搜索页时继续线程池任务

pull/123/head
Dehong 3 years ago
parent f59316be36
commit 026cdd0ded
  1. 3
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/CollectActivity.java

@ -125,7 +125,8 @@ public class CollectActivity extends BaseActivity {
mAdapter.add(Collect.all());
mPageAdapter.notifyDataSetChanged();
int core = Runtime.getRuntime().availableProcessors();
mExecutor = new PausableThreadPoolExecutor(Math.max(Constant.THREAD_POOL, core), core * 2, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
int corePoolSize = Math.max(Constant.THREAD_POOL, core);
mExecutor = new PausableThreadPoolExecutor(corePoolSize, corePoolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
mBinding.result.setText(getString(R.string.collect_result, getKeyword()));
for (Site site : mSites) mExecutor.execute(() -> search(site));
}

Loading…
Cancel
Save