App won't crash (and will continue to work) when keyboard is opened/closed or orientation changes (at last!)

This commit is contained in:
pelya
2010-08-31 16:02:26 +03:00
parent 79911b77c3
commit 5373a8e9cd
3 changed files with 5 additions and 21 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.googlecode.opentyrian"
android:versionCode="2106"
android:versionName="2.1.06"
android:versionCode="2107"
android:versionName="2.1.07"
android:installLocation="preferExternal"
>
<application android:label="@string/app_name"

View File

@@ -8,7 +8,6 @@ import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.os.PowerManager;
import android.widget.TextView;
import android.content.res.Configuration;
@@ -51,9 +50,6 @@ public class MainActivity extends Activity {
mGLView.setFocusableInTouchMode(true);
mGLView.setFocusable(true);
mGLView.requestFocus();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, Globals.ApplicationName);
wakeLock.acquire();
}
@Override
@@ -63,9 +59,7 @@ public class MainActivity extends Activity {
downloader.setParent(null, null);
}
}
// TODO: if application pauses it's screen is messed up
if( wakeLock != null )
wakeLock.release();
super.onPause();
if( mGLView != null )
mGLView.onPause();
@@ -73,8 +67,6 @@ public class MainActivity extends Activity {
@Override
protected void onResume() {
if( wakeLock != null )
wakeLock.acquire();
super.onResume();
if( mGLView != null )
mGLView.onResume();
@@ -96,9 +88,6 @@ public class MainActivity extends Activity {
downloader.setParent(null, null);
}
}
if( wakeLock != null )
wakeLock.release();
if( mGLView != null )
mGLView.exitApp();
super.onStop();
@@ -133,10 +122,7 @@ public class MainActivity extends Activity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(mGLView != null)
setContentView(mGLView);
else
setContentView(_tv);
// Do nothing here
}
public void setText(final String t)
@@ -157,10 +143,9 @@ public class MainActivity extends Activity {
this.runOnUiThread(cb);
}
private DemoGLSurfaceView mGLView = null;
private static DemoGLSurfaceView mGLView = null;
private static LoadLibrary mLoadLibraryStub = null;
private static AudioThread mAudioThread = null;
private PowerManager.WakeLock wakeLock = null;
private static DataDownloader downloader = null;
private TextView _tv = null;
private boolean sdlInited = false;

View File

@@ -159,7 +159,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
public boolean onTouchEvent(final MotionEvent 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
synchronized (mRenderer) {
try {