Example usage for android.content.res TypedArray getColor

List of usage examples for android.content.res TypedArray getColor

Introduction

In this page you can find the example usage for android.content.res TypedArray getColor.

Prototype

@ColorInt
public int getColor(@StyleableRes int index, @ColorInt int defValue) 

Source Link

Document

Retrieve the color value for the attribute at index.

Usage

From source file:com.filemanager.free.ui.views.Indicator.java

public Indicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Indicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.Indicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;// w  w  w . j  a  va2  s .co m
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.Indicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.Indicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    int unselectedColour = a.getColor(R.styleable.Indicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    int selectedColour = a.getColor(R.styleable.Indicator_currentPageIndicatorColor, DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:com.commit451.inkpageindicator.InkPageIndicator.java

public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;//from w w w.  ja v  a  2  s .  c  o  m
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = new FastOutSlowInInterpolator();

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:com.amitupadhyay.aboutexample.ui.widget.InkPageIndicator.java

public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;//from ww  w .  ja  va 2s  .c o  m
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:com.fjoglar.etsitnoticias.view.widget.InkPageIndicator.java

public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;//  w w w .ja va2 s  . c o m
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        interpolator = AnimUtils.getFastOutSlowInInterpolator(context);
    } else {
        interpolator = null;
    }

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:br.liveo.searchliveo.SearchCardLiveo.java

private void initAttribute(Context context, AttributeSet attributeSet, int defStyleAttr) {
    TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.search_card_liveo, defStyleAttr,
            0);//from   www  .j  a va  2 s . co  m
    if (attr != null) {
        try {

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_hint)) {
                hint(attr.getString(R.styleable.search_card_liveo_search_card_liveo_hint));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_text_color)) {
                mEdtSearch.setTextColor(
                        attr.getColor(R.styleable.search_card_liveo_search_card_liveo_text_color, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_hint_color)) {
                mEdtSearch.setHintTextColor(
                        attr.getColor(R.styleable.search_card_liveo_search_card_liveo_hint_color, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_icon)) {
                setColorIcon(attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_icon, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_arrow)) {
                setColorIconArrow(
                        attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_arrow, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_voice)) {
                setColorIconVoice(
                        attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_voice, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_close)) {
                setColorIconClose(
                        attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_close, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_background)) {
                mCardSearch.setBackgroundColor(
                        attr.getColor(R.styleable.search_card_liveo_search_card_liveo_background, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_status_bar_show_color)) {
                setStatusBarShowColor(attr
                        .getColor(R.styleable.search_card_liveo_search_card_liveo_status_bar_show_color, -1));
            }

            if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_status_bar_hide_color)) {
                setStatusBarHideColor(attr
                        .getColor(R.styleable.search_card_liveo_search_card_liveo_status_bar_hide_color, -1));
            }
        } finally {
            attr.recycle();
        }
    }
}

From source file:com.seatgeek.placesautocompletedemo.MainFragment.java

/**
 * chooses a random color from array.xml
 *//*from  www  .  ja  v  a2 s  .  c om*/
