Android ColorStateList - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ColorStateList class.

This code example shows how to use the following methods:getColorForState
    } 
 
    @Override 
    protected boolean onStateChange(int[] stateSet) {
        if (mColorMode == COLOR_MODE_COLOR_STATE_LIST) {
            int pinColor = (mPinColorStateList != null) ? mPinColorStateList.getColorForState(stateSet, Color.BLACK) : Color.BLACK;
            int dotColor = (mDotColorStateList != null) ? mDotColorStateList.getColorForState(stateSet, Color.BLACK) : Color.BLACK;
            if (mCurrentPinColor != pinColor || mCurrentDotColor != dotColor) {
                mCurrentPinColor = pinColor;
                mCurrentDotColor = dotColor;
                mNeedRebuild = true;
                return true; 
            } 
        } 
        return false; 
    } 
 
    @Override 
    public void draw(Canvas canvas) {
        if (mNeedRebuild) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColorForState, getDefaultColor
This code example shows how to use the following methods:
    } 
 
    @Implements(TextView.class)
    public static class TextViewWithDummyGetTextColorsMethod { 
        public static ColorStateList getTextColors(Context context, TypedArray attrs) {
            return new ColorStateList(new int[0][0], new int[0]);
        } 
    } 
 
    @Test 
    public void testDirectlyOn_CallTwiceChecking() throws Exception { 
        directlyOn(View.class);
 
        Exception e = null;
        try { 
            directlyOn(View.class);
        } catch (RuntimeException e1) {
            e = e1;
        } 
        assertNotNull(e);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDefaultColor
    public int getBorder() { 
        return mBorderWidth;
    } 
 
    public int getBorderColor() { 
        return mBorderColor.getDefaultColor();
    } 
 
    public ColorStateList getBorderColors() {
        return mBorderColor;
    } 
 
    public void setCornerRadius(int radius) {
        if (mCornerRadius == radius) {
            return; 
        } 
 
        mCornerRadius = radius;
        if (mDrawable instanceof RoundedDrawable) {
            ((RoundedDrawable) mDrawable).setCornerRadius(radius);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColorForState, getDefaultColor
        mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
        mThumbDrawable.draw(canvas);
 
        // mTextColors should not be null, but just in case 
        if (mTextColors != null) {
            mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(), mTextColors.getDefaultColor()));
        } 
        mTextPaint.drawableState = getDrawableState();
 
        final Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
 
        canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
        switchText.draw(canvas);
 
        canvas.restore();
    } 
 
    @Override 
    public int getCompoundPaddingRight() { 
        int padding = super.getCompoundPaddingRight() + mSwitchWidth;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isStateful
        mBorderPaint.setStrokeWidth(border);
    } 
 
    @Override 
    public boolean isStateful() { 
        return mBorderColor.isStateful();
    } 
 
    @Override 
    protected boolean onStateChange(int[] state) {
        int newColor = mBorderColor.getColorForState(state, 0);
        if (mBorderPaint.getColor() != newColor) {
            mBorderPaint.setColor(newColor);
            return true; 
        } else { 
            return super.onStateChange(state);
        } 
    } 
 
    protected void setScaleType(ScaleType scaleType) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    verifyAll(); 
  } 
 
  @SmallTest 
  public void testGetColorStateList() { 
    ColorStateList stateList = new ColorStateList(new int[0][0], new int[0]);
    expect(base.getColorStateList(10)).andReturn(stateList);
    replayAll(); 
 
    assertSame(stateList, resources.getColorStateList(10));
 
    verifyAll(); 
  } 
 
  @SmallTest 
  public void  testGetConfiguration() { 
    Configuration configuration = new Configuration();
    expect(base.getConfiguration()).andReturn(configuration);
    replayAll(); 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColorForState, getDefaultColor
		mThumbDrawable.draw(canvas);
 
		// mTextColors should not be null, but just in case 
		if (mTextColors != null)
		{ 
			mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(), mTextColors.getDefaultColor()));
		} 
		mTextPaint.drawableState = getDrawableState();
 
		Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
		if (switchText != null)
		{ 
			canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
			switchText.draw(canvas);
		} 
 
		canvas.restore();
	} 
 
	@Override 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColorForState
    @Override 
    protected boolean onStateChange(final int[] stateSet) {
        if (mColorMode == COLOR_MODE_COLOR_STATE_LIST) {
            int pinColor = (mPinColorStateList != null) ? mPinColorStateList.getColorForState(
                    stateSet, Color.BLACK) : Color.BLACK;
            int dotColor = (mDotColorStateList != null) ? mDotColorStateList.getColorForState(
                    stateSet, Color.BLACK) : Color.BLACK;
            if (mCurrentPinColor != pinColor || mCurrentDotColor != dotColor) {
                mCurrentPinColor = pinColor;
                mCurrentDotColor = dotColor;
                mNeedRebuild = true;
                return true; 
            } 
        } 
        return false; 
    } 
 
    @Override 
    public void draw(final Canvas canvas) {
        if (mNeedRebuild) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:writeToParcel
        } else { 
            dest.writeInt(0);
        } 
        if (mTextColorLink != null) {
            dest.writeInt(1);
            mTextColorLink.writeToParcel(dest, flags);
        } else { 
            dest.writeInt(0);
        } 
    } 
 
    /** 
     * Returns the typeface family specified by this span, or <code>null</code> 
     * if it does not specify one. 
     */ 
    public String getFamily() {
        return mTypeface;
    } 
 
    /** 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android ColorStateList Questions & Answers:

See Code Examples for Android ColorStateList Methods: