android.support.v4.graphics.drawable.DrawableCompat Java Examples

The following examples show how to use android.support.v4.graphics.drawable.DrawableCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmTintUtils.java    From AndroidTint with Apache License 2.0 6 votes vote down vote up
public static void setTint(@NonNull Button button, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        button.setCompoundDrawableTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable drawable = DrawableCompat.wrap(button.getCompoundDrawables()[1]);
        button.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
        DrawableCompat.setTintList(drawable, s1);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (button.getCompoundDrawables()[1] != null)
            button.getCompoundDrawables()[1].setColorFilter(color, mode);
    }
}
 
Example #2
Source File: AppCompatImageHelper.java    From MagicaSakura with Apache License 2.0 6 votes vote down vote up
private boolean applySupportImageTint() {
    Drawable image = mView.getDrawable();
    if (image != null && mImageTintInfo != null && mImageTintInfo.mHasTintList) {
        Drawable tintDrawable = image.mutate();
        tintDrawable = DrawableCompat.wrap(tintDrawable);
        if (mImageTintInfo.mHasTintList) {
            DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList);
        }
        if (mImageTintInfo.mHasTintMode) {
            DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode);
        }
        if (tintDrawable.isStateful()) {
            tintDrawable.setState(mView.getDrawableState());
        }
        setImageDrawable(tintDrawable);
        if (image == tintDrawable) {
            tintDrawable.invalidateSelf();
        }
        return true;
    }
    return false;
}
 
Example #3
Source File: MessageInputStyle.java    From ChatKit with Apache License 2.0 6 votes vote down vote up
private Drawable getSelector(@ColorInt int normalColor, @ColorInt int pressedColor,
                             @ColorInt int disabledColor, @DrawableRes int shape) {

    Drawable drawable = DrawableCompat.wrap(getVectorDrawable(shape)).mutate();
    DrawableCompat.setTintList(
            drawable,
            new ColorStateList(
                    new int[][]{
                            new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed},
                            new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed},
                            new int[]{-android.R.attr.state_enabled}
                    },
                    new int[]{normalColor, pressedColor, disabledColor}
            ));
    return drawable;
}
 
Example #4
Source File: StoryView.java    From zom-android-matrix with Apache License 2.0 6 votes vote down vote up
private void setRecordedAudio(MediaInfo recordedAudio) {
    this.recordedAudio = recordedAudio;
    if (this.recordedAudio != null) {
        mMicButton.setVisibility(View.GONE);
        mSendButton.setVisibility(View.VISIBLE);
        Drawable d = ActivityCompat.getDrawable(mActivity, R.drawable.ic_close_white_24dp).mutate();
        DrawableCompat.setTint(d, Color.GRAY);
        mActivity.getSupportActionBar().setHomeAsUpIndicator(d);
        mActivity.setBackButtonHandler(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StoryExoPlayerManager.stop(previewAudio);
                setRecordedAudio(null);
            }
        });
    } else {
        mActivity.getSupportActionBar().setHomeAsUpIndicator(null);
        mActivity.setBackButtonHandler(null);
        previewAudio.setVisibility(View.GONE);
        mComposeMessage.setVisibility(View.VISIBLE);
        mComposeMessage.setText("");
        mMicButton.setVisibility(View.VISIBLE);
    }
}
 
Example #5
Source File: LayerDrawable.java    From RippleDrawable with MIT License 6 votes vote down vote up
/**
 * Add a new layer to this drawable. The new layer is identified by an id.
 *
 * @param layer      The drawable to add as a layer.
 * @param themeAttrs Theme attributes extracted from the layer.
 * @param id         The id of the new layer.
 * @param left       The left padding of the new layer.
 * @param top        The top padding of the new layer.
 * @param right      The right padding of the new layer.
 * @param bottom     The bottom padding of the new layer.
 */
ChildDrawable addLayer(Drawable layer, TypedValue[] themeAttrs, int id, int left, int top, int right, int bottom) {
    final ChildDrawable childDrawable = new ChildDrawable();
    childDrawable.mId = id;
    childDrawable.mThemeAttrs = themeAttrs;
    childDrawable.mDrawable = layer;
    DrawableCompat.setAutoMirrored(childDrawable.mDrawable, isAutoMirrored());
    childDrawable.mInsetL = left;
    childDrawable.mInsetT = top;
    childDrawable.mInsetR = right;
    childDrawable.mInsetB = bottom;

    addLayer(childDrawable);

    mLayerState.mChildrenChangingConfigurations |= layer.getChangingConfigurations();
    layer.setCallback(this);

    return childDrawable;
}
 
Example #6
Source File: CameraSwitchView.java    From phoenix with Apache License 2.0 6 votes vote down vote up
private void initializeView() {
    Context context = getContext();
    frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.phoenix_camera_alt_white);
    frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable);
    DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.phoenix_selector_switch_camera_mode));

    rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.phoenix_camera_alt_white);
    rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable);
    DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.phoenix_selector_switch_camera_mode));

    setBackgroundResource(android.R.color.transparent);
    displayBackCamera();

    padding = DeviceUtils.convertDipToPixels(context, padding);
    setPadding(padding, padding, padding, padding);

    displayBackCamera();
}
 
Example #7
Source File: PickerThemeUtils.java    From AppCompat-Extension-Library with Apache License 2.0 6 votes vote down vote up
public static void setNavButtonDrawable(Context context, ImageButton left, ImageButton right,
                                        int monthTextAppearanceResId) {
    // Retrieve the previous and next drawables
    AppCompatDrawableManager dm = AppCompatDrawableManager.get();
    Drawable prevDrawable = dm.getDrawable(context, R.drawable.ic_chevron_left_black_24dp);
    Drawable nextDrawable = dm.getDrawable(context, R.drawable.ic_chevron_right_black_24dp);

    // Proxy the month text color into the previous and next drawables.
    final TypedArray ta = context.obtainStyledAttributes(null,
            new int[]{android.R.attr.textColor}, 0, monthTextAppearanceResId);
    final ColorStateList monthColor = ta.getColorStateList(0);
    if (monthColor != null) {
        DrawableCompat.setTint(DrawableCompat.wrap(prevDrawable), monthColor.getDefaultColor());
        DrawableCompat.setTint(DrawableCompat.wrap(nextDrawable), monthColor.getDefaultColor());
    }
    ta.recycle();

    // Set the previous and next drawables
    left.setImageDrawable(prevDrawable);
    right.setImageDrawable(nextDrawable);
}
 
Example #8
Source File: MessagesListStyle.java    From ChatKit with Apache License 2.0 6 votes vote down vote up
private Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor,
                                    @ColorInt int pressedColor, @DrawableRes int shape) {

    Drawable drawable = DrawableCompat.wrap(getVectorDrawable(shape)).mutate();
    DrawableCompat.setTintList(
            drawable,
            new ColorStateList(
                    new int[][]{
                            new int[]{android.R.attr.state_selected},
                            new int[]{android.R.attr.state_pressed},
                            new int[]{-android.R.attr.state_pressed, -android.R.attr.state_selected}
                    },
                    new int[]{selectedColor, pressedColor, normalColor}
            ));
    return drawable;
}
 
Example #9
Source File: Easel.java    From andela-crypto-app with Apache License 2.0 6 votes vote down vote up
/**
 * Tint the radio button
 *
 * @param radioButton the radio button
 * @param color       the color
 */
public static void tint(@NonNull RadioButton radioButton, @ColorInt int color) {
    final int disabledColor = getDisabledColor(radioButton.getContext());
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            getThemeAttrColor(radioButton.getContext(), R.attr.colorControlNormal),
            color,
            disabledColor,
            disabledColor
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, sl);
        radioButton.setButtonDrawable(d);
    }
}
 
Example #10
Source File: BitmapHelper.java    From CameraButton with Apache License 2.0 6 votes vote down vote up
@SuppressLint("ObsoleteSdkInt")
static Bitmap getBitmap(Drawable drawable) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }

    Bitmap bitmap = Bitmap.createBitmap(
            drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(),
            Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
 
Example #11
Source File: IncDecImageButton.java    From IncDec with Apache License 2.0 6 votes vote down vote up
private void setupLeftButton(ImageButton leftButton, Drawable leftSrc,
                             int leftButtonTint, int leftDrawableTint,Drawable background) {
    if(leftSrc!=null) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            leftSrc.setTintList(new ColorStateList(new int[][]{new int[]{0}},
                    new int[]{leftDrawableTint}));
        }
        else
        {
            final Drawable wrappedDrawable = DrawableCompat.wrap(leftSrc);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(leftDrawableTint));
        }
        leftButton.setImageDrawable(leftSrc);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        leftButton.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}},
                new int[]{leftButtonTint}));
    }
    else
    {
        ViewCompat.setBackgroundTintList(leftButton, ColorStateList.valueOf(leftButtonTint));
    }
    leftButton.setBackground(background);

}
 
