diff options
author | Javier <dev.git@javispedro.com> | 2020-02-12 00:08:06 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2020-02-12 20:48:39 +0100 |
commit | ac329e140435c3488ea5dfef89d237e2325da9e4 (patch) | |
tree | 47f03d0ae7ef63f9649aed834c0110b47e9936b5 /app/src/main/java/com/javispedro/wallmotion/WallService.java | |
download | wallmotion-ac329e140435c3488ea5dfef89d237e2325da9e4.tar.gz wallmotion-ac329e140435c3488ea5dfef89d237e2325da9e4.zip |
initial import
Diffstat (limited to 'app/src/main/java/com/javispedro/wallmotion/WallService.java')
-rw-r--r-- | app/src/main/java/com/javispedro/wallmotion/WallService.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/app/src/main/java/com/javispedro/wallmotion/WallService.java b/app/src/main/java/com/javispedro/wallmotion/WallService.java new file mode 100644 index 0000000..6a004ff --- /dev/null +++ b/app/src/main/java/com/javispedro/wallmotion/WallService.java @@ -0,0 +1,65 @@ +package com.javispedro.wallmotion; + +import android.service.wallpaper.WallpaperService; +import android.util.Log; +import android.view.SurfaceHolder; + +public class WallService extends WallpaperService { + private static final String TAG = "WallService"; + + @Override + public Engine onCreateEngine() { + return new WallpaperEngine(); + } + + private class WallpaperEngine extends Engine { + private static final String TAG = "WallpaperEngine"; + + private Renderer renderer; + + @Override + public void onCreate(SurfaceHolder surfaceHolder) { + Log.d(TAG, "onCreate"); + renderer = new Renderer(WallService.this); + } + + @Override + public void onDestroy() { + Log.d(TAG, "onDestroy"); + renderer.stop(); + renderer = null; + } + + @Override + public void onSurfaceDestroyed(SurfaceHolder holder) { + Log.d(TAG, "onSurfaceDestroyed"); + renderer.stop(); + } + + @Override + public void onSurfaceCreated(SurfaceHolder holder) { + Log.d(TAG, "onSurfaceCreated"); + } + + @Override + public void onSurfaceChanged(SurfaceHolder holder, int format, + int width, int height) { + Log.d(TAG, "onSurfaceChanged"); + } + + @Override + public void onSurfaceRedrawNeeded(SurfaceHolder holder) { + Log.d(TAG, "onSurfaceRedrawNeeded"); + } + + @Override + public void onVisibilityChanged(boolean visible) { + Log.d(TAG, "onVisibilityChanged(visible: " + visible + ")"); + if (visible) { + renderer.start(getSurfaceHolder().getSurface()); + } else { + renderer.stop(); + } + } + } +} |