Example usage for android.util TypedValue TYPE_LAST_COLOR_INT

List of usage examples for android.util TypedValue TYPE_LAST_COLOR_INT

Introduction

In this page you can find the example usage for android.util TypedValue TYPE_LAST_COLOR_INT.

Prototype

int TYPE_LAST_COLOR_INT

To view the source code for android.util TypedValue TYPE_LAST_COLOR_INT.

Click Source Link

Document

Identifies the end of integer values that were specified as color constants.

Usage

From source file:org.odk.collect.android.views.ODKView.java

public void highlightWidget(FormIndex formIndex) {
    QuestionWidget qw = getQuestionWidget(formIndex);

    if (qw != null) {
        // postDelayed is needed because otherwise scrolling may not work as expected in case when
        // answers are validated during form finalization.
        new Handler().postDelayed(() -> {
            findViewById(R.id.odk_view_container).scrollTo(0, qw.getTop());

            ValueAnimator va = new ValueAnimator();
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
                va.setIntValues(getResources().getColor(R.color.red_500), getDrawingCacheBackgroundColor());
            } else {
                // Avoid fading to black on certain devices and Android versions that may not support transparency
                TypedValue typedValue = new TypedValue();
                getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
                if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT
                        && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
                    va.setIntValues(getResources().getColor(R.color.red_500), typedValue.data);
                } else {
                    va.setIntValues(getResources().getColor(R.color.red_500), getDrawingCacheBackgroundColor());
                }/*from   www.j  av  a2  s .  c om*/
            }

            va.setEvaluator(new ArgbEvaluator());
            va.addUpdateListener(
                    valueAnimator -> qw.setBackgroundColor((int) valueAnimator.getAnimatedValue()));
            va.setDuration(2500);
            va.start();
        }, 100);
    }
}

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static int getThemeForegroundColor(final Context context, int themeRes) {
    @SuppressWarnings("ConstantConditions")
    final TypedValue value = new TypedValue();
    final Resources.Theme theme;
    if (themeRes != 0) {
        theme = context.getResources().newTheme();
        theme.applyStyle(themeRes, false);
    } else {//from w ww .j a  v a 2s  .  c  om
        theme = context.getTheme();
    }
    if (!theme.resolveAttribute(android.R.attr.colorForeground, value, true)) {
        return 0;
    }
    if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
        // windowBackground is a color
        return value.data;
    } else if (value.type == TypedValue.TYPE_REFERENCE) {
        return theme.getResources().getColor(value.resourceId);
    }
    return 0;
}

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static boolean isColorType(int type) {
    return (type >= TypedValue.TYPE_FIRST_COLOR_INT) && (type <= TypedValue.TYPE_LAST_COLOR_INT);
}