5959import com .jme3 .system .*;
6060import com .jme3 .util .BufferAllocatorFactory ;
6161import com .jme3 .util .PrimitiveAllocator ;
62-
6362import java .util .concurrent .atomic .AtomicBoolean ;
6463import java .util .logging .Level ;
6564import java .util .logging .Logger ;
@@ -79,7 +78,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
7978 protected SystemListener listener ;
8079 protected boolean autoFlush = true ;
8180 protected AndroidInputHandler androidInput ;
82- protected long minFrameDuration = 0 ; // No FPS cap
81+ protected long minFrameDuration = 0 ; // No FPS cap
8382 protected long lastUpdateTime = 0 ;
8483
8584 static {
@@ -90,8 +89,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
9089 }
9190 }
9291
93- public OGLESContext () {
94- }
92+ public OGLESContext () {}
9593
9694 @ Override
9795 public Type getType () {
@@ -115,9 +113,11 @@ public GLSurfaceView createView(Context context) {
115113 if (Build .VERSION .SDK_INT < Build .VERSION_CODES .ICE_CREAM_SANDWICH ) {
116114 // below 4.0, check OpenGL ES 2.0 support.
117115 if (info .reqGlEsVersion < 0x20000 ) {
118- throw new UnsupportedOperationException ("OpenGL ES 2.0 or better is not supported on this device" );
116+ throw new UnsupportedOperationException (
117+ "OpenGL ES 2.0 or better is not supported on this device"
118+ );
119119 }
120- } else if (Build .VERSION .SDK_INT < 9 ){
120+ } else if (Build .VERSION .SDK_INT < 9 ) {
121121 throw new UnsupportedOperationException ("jME3 requires Android 2.3 or later" );
122122 }
123123
@@ -127,7 +127,7 @@ public GLSurfaceView createView(Context context) {
127127 if (androidInput == null ) {
128128 if (Build .VERSION .SDK_INT >= 14 ) {
129129 androidInput = new AndroidInputHandler14 ();
130- } else if (Build .VERSION .SDK_INT >= 9 ){
130+ } else if (Build .VERSION .SDK_INT >= 9 ) {
131131 androidInput = new AndroidInputHandler ();
132132 }
133133 }
@@ -137,7 +137,7 @@ public GLSurfaceView createView(Context context) {
137137 // setEGLContextClientVersion must be set before calling setRenderer
138138 // this means it cannot be set in AndroidConfigChooser (too late)
139139 // use proper openGL ES version
140- view .setEGLContextClientVersion (info .reqGlEsVersion >> 16 );
140+ view .setEGLContextClientVersion (info .reqGlEsVersion >> 16 );
141141
142142 view .setFocusableInTouchMode (true );
143143 view .setFocusable (true );
@@ -200,22 +200,35 @@ protected void initInThread() {
200200 logger .log (Level .FINE , "Running on thread: {0}" , Thread .currentThread ().getName ());
201201
202202 // Setup unhandled Exception Handler
203- Thread .currentThread ().setUncaughtExceptionHandler (new Thread .UncaughtExceptionHandler () {
204- @ Override
205- public void uncaughtException (Thread thread , Throwable thrown ) {
206- listener .handleError ("Exception thrown in " + thread .toString (), thrown );
207- }
208- });
203+ Thread
204+ .currentThread ()
205+ .setUncaughtExceptionHandler (
206+ new Thread .UncaughtExceptionHandler () {
207+ @ Override
208+ public void uncaughtException (Thread thread , Throwable thrown ) {
209+ listener .handleError ("Exception thrown in " + thread .toString (), thrown );
210+ }
211+ }
212+ );
209213
210214 timer = new NanoTimer ();
211215 GL gl = new AndroidGL ();
212216 if (settings .getBoolean ("GraphicsDebug" )) {
213- gl = (GL ) GLDebug .createProxy (gl , gl , GL .class , GL2 .class , GLES_30 .class , GLFbo .class , GLExt .class );
217+ gl =
218+ (GL ) GLDebug .createProxy (
219+ gl ,
220+ gl ,
221+ GL .class ,
222+ GL2 .class ,
223+ GLES_30 .class ,
224+ GLFbo .class ,
225+ GLExt .class
226+ );
214227 }
215228 if (settings .getBoolean ("GraphicsTrace" )) {
216- gl = (GL )GLTracer .createGlesTracer (gl , GL .class , GLES_30 .class , GLFbo .class , GLExt .class );
229+ gl = (GL ) GLTracer .createGlesTracer (gl , GL .class , GLES_30 .class , GLFbo .class , GLExt .class );
217230 }
218- renderer = new GLRenderer (gl , (GLExt )gl , (GLFbo )gl );
231+ renderer = new GLRenderer (gl , (GLExt ) gl , (GLFbo ) gl );
219232 renderer .initialize ();
220233
221234 JmeSystem .setSoftTextDialogInput (this );
@@ -254,7 +267,7 @@ public void setSettings(AppSettings settings) {
254267 }
255268
256269 if (settings .getFrameRate () > 0 ) {
257- minFrameDuration = (long )(1000d / settings .getFrameRate ()); // ms
270+ minFrameDuration = (long ) (1000d / settings .getFrameRate ()); // ms
258271 logger .log (Level .FINE , "Setting min tpf: {0}ms" , minFrameDuration );
259272 } else {
260273 minFrameDuration = 0 ;
@@ -312,8 +325,7 @@ public Timer getTimer() {
312325 }
313326
314327 @ Override
315- public void setTitle (String title ) {
316- }
328+ public void setTitle (String title ) {}
317329
318330 @ Override
319331 public boolean isCreated () {
@@ -329,7 +341,11 @@ public void setAutoFlushFrames(boolean enabled) {
329341 @ Override
330342 public void onSurfaceChanged (GL10 gl , int width , int height ) {
331343 if (logger .isLoggable (Level .FINE )) {
332- logger .log (Level .FINE , "GL Surface changed, width: {0} height: {1}" , new Object []{width , height });
344+ logger .log (
345+ Level .FINE ,
346+ "GL Surface changed, width: {0} height: {1}" ,
347+ new Object [] { width , height }
348+ );
333349 }
334350 // update the application settings with the new resolution
335351 settings .setResolution (width , height );
@@ -372,16 +388,14 @@ public void onDrawFrame(GL10 gl) {
372388
373389 // Enforce a FPS cap
374390 if (updateDelta < minFrameDuration ) {
375- // logger.log(Level.INFO, "lastUpdateTime: {0}, updateDelta: {1}, minTimePerFrame: {2}",
376- // new Object[]{lastUpdateTime, updateDelta, minTimePerFrame});
391+ // logger.log(Level.INFO, "lastUpdateTime: {0}, updateDelta: {1}, minTimePerFrame: {2}",
392+ // new Object[]{lastUpdateTime, updateDelta, minTimePerFrame});
377393 try {
378394 Thread .sleep (minFrameDuration - updateDelta );
379- } catch (InterruptedException e ) {
380- }
395+ } catch (InterruptedException e ) {}
381396 }
382397
383398 lastUpdateTime = System .currentTimeMillis ();
384-
385399 }
386400 }
387401
@@ -402,8 +416,7 @@ public void create() {
402416 }
403417
404418 @ Override
405- public void restart () {
406- }
419+ public void restart () {}
407420
408421 @ Override
409422 public void destroy (boolean waitFor ) {
@@ -421,76 +434,99 @@ protected void waitFor(boolean createdVal) {
421434 while (renderable .get () != createdVal ) {
422435 try {
423436 Thread .sleep (10 );
424- } catch (InterruptedException ex ) {
425- }
437+ } catch (InterruptedException ex ) {}
426438 }
427439 }
428440
429441 @ Override
430- public void requestDialog (final int id , final String title , final String initialValue , final SoftTextDialogInputListener listener ) {
442+ public void requestDialog (
443+ final int id ,
444+ final String title ,
445+ final String initialValue ,
446+ final SoftTextDialogInputListener listener
447+ ) {
431448 if (logger .isLoggable (Level .FINE )) {
432- logger .log (Level .FINE , "requestDialog: title: {0}, initialValue: {1}" ,
433- new Object []{title , initialValue });
449+ logger .log (
450+ Level .FINE ,
451+ "requestDialog: title: {0}, initialValue: {1}" ,
452+ new Object [] { title , initialValue }
453+ );
434454 }
435455
436456 final View view = JmeAndroidSystem .getView ();
437- view .getHandler ().post (new Runnable () {
438- @ Override
439- public void run () {
440-
441- final FrameLayout layoutTextDialogInput = new FrameLayout (view .getContext ());
442- final EditText editTextDialogInput = new EditText (view .getContext ());
443- editTextDialogInput .setWidth (LayoutParams .FILL_PARENT );
444- editTextDialogInput .setHeight (LayoutParams .FILL_PARENT );
445- editTextDialogInput .setPadding (20 , 20 , 20 , 20 );
446- editTextDialogInput .setGravity (Gravity .FILL_HORIZONTAL );
447- //editTextDialogInput.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
448-
449- editTextDialogInput .setText (initialValue );
450-
451- switch (id ) {
452- case SoftTextDialogInput .TEXT_ENTRY_DIALOG :
453-
454- editTextDialogInput .setInputType (InputType .TYPE_CLASS_TEXT );
455- break ;
456-
457- case SoftTextDialogInput .NUMERIC_ENTRY_DIALOG :
458-
459- editTextDialogInput .setInputType (InputType .TYPE_CLASS_NUMBER | InputType .TYPE_NUMBER_FLAG_DECIMAL | InputType .TYPE_NUMBER_FLAG_SIGNED );
460- break ;
461-
462- case SoftTextDialogInput .NUMERIC_KEYPAD_DIALOG :
463-
464- editTextDialogInput .setInputType (InputType .TYPE_CLASS_PHONE );
465- break ;
466-
467- default :
468- break ;
457+ view
458+ .getHandler ()
459+ .post (
460+ new Runnable () {
461+ @ Override
462+ public void run () {
463+ final FrameLayout layoutTextDialogInput = new FrameLayout (view .getContext ());
464+ final EditText editTextDialogInput = new EditText (view .getContext ());
465+ editTextDialogInput .setWidth (LayoutParams .FILL_PARENT );
466+ editTextDialogInput .setHeight (LayoutParams .FILL_PARENT );
467+ editTextDialogInput .setPadding (20 , 20 , 20 , 20 );
468+ editTextDialogInput .setGravity (Gravity .FILL_HORIZONTAL );
469+ //editTextDialogInput.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
470+
471+ editTextDialogInput .setText (initialValue );
472+
473+ switch (id ) {
474+ case SoftTextDialogInput .TEXT_ENTRY_DIALOG :
475+ editTextDialogInput .setInputType (InputType .TYPE_CLASS_TEXT );
476+ break ;
477+ case SoftTextDialogInput .NUMERIC_ENTRY_DIALOG :
478+ editTextDialogInput .setInputType (
479+ InputType .TYPE_CLASS_NUMBER |
480+ InputType .TYPE_NUMBER_FLAG_DECIMAL |
481+ InputType .TYPE_NUMBER_FLAG_SIGNED
482+ );
483+ break ;
484+ case SoftTextDialogInput .NUMERIC_KEYPAD_DIALOG :
485+ editTextDialogInput .setInputType (InputType .TYPE_CLASS_PHONE );
486+ break ;
487+ default :
488+ break ;
489+ }
490+
491+ layoutTextDialogInput .addView (editTextDialogInput );
492+
493+ AlertDialog dialogTextInput = new AlertDialog .Builder (view .getContext ())
494+ .setTitle (title )
495+ .setView (layoutTextDialogInput )
496+ .setPositiveButton (
497+ "OK" ,
498+ new DialogInterface .OnClickListener () {
499+ @ Override
500+ public void onClick (DialogInterface dialog , int whichButton ) {
501+ /* User clicked OK, send COMPLETE action
502+ * and text */
503+ listener .onSoftText (
504+ SoftTextDialogInputListener .COMPLETE ,
505+ editTextDialogInput .getText ().toString ()
506+ );
507+ }
508+ }
509+ )
510+ .setNegativeButton (
511+ "Cancel" ,
512+ new DialogInterface .OnClickListener () {
513+ @ Override
514+ public void onClick (DialogInterface dialog , int whichButton ) {
515+ /* User clicked CANCEL, send CANCEL action
516+ * and text */
517+ listener .onSoftText (
518+ SoftTextDialogInputListener .CANCEL ,
519+ editTextDialogInput .getText ().toString ()
520+ );
521+ }
522+ }
523+ )
524+ .create ();
525+
526+ dialogTextInput .show ();
527+ }
469528 }
470-
471- layoutTextDialogInput .addView (editTextDialogInput );
472-
473- AlertDialog dialogTextInput = new AlertDialog .Builder (view .getContext ()).setTitle (title ).setView (layoutTextDialogInput ).setPositiveButton ("OK" ,
474- new DialogInterface .OnClickListener () {
475- @ Override
476- public void onClick (DialogInterface dialog , int whichButton ) {
477- /* User clicked OK, send COMPLETE action
478- * and text */
479- listener .onSoftText (SoftTextDialogInputListener .COMPLETE , editTextDialogInput .getText ().toString ());
480- }
481- }).setNegativeButton ("Cancel" ,
482- new DialogInterface .OnClickListener () {
483- @ Override
484- public void onClick (DialogInterface dialog , int whichButton ) {
485- /* User clicked CANCEL, send CANCEL action
486- * and text */
487- listener .onSoftText (SoftTextDialogInputListener .CANCEL , editTextDialogInput .getText ().toString ());
488- }
489- }).create ();
490-
491- dialogTextInput .show ();
492- }
493- });
529+ );
494530 }
495531
496532 @ Override
@@ -542,11 +578,11 @@ public int getWindowXPosition() {
542578 public int getWindowYPosition () {
543579 throw new UnsupportedOperationException ("not implemented yet" );
544580 }
545-
581+
546582 /**
547583 * Retrieves the dimensions of the input surface. Note: do not modify the
548584 * returned object.
549- *
585+ *
550586 * @return the dimensions (in pixels, left and top are 0)
551587 */
552588 private Rect getSurfaceFrame () {
@@ -555,4 +591,16 @@ private Rect getSurfaceFrame() {
555591 Rect result = holder .getSurfaceFrame ();
556592 return result ;
557593 }
594+
595+ @ Override
596+ public Displays getDisplays () {
597+ // TODO Auto-generated method stub
598+ return null ;
599+ }
600+
601+ @ Override
602+ public int getPrimaryDisplay () {
603+ // TODO Auto-generated method stub
604+ return 0 ;
605+ }
558606}
0 commit comments