Example #12
Source File: AppCompatForegroundHelper.java    From timecat with Apache License 2.0 6 votes vote down vote up
private boolean applySupportForegroundTint() {
    Drawable foregroundDrawable = getForeground();
    if (foregroundDrawable != null && mForegroundTintInfo != null && mForegroundTintInfo.mHasTintList) {
        foregroundDrawable = DrawableCompat.wrap(foregroundDrawable);
        foregroundDrawable = foregroundDrawable.mutate();
        if (mForegroundTintInfo.mHasTintList) {
            DrawableCompat.setTintList(foregroundDrawable, mForegroundTintInfo.mTintList);
        }
        if (mForegroundTintInfo.mHasTintMode) {
            DrawableCompat.setTintMode(foregroundDrawable, mForegroundTintInfo.mTintMode);
        }
        if (foregroundDrawable.isStateful()) {
            foregroundDrawable.setState(mView.getDrawableState());
        }
        setForegroundDrawable(foregroundDrawable);
        return true;
    }
    return false;
}
 
Example #13
Source File: ShowHidePasswordEditText.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
/**
 * 显示或隐藏小眼睛
 *
 * @param show
 */
private void showPasswordVisibilityIndicator(boolean show) {
    if (show) {
        Drawable original = isShowingPassword ?
                ContextCompat.getDrawable(getContext(), visiblityIndicatorHide) :
                ContextCompat.getDrawable(getContext(), visiblityIndicatorShow);
        original.mutate();

        if (tintColor == 0) {
            setCompoundDrawablesWithIntrinsicBounds(leftToRight ? null : original, null, leftToRight ? original : null, null);
        } else {
            Drawable wrapper = DrawableCompat.wrap(original);
            DrawableCompat.setTint(wrapper, tintColor);
            setCompoundDrawablesWithIntrinsicBounds(leftToRight ? null : wrapper, null, leftToRight ? wrapper : null, null);
        }
    } else {
        setCompoundDrawables(null, null, null, null);
    }
}
 
Example #14
Source File: BottomDialog.java    From BottomDialog with MIT License 5 votes vote down vote up
/**
 * @param drawable Drawable from menu item
 * @return Drawable resized 32dp x 32dp and colored with color textColorSecondary
 */
private Drawable icon(Drawable drawable) {
    if (drawable != null) {
        Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
        Drawable resizeIcon = new BitmapDrawable(getContext().getResources(), Bitmap.createScaledBitmap(bitmap, icon, icon, true));
        Drawable.ConstantState state = resizeIcon.getConstantState();
        resizeIcon = DrawableCompat.wrap(state == null ? resizeIcon : state.newDrawable()).mutate();
        DrawableCompat.setTintList(resizeIcon, Utils.colorStateListIcon(getContext()));
        return resizeIcon;
    }
    return null;
}
 
Example #15
Source File: WaterView.java    From KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo with Apache License 2.0 5 votes vote down vote up
private Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }

    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
 
Example #16
Source File: AlbumActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.album, menu);
    this.menu = menu;

    if (pick_photos) {
        menu.findItem(R.id.share).setVisible(false);
        menu.findItem(R.id.exclude).setVisible(false);
        menu.findItem(R.id.pin).setVisible(false);
        menu.findItem(R.id.rename).setVisible(false);
        menu.findItem(R.id.copy).setVisible(false);
        menu.findItem(R.id.move).setVisible(false);
        menu.findItem(R.id.delete).setVisible(false);
    } else if (album != null) {
        setupMenu();
    }

    int sort_by = Settings.getInstance(this).sortAlbumBy();
    if (sort_by == SortUtil.BY_DATE) {
        menu.findItem(R.id.sort_by_date).setChecked(true);
    } else if (sort_by == SortUtil.BY_NAME) {
        menu.findItem(R.id.sort_by_name).setChecked(true);
    }

    MenuItem selectAll = menu.findItem(R.id.select_all);
    Drawable d = selectAll.getIcon();
    DrawableCompat.wrap(d);
    DrawableCompat.setTint(d, accentTextColor);
    DrawableCompat.unwrap(d);

    return super.onCreateOptionsMenu(menu);
}
 
