mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Merge pull request #2558 from sigmabeta/android-panic-alerts
Android: Display Panic Alerts on-screen as a Toast message.
This commit is contained in:
@ -8,6 +8,9 @@ package org.dolphinemu.dolphinemu;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||
|
||||
/**
|
||||
* Class which contains methods that interact
|
||||
@ -15,6 +18,8 @@ import android.view.Surface;
|
||||
*/
|
||||
public final class NativeLibrary
|
||||
{
|
||||
private static EmulationActivity mEmulationActivity;
|
||||
|
||||
/**
|
||||
* Button type for use in onTouchEvent
|
||||
*/
|
||||
@ -235,6 +240,13 @@ public final class NativeLibrary
|
||||
/** Native EGL functions not exposed by Java bindings **/
|
||||
public static native void eglBindAPI(int api);
|
||||
|
||||
/**
|
||||
* The methods C++ uses to find references to Java classes and methods
|
||||
* are really expensive. Rather than calling them every time we want to
|
||||
* run them, do it once when we load the native library.
|
||||
*/
|
||||
private static native void CacheClassesAndMethods();
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
@ -245,5 +257,26 @@ public final class NativeLibrary
|
||||
{
|
||||
Log.e("NativeLibrary", ex.toString());
|
||||
}
|
||||
|
||||
CacheClassesAndMethods();
|
||||
}
|
||||
|
||||
public static void displayAlertMsg(final String alert)
|
||||
{
|
||||
Log.e("DolphinEmu", "Alert: " + alert);
|
||||
mEmulationActivity.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Toast.makeText(mEmulationActivity, "Panic Alert: " + alert, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setEmulationActivity(EmulationActivity emulationActivity)
|
||||
{
|
||||
Log.v("DolphinEmu", "Registering EmulationActivity.");
|
||||
mEmulationActivity = emulationActivity;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@ -91,6 +92,23 @@ public final class EmulationActivity extends Activity
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
Log.d("DolphinEmu", "EmulationActivity starting.");
|
||||
NativeLibrary.setEmulationActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
Log.d("DolphinEmu", "EmulationActivity stopping.");
|
||||
|
||||
NativeLibrary.setEmulationActivity(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState)
|
||||
{
|
||||
|
Reference in New Issue
Block a user