Skip to content
Permalink
Browse files

Android: Add getter method for NativeLibrary.sEmulationActivity

Also makes sEmulationActivity private.
  • Loading branch information...
stenzek committed Jan 22, 2019
1 parent e9b02e7 commit 82fd923a4e33451dd30fcb6a612c8b5db0034f75
@@ -21,7 +21,16 @@
*/
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 @@

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 static boolean OpenAdapter()
}
}

final Activity emulationActivity = NativeLibrary.sEmulationActivity.get();
final Activity emulationActivity = NativeLibrary.getEmulationActivity();
if (emulationActivity != null)
{
emulationActivity.runOnUiThread(() -> Toast.makeText(emulationActivity,
@@ -34,7 +34,7 @@

private static void RequestPermission()
{
Context context = NativeLibrary.sEmulationActivity.get();
Context context = NativeLibrary.getEmulationActivity();
if (context != null)
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();

0 comments on commit 82fd923

Please sign in to comment.
You can’t perform that action at this time.