<commit_before>package jsettlers.main.android;

import go.graphics.android.AndroidSoundPlayer;
import go.graphics.android.GOSurfaceView;
import go.graphics.area.Area;
import go.graphics.region.Region;

import java.io.File;

import jsettlers.common.map.IGraphicsGrid;
import jsettlers.common.resources.ResourceManager;
import jsettlers.common.statistics.IStatisticable;
import jsettlers.graphics.map.MapContent;
import jsettlers.graphics.map.MapInterfaceConnector;
import jsettlers.graphics.map.draw.ImageProvider;
import jsettlers.graphics.sound.SoundManager;
import jsettlers.graphics.startscreen.IStartScreenConnector;
import jsettlers.main.ManagedJSettlers;
import jsettlers.main.android.bg.BgControls;
import jsettlers.main.android.bg.BgMap;
import jsettlers.main.android.bg.BgStats;
import jsettlers.main.android.fragments.GameCommandFragment;
import jsettlers.main.android.fragments.JsettlersFragment;
import jsettlers.main.android.fragments.StartScreenFragment;
import jsettlers.main.android.resources.ResourceProvider;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Environment;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

public class JsettlersActivity extends Activity {

	private static final int SOUND_THREADS = 6;
	private ManagedJSettlers manager;
	private IStartScreenConnector connector;
	private GOSurfaceView goView;
	private Region goRegion;
	private AndroidSoundPlayer soundPlayer;
	private boolean glInForeground;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		keepScreenOn();
		setContentView(R.layout.base);
		System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
		addImageLookups();

		goRegion = new Region(Region.POSITION_CENTER);
		Area goArea = new Area();
		goArea.add(goRegion);
		goView = new GOSurfaceView(this, goArea);
		((FrameLayout) findViewById(R.id.base_gl)).addView(goView);
		soundPlayer = new AndroidSoundPlayer(SOUND_THREADS);

		getManager().start(new JsettlersActivityDisplay(this));

		showBgMap();
	}

	@Override
	protected void onStart() {
		super.onStart();
	}

	@Override
	protected void onResume() {
		super.onResume();
		goView.onResume();
		soundPlayer.setPaused(false);
	}

	@Override
	protected void onPause() {
		super.onPause();
		goView.onPause();
		soundPlayer.setPaused(true);

		if (!goView.canPreserveContext()) {
			ImageProvider.getInstance().invalidateAll();
		}
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();

		getManager().stop();
		manager = null;

		goRegion = null;<commit_msg>Fixed the problems with gl context destruction by adding a destruction listener. Fixes #115<commit_after>package jsettlers.main.android;

import go.graphics.android.AndroidSoundPlayer;
import go.graphics.android.GOSurfaceView;
import go.graphics.android.IContextDestroyedListener;
import go.graphics.area.Area;
import go.graphics.region.Region;

import java.io.File;

import jsettlers.common.map.IGraphicsGrid;
import jsettlers.common.resources.ResourceManager;
import jsettlers.common.statistics.IStatisticable;
import jsettlers.graphics.map.MapContent;
import jsettlers.graphics.map.MapInterfaceConnector;
import jsettlers.graphics.map.draw.ImageProvider;
import jsettlers.graphics.sound.SoundManager;
import jsettlers.graphics.startscreen.IStartScreenConnector;
import jsettlers.main.ManagedJSettlers;
import jsettlers.main.android.bg.BgControls;
import jsettlers.main.android.bg.BgMap;
import jsettlers.main.android.bg.BgStats;
import jsettlers.main.android.fragments.GameCommandFragment;
import jsettlers.main.android.fragments.JsettlersFragment;
import jsettlers.main.android.fragments.StartScreenFragment;
import jsettlers.main.android.resources.ResourceProvider;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Environment;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

public class JsettlersActivity extends Activity {

	private static final int SOUND_THREADS = 6;
	private ManagedJSettlers manager;
	private IStartScreenConnector connector;
	private GOSurfaceView goView;
	private Region goRegion;
	private AndroidSoundPlayer soundPlayer;
	private boolean glInForeground;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		keepScreenOn();
		setContentView(R.layout.base);
		System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
		addImageLookups();

		goRegion = new Region(Region.POSITION_CENTER);
		Area goArea = new Area();
		goArea.add(goRegion);
		goView = new GOSurfaceView(this, goArea);
		((FrameLayout) findViewById(R.id.base_gl)).addView(goView);
		soundPlayer = new AndroidSoundPlayer(SOUND_THREADS);

		getManager().start(new JsettlersActivityDisplay(this));

		showBgMap();
	}

	@Override
	protected void onStart() {
		super.onStart();
	}

	@Override
	protected void onResume() {
		super.onResume();
		goView.onResume();
		soundPlayer.setPaused(false);
	}

	@Override
	protected void onPause() {
		super.onPause();
		goView.onPause();
		soundPlayer.setPaused(true);

		goView.setContextDestroyedListener(new IContextDestroyedListener() {
			@Override
			public void glContextDestroyed() {
				ImageProvider.getInstance().invalidateAll();
			}
		});
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();

		getManager().stop();
		manager = null;

		goRegion = null;
{'fraction_non_alphanumeric': 0.10452173913043478, 'fraction_numerical': 0.001565217391304348, 'mean_word_length': 5.9963503649635035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4326352', 'n_tokens_mistral': 1929, 'n_tokens_neox': 1764, 'n_words': 332}