/** * When the Fragment resumes (ie. after app resumes or device screen turned * back on), call the gainFocus() in the jME application. */ @Override public void onResume() { logger.fine("onResume"); super.onResume(); gainFocus(); }
@Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(exitDialogTitle); builder.setPositiveButton("Yes", AndroidHarnessFragment.this); builder.setNegativeButton("No", AndroidHarnessFragment.this); builder.setMessage(exitDialogMessage); AlertDialog dialog = builder.create(); dialog.show(); } });
/** * When the Fragment pauses (ie. after home button pressed on the device * or device screen turned off) , call the loseFocus() in the jME application. */ @Override public void onPause() { logger.fine("onPause"); loseFocus(); super.onPause(); }
initializeLogHandler(); logger.fine("onCreate"); super.onCreate(savedInstanceState); app.start(); } catch (Exception ex) { handleError("Class " + appClass + " init failed", ex); setRetainInstance(true);
((ViewGroup) frameLayout.getParent()).removeView(frameLayout); frameLayout = new FrameLayout(getActivity()); splashImageView = new ImageView(getActivity()); Drawable drawable = getResources().getDrawable(splashPicID); if (drawable instanceof NinePatchDrawable) { splashImageView.setBackgroundDrawable(drawable);
/** * Called by the system to create the View hierchy associated with this * Fragment. For jME, this is a FrameLayout that contains the GLSurfaceView * and an overlaying SplashScreen Image (if used). The View that is returned * will be placed on the screen within the boundries of the View borders defined * by the Activity's layout parameters for this Fragment. For jME, we also * update the application reference to the new view. * * @param inflater * @param container * @param savedInstanceState * @return */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { logger.fine("onCreateView"); // Create the GLSurfaceView for the application view = ((OGLESContext) app.getContext()).createView(getActivity()); // store the glSurfaceView in JmeAndroidSystem for future use JmeAndroidSystem.setView(view); createLayout(); view.addOnLayoutChangeListener(this); return frameLayout; }
@Override public void update() { app.update(); // call to remove the splash screen, if present. // call after app.update() to make sure no gap between // splash screen going away and app display being shown. if (firstDrawFrame) { removeSplashScreen(); firstDrawFrame = false; } }
@Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(finalTitle); builder.setPositiveButton("Kill", AndroidHarnessFragment.this); builder.setMessage(finalMsg); AlertDialog dialog = builder.create(); dialog.show(); } });
@Override public void destroy() { if (app != null) { app.destroy(); } if (finishOnAppStop) { getActivity().finish(); } }
public void removeSplashScreen() { logger.log(Level.FINE, "Splash Screen Picture Resource ID: {0}", splashPicID); if (splashPicID != 0) { if (frameLayout != null) { if (splashImageView != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { splashImageView.setVisibility(View.INVISIBLE); frameLayout.removeView(splashImageView); } }); } else { logger.fine("splashImageView is null"); } } else { logger.fine("frameLayout is null"); } } }
/** * Called by the android alert dialog, terminate the activity and OpenGL * rendering * * @param dialog * @param whichButton */ @Override public void onClick(DialogInterface dialog, int whichButton) { if (whichButton != -2) { if (app != null) { app.stop(true); } app = null; getActivity().finish(); } }
getActivity().runOnUiThread(new Runnable() { @Override public void run() {
/** * Gets called by the InputManager on all touch/drag/scale events */ @Override public void onTouch(String name, TouchEvent evt, float tpf) { if (name.equals(ESCAPE_EVENT)) { switch (evt.getType()) { case KEY_UP: getActivity().runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(exitDialogTitle); builder.setPositiveButton("Yes", AndroidHarnessFragment.this); builder.setNegativeButton("No", AndroidHarnessFragment.this); builder.setMessage(exitDialogMessage); AlertDialog dialog = builder.create(); dialog.show(); } }); break; default: break; } } }