File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 2222import java .util .Map ;
2323import java .util .concurrent .ExecutorService ;
2424import java .util .concurrent .Executors ;
25+ import java .util .concurrent .ThreadFactory ;
2526
2627public class ApkListAdapter extends RecyclerView .Adapter <ApkListAdapter .ViewHolder > {
28+ private ThreadFactory tFactory = new ThreadFactory () {
29+ @ Override
30+ public Thread newThread (Runnable r ) {
31+ Thread t = new Thread (r );
32+ t .setDaemon (true );
33+ return t ;
34+ }
35+ };
36+
2737 private ArrayList <ApplicationInfo > list = new ArrayList <ApplicationInfo >();
2838 private ArrayList <ApplicationInfo > list_original = new ArrayList <ApplicationInfo >();
29- private ExecutorService executorServiceNames = Executors .newFixedThreadPool (3 );
30- private ExecutorService executorServiceIcons = Executors .newFixedThreadPool (3 );
39+ private ExecutorService executorServiceNames = Executors .newFixedThreadPool (3 , tFactory );
40+ private ExecutorService executorServiceIcons = Executors .newFixedThreadPool (3 , tFactory );
3141 private Handler handler = new Handler ();
3242 public MainActivity mActivity ;
3343 public final PackageManager packageManager ;
@@ -58,7 +68,10 @@ public void run() {
5868 @ Override
5969 public void run () {
6070 names_to_load --;
61- if (names_to_load == 0 ) mActivity .hideProgressBar ();
71+ if (names_to_load == 0 ) {
72+ mActivity .hideProgressBar ();
73+ executorServiceNames .shutdown ();
74+ }
6275 }
6376 });
6477 }
You can’t perform that action at this time.
0 commit comments