<commit_before>package axp.tool.apkextractor;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ApkListAdapter extends RecyclerView.Adapter<ApkListAdapter.ViewHolder> {
	private ArrayList<ApplicationInfo> list                 = new ArrayList<ApplicationInfo>();
	private ArrayList<ApplicationInfo> list_original        = new ArrayList<ApplicationInfo>();
	private ExecutorService            executorServiceNames = Executors.newFixedThreadPool(3);
	private ExecutorService            executorServiceIcons = Executors.newFixedThreadPool(3);
	private Handler                    handler              = new Handler();
	public       MainActivity   mActivity;
	public final PackageManager packageManager;

	int names_to_load = 0;

	private Map<String, String>   cache_appName = Collections.synchronizedMap(new LinkedHashMap<String, String>(10, 1.5f, true));
	private Map<String, Drawable> cache_appIcon = Collections.synchronizedMap(new LinkedHashMap<String, Drawable>(10, 1.5f, true));

	private String search_pattern;

	public ApkListAdapter(MainActivity activity) {
		this.packageManager = activity.getPackageManager();
		mActivity = activity;
	}

	class AppNameLoader implements Runnable {
		private ApplicationInfo applicationInfo;

		public AppNameLoader(ApplicationInfo info) {
			applicationInfo = info;
		}

		@Override
		public void run() {
			cache_appName.put(applicationInfo.packageName, (String)applicationInfo.loadLabel(packageManager));
			handler.post(new Runnable() {
				@Override
				public void run() {
					names_to_load--;
					if (names_to_load == 0) mActivity.hideProgressBar();
				}
			});
		}
	}

	class GuiLoader implements Runnable {
		private ViewHolder      viewHolder;
		private ApplicationInfo applicationInfo;

		public GuiLoader(ViewHolder h, ApplicationInfo info) {
			viewHolder = h;
			applicationInfo = info;
		}

		@Override<commit_msg>automatically kill executorservices<commit_after>package axp.tool.apkextractor;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class ApkListAdapter extends RecyclerView.Adapter<ApkListAdapter.ViewHolder> {
	private ThreadFactory tFactory = new ThreadFactory() {
		@Override
		public Thread newThread(Runnable r) {
			Thread t = new Thread(r);
			t.setDaemon(true);
			return t;
		}
	};

	private ArrayList<ApplicationInfo> list                 = new ArrayList<ApplicationInfo>();
	private ArrayList<ApplicationInfo> list_original        = new ArrayList<ApplicationInfo>();
	private ExecutorService            executorServiceNames = Executors.newFixedThreadPool(3, tFactory);
	private ExecutorService            executorServiceIcons = Executors.newFixedThreadPool(3, tFactory);
	private Handler                    handler              = new Handler();
	public       MainActivity   mActivity;
	public final PackageManager packageManager;

	int names_to_load = 0;

	private Map<String, String>   cache_appName = Collections.synchronizedMap(new LinkedHashMap<String, String>(10, 1.5f, true));
	private Map<String, Drawable> cache_appIcon = Collections.synchronizedMap(new LinkedHashMap<String, Drawable>(10, 1.5f, true));

	private String search_pattern;

	public ApkListAdapter(MainActivity activity) {
		this.packageManager = activity.getPackageManager();
		mActivity = activity;
	}

	class AppNameLoader implements Runnable {
		private ApplicationInfo applicationInfo;

		public AppNameLoader(ApplicationInfo info) {
			applicationInfo = info;
		}

		@Override
		public void run() {
			cache_appName.put(applicationInfo.packageName, (String)applicationInfo.loadLabel(packageManager));
			handler.post(new Runnable() {
				@Override
				public void run() {
					names_to_load--;
					if (names_to_load == 0) {
						mActivity.hideProgressBar();
						executorServiceNames.shutdown();
					}
				}
			});
		}
	}

	class GuiLoader implements Runnable {
		private ViewHolder      viewHolder;
		private ApplicationInfo applicationInfo;

		public GuiLoader(ViewHolder h, ApplicationInfo info) {
			viewHolder = h;
			applicationInfo = info;
		}

		@Override
{'fraction_non_alphanumeric': 0.08759124087591241, 'fraction_numerical': 0.004744525547445255, 'mean_word_length': 4.691588785046729, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7549255', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1501, 'n_words': 341}