summaryrefslogtreecommitdiff
path: root/src/SFML/System/Android
diff options
context:
space:
mode:
Diffstat (limited to 'src/SFML/System/Android')
-rw-r--r--src/SFML/System/Android/Activity.cpp2
-rw-r--r--src/SFML/System/Android/NativeActivity.cpp39
-rw-r--r--src/SFML/System/Android/ResourceStream.cpp41
3 files changed, 76 insertions, 6 deletions
diff --git a/src/SFML/System/Android/Activity.cpp b/src/SFML/System/Android/Activity.cpp
index fe3d015..89b9fb8 100644
--- a/src/SFML/System/Android/Activity.cpp
+++ b/src/SFML/System/Android/Activity.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/System/Android/NativeActivity.cpp b/src/SFML/System/Android/NativeActivity.cpp
new file mode 100644
index 0000000..99aef3f
--- /dev/null
+++ b/src/SFML/System/Android/NativeActivity.cpp
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/NativeActivity.hpp>
+#include <SFML/System/Android/Activity.hpp>
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+ANativeActivity* getNativeActivity()
+{
+ return priv::getActivity()->activity;
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Android/ResourceStream.cpp b/src/SFML/System/Android/ResourceStream.cpp
index fbc1ec4..93280aa 100644
--- a/src/SFML/System/Android/ResourceStream.cpp
+++ b/src/SFML/System/Android/ResourceStream.cpp
@@ -49,35 +49,66 @@ m_file (NULL)
////////////////////////////////////////////////////////////
ResourceStream::~ResourceStream()
{
- AAsset_close(m_file);
+ if (m_file)
+ {
+ AAsset_close(m_file);
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::read(void *data, Int64 size)
{
- return AAsset_read(m_file, data, size);
+ if (m_file)
+ {
+ return AAsset_read(m_file, data, size);
+ }
+ else
+ {
+ return -1;
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::seek(Int64 position)
{
- return AAsset_seek(m_file, position, SEEK_SET);
+ if (m_file)
+ {
+ return AAsset_seek(m_file, position, SEEK_SET);
+ }
+ else
+ {
+ return -1;
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::tell()
{
- return getSize() - AAsset_getRemainingLength(m_file);
+ if (m_file)
+ {
+ return getSize() - AAsset_getRemainingLength(m_file);
+ }
+ else
+ {
+ return -1;
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::getSize()
{
- return AAsset_getLength(m_file);
+ if (m_file)
+ {
+ return AAsset_getLength(m_file);
+ }
+ else
+ {
+ return -1;
+ }
}