OSDN Git Service

b/2343548
authorMarco Nelissen <marcone@google.com>
Tue, 12 Jan 2010 21:58:12 +0000 (13:58 -0800)
committerMarco Nelissen <marcone@google.com>
Tue, 12 Jan 2010 21:58:12 +0000 (13:58 -0800)
Fix the "recently added" spinner.

res/drawable-hdpi/pickerbox_background.9.png [new file with mode: 0644]
res/drawable-hdpi/pickerbox_background.png [deleted file]
res/drawable-mdpi/pickerbox_background.9.png [new file with mode: 0644]
res/drawable-mdpi/pickerbox_background.png [deleted file]
src/com/android/music/VerticalTextSpinner.java

diff --git a/res/drawable-hdpi/pickerbox_background.9.png b/res/drawable-hdpi/pickerbox_background.9.png
new file mode 100644 (file)
index 0000000..fcb4989
Binary files /dev/null and b/res/drawable-hdpi/pickerbox_background.9.png differ
diff --git a/res/drawable-hdpi/pickerbox_background.png b/res/drawable-hdpi/pickerbox_background.png
deleted file mode 100644 (file)
index 9315a31..0000000
Binary files a/res/drawable-hdpi/pickerbox_background.png and /dev/null differ
diff --git a/res/drawable-mdpi/pickerbox_background.9.png b/res/drawable-mdpi/pickerbox_background.9.png
new file mode 100644 (file)
index 0000000..3429abf
Binary files /dev/null and b/res/drawable-mdpi/pickerbox_background.9.png differ
diff --git a/res/drawable-mdpi/pickerbox_background.png b/res/drawable-mdpi/pickerbox_background.png
deleted file mode 100644 (file)
index 6494cd8..0000000
Binary files a/res/drawable-mdpi/pickerbox_background.png and /dev/null differ
index d297d1c..e599eeb 100644 (file)
@@ -21,8 +21,10 @@ import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
+import android.graphics.drawable.NinePatchDrawable;
 import android.text.TextPaint;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
@@ -32,25 +34,21 @@ public class VerticalTextSpinner extends View {
 
     private static final int SELECTOR_ARROW_HEIGHT = 15;
 
-    private static final int TEXT_SPACING = 18;
-    private static final int TEXT_MARGIN_RIGHT = 25;
-    private static final int TEXT_SIZE = 22;
-
-    /* Keep the calculations as this is really a for loop from
-     * -2 to 2 but precalculated so we don't have to do in the onDraw.
-     */
-    private static final int TEXT1_Y = (TEXT_SIZE * (-2 + 2)) + (TEXT_SPACING * (-2 + 1));
-    private static final int TEXT2_Y = (TEXT_SIZE * (-1 + 2)) + (TEXT_SPACING * (-1 + 1));
-    private static final int TEXT3_Y = (TEXT_SIZE * (0 + 2)) + (TEXT_SPACING * (0 + 1));
-    private static final int TEXT4_Y = (TEXT_SIZE * (1 + 2)) + (TEXT_SPACING * (1 + 1));
-    private static final int TEXT5_Y = (TEXT_SIZE * (2 + 2)) + (TEXT_SPACING * (2 + 1));
+    private static int TEXT_SPACING;
+    private static int TEXT_MARGIN_RIGHT;
+    private static int TEXT_SIZE;
+    private static int TEXT1_Y;
+    private static int TEXT2_Y;
+    private static int TEXT3_Y;
+    private static int TEXT4_Y;
+    private static int TEXT5_Y;
+    private static int SCROLL_DISTANCE;
 
     private static final int SCROLL_MODE_NONE = 0;
     private static final int SCROLL_MODE_UP = 1;
     private static final int SCROLL_MODE_DOWN = 2;
 
     private static final long DEFAULT_SCROLL_INTERVAL_MS = 400;
-    private static final int SCROLL_DISTANCE = TEXT_SIZE + TEXT_SPACING;
     private static final int MIN_ANIMATIONS = 4;
 
     private final Drawable mBackgroundFocused;
@@ -105,6 +103,17 @@ public class VerticalTextSpinner extends View {
             int defStyle) {
         super(context, attrs, defStyle);
 
+        float scale = getResources().getDisplayMetrics().density;
+        TEXT_SPACING = (int)(18 * scale);
+        TEXT_MARGIN_RIGHT = (int)(25 * scale);
+        TEXT_SIZE = (int)(22 * scale);
+        SCROLL_DISTANCE = TEXT_SIZE + TEXT_SPACING;
+        TEXT1_Y = (TEXT_SIZE * (-2 + 2)) + (TEXT_SPACING * (-2 + 1));
+        TEXT2_Y = (TEXT_SIZE * (-1 + 2)) + (TEXT_SPACING * (-1 + 1));
+        TEXT3_Y = (TEXT_SIZE * (0 + 2)) + (TEXT_SPACING * (0 + 1));
+        TEXT4_Y = (TEXT_SIZE * (1 + 2)) + (TEXT_SPACING * (1 + 1));
+        TEXT5_Y = (TEXT_SIZE * (2 + 2)) + (TEXT_SPACING * (2 + 1));
+
         mBackgroundFocused = context.getResources().getDrawable(R.drawable.pickerbox_background);
         mSelectorFocused = context.getResources().getDrawable(R.drawable.pickerbox_selected);
         mSelectorNormal = context.getResources().getDrawable(R.drawable.pickerbox_unselected);
@@ -252,7 +261,7 @@ public class VerticalTextSpinner extends View {
         /* The bounds of the selector */
         final int selectorLeft = 0;
         final int selectorTop = mSelectorY;
-        final int selectorRight = getMeasuredWidth();
+        final int selectorRight = getWidth();
         final int selectorBottom = mSelectorY + mSelectorHeight;
 
         /* Draw the selector */