Fix intermittent surface crash on exit
This commit is contained in:
parent
d10ac46405
commit
c208d9f31a
2 changed files with 13 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?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="org.ab.x48" android:installLocation="auto" android:versionCode="76" android:versionName="1.76">
|
package="org.ab.x48" android:installLocation="auto" android:versionCode="77" android:versionName="1.77">
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||||
<activity android:name=".X48"
|
<activity android:name=".X48"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|
|
@ -34,6 +34,7 @@ import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
public class HPView extends SurfaceView implements SurfaceHolder.Callback {
|
public class HPView extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
private Bitmap mainScreen;
|
private Bitmap mainScreen;
|
||||||
private SurfaceHolder mSurfaceHolder;
|
private SurfaceHolder mSurfaceHolder;
|
||||||
private boolean surfaceValid;
|
private boolean surfaceValid;
|
||||||
|
private int visibility = VISIBLE;
|
||||||
private Bitmap annImages [];
|
private Bitmap annImages [];
|
||||||
private Bitmap menuIcon;
|
private Bitmap menuIcon;
|
||||||
boolean ann [];
|
boolean ann [];
|
||||||
|
@ -945,6 +947,12 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
//Log.i("x48", "data: " + data.length);
|
//Log.i("x48", "data: " + data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||||
|
super.onVisibilityChanged(changedView, visibility);
|
||||||
|
this.visibility = visibility;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
synchronized (mSurfaceHolder) {
|
synchronized (mSurfaceHolder) {
|
||||||
|
@ -1072,7 +1080,9 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
else
|
else
|
||||||
currentOrientation = Configuration.ORIENTATION_LANDSCAPE;
|
currentOrientation = Configuration.ORIENTATION_LANDSCAPE;
|
||||||
//initGraphicsElements();
|
//initGraphicsElements();
|
||||||
|
synchronized (mSurfaceHolder) {
|
||||||
backBuffer = null;
|
backBuffer = null;
|
||||||
|
}
|
||||||
x48.flipScreen();
|
x48.flipScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,7 +1126,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
if (surfaceValid) {
|
if (surfaceValid && visibility == VISIBLE) {
|
||||||
if (needFlip || x48.fillScreenData(buf, ann) == 1) {
|
if (needFlip || x48.fillScreenData(buf, ann) == 1) {
|
||||||
needFlip = false;
|
needFlip = false;
|
||||||
refreshMainScreen(buf);
|
refreshMainScreen(buf);
|
||||||
|
|
Loading…
Reference in a new issue