<commit_before>package com.stanfy.app.beans;

import java.net.ContentHandler;
import java.net.ResponseCache;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.Log;

import com.stanfy.DebugFlags;
import com.stanfy.app.ActivityBehaviorFactory;
import com.stanfy.app.CrucialGUIOperationManager;
import com.stanfy.content.AppDatabaseManager;
import com.stanfy.images.ImagesManager;
import com.stanfy.images.cache.ImageFileCache;
import com.stanfy.images.cache.ImageMemoryCache;
import com.stanfy.images.cache.SupportLruImageMemoryCache;
import com.stanfy.io.BuffersPool;
import com.stanfy.serverapi.RemoteServerApiConfiguration;
import com.stanfy.serverapi.request.SimpleRequestBuilder;
import com.stanfy.serverapi.response.handler.GsonContentHandler;
import com.stanfy.serverapi.response.handler.StringContentHandler;
import com.stanfy.serverapi.response.handler.XmlGsonContentHandler;
import com.stanfy.stats.EmptyStatsManager;
import com.stanfy.stats.StatsManager;
import com.stanfy.utils.AppUtils;
import com.stanfy.utils.sdk.SDKDependentUtilsFactory;

/**
 * Beans manager.
 * @author <NAME> (Stanfy - http://stanfy.com)
 */
public class BeansManager {

  /** Debug flag. */
  private static final boolean DEBUG = DebugFlags.DEBUG_GUI;

  /** Logging tag. */
  private static final String TAG = "Beans";

  /** Old SDK flag. */
  private static final boolean OLD_SDK = VERSION.SDK_INT < VERSION_CODES.ICE_CREAM_SANDWICH;

  /** Singleton instance. */
  private static BeansManager instance;

  /** Application instance. */
  private final Application application;

  /** Container. */
  private final BeansContainer container;

  /** Register callbacks flag. */
  private boolean callbacksRegistered = false;

  /** Whether commit is currently performed. */
  private boolean commitInProgress = false;

  /** Postponed edit actions. */
  private LinkedHashMap<String, PutBean> postponedActions;

  protected BeansManager(final Application application) {
    this.application = application;
    this.container = createContainer(application);
  }

  public static synchronized BeansManager get(final Context context) {
    if (instance == null) {
      if (context == null) { return null; }
      instance = new BeansManager((Application)context.getApplicationContext());
    }
    return instance;
  }

  /**
   * Call this method from {@link Application#onLowMemory()} to integrate enroscar on pre-ICS versions.
   * @param context application context
   */
  public static void onLowMemory(final Context context) {
    if (OLD_SDK) {
      get(context).container.onLowMemory();
    }
  }
  /**
   * Call this method from {@link Application#onConfigurationChanged()} to integrate enroscar on pre-ICS versions.
   * @param context application context
   * @param newConfig new configuration
   */
  public static void onConfigurationChanged(final Context context, final Configuration newConfig) {<commit_msg>check application context type<commit_after>package com.stanfy.app.beans;

import java.net.ContentHandler;
import java.net.ResponseCache;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.Log;

import com.stanfy.DebugFlags;
import com.stanfy.app.ActivityBehaviorFactory;
import com.stanfy.app.CrucialGUIOperationManager;
import com.stanfy.content.AppDatabaseManager;
import com.stanfy.images.ImagesManager;
import com.stanfy.images.cache.ImageFileCache;
import com.stanfy.images.cache.ImageMemoryCache;
import com.stanfy.images.cache.SupportLruImageMemoryCache;
import com.stanfy.io.BuffersPool;
import com.stanfy.serverapi.RemoteServerApiConfiguration;
import com.stanfy.serverapi.request.SimpleRequestBuilder;
import com.stanfy.serverapi.response.handler.GsonContentHandler;
import com.stanfy.serverapi.response.handler.StringContentHandler;
import com.stanfy.serverapi.response.handler.XmlGsonContentHandler;
import com.stanfy.stats.EmptyStatsManager;
import com.stanfy.stats.StatsManager;
import com.stanfy.utils.AppUtils;
import com.stanfy.utils.sdk.SDKDependentUtilsFactory;

/**
 * Beans manager.
 * @author <NAME> (Stanfy - http://stanfy.com)
 */
public class BeansManager {

  /** Debug flag. */
  private static final boolean DEBUG = DebugFlags.DEBUG_GUI;

  /** Logging tag. */
  private static final String TAG = "Beans";

  /** Old SDK flag. */
  private static final boolean OLD_SDK = VERSION.SDK_INT < VERSION_CODES.ICE_CREAM_SANDWICH;

  /** Singleton instance. */
  private static BeansManager instance;

  /** Application instance. */
  private final Application application;

  /** Container. */
  private final BeansContainer container;

  /** Register callbacks flag. */
  private boolean callbacksRegistered = false;

  /** Whether commit is currently performed. */
  private boolean commitInProgress = false;

  /** Postponed edit actions. */
  private LinkedHashMap<String, PutBean> postponedActions;

  protected BeansManager(final Application application) {
    this.application = application;
    this.container = createContainer(application);
  }

  public static synchronized BeansManager get(final Context context) {
    if (instance == null) {
      if (context == null) { return null; }
      final Context appContext = context.getApplicationContext();
      if (appContext != null && appContext instanceof Application) {
        instance = new BeansManager((Application) appContext);
      } else if (DEBUG) {
        Log.v(TAG, "Context " + context + " provides wrong application context " + appContext);
      }
    }
    return instance;
  }

  /**
   * Call this method from {@link Application#onLowMemory()} to integrate enroscar on pre-ICS versions.
   * @param context application context
   */
  public static void onLowMemory(final Context context) {
    if (OLD_SDK) {
      get(context).container.onLowMemory();
    }
  }
  /**
   * Call this method from {@link Application#onConfigurationChanged()} to integrate enroscar on pre-ICS versions.
   * @param context application context
   * @param newConfig new configuration
   */
  public static void onConfigurationChanged(final Context context, final Configuration newConfig) {
{'fraction_non_alphanumeric': 0.10003031221582298, 'fraction_numerical': 0.0, 'mean_word_length': 4.52680067001675, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3312597', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1836, 'n_words': 463}