OSDN Git Service

Update edge and glow rendering to match new specs.
authorMindy Pereira <mindyp@google.com>
Tue, 23 Nov 2010 19:07:30 +0000 (11:07 -0800)
committerMindy Pereira <mindyp@google.com>
Tue, 23 Nov 2010 19:12:20 +0000 (11:12 -0800)
Change-Id: Id2ad0ff4fa78617cb79475952e9ce561ee8fec10

core/java/android/widget/AbsListView.java
core/java/android/widget/EdgeGlow.java

index eb8e2de..423a788 100644 (file)
@@ -3115,8 +3115,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                 final int restoreCount = canvas.save();
                 final int width = getWidth();
 
-                canvas.translate(-width / 2, Math.min(0, scrollY + mFirstPositionDistanceGuess));
-                mEdgeGlowTop.setSize(width * 2, getHeight());
+                canvas.translate(0, Math.min(0, scrollY + mFirstPositionDistanceGuess));
+                mEdgeGlowTop.setSize(width, getHeight());
                 if (mEdgeGlowTop.draw(canvas)) {
                     invalidate();
                 }
@@ -3127,10 +3127,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                 final int width = getWidth();
                 final int height = getHeight();
 
-                canvas.translate(-width / 2,
-                        Math.max(height, scrollY + mLastPositionDistanceGuess));
-                canvas.rotate(180, width, 0);
-                mEdgeGlowBottom.setSize(width * 2, height);
+                canvas.translate(-width, 0);
+                canvas.rotate(-180, width, 0);
+                canvas.translate(0, -height);
+                mEdgeGlowBottom.setSize(width, height);
                 if (mEdgeGlowBottom.draw(canvas)) {
                     invalidate();
                 }
index 416be86..9b3a6e6 100644 (file)
@@ -245,19 +245,23 @@ public class EdgeGlow {
         update();
 
         final int edgeHeight = mEdge.getIntrinsicHeight();
+        final int edgeWidth = mEdge.getIntrinsicWidth();
         final int glowHeight = mGlow.getIntrinsicHeight();
-
-        final float distScale = (float) mHeight / mWidth;
+        final int glowWidth = mGlow.getIntrinsicWidth();
 
         mGlow.setAlpha((int) (Math.max(0, Math.min(mGlowAlpha, 1)) * 255));
-        // Width of the image should be 3 * the width of the screen.
-        // Should start off screen to the left.
-        mGlow.setBounds(-mWidth, 0, mWidth * 2, (int) Math.min(
-                glowHeight * mGlowScaleY * distScale * 0.6f, mHeight * MAX_GLOW_HEIGHT));
+
+        // Center the glow inside the width of the container.
+        int glowLeft = (mWidth - glowWidth)/2;
+        mGlow.setBounds(glowLeft, 0, mWidth - glowLeft, (int) Math.min(
+                glowHeight * mGlowScaleY * glowHeight/ glowWidth * 0.6f,
+                glowHeight * MAX_GLOW_HEIGHT));
         mGlow.draw(canvas);
 
         mEdge.setAlpha((int) (Math.max(0, Math.min(mEdgeAlpha, 1)) * 255));
-        mEdge.setBounds(0, 0, mWidth, (int) (edgeHeight * mEdgeScaleY));
+
+        int edgeLeft = (mWidth - edgeWidth)/2;
+        mEdge.setBounds(edgeLeft, 0, mWidth - edgeLeft, (int) (edgeHeight * mEdgeScaleY));
         mEdge.draw(canvas);
 
         return mState != STATE_IDLE;