<commit_before>/**
 * Copyright 2009 <NAME>
 */

package com.joelapenna.foursquared;

import com.googlecode.dumpcatcher.logging.Dumpcatcher;
import com.googlecode.dumpcatcher.logging.DumpcatcherUncaughtExceptionHandler;
import com.joelapenna.foursquare.Foursquare;
import com.joelapenna.foursquare.error.FoursquareCredentialsError;
import com.joelapenna.foursquared.maps.BestLocationListener;
import com.joelapenna.foursquared.util.RemoteResourceManager;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationManager;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;

import java.lang.Thread.UncaughtExceptionHandler;
import java.util.List;

/**
 * @author <NAME> (<EMAIL>)
 */
public class Foursquared extends Application {
    public static final String TAG = "Foursquared";
    public static final boolean DEBUG = FoursquaredSettings.DEBUG;

    public static final String INTENT_ACTION_LOGGED_OUT = "com.joelapenna.foursquared.intent.action.LOGGED_OUT";

    // Common menu items
    private static final int MENU_PREFERENCES = -1;
    private static final int MENU_GROUP_SYSTEM = 20;

    private Dumpcatcher mDumpcatcher;

    private LocationListener mLocationListener = new LocationListener();

    private SharedPreferences mPrefs;

    private static Foursquare sFoursquare;
    private static RemoteResourceManager sUserPhotoManager;
    private static RemoteResourceManager sBadgeIconManager;

    @Override
    public void onCreate() {
        mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

        if (FoursquaredSettings.USE_DUMPCATCHER) {
            setupDumpcatcher();
        }

        sFoursquare = new Foursquare();
        sUserPhotoManager = new RemoteResourceManager("user_photo");
        sBadgeIconManager = new RemoteResourceManager("badges");

        // Set the oauth credentials.
        sFoursquare.setOAuthConsumerCredentials( //
                getResources().getString(R.string.oauth_consumer_key), //
                getResources().getString(R.string.oauth_consumer_secret));
        mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

        try {
            loadCredentials();
        } catch (FoursquareCredentialsError e) {
            // We're not doing anything because hopefully our related activities
            // will handle the failure. This is simply convenience.
        }
    }

    @Override
    public void onTerminate() {
        sFoursquare = null;

        sUserPhotoManager.shutdown();
        sUserPhotoManager = null;

        sBadgeIconManager.shutdown();<commit_msg>Don't crash creating resource managers if there is no SD card.<commit_after>/**
 * Copyright 2009 <NAME>
 */

package com.joelapenna.foursquared;

import com.googlecode.dumpcatcher.logging.Dumpcatcher;
import com.googlecode.dumpcatcher.logging.DumpcatcherUncaughtExceptionHandler;
import com.joelapenna.foursquare.Foursquare;
import com.joelapenna.foursquare.error.FoursquareCredentialsError;
import com.joelapenna.foursquared.maps.BestLocationListener;
import com.joelapenna.foursquared.util.RemoteResourceManager;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationManager;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;

import java.lang.Thread.UncaughtExceptionHandler;
import java.util.List;

/**
 * @author <NAME> (<EMAIL>)
 */
public class Foursquared extends Application {
    public static final String TAG = "Foursquared";
    public static final boolean DEBUG = FoursquaredSettings.DEBUG;

    public static final String INTENT_ACTION_LOGGED_OUT = "com.joelapenna.foursquared.intent.action.LOGGED_OUT";

    // Common menu items
    private static final int MENU_PREFERENCES = -1;
    private static final int MENU_GROUP_SYSTEM = 20;

    private Dumpcatcher mDumpcatcher;

    private LocationListener mLocationListener = new LocationListener();

    private SharedPreferences mPrefs;

    private static Foursquare sFoursquare;
    private static RemoteResourceManager sUserPhotoManager;
    private static RemoteResourceManager sBadgeIconManager;

    @Override
    public void onCreate() {
        mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

        if (FoursquaredSettings.USE_DUMPCATCHER) {
            setupDumpcatcher();
        }

        sFoursquare = new Foursquare();

        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            sUserPhotoManager = new RemoteResourceManager("user_photo");
            sBadgeIconManager = new RemoteResourceManager("badges");
        }

        // Set the oauth credentials.
        sFoursquare.setOAuthConsumerCredentials( //
                getResources().getString(R.string.oauth_consumer_key), //
                getResources().getString(R.string.oauth_consumer_secret));
        mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

        try {
            loadCredentials();
        } catch (FoursquareCredentialsError e) {
            // We're not doing anything because hopefully our related activities
            // will handle the failure. This is simply convenience.
        }
    }

    @Override
    public void onTerminate() {
        sFoursquare = null;

        sUserPhotoManager.shutdown();
        sUserPhotoManager = null;

        sBadgeIconManager.shutdown();
{'fraction_non_alphanumeric': 0.08122503328894808, 'fraction_numerical': 0.002330226364846871, 'mean_word_length': 3.799520766773163, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3828900', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1643, 'n_words': 355}