• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

Revisionf4c9690e81f1be68fc5e489944449fb80e16aa1c (tree)
Time2013-05-11 12:53:09
Authoriwgeric@gmail.com <iwgeric@gmai...>
Commiteriwgeric@gmail.com

Log Message

Android: Moved some code from onPause/onResume to loseFocus/gainFocus to address issues/patches 593, 566, 564. Users can now override loseFocus/gainFocus in MainActivity if they do not want to pause/resume the app based on Android's lifecycle methods onPause/onResume.
https://code.google.com/p/jmonkeyengine/issues/detail?id=593
https://code.google.com/p/jmonkeyengine/issues/detail?id=564
https://code.google.com/p/jmonkeyengine/issues/detail?id=566
(Yes, there were 3 patch requests for the same thing)

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10607 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Change Summary

Incremental Difference

--- a/engine/src/android/com/jme3/app/AndroidHarness.java
+++ b/engine/src/android/com/jme3/app/AndroidHarness.java
@@ -243,67 +243,16 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
243243 protected void onResume() {
244244 logger.fine("onResume");
245245 super.onResume();
246- if (view != null) {
247- view.onResume();
248- }
249- if (app != null) {
250- //resume the audio
251- AudioRenderer result = app.getAudioRenderer();
252- if (result != null) {
253- if (result instanceof AndroidAudioRenderer) {
254- AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
255- renderer.resumeAll();
256- }
257- }
258- //resume the sensors (aka joysticks)
259- if (app.getContext() != null) {
260- JoyInput joyInput = app.getContext().getJoyInput();
261- if (joyInput != null) {
262- if (joyInput instanceof AndroidSensorJoyInput) {
263- AndroidSensorJoyInput androidJoyInput = (AndroidSensorJoyInput) joyInput;
264- androidJoyInput.resumeSensors();
265- }
266- }
267- }
268- }
269-
270- isGLThreadPaused = false;
271246
272247 gainFocus();
273248 }
274249
275250 @Override
276251 protected void onPause() {
252+ logger.fine("onPause");
277253 loseFocus();
278254
279- logger.fine("onPause");
280255 super.onPause();
281- if (view != null) {
282- view.onPause();
283- }
284-
285- if (app != null) {
286- //pause the audio
287- AudioRenderer result = app.getAudioRenderer();
288- if (result != null) {
289- logger.log(Level.FINE, "pause: {0}", result.getClass().getSimpleName());
290- if (result instanceof AndroidAudioRenderer) {
291- AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
292- renderer.pauseAll();
293- }
294- }
295- //pause the sensors (aka joysticks)
296- if (app.getContext() != null) {
297- JoyInput joyInput = app.getContext().getJoyInput();
298- if (joyInput != null) {
299- if (joyInput instanceof AndroidSensorJoyInput) {
300- AndroidSensorJoyInput androidJoyInput = (AndroidSensorJoyInput) joyInput;
301- androidJoyInput.pauseSensors();
302- }
303- }
304- }
305- }
306- isGLThreadPaused = true;
307256 }
308257
309258 @Override
@@ -524,14 +473,70 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
524473 }
525474
526475 public void gainFocus() {
476+ logger.fine("gainFocus");
477+ if (view != null) {
478+ view.onResume();
479+ }
480+
481+ if (app != null) {
482+ //resume the audio
483+ AudioRenderer result = app.getAudioRenderer();
484+ if (result != null) {
485+ if (result instanceof AndroidAudioRenderer) {
486+ AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
487+ renderer.resumeAll();
488+ }
489+ }
490+ //resume the sensors (aka joysticks)
491+ if (app.getContext() != null) {
492+ JoyInput joyInput = app.getContext().getJoyInput();
493+ if (joyInput != null) {
494+ if (joyInput instanceof AndroidSensorJoyInput) {
495+ AndroidSensorJoyInput androidJoyInput = (AndroidSensorJoyInput) joyInput;
496+ androidJoyInput.resumeSensors();
497+ }
498+ }
499+ }
500+ }
501+
502+ isGLThreadPaused = false;
503+
527504 if (app != null) {
528505 app.gainFocus();
529506 }
530507 }
531508
532509 public void loseFocus() {
510+ logger.fine("loseFocus");
533511 if (app != null) {
534512 app.loseFocus();
535513 }
514+
515+ if (view != null) {
516+ view.onPause();
517+ }
518+
519+ if (app != null) {
520+ //pause the audio
521+ AudioRenderer result = app.getAudioRenderer();
522+ if (result != null) {
523+ logger.log(Level.FINE, "pause: {0}", result.getClass().getSimpleName());
524+ if (result instanceof AndroidAudioRenderer) {
525+ AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
526+ renderer.pauseAll();
527+ }
528+ }
529+ //pause the sensors (aka joysticks)
530+ if (app.getContext() != null) {
531+ JoyInput joyInput = app.getContext().getJoyInput();
532+ if (joyInput != null) {
533+ if (joyInput instanceof AndroidSensorJoyInput) {
534+ AndroidSensorJoyInput androidJoyInput = (AndroidSensorJoyInput) joyInput;
535+ androidJoyInput.pauseSensors();
536+ }
537+ }
538+ }
539+ }
540+ isGLThreadPaused = true;
536541 }
537542 }