Example usage for android.util TypedValue TypedValue

List of usage examples for android.util TypedValue TypedValue

Introduction

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

Prototype

TypedValue

Source Link

Usage

From source file:com.danimahardhika.android.helpers.core.ColorHelper.java

@ColorInt
public static int getAttributeColor(Context context, @AttrRes int attr) {
    if (context == null) {
        Log.e("ColorHelper", "getAttributeColor() context is null");
        return Color.WHITE;
    }/*  w w  w  . j  a  va  2  s.com*/

    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = context.getTheme();
    theme.resolveAttribute(attr, typedValue, true);
    return typedValue.data;
}

From source file:com.android.messaging.ui.CustomHeaderViewPager.java

public CustomHeaderViewPager(final Context context, final AttributeSet attrs) {
    super(context, attrs);

    final LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.custom_header_view_pager, this, true);
    setOrientation(LinearLayout.VERTICAL);

    mTabstrip = (ViewPagerTabs) findViewById(R.id.tab_strip);
    mViewPager = (ViewPager) findViewById(R.id.pager);

    TypedValue tv = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
    mDefaultTabStripSize = context.getResources().getDimensionPixelSize(tv.resourceId);
}

From source file:android.support.v7.app.MediaRouterThemeHelper.java

public static int getThemeResource(Context context, int attr) {
    TypedValue value = new TypedValue();
    return context.getTheme().resolveAttribute(attr, value, true) ? value.resourceId : 0;
}

From source file:com.gudong.appkit.utils.Utils.java

/**
 * ??/*from w  w  w .j  a v a2 s.co m*/
 *
 * @param context
 * @return
 */
public static int getThemePrimaryColor(Context context) {
    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = context.getTheme();
    theme.resolveAttribute(R.attr.theme_color, typedValue, true);
    return typedValue.data;
}

From source file:com.facebook.react.views.checkbox.ReactCheckBoxManager.java

private static int getThemeColor(final Context context, String colorId) {
    final TypedValue value = new TypedValue();
    context.getTheme().resolveAttribute(getIdentifier(context, colorId), value, true);
    return value.data;
}

From source file:android.support.v7.app.MediaRouterThemeHelper.java

public static float getDisabledAlpha(Context context) {
    TypedValue value = new TypedValue();
    return context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, value, true) ? value.getFloat()
            : 0.5f;//from  w  w  w. j av  a  2s.com
}

From source file:com.fjoglar.etsitnoticias.utils.UiUtils.java

/**
 * Configure the TextViews that will show the attachments of the new.
 *
 * @param textView      TextView to be configured.
 * @param title         Text shown in TextView
 * @param downloadLink  Link attached to TextView.
 * @param fileType      Type of file of the attachment.
 * @param context       The context of activity.
 *///from w w w.  j  a  va2  s. com
public static void configureTextView(TextView textView, String title, final String downloadLink,
        Attachment.FILE_TYPE fileType, final Context context) {

    final int TEXT_VIEW_MIN_HEIGHT = 40;
    final int TEXT_VIEW_MARGIN_TOP = 4;

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, convertDpToPx(TEXT_VIEW_MARGIN_TOP, context), 0, 0);
    textView.setLayoutParams(params);

    textView.setText(title);
    textView.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    textView.setMinHeight(convertDpToPx(TEXT_VIEW_MIN_HEIGHT, context));
    textView.setGravity(Gravity.CENTER_VERTICAL);

    switch (fileType) {
    case FILE:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file, 0, 0, 0);
        break;
    case IMAGE:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_photo, 0, 0, 0);
        break;
    case FOLDER:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_folder, 0, 0, 0);
        break;
    default:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_link, 0, 0, 0);
        break;
    }

    textView.setCompoundDrawablePadding(convertDpToPx(4, context));

    TypedValue typedValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    textView.setBackgroundResource(typedValue.resourceId);

    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Navigator.getInstance().openUrl(context, downloadLink);
        }
    });
}

From source file:android.support.v7.internal.widget.ThemeUtils.java

private static TypedValue getTypedValue() {
    TypedValue typedValue = TL_TYPED_VALUE.get();
    if (typedValue == null) {
        typedValue = new TypedValue();
        TL_TYPED_VALUE.set(typedValue);//from  w w w. j a v  a 2 s.  com
    }
    return typedValue;
}

From source file:android.support.v7ox.widget.AbsActionBarView.java

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

    final TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(R.attr.actionBarPopupTheme_ox, tv, true) && tv.resourceId != 0) {
        mPopupContext = new ContextThemeWrapper(context, tv.resourceId);
    } else {/*from ww  w  .  j  a  v a2 s .c o  m*/
        mPopupContext = context;
    }
}

From source file:com.example.domiter.fileexplorer.dialog.BaseDialogFragment.java

private int getIconTintColor() {
    // Resolve AlertDialog theme
    TypedValue outValue = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.R.attr.alertDialogTheme, outValue, true);
    int theme = outValue.resourceId;
    ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme);

    // Try to get title color
    int colorId = getThemedResourceId(contextThemeWrapper.getTheme(), textColorPrimary);
    int tintColor;
    if (colorId == -1) {
        tintColor = getThemedColor(contextThemeWrapper.getTheme(), textColorPrimary);
    } else {/* www.j  a  v  a2  s.  c  o  m*/
        tintColor = contextThemeWrapper.getResources().getColor(colorId);
    }

    return tintColor;
}