| 349 | /// |
| 350 | /// this method is invoked internally do not invoke it! |
| 351 | public static void init(Object m) { |
| 352 | if (!INSTANCE.codenameOneRunning) { |
| 353 | INSTANCE.codenameOneRunning = true; |
| 354 | INSTANCE.initialWindowSizeApplied = false; |
| 355 | INSTANCE.pluginSupport = new PluginSupport(); |
| 356 | INSTANCE.displayInitTime = System.currentTimeMillis(); |
| 357 | |
| 358 | //restore menu state from previous run if exists |
| 359 | int commandBehaviour = COMMAND_BEHAVIOR_DEFAULT; |
| 360 | if (impl != null) { |
| 361 | commandBehaviour = impl.getCommandBehavior(); |
| 362 | } |
| 363 | impl = (CodenameOneImplementation) ImplementationFactory.getInstance().createImplementation(); |
| 364 | INSTANCE.simd = null; |
| 365 | |
| 366 | impl.setDisplayLock(lock); |
| 367 | impl.initImpl(m); |
| 368 | INSTANCE.codenameOneGraphics = new Graphics(impl.getNativeGraphics()); |
| 369 | INSTANCE.codenameOneGraphics.paintPeersBehind = impl.paintNativePeersBehind(); |
| 370 | impl.setCodenameOneGraphics(INSTANCE.codenameOneGraphics); |
| 371 | |
| 372 | if (INSTANCE.disableScreenshots) { |
| 373 | impl.setDisableScreenshots(true); |
| 374 | INSTANCE.disableScreenshots = false; |
| 375 | } |
| 376 | |
| 377 | // only enable but never disable the third softbutton |
| 378 | if (impl.isThirdSoftButton()) { |
| 379 | INSTANCE.thirdSoftButton = true; |
| 380 | } |
| 381 | if (impl.getSoftkeyCount() > 0) { |
| 382 | MenuBar.leftSK = impl.getSoftkeyCode(0)[0]; |
| 383 | if (impl.getSoftkeyCount() > 1) { |
| 384 | MenuBar.rightSK = impl.getSoftkeyCode(1)[0]; |
| 385 | if (impl.getSoftkeyCode(1).length > 1) { |
| 386 | MenuBar.rightSK2 = impl.getSoftkeyCode(1)[1]; |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | MenuBar.backSK = impl.getBackKeyCode(); |
| 391 | MenuBar.backspaceSK = impl.getBackspaceKeyCode(); |
| 392 | MenuBar.clearSK = impl.getClearKeyCode(); |
| 393 | |
| 394 | INSTANCE.PATHLENGTH = impl.getDragPathLength(); |
| 395 | INSTANCE.dragPathX = new float[INSTANCE.PATHLENGTH]; |
| 396 | INSTANCE.dragPathY = new float[INSTANCE.PATHLENGTH]; |
| 397 | INSTANCE.dragPathTime = new long[INSTANCE.PATHLENGTH]; |
| 398 | com.codename1.util.StringUtil.setImplementation(impl); |
| 399 | Util.setImplementation(impl); |
| 400 | |
| 401 | // this can happen on some cases where an application was restarted etc... |
| 402 | // generally its probably a bug but we can let it slide... |
| 403 | if (INSTANCE.edt == null) { |
| 404 | INSTANCE.touchScreen = impl.isTouchDevice(); |
| 405 | // initialize the Codename One EDT which from now on will take all responsibility |
| 406 | // for the event delivery. |
| 407 | INSTANCE.edt = new CodenameOneThread(new RunnableWrapper(null, 3), "EDT"); |
| 408 | impl.setThreadPriority(INSTANCE.edt, impl.getEDTThreadPriority()); |