Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.ui; | 5 package org.chromium.ui; |
| 6 | 6 |
| 7 import android.graphics.Canvas; | 7 import android.graphics.Canvas; |
| 8 import android.graphics.ColorFilter; | 8 import android.graphics.ColorFilter; |
| 9 import android.graphics.Paint; | 9 import android.graphics.Paint; |
| 10 import android.graphics.PixelFormat; | 10 import android.graphics.PixelFormat; |
| 11 import android.graphics.Rect; | 11 import android.graphics.Rect; |
| 12 import android.graphics.drawable.Drawable; | 12 import android.graphics.drawable.Drawable; |
| 13 | 13 |
| 14 class DropdownDividerDrawable extends Drawable { | 14 class DropdownDividerDrawable extends Drawable { |
| 15 | 15 |
| 16 private Paint mPaint; | 16 private Paint mPaint; |
| 17 private Rect mDividerRect; | 17 private Rect mDividerRect; |
| 18 private int mBackgroundColor; | |
| 18 | 19 |
| 19 public DropdownDividerDrawable() { | 20 /** |
| 21 * Creates a drawable to draw a divider line that separate the list of {@cod e DropdownItem} and, | |
|
Theresa
2016/12/08 21:38:17
s/separate/separates
{@link DropdownItem}
csashi
2016/12/08 23:03:30
Done.
| |
| 22 * optionally, paints the rectangular canvas. | |
| 23 * @param backgroundColor Popup background color. Skips painting the canvas if | |
| 24 * {@code Color.TRANSPARENT}. | |
| 25 */ | |
| 26 public DropdownDividerDrawable(int backgroundColor) { | |
| 20 mPaint = new Paint(); | 27 mPaint = new Paint(); |
| 21 mDividerRect = new Rect(); | 28 mDividerRect = new Rect(); |
| 29 mBackgroundColor = backgroundColor; | |
| 22 } | 30 } |
| 23 | 31 |
| 24 @Override | 32 @Override |
| 25 public void draw(Canvas canvas) { | 33 public void draw(Canvas canvas) { |
| 34 if (mBackgroundColor != 0) canvas.drawColor(mBackgroundColor); | |
| 26 canvas.drawRect(mDividerRect, mPaint); | 35 canvas.drawRect(mDividerRect, mPaint); |
| 27 } | 36 } |
| 28 | 37 |
| 29 @Override | 38 @Override |
| 30 public void onBoundsChange(Rect bounds) { | 39 public void onBoundsChange(Rect bounds) { |
| 31 mDividerRect.set(0, 0, bounds.width(), mDividerRect.height()); | 40 mDividerRect.set(0, 0, bounds.width(), mDividerRect.height()); |
| 32 } | 41 } |
| 33 | 42 |
| 34 public void setHeight(int height) { | 43 public void setHeight(int height) { |
| 35 mDividerRect.set(0, 0, mDividerRect.right, height); | 44 mDividerRect.set(0, 0, mDividerRect.right, height); |
| 36 } | 45 } |
| 37 | 46 |
| 38 public void setColor(int color) { | 47 public void setDividerColor(int color) { |
| 39 mPaint.setColor(color); | 48 mPaint.setColor(color); |
| 40 } | 49 } |
| 41 | 50 |
| 42 @Override | 51 @Override |
| 43 public void setAlpha(int alpha) { | 52 public void setAlpha(int alpha) { |
| 44 } | 53 } |
| 45 | 54 |
| 46 @Override | 55 @Override |
| 47 public void setColorFilter(ColorFilter cf) { | 56 public void setColorFilter(ColorFilter cf) { |
| 48 } | 57 } |
| 49 | 58 |
| 50 @Override | 59 @Override |
| 51 public int getOpacity() { | 60 public int getOpacity() { |
| 52 return PixelFormat.TRANSPARENT; | 61 return PixelFormat.TRANSPARENT; |
| 53 } | 62 } |
| 54 } | 63 } |
| OLD | NEW |