From 9ecd4810334c02566faaa1c9b3b079a089d5314a Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Mon, 1 Sep 2014 01:57:32 +0200 Subject: photophase: don't reset transition timer on pause JIRA: CYAN-4836 https://jira.cyanogenmod.org/browse/CYAN-4836 Signed-off-by: Jorge Ruesga Change-Id: I816ac4b0c015ec6c3f85272d33100fd710e76e6f --- .../wallpapers/photophase/PhotoPhaseRenderer.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java index 7fb467f..bbb71d1 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java +++ b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java @@ -80,6 +80,7 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer { OopsShape mOopsShape; long mLastRunningTransition; + long mLastTransition; private long mLastTouchTime; private static final long TOUCH_BARRIER_TIME = 1000L; @@ -167,6 +168,7 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer { // Select a new transition mWorld.selectRandomTransition(); mLastRunningTransition = System.currentTimeMillis(); + mLastTransition = System.currentTimeMillis(); // Now force continuously render while transition is applied mDispatcher.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); @@ -589,6 +591,8 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer { mMeasuredHeight = -1; mStatusBarHeight = 0; + mLastTransition = System.currentTimeMillis(); + // We have a 2d (fake) scenario, disable all unnecessary tests. Deep are // necessary for some 3d effects GLES20.glDisable(GL10.GL_DITHER); @@ -725,15 +729,16 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer { // Check if we have some pending transition or transition has // exceed its timeout synchronized (mDrawing) { - if (Preferences.General.Transitions.getTransitionInterval() > 0) { + final int interval = Preferences.General.Transitions.getTransitionInterval(); + if (interval > 0) { if (!mWorld.hasRunningTransition() || isTransitionTimeoutFired()) { mDispatcher.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // Now start a delayed thread to generate the next effect deselectCurrentTransition(); - mLastRunningTransition = 0; - mHandler.postDelayed(mTransitionThread, - Preferences.General.Transitions.getTransitionInterval()); + long diff = System.currentTimeMillis() - mLastTransition; + long delay = Math.max(200, interval - diff); + mHandler.postDelayed(mTransitionThread, delay); } } else { // Just display the initial frames and never make transitions -- cgit v1.2.3