<commit_before>package plugin.google.maps;

import android.annotation.SuppressLint;
import android.content.res.Resources;
import android.util.Log;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.GroundOverlay;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.TileOverlay;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.PluginEntry;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;

public class MyPlugin extends CordovaPlugin implements MyPluginInterface {
  protected HashMap<String, Object> objects;
  public MyPlugin self = null;
  public final HashMap<String, Method> methods = new HashMap<String, Method>();

  public GoogleMaps mapCtrl = null;
  public GoogleMap map = null;
  public PluginMap pluginMap = null;
  public float density = Resources.getSystem().getDisplayMetrics().density;

  public void setPluginMap(PluginMap pluginMap) {
    this.pluginMap = pluginMap;
    this.mapCtrl = pluginMap.mapCtrl;
    this.map = pluginMap.map;
  }
  protected String TAG = "";

  @SuppressLint("UseSparseArrays")
  @Override
  public void initialize(CordovaInterface cordova, final CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.objects = new HashMap<String, Object>();
    TAG = this.getServiceName();
  }
  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    if (methods.size() == 0) {
      self = this;
      TAG = this.getServiceName();
      //Log.d("MyPlugin", "TAG = " + TAG);
      if (!TAG.contains("-")) {
        mapCtrl.mapPlugins.put(TAG, (PluginMap) this);
      } else {
        PluginEntry pluginEntry = new PluginEntry(TAG, this);
        pluginMap.plugins.put(TAG, pluginEntry);
      }


      //CordovaPlugin plugin = mapCtrl.webView.getPluginManager().getPlugin(this.getServiceName());
      //    Log.d("MyPlugin", "---> this = " + this);
      //    Log.d("MyPlugin", "---> plugin = " + plugin);

      Method[] classMethods = self.getClass().getMethods();
      for (Method classMethod : classMethods) {
        methods.put(classMethod.getName(), classMethod);
      }
    }
    //  this.create(args, callbackContext);
    //  return true;
    if (methods.containsKey(action)) {
      self = this;
      if (self.mapCtrl.isDebug) {
        if (args != null && args.length() > 0) {
          Log.d(TAG, "(debug)action=" + action + " args[0]=" + args.getString(0));
        } else {
          Log.d(TAG, "(debug)action=" + action);
        }
      }
      Method method = methods.get(action);
      try {
        method.invoke(self, args, callbackContext);
        return true;
      } catch (IllegalAccessException e) {
        e.printStackTrace();
        callbackContext.error("Cannot access to the '" + action + "' method.");
        return false;
      } catch (InvocationTargetException e) {
        e.printStackTrace();
        callbackContext.error("Cannot access to the '" + action + "' method.");
        return false;
      }
    } else {
      return false;
    }

  }

  protected void create(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
    // dummy
  }

  protected Circle getCircle(String id) {
    return (Circle)this.objects.get(id);
  }<commit_msg>The most code runs in the background thread.<commit_after>package plugin.google.maps;

import android.annotation.SuppressLint;
import android.content.res.Resources;
import android.util.Log;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.GroundOverlay;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.TileOverlay;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.PluginEntry;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;

public class MyPlugin extends CordovaPlugin implements MyPluginInterface {
  protected HashMap<String, Object> objects;
  public MyPlugin self = null;
  public final HashMap<String, Method> methods = new HashMap<String, Method>();

  public GoogleMaps mapCtrl = null;
  public GoogleMap map = null;
  public PluginMap pluginMap = null;
  public float density = Resources.getSystem().getDisplayMetrics().density;

  public void setPluginMap(PluginMap pluginMap) {
    this.pluginMap = pluginMap;
    this.mapCtrl = pluginMap.mapCtrl;
    this.map = pluginMap.map;
  }
  protected String TAG = "";

  @SuppressLint("UseSparseArrays")
  @Override
  public void initialize(CordovaInterface cordova, final CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.objects = new HashMap<String, Object>();
    TAG = this.getServiceName();
  }
  @Override
  public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {


    if (methods.size() == 0) {
      self = this;
      TAG = this.getServiceName();
      //Log.d("MyPlugin", "TAG = " + TAG);
      if (!TAG.contains("-")) {
        mapCtrl.mapPlugins.put(TAG, (PluginMap) this);
      } else {
        PluginEntry pluginEntry = new PluginEntry(TAG, this);
        pluginMap.plugins.put(TAG, pluginEntry);
      }


      //CordovaPlugin plugin = mapCtrl.webView.getPluginManager().getPlugin(this.getServiceName());
      //    Log.d("MyPlugin", "---> this = " + this);
      //    Log.d("MyPlugin", "---> plugin = " + plugin);

      Method[] classMethods = self.getClass().getMethods();
      for (Method classMethod : classMethods) {
        methods.put(classMethod.getName(), classMethod);
      }
    }
    //  this.create(args, callbackContext);
    //  return true;
    if (methods.containsKey(action)) {
      self = this;
      if (self.mapCtrl.isDebug) {
        if (args != null && args.length() > 0) {
          Log.d(TAG, "(debug)action=" + action + " args[0]=" + args.getString(0));
        } else {
          Log.d(TAG, "(debug)action=" + action);
        }
      }
      cordova.getThreadPool().submit(new Runnable() {
        @Override
        public void run() {
          Method method = methods.get(action);
          try {
            method.invoke(self, args, callbackContext);
          } catch (IllegalAccessException e) {
            e.printStackTrace();
            callbackContext.error("Cannot access to the '" + action + "' method.");
          } catch (InvocationTargetException e) {
            e.printStackTrace();
            callbackContext.error("Cannot access to the '" + action + "' method.");
          }
        }
      });
      return true;
    } else {
      return false;
    }

  }

  protected void create(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
    // dummy
  }

  protected Circle getCircle(String id) {
    return (Circle)this.objects.get(id);
  }
{'fraction_non_alphanumeric': 0.12506400409626217, 'fraction_numerical': 0.0010240655401945725, 'mean_word_length': 3.2624113475177303, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '4882691', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2286, 'n_words': 500}