1/*
2 * Copyright (C) 2014 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
17package android.support.v7.widget;
18
19import android.content.Context;
20import android.graphics.Canvas;
21import android.support.v7.appcompat.R;
22import android.util.AttributeSet;
23import android.widget.SeekBar;
24
25/**
26 * A {@link SeekBar} which supports compatible features on older version of the platform.
27 *
28 * <p>This will automatically be used when you use {@link SeekBar} in your layouts.
29 * You should only need to manually use this class when writing custom views.</p>
30 */
31public class AppCompatSeekBar extends SeekBar {
32
33    private AppCompatSeekBarHelper mAppCompatSeekBarHelper;
34    private AppCompatDrawableManager mDrawableManager;
35
36    public AppCompatSeekBar(Context context) {
37        this(context, null);
38    }
39
40    public AppCompatSeekBar(Context context, AttributeSet attrs) {
41        this(context, attrs, R.attr.seekBarStyle);
42    }
43
44    public AppCompatSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
45        super(context, attrs, defStyleAttr);
46
47        mDrawableManager = AppCompatDrawableManager.get();
48
49        mAppCompatSeekBarHelper = new AppCompatSeekBarHelper(this, mDrawableManager);
50        mAppCompatSeekBarHelper.loadFromAttributes(attrs, defStyleAttr);
51    }
52
53    @Override
54    protected void onDraw(Canvas canvas) {
55        super.onDraw(canvas);
56        mAppCompatSeekBarHelper.drawTickMarks(canvas);
57    }
58
59    @Override
60    protected void drawableStateChanged() {
61        super.drawableStateChanged();
62        mAppCompatSeekBarHelper.drawableStateChanged();
63    }
64
65    @Override
66    public void jumpDrawablesToCurrentState() {
67        super.jumpDrawablesToCurrentState();
68        mAppCompatSeekBarHelper.jumpDrawablesToCurrentState();
69    }
70}
71