コード例 #1
0
 public void onResume() {
   if (AndroidLiveWallpaperService.DEBUG)
     Log.d(
         AndroidLiveWallpaperService.this.TAG,
         " > onResume() " + hashCode() + ", running: " + runningEngines);
   app.onResume();
   view.onResume();
 }
コード例 #2
0
    public AndroidWallpaperEngine(AndroidApplicationConfiguration config) {
      ApplicationListener listener = createListener(this.isPreview());
      if (AndroidLiveWallpaperService.DEBUG)
        Log.d(AndroidLiveWallpaperService.this.TAG, " > MyEngine() " + hashCode());
      this.app = new AndroidLiveWallpaper(AndroidLiveWallpaperService.this, this);
      this.app.initialize(listener, config);
      this.listener = listener;
      this.view = ((AndroidGraphicsLiveWallpaper) app.getGraphics()).getView();

      if (config.getTouchEventsForLiveWallpaper
          && Integer.parseInt(android.os.Build.VERSION.SDK) < 9) this.setTouchEventsEnabled(true);
    }
コード例 #3
0
  private void updatePpi() {
    DisplayMetrics metrics = new DisplayMetrics();

    // jw: changed
    app.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    // final Display display =
    // ((WindowManager)app.getService().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    // display.getMetrics(metrics);

    ppiX = metrics.xdpi;
    ppiY = metrics.ydpi;
    ppcX = metrics.xdpi / 2.54f;
    ppcY = metrics.ydpi / 2.54f;
    density = metrics.density;
  }
コード例 #4
0
    @Override
    public void onOffsetsChanged(
        final float xOffset,
        final float yOffset,
        final float xOffsetStep,
        final float yOffsetStep,
        final int xPixelOffset,
        final int yPixelOffset) {

      if (AndroidLiveWallpaperService.DEBUG)
        Log.d(
            AndroidLiveWallpaperService.this.TAG,
            " > onOffsetChanged("
                + xOffset
                + " "
                + yOffset
                + " "
                + xOffsetStep
                + " "
                + yOffsetStep
                + " "
                + xPixelOffset
                + " "
                + yPixelOffset
                + ") "
                + hashCode());

      app.postRunnable(
          new Runnable() {
            @Override
            public void run() {
              AndroidLiveWallpaperService.this.offsetChange(
                  listener, xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
            }
          });
      super.onOffsetsChanged(
          xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
    }
コード例 #5
0
  @Override
  public void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl, EGLConfig config) {
    eglContext = ((EGL10) EGLContext.getEGL()).eglGetCurrentContext(); // jw: added
    setupGL(gl);
    logConfig(config);
    updatePpi();

    Mesh.invalidateAllMeshes(app);
    Texture.invalidateAllTextures(app);
    ShaderProgram.invalidateAllShaderPrograms(app);
    FrameBuffer.invalidateAllFrameBuffers(app);

    if (AndroidLiveWallpaperService
        .DEBUG) { // to prevent creating too many string buffers in live wallpapers
      Gdx.app.debug("AndroidGraphics", Mesh.getManagedStatus());
      Gdx.app.debug("AndroidGraphics", Texture.getManagedStatus());
      Gdx.app.debug("AndroidGraphics", ShaderProgram.getManagedStatus());
      Gdx.app.debug("AndroidGraphics", FrameBuffer.getManagedStatus());
    }

    Display display = app.getWindowManager().getDefaultDisplay();
    this.width = display.getWidth();
    this.height = display.getHeight();
    mean = new WindowedMean(5);
    this.lastFrameTime = System.nanoTime();

    gl.glViewport(0, 0, this.width, this.height);

    // jw: moved to onSurfaceChanged (as in AndroidGraphics class)
    /*if (created == false) {
    	app.getListener().create();
    	created = true;
    	synchronized (this) {
    		running = true;
    	}
    }*/
  }
コード例 #6
0
 @Override
 public DisplayMode getDesktopDisplayMode() {
   DisplayMetrics metrics = new DisplayMetrics();
   app.getWindowManager().getDefaultDisplay().getMetrics(metrics);
   return new AndroidDisplayMode(metrics.widthPixels, metrics.heightPixels, 0, 0);
 }