Example #17
Source File: SublimeSubheaderItemView.java    From SublimeNavigationView with Apache License 2.0 5 votes vote down vote up
@Override
public void setIconTintList(ColorStateList tintList) {
    mExpandDrawable = DrawableCompat.wrap(mExpandDrawable
            .getConstantState().newDrawable()).mutate();
    DrawableCompat.setTintList(mExpandDrawable, tintList);

    mCollapseDrawable = DrawableCompat.wrap(mCollapseDrawable
            .getConstantState().newDrawable()).mutate();
    DrawableCompat.setTintList(mCollapseDrawable, tintList);

    super.setIconTintList(tintList);
}
 
Example #18
Source File: ProfileFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Drawable getTopFabDrawable() {
    Drawable drawable = DrawableCompat.wrap(
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add));
    DrawableCompat.setTint(drawable, Color.WHITE);
    return drawable;
}
 
Example #19
Source File: PasswordEditText.java    From materialandroid with Apache License 2.0 5 votes vote down vote up
private Drawable tintDrawable(Drawable drawable) {
  if (tintColor != 0) {
    Drawable wrapper = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(wrapper, tintColor);
    return wrapper;
  }
  return drawable;
}
 
Example #20
Source File: UnlockFingerprintDialog.java    From masterpassword with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
    super.onAuthenticationHelp(helpCode, helpString);
    if (fingerprint != null) {
        DrawableCompat.setTint(fingerprint, Color.YELLOW);
    }
    helpText.setText(helpString);
    helpText.setVisibility(View.VISIBLE);
}
 
Example #21
Source File: ThemeUtils.java    From MagicaSakura with Apache License 2.0 5 votes vote down vote up
public static Drawable tintDrawable(Drawable drawable, @ColorInt int color, PorterDuff.Mode mode) {
    if (drawable == null) return null;
    Drawable wrapper = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTint(wrapper, color);
    DrawableCompat.setTintMode(drawable, mode);
    return wrapper;
}
 
Example #22
Source File: ActionButtonItems.java    From SpringActionMenu with Apache License 2.0 5 votes vote down vote up
/**
 * vector to bitmap
 */
private Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
    Drawable drawable = ContextCompat.getDrawable(context, drawableId);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }

    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
 
Example #23
Source File: FloatingSearchView.java    From FloatingSearchView with Apache License 2.0 5 votes vote down vote up
static private Drawable unwrap(Drawable icon) {
    if(icon instanceof android.support.v7.graphics.drawable.DrawableWrapper)
        return ((android.support.v7.graphics.drawable.DrawableWrapper)icon).getWrappedDrawable();
    if(icon instanceof android.support.v4.graphics.drawable.DrawableWrapper)
        return ((android.support.v4.graphics.drawable.DrawableWrapper)icon).getWrappedDrawable();
    if(Build.VERSION.SDK_INT >= 23 && icon instanceof android.graphics.drawable.DrawableWrapper)
        return ((android.graphics.drawable.DrawableWrapper)icon).getDrawable();
    return DrawableCompat.unwrap(icon);
}
 
Example #24
Source File: Easel.java    From andela-crypto-app with Apache License 2.0 5 votes vote down vote up
public static void tint(@NonNull SwitchCompat switchCompat, @ColorInt int color, @ColorInt int unpressedColor) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_checked},
            new int[]{android.R.attr.state_checked}
    }, new int[]{
            unpressedColor,
            color
    });

    DrawableCompat.setTintList(switchCompat.getThumbDrawable(), sl);
    DrawableCompat.setTintList(switchCompat.getTrackDrawable(), createSwitchTrackColorStateList(switchCompat.getContext(), color));
}
 
