<commit_before>package cgeo.geocaching;

import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.AbstractListActivity;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
import cgeo.geocaching.apps.cachelist.CacheListAppFactory;
import cgeo.geocaching.enumerations.CacheListType;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.files.GPXImporter;
import cgeo.geocaching.filter.FilterBySize;
import cgeo.geocaching.filter.FilterByTrackables;
import cgeo.geocaching.filter.FilterByType;
import cgeo.geocaching.filter.IFilter;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.CGeoMap;
import cgeo.geocaching.sorting.CacheComparator;
import cgeo.geocaching.sorting.DateComparator;
import cgeo.geocaching.sorting.DifficultyComparator;
import cgeo.geocaching.sorting.FindsComparator;
import cgeo.geocaching.sorting.GeocodeComparator;
import cgeo.geocaching.sorting.InventoryComparator;
import cgeo.geocaching.sorting.NameComparator;
import cgeo.geocaching.sorting.PopularityComparator;
import cgeo.geocaching.sorting.RatingComparator;
import cgeo.geocaching.sorting.SizeComparator;
import cgeo.geocaching.sorting.StateComparator;
import cgeo.geocaching.sorting.TerrainComparator;
import cgeo.geocaching.sorting.VisitComparator;
import cgeo.geocaching.sorting.VoteComparator;
import cgeo.geocaching.utils.RunnableWithArgument;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class cgeocaches extends AbstractListActivity {

    private static final int MAX_LIST_ITEMS = 1000;
    private static final String EXTRAS_LIST_TYPE = "type";
    private static final int MENU_COMPASS = 1;
    private static final int MENU_REFRESH_STORED = 2;
    private static final int MENU_CACHE_DETAILS = 4;
    private static final int MENU_DROP_CACHES = 5;
    private static final int MENU_IMPORT_GPX = 6;
    private static final int MENU_CREATE_LIST = 7;
    private static final int MENU_DROP_LIST = 8;
    private static final int MENU_INVERT_SELECTION = 9;
    private static final int MENU_SORT_DISTANCE = 10;
    private static final int MENU_SORT_DIFFICULTY = 11;
    private static final int MENU_SORT_TERRAIN = 12;
    private static final int MENU_SORT_SIZE = 13;
    private static final int MENU_SORT_FAVORITES = 14;
    private static final int MENU_SORT_NAME = 15;
    private static final int MENU_SORT_GEOCODE = 16;
    private static final int MENU_SWITCH_LIST = 17;
    private static final int MENU_SORT_RATING = 18;
    private static final int MENU_SORT_VOTE = 19;
    private static final int MENU_SORT_INVENTORY = 20;
    private static final int MENU_IMPORT_WEB = 21;
    private static final int MENU_EXPORT_NOTES = 22;
    private static final int MENU_REMOVE_FROM_HISTORY = 23;
    private static final int MENU_DROP_CACHE = 24;
    private static final int MENU_MOVE_TO_LIST = 25;
    private static final int MENU_FILTER_CLEAR = 26;
    private static final int MENU_FILTER_TRACKABLES = 27;
    private static final int SUBMENU_FILTER_SIZE = 28;
    private static final int SUBMENU_FILTER_TYPE = 29;
    private static final int MENU_SWITCH_SELECT_MODE = 52;
    private static final int SUBMENU_SHOW_MAP = 54;
    private static final int SUBMENU_MANAGE_LISTS = 55;
    private static final int SUBMENU_MANAGE_OFFLINE = 56;
    private static final int SUBMENU_SORT = 57;
    private static final int SUBMENU_FILTER = 58;
    private static final int SUBMENU_IMPORT = 59;
    private static final int SUBMENU_MANAGE_HISTORY = 60;
    private static final int MENU_SORT_DATE = 61;
    private static final int MENU_SORT_FINDS = 62;
    private static final int MENU_SORT_STATE = 63;
    private static final int MENU_RENAME_LIST = 64;
    private static final int MENU_DROP_CACHES_AND_LIST = 65;

    private static final int CONTEXT_MENU_MOVE_TO_LIST = 1000;

    private String action = null;
    private CacheListType type = null;
    private Geopoint coords = null;
    private CacheType cacheType = null;
    private String keyword = null;
    private String address = null;
    private String username = null;
    private cgSearch search = null;
    private List<cgCache> cacheList = new ArrayList<cgCache>();
    private CacheListAdapter adapter = null;
    private LayoutInflater inflater = null;
    private View listFooter = null;
    private TextView listFooterText = null;
    private ProgressDialog waitDialog = null;
    private Float northHeading = 0f;
    private cgGeo geo = null;
    private cgDirection dir = null;
    private UpdateLocationCallback geoUpdate = new UpdateLocation();
    private UpdateDirectionCallback dirUpdate = new UpdateDirection();
    private String title = "";
    private int detailTotal = 0;<commit_msg>fix: NPE with CacheType (on resuming activity)<commit_after>package cgeo.geocaching;

import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.AbstractListActivity;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
import cgeo.geocaching.apps.cachelist.CacheListAppFactory;
import cgeo.geocaching.enumerations.CacheListType;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.files.GPXImporter;
import cgeo.geocaching.filter.FilterBySize;
import cgeo.geocaching.filter.FilterByTrackables;
import cgeo.geocaching.filter.FilterByType;
import cgeo.geocaching.filter.IFilter;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.CGeoMap;
import cgeo.geocaching.sorting.CacheComparator;
import cgeo.geocaching.sorting.DateComparator;
import cgeo.geocaching.sorting.DifficultyComparator;
import cgeo.geocaching.sorting.FindsComparator;
import cgeo.geocaching.sorting.GeocodeComparator;
import cgeo.geocaching.sorting.InventoryComparator;
import cgeo.geocaching.sorting.NameComparator;
import cgeo.geocaching.sorting.PopularityComparator;
import cgeo.geocaching.sorting.RatingComparator;
import cgeo.geocaching.sorting.SizeComparator;
import cgeo.geocaching.sorting.StateComparator;
import cgeo.geocaching.sorting.TerrainComparator;
import cgeo.geocaching.sorting.VisitComparator;
import cgeo.geocaching.sorting.VoteComparator;
import cgeo.geocaching.utils.RunnableWithArgument;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class cgeocaches extends AbstractListActivity {

    private static final int MAX_LIST_ITEMS = 1000;
    private static final String EXTRAS_LIST_TYPE = "type";
    private static final int MENU_COMPASS = 1;
    private static final int MENU_REFRESH_STORED = 2;
    private static final int MENU_CACHE_DETAILS = 4;
    private static final int MENU_DROP_CACHES = 5;
    private static final int MENU_IMPORT_GPX = 6;
    private static final int MENU_CREATE_LIST = 7;
    private static final int MENU_DROP_LIST = 8;
    private static final int MENU_INVERT_SELECTION = 9;
    private static final int MENU_SORT_DISTANCE = 10;
    private static final int MENU_SORT_DIFFICULTY = 11;
    private static final int MENU_SORT_TERRAIN = 12;
    private static final int MENU_SORT_SIZE = 13;
    private static final int MENU_SORT_FAVORITES = 14;
    private static final int MENU_SORT_NAME = 15;
    private static final int MENU_SORT_GEOCODE = 16;
    private static final int MENU_SWITCH_LIST = 17;
    private static final int MENU_SORT_RATING = 18;
    private static final int MENU_SORT_VOTE = 19;
    private static final int MENU_SORT_INVENTORY = 20;
    private static final int MENU_IMPORT_WEB = 21;
    private static final int MENU_EXPORT_NOTES = 22;
    private static final int MENU_REMOVE_FROM_HISTORY = 23;
    private static final int MENU_DROP_CACHE = 24;
    private static final int MENU_MOVE_TO_LIST = 25;
    private static final int MENU_FILTER_CLEAR = 26;
    private static final int MENU_FILTER_TRACKABLES = 27;
    private static final int SUBMENU_FILTER_SIZE = 28;
    private static final int SUBMENU_FILTER_TYPE = 29;
    private static final int MENU_SWITCH_SELECT_MODE = 52;
    private static final int SUBMENU_SHOW_MAP = 54;
    private static final int SUBMENU_MANAGE_LISTS = 55;
    private static final int SUBMENU_MANAGE_OFFLINE = 56;
    private static final int SUBMENU_SORT = 57;
    private static final int SUBMENU_FILTER = 58;
    private static final int SUBMENU_IMPORT = 59;
    private static final int SUBMENU_MANAGE_HISTORY = 60;
    private static final int MENU_SORT_DATE = 61;
    private static final int MENU_SORT_FINDS = 62;
    private static final int MENU_SORT_STATE = 63;
    private static final int MENU_RENAME_LIST = 64;
    private static final int MENU_DROP_CACHES_AND_LIST = 65;

    private static final int CONTEXT_MENU_MOVE_TO_LIST = 1000;

    private String action = null;
    private CacheListType type = null;
    private Geopoint coords = null;
    private CacheType cacheType = Settings.getCacheType();
    private String keyword = null;
    private String address = null;
    private String username = null;
    private cgSearch search = null;
    private List<cgCache> cacheList = new ArrayList<cgCache>();
    private CacheListAdapter adapter = null;
    private LayoutInflater inflater = null;
    private View listFooter = null;
    private TextView listFooterText = null;
    private ProgressDialog waitDialog = null;
    private Float northHeading = 0f;
    private cgGeo geo = null;
    private cgDirection dir = null;
    private UpdateLocationCallback geoUpdate = new UpdateLocation();
    private UpdateDirectionCallback dirUpdate = new UpdateDirection();
    private String title = "";
    private int detailTotal = 0;
{'fraction_non_alphanumeric': 0.06674117834903401, 'fraction_numerical': 0.01357177071690883, 'mean_word_length': 5.051690821256039, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7646517', 'n_tokens_mistral': 4079, 'n_tokens_neox': 3914, 'n_words': 1015}