forked from joejulian/gio
app: [android] replace OnFocusChangedListener with onPause/onResume
References: https://lists.sr.ht/~eliasnaur/gio/%3CCAMAFT9Uyh_JWrkQQt+AmekJWFBqhZPsP_3ZxC1fUNB+=VGGorw@mail.gmail.com%3E Signed-off-by: CoyAce <akeycoy@gmail.com> Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -48,6 +48,16 @@ public final class GioActivity extends Activity {
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
view.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
view.resume();
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void onConfigurationChanged(Configuration c) {
|
@Override public void onConfigurationChanged(Configuration c) {
|
||||||
super.onConfigurationChanged(c);
|
super.onConfigurationChanged(c);
|
||||||
view.configurationChanged();
|
view.configurationChanged();
|
||||||
|
|||||||
+12
-7
@@ -62,7 +62,6 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
|
|||||||
private static boolean jniLoaded;
|
private static boolean jniLoaded;
|
||||||
|
|
||||||
private final SurfaceHolder.Callback surfCallbacks;
|
private final SurfaceHolder.Callback surfCallbacks;
|
||||||
private final View.OnFocusChangeListener focusCallback;
|
|
||||||
private final InputMethodManager imm;
|
private final InputMethodManager imm;
|
||||||
private final float scrollXScale;
|
private final float scrollXScale;
|
||||||
private final float scrollYScale;
|
private final float scrollYScale;
|
||||||
@@ -114,12 +113,6 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
|
|||||||
nhandle = onCreateView(this);
|
nhandle = onCreateView(this);
|
||||||
setFocusable(true);
|
setFocusable(true);
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
focusCallback = new View.OnFocusChangeListener() {
|
|
||||||
@Override public void onFocusChange(View v, boolean focus) {
|
|
||||||
GioView.this.onFocusChange(nhandle, focus);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
setOnFocusChangeListener(focusCallback);
|
|
||||||
surfCallbacks = new SurfaceHolder.Callback() {
|
surfCallbacks = new SurfaceHolder.Callback() {
|
||||||
@Override public void surfaceCreated(SurfaceHolder holder) {
|
@Override public void surfaceCreated(SurfaceHolder holder) {
|
||||||
// Ignore; surfaceChanged is guaranteed to be called immediately after this.
|
// Ignore; surfaceChanged is guaranteed to be called immediately after this.
|
||||||
@@ -482,6 +475,18 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pause() {
|
||||||
|
if (nhandle != 0) {
|
||||||
|
onFocusChange(nhandle, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resume() {
|
||||||
|
if (nhandle != 0) {
|
||||||
|
onFocusChange(nhandle, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (nhandle != 0) {
|
if (nhandle != 0) {
|
||||||
onDestroyView(nhandle);
|
onDestroyView(nhandle);
|
||||||
|
|||||||
Reference in New Issue
Block a user