@Override public void onOffsetsChanged( float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) { super.onOffsetsChanged( xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset); int xStep = 1; int yStep = 1; if (xOffsetStep > 0) xStep = Math.round(1f / xOffsetStep) + 1; if (yOffsetStep > 0) yStep = Math.round(1f / yOffsetStep) + 1; if (xOffsetStep == 1 && xOffset == 0.5) xStep = 1; if (yOffsetStep == 1 && yOffset == 0.5) yStep = 1; if (yStep != this.ySteps || xStep != this.xSteps) this.replaceRequired = true; synchronized (this) { this.xSteps = xStep; this.ySteps = yStep; this.xPos = xOffset; this.yPos = yOffset; this.redrawRequired = true; updateSize(); } redrawImage(); }
void doOffsetsChanged(boolean always) { if (mDestroyed) { return; } if (!always && !mOffsetsChanged) { return; } float xOffset; float yOffset; float xOffsetStep; float yOffsetStep; boolean sync; synchronized (mLock) { xOffset = mPendingXOffset; yOffset = mPendingYOffset; xOffsetStep = mPendingXOffsetStep; yOffsetStep = mPendingYOffsetStep; sync = mPendingSync; mPendingSync = false; mOffsetMessageEnqueued = false; } if (mSurfaceCreated) { if (mReportedVisible) { if (DEBUG) Log.v(TAG, "Offsets change in " + this + ": " + xOffset + "," + yOffset); final int availw = mIWallpaperEngine.mReqWidth - mCurWidth; final int xPixels = availw > 0 ? -(int) (availw * xOffset + .5f) : 0; final int availh = mIWallpaperEngine.mReqHeight - mCurHeight; final int yPixels = availh > 0 ? -(int) (availh * yOffset + .5f) : 0; onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels); } else { mOffsetsChanged = true; } } if (sync) { try { if (DEBUG) Log.v(TAG, "Reporting offsets change complete"); mSession.wallpaperOffsetsComplete(mWindow.asBinder()); } catch (RemoteException e) { } } }