<commit_before>// Copyright eeGeo Ltd (2012-2014), All Rights Reserved

#include "AppRunner.h"
#include "Graphics.h"
#include "AndroidThreadHelper.h"
#include "AndroidAppThreadAssertionMacros.h"

AppRunner::AppRunner
(
    AndroidNativeState* pNativeState
)
	: m_pNativeState(pNativeState)
	, m_pAppHost(NULL)
	, m_updatingNative(true)
{
	ASSERT_NATIVE_THREAD

	Eegeo::Helpers::ThreadHelpers::SetThisThreadAsMainThread();
}

AppRunner::~AppRunner()
{
	ASSERT_NATIVE_THREAD

	bool destroyEGL = true;
	m_displayService.ReleaseDisplay(destroyEGL);

	if(m_pAppHost != NULL)
	{
		Eegeo_DELETE(m_pAppHost);
	}
}

void AppRunner::CreateAppHost()
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost == NULL && m_displayService.IsDisplayAvailable())
	{
		m_pAppHost = Eegeo_NEW(AppHost)
		             (
		                 *m_pNativeState,
		                 m_displayService.GetDisplayWidth(),
		                 m_displayService.GetDisplayHeight(),
		                 m_displayService.GetDisplay(),
		                 m_displayService.GetSharedSurface(),
		                 m_displayService.GetResourceBuildSharedContext()
		             );
	}
}

void AppRunner::Pause()
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost != NULL)
	{
		m_pAppHost->OnPause();
	}

	ReleaseDisplay();
}

void AppRunner::Resume()
{
	if(m_pAppHost != NULL)
	{
		m_pAppHost->OnResume();
	}
}

void AppRunner::ActivateSurface()
{
	ASSERT_NATIVE_THREAD

	ReleaseDisplay();
	bool displayBound = TryBindDisplay();
	Eegeo_ASSERT(displayBound, "Failed to bind display");
	CreateAppHost();
}

void AppRunner::HandleTouchEvent(const Eegeo::Android::Input::TouchInputEvent& event)
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost != NULL)<commit_msg>Missing assertion in AppRunner<commit_after>// Copyright eeGeo Ltd (2012-2014), All Rights Reserved

#include "AppRunner.h"
#include "Graphics.h"
#include "AndroidThreadHelper.h"
#include "AndroidAppThreadAssertionMacros.h"

AppRunner::AppRunner
(
    AndroidNativeState* pNativeState
)
	: m_pNativeState(pNativeState)
	, m_pAppHost(NULL)
	, m_updatingNative(true)
{
	ASSERT_NATIVE_THREAD

	Eegeo::Helpers::ThreadHelpers::SetThisThreadAsMainThread();
}

AppRunner::~AppRunner()
{
	ASSERT_NATIVE_THREAD

	bool destroyEGL = true;
	m_displayService.ReleaseDisplay(destroyEGL);

	if(m_pAppHost != NULL)
	{
		Eegeo_DELETE(m_pAppHost);
	}
}

void AppRunner::CreateAppHost()
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost == NULL && m_displayService.IsDisplayAvailable())
	{
		m_pAppHost = Eegeo_NEW(AppHost)
		             (
		                 *m_pNativeState,
		                 m_displayService.GetDisplayWidth(),
		                 m_displayService.GetDisplayHeight(),
		                 m_displayService.GetDisplay(),
		                 m_displayService.GetSharedSurface(),
		                 m_displayService.GetResourceBuildSharedContext()
		             );
	}
}

void AppRunner::Pause()
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost != NULL)
	{
		m_pAppHost->OnPause();
	}

	ReleaseDisplay();
}

void AppRunner::Resume()
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost != NULL)
	{
		m_pAppHost->OnResume();
	}
}

void AppRunner::ActivateSurface()
{
	ASSERT_NATIVE_THREAD

	ReleaseDisplay();
	bool displayBound = TryBindDisplay();
	Eegeo_ASSERT(displayBound, "Failed to bind display");
	CreateAppHost();
}

void AppRunner::HandleTouchEvent(const Eegeo::Android::Input::TouchInputEvent& event)
{
	ASSERT_NATIVE_THREAD

	if(m_pAppHost != NULL)
{'fraction_non_alphanumeric': 0.11235294117647059, 'fraction_numerical': 0.004705882352941176, 'mean_word_length': 4.053491827637444, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6168039', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1153, 'n_words': 161}