Example #25
Source File: MainActivity.java    From badgebutton with Apache License 2.0 5 votes vote down vote up
Drawable wrap(int icon) {
    Drawable drawable = ResourcesCompat.getDrawable(getResources(),icon, getTheme());
    if (mTint == null) {
        mTint = ResourcesCompat.getColorStateList(getResources(), R.color.tab, getTheme());
    }
    if (drawable != null) {
        drawable = DrawableCompat.wrap(drawable.mutate());
        DrawableCompat.setTintList(drawable, mTint);
    }
    return drawable;
}
 
Example #26
Source File: NoticeView.java    From noticeview with Apache License 2.0 5 votes vote down vote up
private void initWithContext(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NoticeView);
    mIcon = a.getDrawable(R.styleable.NoticeView_nvIcon);
    mIconPadding = (int)a.getDimension(R.styleable.NoticeView_nvIconPadding, 0);

    boolean hasIconTint = a.hasValue(R.styleable.NoticeView_nvIconTint);

    if (hasIconTint) {
        mIconTint = a.getColor(R.styleable.NoticeView_nvIconTint, 0xff999999);
    }

    mInterval = a.getInteger(R.styleable.NoticeView_nvInterval, 4000);
    mDuration = a.getInteger(R.styleable.NoticeView_nvDuration, 900);

    mDefaultFactory.resolve(a);
    a.recycle();

    if (mIcon != null) {
        mPaddingLeft = getPaddingLeft();
        int realPaddingLeft = mPaddingLeft + mIconPadding + mIcon.getIntrinsicWidth();
        setPadding(realPaddingLeft, getPaddingTop(), getPaddingRight(), getPaddingBottom());

        if (hasIconTint) {
            mIcon = mIcon.mutate();
            DrawableCompat.setTint(mIcon, mIconTint);
        }
    }
}
 
Example #27
Source File: WebViewActivity.java    From mobile-messaging-sdk-android with Apache License 2.0 5 votes vote down vote up
@NonNull
private Drawable tintXButton(Menu menu) {
    Drawable drawable = menu.findItem(R.id.ib_menu_cancel).getIcon();
    drawable = DrawableCompat.wrap(drawable);

    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = getTheme();
    theme.resolveAttribute(R.attr.colorControlNormal, typedValue, true);
    drawable.setColorFilter(typedValue.data, PorterDuff.Mode.SRC_IN);
    return drawable;
}
 
Example #28
Source File: BaseFragment.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public View buildRecord(String titleText, String valueText, int resourceId, boolean showIcon, boolean isLast,
                        LayoutInflater inflater, ViewGroup container) {
    final View recordView = inflater.inflate(R.layout.contact_record, container, false);
    TextView value = (TextView) recordView.findViewById(R.id.value);
    TextView title = (TextView) recordView.findViewById(R.id.title);

    title.setText(titleText);
    title.setTextColor(style.getTextSecondaryColor());

    value.setTextColor(style.getTextPrimaryColor());
    value.setText(valueText);

    if (!isLast) {
        recordView.findViewById(R.id.divider).setVisibility(View.GONE);
    }

    if (resourceId != 0 && showIcon) {
        ImageView iconView = (ImageView) recordView.findViewById(R.id.recordIcon);
        Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(resourceId));
        drawable.mutate();
        DrawableCompat.setTint(drawable, style.getSettingsIconColor());
        iconView.setImageDrawable(drawable);
    }

    container.addView(recordView);

    return recordView;
}
 
Example #29
Source File: VectorDrawableInflateImpl.java    From timecat with Apache License 2.0 5 votes vote down vote up
@Override
public Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
    ColorStateList colorFilter = getTintColorList(context, attrs, android.R.attr.tint);
    Drawable d;
    if (resId == 0) {
        d = VectorDrawableCompat.createFromXmlInner(context.getResources(), parser, attrs);
    } else {
        d = VectorDrawableCompat.create(context.getResources(), resId, context.getTheme());
    }
    if (d != null && colorFilter != null) {
        DrawableCompat.setTintList(d, colorFilter);
    }
    return d;
}
 
Example #30
Source File: BottomNavigationItemView.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setIcon(Drawable icon) {
    if (icon != null) {
        Drawable.ConstantState state = icon.getConstantState();
        icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate();
        DrawableCompat.setTintList(icon, mIconTint);
    }
    mIcon.setImageDrawable(icon);
}