@Override protected void onResume() { super.onResume(); /* * when the activity is resumed, we acquire a wake-lock so that the * screen stays on, since the user will likely not be fiddling with the * screen or buttons. */ mWakeLock.acquire(); // Start the simulation mSimulationView.startSimulation(); }
@Override protected void onPause() { super.onPause(); /* * When the activity is paused, we make sure to stop the simulation, * release our sensor resources and wake locks */ // Stop the simulation mSimulationView.stopSimulation(); // and release our wake-lock mWakeLock.release(); }
// Push colorModel back out to AWT private void updateColors() { if (pixels.length < width * height) pixels = new byte[width * height]; byte value; // Draw the colorbar, pixel by pixel. for (int i = 0; i < height; i++) { // value = (byte)(i*((float)tableSize)/(height)); // shows whole table value = (byte) (startColor + (endColor + 1 - startColor) * i / height); for (int j = 0; j < width; j++) pixels[i * width + j] = value; } cbsource = new MemoryImageSource( width, height, colorModel, pixels, width * (height - 1), -width); /* <- flips image upside down */ setIcon(new ImageIcon(createImage(cbsource))); if (view != null) view.redisplay(colorModel); }