The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.widget; |
| 18 | |
| 19 | import android.graphics.Canvas; |
| 20 | import android.graphics.ColorFilter; |
| 21 | import android.graphics.PixelFormat; |
| 22 | import android.graphics.Rect; |
| 23 | import android.graphics.drawable.Drawable; |
| 24 | |
| 25 | /** |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 26 | * This is only used by View for displaying its scroll bars. It should probably |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | * be moved in to the view package since it is used in that lower-level layer. |
| 28 | * For now, we'll hide it so it can be cleaned up later. |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 29 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | * {@hide} |
| 31 | */ |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 32 | public class ScrollBarDrawable extends Drawable implements Drawable.Callback { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | private Drawable mVerticalTrack; |
| 34 | private Drawable mHorizontalTrack; |
| 35 | private Drawable mVerticalThumb; |
| 36 | private Drawable mHorizontalThumb; |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 37 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | private int mRange; |
| 39 | private int mOffset; |
| 40 | private int mExtent; |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 41 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | private boolean mVertical; |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 43 | private boolean mBoundsChanged; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | private boolean mRangeChanged; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | private boolean mAlwaysDrawHorizontalTrack; |
| 46 | private boolean mAlwaysDrawVerticalTrack; |
Alan Viverette | f8512ce | 2015-02-05 15:58:56 -0800 | [diff] [blame] | 47 | private boolean mMutated; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 49 | private int mAlpha = 255; |
| 50 | private boolean mHasSetAlpha; |
| 51 | |
| 52 | private ColorFilter mColorFilter; |
| 53 | private boolean mHasSetColorFilter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | |
| 55 | /** |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 56 | * Indicate whether the horizontal scrollbar track should always be drawn |
| 57 | * regardless of the extent. Defaults to false. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | * |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 59 | * @param alwaysDrawTrack Whether the track should always be drawn |
| 60 | * |
| 61 | * @see #getAlwaysDrawHorizontalTrack() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | */ |
| 63 | public void setAlwaysDrawHorizontalTrack(boolean alwaysDrawTrack) { |
| 64 | mAlwaysDrawHorizontalTrack = alwaysDrawTrack; |
| 65 | } |
| 66 | |
| 67 | /** |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 68 | * Indicate whether the vertical scrollbar track should always be drawn |
| 69 | * regardless of the extent. Defaults to false. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | * |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 71 | * @param alwaysDrawTrack Whether the track should always be drawn |
| 72 | * |
| 73 | * @see #getAlwaysDrawVerticalTrack() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | */ |
| 75 | public void setAlwaysDrawVerticalTrack(boolean alwaysDrawTrack) { |
| 76 | mAlwaysDrawVerticalTrack = alwaysDrawTrack; |
| 77 | } |
| 78 | |
| 79 | /** |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 80 | * @return whether the vertical scrollbar track should always be drawn |
| 81 | * regardless of the extent. |
| 82 | * |
| 83 | * @see #setAlwaysDrawVerticalTrack(boolean) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | */ |
| 85 | public boolean getAlwaysDrawVerticalTrack() { |
| 86 | return mAlwaysDrawVerticalTrack; |
| 87 | } |
| 88 | |
| 89 | /** |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 90 | * @return whether the horizontal scrollbar track should always be drawn |
| 91 | * regardless of the extent. |
| 92 | * |
| 93 | * @see #setAlwaysDrawHorizontalTrack(boolean) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | */ |
| 95 | public boolean getAlwaysDrawHorizontalTrack() { |
| 96 | return mAlwaysDrawHorizontalTrack; |
| 97 | } |
| 98 | |
| 99 | public void setParameters(int range, int offset, int extent, boolean vertical) { |
| 100 | if (mVertical != vertical) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 101 | mVertical = vertical; |
| 102 | |
| 103 | mBoundsChanged = true; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | if (mRange != range || mOffset != offset || mExtent != extent) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 107 | mRange = range; |
| 108 | mOffset = offset; |
| 109 | mExtent = extent; |
| 110 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | mRangeChanged = true; |
| 112 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public void draw(Canvas canvas) { |
| 117 | final boolean vertical = mVertical; |
| 118 | final int extent = mExtent; |
| 119 | final int range = mRange; |
| 120 | |
| 121 | boolean drawTrack = true; |
| 122 | boolean drawThumb = true; |
| 123 | if (extent <= 0 || range <= extent) { |
| 124 | drawTrack = vertical ? mAlwaysDrawVerticalTrack : mAlwaysDrawHorizontalTrack; |
| 125 | drawThumb = false; |
| 126 | } |
| 127 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 128 | final Rect r = getBounds(); |
Romain Guy | 8fb9542 | 2010-08-17 18:38:51 -0700 | [diff] [blame] | 129 | if (canvas.quickReject(r.left, r.top, r.right, r.bottom, Canvas.EdgeType.AA)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | return; |
| 131 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 132 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | if (drawTrack) { |
| 134 | drawTrack(canvas, r, vertical); |
| 135 | } |
| 136 | |
| 137 | if (drawThumb) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 138 | final int size = vertical ? r.height() : r.width(); |
| 139 | final int thickness = vertical ? r.width() : r.height(); |
| 140 | final int minLength = thickness * 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 142 | // Avoid the tiny thumb. |
| 143 | int length = Math.round((float) size * extent / range); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | if (length < minLength) { |
| 145 | length = minLength; |
| 146 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 147 | |
| 148 | // Avoid the too-big thumb. |
| 149 | int offset = Math.round((float) (size - length) * mOffset / (range - extent)); |
| 150 | if (offset > size - length) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | offset = size - length; |
| 152 | } |
| 153 | |
| 154 | drawThumb(canvas, r, offset, length, vertical); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | @Override |
| 159 | protected void onBoundsChange(Rect bounds) { |
| 160 | super.onBoundsChange(bounds); |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 161 | mBoundsChanged = true; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | } |
| 163 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 164 | @Override |
| 165 | public boolean isStateful() { |
| 166 | return (mVerticalTrack != null && mVerticalTrack.isStateful()) |
| 167 | || (mVerticalThumb != null && mVerticalThumb.isStateful()) |
| 168 | || (mHorizontalTrack != null && mHorizontalTrack.isStateful()) |
| 169 | || (mHorizontalThumb != null && mHorizontalThumb.isStateful()) |
| 170 | || super.isStateful(); |
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | protected boolean onStateChange(int[] state) { |
| 175 | boolean changed = super.onStateChange(state); |
| 176 | if (mVerticalTrack != null) { |
| 177 | changed |= mVerticalTrack.setState(state); |
| 178 | } |
| 179 | if (mVerticalThumb != null) { |
| 180 | changed |= mVerticalThumb.setState(state); |
| 181 | } |
| 182 | if (mHorizontalTrack != null) { |
| 183 | changed |= mHorizontalTrack.setState(state); |
| 184 | } |
| 185 | if (mHorizontalThumb != null) { |
| 186 | changed |= mHorizontalThumb.setState(state); |
| 187 | } |
| 188 | return changed; |
| 189 | } |
| 190 | |
| 191 | private void drawTrack(Canvas canvas, Rect bounds, boolean vertical) { |
| 192 | final Drawable track; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | if (vertical) { |
| 194 | track = mVerticalTrack; |
| 195 | } else { |
| 196 | track = mHorizontalTrack; |
| 197 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 198 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 199 | if (track != null) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 200 | if (mBoundsChanged) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | track.setBounds(bounds); |
| 202 | } |
| 203 | track.draw(canvas); |
| 204 | } |
| 205 | } |
| 206 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 207 | private void drawThumb(Canvas canvas, Rect bounds, int offset, int length, boolean vertical) { |
| 208 | final boolean changed = mRangeChanged || mBoundsChanged; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | if (vertical) { |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 210 | if (mVerticalThumb != null) { |
| 211 | final Drawable thumb = mVerticalThumb; |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 212 | if (changed) { |
| 213 | thumb.setBounds(bounds.left, bounds.top + offset, |
| 214 | bounds.right, bounds.top + offset + length); |
| 215 | } |
| 216 | |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 217 | thumb.draw(canvas); |
| 218 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 219 | } else { |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 220 | if (mHorizontalThumb != null) { |
| 221 | final Drawable thumb = mHorizontalThumb; |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 222 | if (changed) { |
| 223 | thumb.setBounds(bounds.left + offset, bounds.top, |
| 224 | bounds.left + offset + length, bounds.bottom); |
| 225 | } |
| 226 | |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 227 | thumb.draw(canvas); |
| 228 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
| 232 | public void setVerticalThumbDrawable(Drawable thumb) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 233 | if (mVerticalThumb != null) { |
| 234 | mVerticalThumb.setCallback(null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 235 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 236 | |
| 237 | propagateCurrentState(thumb); |
| 238 | mVerticalThumb = thumb; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | public void setVerticalTrackDrawable(Drawable track) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 242 | if (mVerticalTrack != null) { |
| 243 | mVerticalTrack.setCallback(null); |
Alan Viverette | 03748a5 | 2015-01-15 13:00:21 -0800 | [diff] [blame] | 244 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 245 | |
| 246 | propagateCurrentState(track); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | mVerticalTrack = track; |
| 248 | } |
| 249 | |
| 250 | public void setHorizontalThumbDrawable(Drawable thumb) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 251 | if (mHorizontalThumb != null) { |
| 252 | mHorizontalThumb.setCallback(null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 254 | |
| 255 | propagateCurrentState(thumb); |
| 256 | mHorizontalThumb = thumb; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | public void setHorizontalTrackDrawable(Drawable track) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 260 | if (mHorizontalTrack != null) { |
| 261 | mHorizontalTrack.setCallback(null); |
Alan Viverette | 03748a5 | 2015-01-15 13:00:21 -0800 | [diff] [blame] | 262 | } |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 263 | |
| 264 | propagateCurrentState(track); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 265 | mHorizontalTrack = track; |
| 266 | } |
| 267 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 268 | private void propagateCurrentState(Drawable d) { |
| 269 | if (d != null) { |
Alan Viverette | b989c55 | 2015-02-05 17:10:47 -0800 | [diff] [blame] | 270 | if (mMutated) { |
| 271 | d.mutate(); |
| 272 | } |
| 273 | |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 274 | d.setState(getState()); |
| 275 | d.setCallback(this); |
| 276 | |
| 277 | if (mHasSetAlpha) { |
| 278 | d.setAlpha(mAlpha); |
| 279 | } |
| 280 | |
| 281 | if (mHasSetColorFilter) { |
| 282 | d.setColorFilter(mColorFilter); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | public int getSize(boolean vertical) { |
| 288 | if (vertical) { |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 289 | return mVerticalTrack != null ? mVerticalTrack.getIntrinsicWidth() : |
| 290 | mVerticalThumb != null ? mVerticalThumb.getIntrinsicWidth() : 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 291 | } else { |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 292 | return mHorizontalTrack != null ? mHorizontalTrack.getIntrinsicHeight() : |
| 293 | mHorizontalThumb != null ? mHorizontalThumb.getIntrinsicHeight() : 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
| 297 | @Override |
Alan Viverette | f8512ce | 2015-02-05 15:58:56 -0800 | [diff] [blame] | 298 | public ScrollBarDrawable mutate() { |
| 299 | if (!mMutated && super.mutate() == this) { |
| 300 | if (mVerticalTrack != null) { |
| 301 | mVerticalTrack.mutate(); |
| 302 | } |
| 303 | if (mVerticalThumb != null) { |
| 304 | mVerticalThumb.mutate(); |
| 305 | } |
| 306 | if (mHorizontalTrack != null) { |
| 307 | mHorizontalTrack.mutate(); |
| 308 | } |
| 309 | if (mHorizontalThumb != null) { |
| 310 | mHorizontalThumb.mutate(); |
| 311 | } |
| 312 | mMutated = true; |
| 313 | } |
| 314 | return this; |
| 315 | } |
| 316 | |
| 317 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | public void setAlpha(int alpha) { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 319 | mAlpha = alpha; |
| 320 | mHasSetAlpha = true; |
| 321 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 322 | if (mVerticalTrack != null) { |
| 323 | mVerticalTrack.setAlpha(alpha); |
| 324 | } |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 325 | if (mVerticalThumb != null) { |
| 326 | mVerticalThumb.setAlpha(alpha); |
| 327 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 328 | if (mHorizontalTrack != null) { |
| 329 | mHorizontalTrack.setAlpha(alpha); |
| 330 | } |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 331 | if (mHorizontalThumb != null) { |
| 332 | mHorizontalThumb.setAlpha(alpha); |
| 333 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | @Override |
Chet Haase | b1af7f3 | 2013-03-08 14:02:04 -0800 | [diff] [blame] | 337 | public int getAlpha() { |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 338 | return mAlpha; |
Chet Haase | b1af7f3 | 2013-03-08 14:02:04 -0800 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | @Override |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame^] | 342 | public void setColorFilter(ColorFilter colorFilter) { |
| 343 | mColorFilter = colorFilter; |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 344 | mHasSetColorFilter = true; |
| 345 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 346 | if (mVerticalTrack != null) { |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame^] | 347 | mVerticalTrack.setColorFilter(colorFilter); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 348 | } |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 349 | if (mVerticalThumb != null) { |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame^] | 350 | mVerticalThumb.setColorFilter(colorFilter); |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 351 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 352 | if (mHorizontalTrack != null) { |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame^] | 353 | mHorizontalTrack.setColorFilter(colorFilter); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 354 | } |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 355 | if (mHorizontalThumb != null) { |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame^] | 356 | mHorizontalThumb.setColorFilter(colorFilter); |
Chet Haase | 6c8fef7 | 2014-06-27 16:49:05 -0700 | [diff] [blame] | 357 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | @Override |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 361 | public ColorFilter getColorFilter() { |
| 362 | return mColorFilter; |
| 363 | } |
| 364 | |
| 365 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | public int getOpacity() { |
| 367 | return PixelFormat.TRANSLUCENT; |
| 368 | } |
| 369 | |
| 370 | @Override |
Alan Viverette | 029d039 | 2015-01-21 15:41:53 -0800 | [diff] [blame] | 371 | public void invalidateDrawable(Drawable who) { |
| 372 | invalidateSelf(); |
| 373 | } |
| 374 | |
| 375 | @Override |
| 376 | public void scheduleDrawable(Drawable who, Runnable what, long when) { |
| 377 | scheduleSelf(what, when); |
| 378 | } |
| 379 | |
| 380 | @Override |
| 381 | public void unscheduleDrawable(Drawable who, Runnable what) { |
| 382 | unscheduleSelf(what); |
| 383 | } |
| 384 | |
| 385 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | public String toString() { |
| 387 | return "ScrollBarDrawable: range=" + mRange + " offset=" + mOffset + |
| 388 | " extent=" + mExtent + (mVertical ? " V" : " H"); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | |