Android: Add getter method for NativeLibrary.sEmulationActivity
Also makes sEmulationActivity private.
This commit is contained in:
parent
e9b02e7dd0
commit
82fd923a4e
|
@ -21,7 +21,16 @@ import java.lang.ref.WeakReference;
|
|||
*/
|
||||
public final class NativeLibrary
|
||||
{
|
||||
public static WeakReference<EmulationActivity> sEmulationActivity = new WeakReference<>(null);
|
||||
private static WeakReference<EmulationActivity> sEmulationActivity = new WeakReference<>(null);
|
||||
|
||||
/**
|
||||
* Returns the current instance of EmulationActivity.
|
||||
* There should only ever be one EmulationActivity instantiated.
|
||||
*/
|
||||
public static EmulationActivity getEmulationActivity()
|
||||
{
|
||||
return sEmulationActivity.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Button type for use in onTouchEvent
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Java_GCAdapter
|
|||
|
||||
private static void RequestPermission()
|
||||
{
|
||||
Context context = NativeLibrary.sEmulationActivity.get();
|
||||
Context context = NativeLibrary.getEmulationActivity();
|
||||
if (context != null)
|
||||
{
|
||||
HashMap<String, UsbDevice> devices = manager.getDeviceList();
|
||||
|
@ -141,7 +141,7 @@ public class Java_GCAdapter
|
|||
}
|
||||
}
|
||||
|
||||
final Activity emulationActivity = NativeLibrary.sEmulationActivity.get();
|
||||
final Activity emulationActivity = NativeLibrary.getEmulationActivity();
|
||||
if (emulationActivity != null)
|
||||
{
|
||||
emulationActivity.runOnUiThread(() -> Toast.makeText(emulationActivity,
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Java_WiimoteAdapter
|
|||
|
||||
private static void RequestPermission()
|
||||
{
|
||||
Context context = NativeLibrary.sEmulationActivity.get();
|
||||
Context context = NativeLibrary.getEmulationActivity();
|
||||
if (context != null)
|
||||
{
|
||||
HashMap<String, UsbDevice> devices = manager.getDeviceList();
|
||||
|
|
Loading…
Reference in New Issue