mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Add failsafe for love.window.getSafeArea in Android.
In case it uses older Java files, the function can safely be called without causing Java crash. --HG-- branch : android-safearea
This commit is contained in:
@@ -98,7 +98,10 @@ bool getSafeArea(int &top, int &left, int &bottom, int &right)
|
|||||||
jmethodID methodID = env->GetMethodID(clazz, "initializeSafeArea", "()Z");
|
jmethodID methodID = env->GetMethodID(clazz, "initializeSafeArea", "()Z");
|
||||||
bool hasSafeArea = false;
|
bool hasSafeArea = false;
|
||||||
|
|
||||||
if ((hasSafeArea = env->CallBooleanMethod(activity, methodID)))
|
if (methodID == nullptr)
|
||||||
|
// NoSuchMethodException is thrown in case methodID is null
|
||||||
|
env->ExceptionClear();
|
||||||
|
else if ((hasSafeArea = env->CallBooleanMethod(activity, methodID)))
|
||||||
{
|
{
|
||||||
top = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaTop", "I"));
|
top = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaTop", "I"));
|
||||||
left = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaLeft", "I"));
|
left = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaLeft", "I"));
|
||||||
|
|||||||
Reference in New Issue
Block a user