private int getRandomMaterialColor(String typeColor) {
    int returnColor = Color.GRAY;
    int arrayId = getResources().getIdentifier("mdcolor_" + typeColor, "array", getContext().getPackageName());

    if (arrayId != 0) {
        TypedArray colors = getResources().obtainTypedArray(arrayId);
        int index = (int) (Math.random() * colors.length());
        returnColor = colors.getColor(index, Color.GRAY);
        colors.recycle();
    }
    return returnColor;
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedPost.java

private void rebuildSubtitle(Context context) {

    // TODO customise display
    // TODO preference for the X days, X hours thing

    final TypedArray appearance = context
            .obtainStyledAttributes(new int[] { R.attr.srPostSubtitleBoldCol, R.attr.srPostSubtitleUpvoteCol,
                    R.attr.srPostSubtitleDownvoteCol, R.attr.srFlairBackCol, R.attr.srFlairTextCol });

    final int boldCol = appearance.getColor(0, 255), rrPostSubtitleUpvoteCol = appearance.getColor(1, 255),
            rrPostSubtitleDownvoteCol = appearance.getColor(2, 255),
            rrFlairBackCol = appearance.getColor(3, 255), rrFlairTextCol = appearance.getColor(4, 255);

    appearance.recycle();//w w  w.  j  a v  a2s.  c  o m

    final BetterSSB postListDescSb = new BetterSSB();

    //      SpannableStringBuilder for the Karma that goes between our up/downvote arrows
    final BetterSSB karmaSb = new BetterSSB();

    final int pointsCol;

    final int score = computeScore();

    if (isUpvoted()) {
        pointsCol = rrPostSubtitleUpvoteCol;
    } else if (isDownvoted()) {
        pointsCol = rrPostSubtitleDownvoteCol;
    } else {
        pointsCol = boldCol;
    }

    if (src.isSpoiler()) {
        postListDescSb.append(" SPOILER ",
                BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, Color.WHITE,
                Color.rgb(50, 50, 50), 1f);
        postListDescSb.append("  ", 0);
    }

    if (src.isStickied()) {
        postListDescSb.append(" STICKY ",
                BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, Color.WHITE,
                Color.rgb(0, 170, 0), 1f); // TODO color?
        postListDescSb.append("  ", 0);
    }

    if (src.isNsfw()) {
        postListDescSb.append(" NSFW ",
                BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, Color.WHITE,
                Color.RED, 1f); // TODO color?
        postListDescSb.append("  ", 0);
    }

    if (src.getFlairText() != null) {
        postListDescSb.append(" " + src.getFlairText() + " ",
                BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR | BetterSSB.BACKGROUND_COLOR, rrFlairTextCol,
                rrFlairBackCol, 1f);
        postListDescSb.append("  ", 0);
    }

    postListDescSb.append(String.valueOf(score), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, pointsCol, 0, 1f);
    postListDescSb.append(" " + context.getString(R.string.subtitle_points) + " ", 0);
    postListDescSb.append(SRTime.formatDurationFrom(context, src.getCreatedTimeSecsUTC() * 1000),
            BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, boldCol, 0, 1f);
    postListDescSb.append(" " + context.getString(R.string.subtitle_by) + " ", 0);
    postListDescSb.append(src.getAuthor(), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, boldCol, 0, 1f);

    if (showSubreddit) {
        postListDescSb.append(" " + context.getString(R.string.subtitle_to) + " ", 0);
        postListDescSb.append(src.getSubreddit(), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, boldCol, 0, 1f);
    }

    postListDescSb.append(" (" + src.getDomain() + ")", 0);

    karmaSb.append(String.valueOf(score), BetterSSB.BOLD | BetterSSB.FOREGROUND_COLOR, pointsCol, 0, 1f);

    postListDescription = postListDescSb.get();
    postKarma = karmaSb.get();
}

From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java

private void setupStyleable(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundCornerProgress);

    radius = (int) typedArray.getDimension(R.styleable.RoundCornerProgress_rcRadius,
            dp2px(DEFAULT_PROGRESS_RADIUS));
    padding = (int) typedArray.getDimension(R.styleable.RoundCornerProgress_rcBackgroundPadding,
            dp2px(DEFAULT_BACKGROUND_PADDING));

    isReverse = typedArray.getBoolean(R.styleable.RoundCornerProgress_rcReverse, false);

    max = typedArray.getFloat(R.styleable.RoundCornerProgress_rcMax, DEFAULT_MAX_PROGRESS);
    progress = typedArray.getFloat(R.styleable.RoundCornerProgress_rcProgress, DEFAULT_PROGRESS);
    secondaryProgress = typedArray.getFloat(R.styleable.RoundCornerProgress_rcSecondaryProgress,
            DEFAULT_SECONDARY_PROGRESS);

    int colorBackgroundDefault = ContextCompat.getColor(context,
            R.color.round_corner_progress_bar_background_default);
    colorBackground = typedArray.getColor(R.styleable.RoundCornerProgress_rcBackgroundColor,
            colorBackgroundDefault);/*from   w w  w.  j a v a2 s  .  c om*/
    int colorProgressDefault = ContextCompat.getColor(context,
            R.color.round_corner_progress_bar_progress_default);
    colorProgress = typedArray.getColor(R.styleable.RoundCornerProgress_rcProgressColor, colorProgressDefault);
    int colorSecondaryProgressDefault = ContextCompat.getColor(context,
            R.color.round_corner_progress_bar_secondary_progress_default);
    colorSecondaryProgress = typedArray.getColor(R.styleable.RoundCornerProgress_rcSecondaryProgressColor,
            colorSecondaryProgressDefault);
    typedArray.recycle();

    initStyleable(context, attrs);
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }//from  w w  w.  j a  v  a 2 s  . c om

    View view = inflater.inflate(R.layout.radial_time_picker_dialog, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId,
            R.styleable.BetterPickersDialogs);

    // Prepare some colors to use.
    int headerBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpBlue));
    int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor,
            ContextCompat.getColor(getActivity(), R.color.bpBlue));
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor,
            ContextCompat.getColor(getActivity(), R.color.bpWhite));
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor,
            ContextCompat.getColor(getActivity(), R.color.radial_gray_light));

    mHourPickerDescription = res.getString(R.string.hour_picker_description);
    mSelectHours = res.getString(R.string.select_hours);
    mMinutePickerDescription = res.getString(R.string.minute_picker_description);
    mSelectMinutes = res.getString(R.string.select_minutes);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute,
            mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mTitleTextView = (TextView) view.findViewById(R.id.time_picker_header);
    if (mTitleText != null) {
        mTitleTextView.setVisibility(View.VISIBLE);
        mTitleTextView.setText(mTitleText);
    } else {
        mTitleTextView.setVisibility(View.GONE);
    }

    mError = (NumberPickerErrorTextView) view.findViewById(R.id.error);

    if (hasTimeLimits()) {
        mError.setVisibility(View.INVISIBLE);
    } else {
        mError.setVisibility(View.GONE);
    }

    mDoneButton = (Button) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        mDoneButton.setText(mDoneText);
    }
    mDoneButton.setTextColor(buttonTextColor);
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            doneClickValidateAndCallback();
        }
    });
    mDoneButton.setOnKeyListener(keyboardListener);

    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    if (mCancelText != null) {
        cancelButton.setText(mCancelText);
    }
    cancelButton.setTextColor(buttonTextColor);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            dismiss();
        }
    });

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(themeColors);

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(headerBgColor);
    view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
    view.findViewById(R.id.time_display).setBackgroundColor(headerBgColor);
    view.findViewById(R.id.time_picker_error_holder).setBackgroundColor(headerBgColor);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(mUnselectedColor);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mUnselectedColor);
    mTimePicker.setBackgroundColor(bodyBgColor);
    return view;
}

