App won't crash (and will continue to work) when keyboard is opened/closed or orientation changes (at last!)
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.googlecode.opentyrian"
|
package="com.googlecode.opentyrian"
|
||||||
android:versionCode="2106"
|
android:versionCode="2107"
|
||||||
android:versionName="2.1.06"
|
android:versionName="2.1.07"
|
||||||
android:installLocation="preferExternal"
|
android:installLocation="preferExternal"
|
||||||
>
|
>
|
||||||
<application android:label="@string/app_name"
|
<application android:label="@string/app_name"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import android.view.MotionEvent;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
@@ -51,9 +50,6 @@ public class MainActivity extends Activity {
|
|||||||
mGLView.setFocusableInTouchMode(true);
|
mGLView.setFocusableInTouchMode(true);
|
||||||
mGLView.setFocusable(true);
|
mGLView.setFocusable(true);
|
||||||
mGLView.requestFocus();
|
mGLView.requestFocus();
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
||||||
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, Globals.ApplicationName);
|
|
||||||
wakeLock.acquire();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,9 +59,7 @@ public class MainActivity extends Activity {
|
|||||||
downloader.setParent(null, null);
|
downloader.setParent(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: if application pauses it's screen is messed up
|
|
||||||
if( wakeLock != null )
|
|
||||||
wakeLock.release();
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if( mGLView != null )
|
if( mGLView != null )
|
||||||
mGLView.onPause();
|
mGLView.onPause();
|
||||||
@@ -73,8 +67,6 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
if( wakeLock != null )
|
|
||||||
wakeLock.acquire();
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if( mGLView != null )
|
if( mGLView != null )
|
||||||
mGLView.onResume();
|
mGLView.onResume();
|
||||||
@@ -96,9 +88,6 @@ public class MainActivity extends Activity {
|
|||||||
downloader.setParent(null, null);
|
downloader.setParent(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( wakeLock != null )
|
|
||||||
wakeLock.release();
|
|
||||||
|
|
||||||
if( mGLView != null )
|
if( mGLView != null )
|
||||||
mGLView.exitApp();
|
mGLView.exitApp();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
@@ -133,10 +122,7 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
if(mGLView != null)
|
// Do nothing here
|
||||||
setContentView(mGLView);
|
|
||||||
else
|
|
||||||
setContentView(_tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(final String t)
|
public void setText(final String t)
|
||||||
@@ -157,10 +143,9 @@ public class MainActivity extends Activity {
|
|||||||
this.runOnUiThread(cb);
|
this.runOnUiThread(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DemoGLSurfaceView mGLView = null;
|
private static DemoGLSurfaceView mGLView = null;
|
||||||
private static LoadLibrary mLoadLibraryStub = null;
|
private static LoadLibrary mLoadLibraryStub = null;
|
||||||
private static AudioThread mAudioThread = null;
|
private static AudioThread mAudioThread = null;
|
||||||
private PowerManager.WakeLock wakeLock = null;
|
|
||||||
private static DataDownloader downloader = null;
|
private static DataDownloader downloader = null;
|
||||||
private TextView _tv = null;
|
private TextView _tv = null;
|
||||||
private boolean sdlInited = false;
|
private boolean sdlInited = false;
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
public boolean onTouchEvent(final MotionEvent event)
|
public boolean onTouchEvent(final MotionEvent event)
|
||||||
{
|
{
|
||||||
touchInput.process(event);
|
touchInput.process(event);
|
||||||
// TODO: add multitouch support (added in Android 2.0 SDK)
|
|
||||||
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
|
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
|
||||||
synchronized (mRenderer) {
|
synchronized (mRenderer) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user