Android: Swap own JNI BooleanSupplier to java.util.function

This commit is contained in:
Simonx22 2025-11-12 18:06:53 -05:00
parent 8495e01668
commit a7d1c1cf1e
7 changed files with 13 additions and 21 deletions

View File

@ -35,6 +35,7 @@ import org.dolphinemu.dolphinemu.model.GpuDriverMetadata
import org.dolphinemu.dolphinemu.ui.main.MainPresenter
import org.dolphinemu.dolphinemu.utils.*
import java.util.*
import java.util.function.BooleanSupplier
import kotlin.collections.ArrayList
import kotlin.math.ceil
import kotlin.math.floor
@ -2593,7 +2594,7 @@ class SettingsFragmentPresenter(
fragmentView.fragmentActivity,
R.string.wii_converting,
0,
{ context.resources.getString(if (f.get()) R.string.wii_convert_success else R.string.wii_convert_failure) }
{ context.resources.getString(if (f.getAsBoolean()) R.string.wii_convert_success else R.string.wii_convert_failure) }
)
}

View File

@ -21,7 +21,7 @@ import org.dolphinemu.dolphinemu.fragments.AboutDialogFragment
import org.dolphinemu.dolphinemu.model.GameFileCache
import org.dolphinemu.dolphinemu.services.GameFileCacheManager
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner
import org.dolphinemu.dolphinemu.utils.BooleanSupplier
import java.util.function.BooleanSupplier
import org.dolphinemu.dolphinemu.utils.CompletableFuture
import org.dolphinemu.dolphinemu.utils.ContentHandler
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization

View File

@ -1,11 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.utils;
import androidx.annotation.Keep;
public interface BooleanSupplier
{
@Keep
boolean get();
}

View File

@ -2,6 +2,8 @@
package org.dolphinemu.dolphinemu.utils
import java.util.function.BooleanSupplier
object WiiUtils {
const val RESULT_SUCCESS = 0
const val RESULT_ERROR = 1

View File

@ -52,7 +52,7 @@ static jmethodID s_network_helper_get_network_prefix_length;
static jmethodID s_network_helper_get_network_gateway;
static jclass s_boolean_supplier_class;
static jmethodID s_boolean_supplier_get;
static jmethodID s_boolean_supplier_get_as_boolean;
static jclass s_ar_cheat_class;
static jfieldID s_ar_cheat_pointer;
@ -310,9 +310,9 @@ jmethodID GetNetworkHelperGetNetworkGateway()
return s_network_helper_get_network_gateway;
}
jmethodID GetBooleanSupplierGet()
jmethodID GetBooleanSupplierGetAsBoolean()
{
return s_boolean_supplier_get;
return s_boolean_supplier_get_as_boolean;
}
jclass GetARCheatClass()
@ -669,10 +669,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->GetStaticMethodID(s_network_helper_class, "GetNetworkGateway", "()I");
env->DeleteLocalRef(network_helper_class);
const jclass boolean_supplier_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/BooleanSupplier");
const jclass boolean_supplier_class = env->FindClass("java/util/function/BooleanSupplier");
s_boolean_supplier_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_supplier_class));
s_boolean_supplier_get = env->GetMethodID(s_boolean_supplier_class, "get", "()Z");
s_boolean_supplier_get_as_boolean =
env->GetMethodID(s_boolean_supplier_class, "getAsBoolean", "()Z");
env->DeleteLocalRef(boolean_supplier_class);
const jclass ar_cheat_class =

View File

@ -51,7 +51,7 @@ jmethodID GetNetworkHelperGetNetworkIpAddress();
jmethodID GetNetworkHelperGetNetworkPrefixLength();
jmethodID GetNetworkHelperGetNetworkGateway();
jmethodID GetBooleanSupplierGet();
jmethodID GetBooleanSupplierGetAsBoolean();
jclass GetARCheatClass();
jfieldID GetARCheatPointer();

View File

@ -87,7 +87,7 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_importWiiSa
{
const std::string path = GetJString(env, jFile);
const auto can_overwrite = [&] {
const jmethodID get = IDCache::GetBooleanSupplierGet();
const jmethodID get = IDCache::GetBooleanSupplierGetAsBoolean();
return static_cast<bool>(env->CallBooleanMethod(jCanOverwrite, get));
};