From source file:android.car.ui.provider.CarDrawerLayout.java

public CarDrawerLayout(final Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mViewFaders = new HashSet<>();
    mEndingViewColor = getResources().getColor(R.color.car_tint);

    mEdgeHighlightPaint.setColor(getResources().getColor(android.R.color.black));

    final float density = getResources().getDisplayMetrics().density;
    final float minVel = MIN_FLING_VELOCITY * density;

    ViewDragCallback viewDragCallback = new ViewDragCallback();
    mDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, viewDragCallback);
    mDragger.setMinVelocity(minVel);/*w ww  .j a  v  a  2s.  c  o  m*/
    viewDragCallback.setDragger(mDragger);

    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);

    if (SHADOW_ENABLED) {
        setDrawerShadow(CarUiResourceLoader.getDrawable(context, "drawer_shadow"));
    }

    Resources.Theme theme = context.getTheme();
    TypedArray ta = theme.obtainStyledAttributes(new int[] { android.R.attr.colorPrimaryDark });
    setScrimColor(ta.getColor(0, context.getResources().getColor(R.color.car_grey_900)));

    mViewFaderInterpolator = new ReversibleInterpolator(
            new QuantumInterpolator(QuantumInterpolator.FAST_OUT_SLOW_IN, 0.25f, 0.25f, 0.5f),
            new QuantumInterpolator(QuantumInterpolator.FAST_OUT_SLOW_IN, 0.43f, 0.14f, 0.43f));
    mDrawerFadeInterpolator = new ReversibleInterpolator(
            new QuantumInterpolator(QuantumInterpolator.FAST_OUT_SLOW_IN, 0.625f, 0.25f, 0.125f),
            new QuantumInterpolator(QuantumInterpolator.FAST_OUT_LINEAR_IN, 0.58f, 0.14f, 0.28f));

    mHasWheel = CarUiResourceLoader.getBoolean(context, "has_wheel", false);
}