Here are the examples of the java api class android.util.TypedValue taken from open source projects.
1. MaterialSuggestionsSearchView#init()
Project: QuickLyric
File: MaterialSuggestionsSearchView.java
File: MaterialSuggestionsSearchView.java
@SuppressWarnings("deprecation") private void init() { setSubmitOnClick(true); if (LyricsSearchSuggestionsProvider.database == null) LyricsSearchSuggestionsProvider.setDatabase(new LyricsSearchSuggestionsProvider(getContext()).getWritableDatabase()); Resources.Theme theme = getContext().getTheme(); TypedValue hintColor = new TypedValue(); TypedValue suggestionColor = new TypedValue(); TypedValue themeName = new TypedValue(); theme.resolveAttribute(android.R.attr.textColorSecondary, hintColor, true); theme.resolveAttribute(android.R.attr.textColorSecondaryInverse, suggestionColor, true); theme.resolveAttribute(R.attr.themeName, themeName, true); setHintTextColor(hintColor.data); ((ImageView) findViewById(com.miguelcatalan.materialsearchview.R.id.action_up_btn)).setColorFilter(suggestionColor.data, PorterDuff.Mode.SRC_IN); if (suggestionIcon != null) { suggestionIcon.setColorFilter(suggestionColor.data, PorterDuff.Mode.SRC_IN); setSuggestionIcon(suggestionIcon); } if (closeIcon != null) { closeIcon.setColorFilter(hintColor.data, PorterDuff.Mode.SRC_IN); setCloseIcon(closeIcon); } }
2. TaskEditControlSet#setupOkButton()
Project: astrid
File: TaskEditControlSet.java
File: TaskEditControlSet.java
/** * Sets up ok button background. Subclasses can override to customize look and feel */ protected void setupOkButton(View view) { Button ok = (Button) view.findViewById(R.id.edit_dlg_ok); Theme theme = activity.getTheme(); TypedValue themeColor = new TypedValue(); theme.resolveAttribute(R.attr.asThemeTextColor, themeColor, false); TypedValue inverseColor = new TypedValue(); theme.resolveAttribute(R.attr.asTextColorInverse, inverseColor, false); if (ok != null) { ok.setBackgroundDrawable(EditDialogOkBackground.getBg(activity.getResources().getColor(themeColor.data))); int[][] states = new int[2][]; states[0] = new int[] { android.R.attr.state_pressed }; states[1] = new int[] { android.R.attr.state_enabled }; int[] colors = new int[] { inverseColor.data, activity.getResources().getColor(themeColor.data) }; ColorStateList csl = new ColorStateList(states, colors); ok.setTextColor(csl); } }
3. ResourceUtils#getAttributeDimension()
Project: popcorn-android-legacy
File: ResourceUtils.java
File: ResourceUtils.java
public static float getAttributeDimension(final Context context, final Resources.Theme theme, final int resId) { // create a new typed value to received the resolved attribute final TypedValue typedValue = new TypedValue(); // value final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); if (// if we can't resolve the value !theme.resolveAttribute(resId, typedValue, true)) { throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(resId)); } if (// if the value isn't of the correct type typedValue.type != TypedValue.TYPE_DIMENSION) { throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(resId) + " type #0x" + Integer.toHexString(typedValue.type) + " is not valid"); } // return the value of the attribute in terms of the display return typedValue.getDimension(displayMetrics); }
4. PlacesSampleActivity#initializeDraggablePanel()
Project: DraggablePanel
File: PlacesSampleActivity.java
File: PlacesSampleActivity.java
/** * Initialize the DraggablePanel with top and bottom Fragments and apply all the configuration. */ private void initializeDraggablePanel() { draggablePanel.setFragmentManager(getSupportFragmentManager()); draggablePanel.setTopFragment(placeFragment); draggablePanel.setBottomFragment(mapFragment); TypedValue typedValue = new TypedValue(); getResources().getValue(R.dimen.x_scale_factor, typedValue, true); float xScaleFactor = typedValue.getFloat(); typedValue = new TypedValue(); getResources().getValue(R.dimen.y_scale_factor, typedValue, true); float yScaleFactor = typedValue.getFloat(); draggablePanel.setXScaleFactor(xScaleFactor); draggablePanel.setYScaleFactor(yScaleFactor); draggablePanel.setTopViewHeight(getResources().getDimensionPixelSize(R.dimen.top_fragment_height)); draggablePanel.setTopFragmentMarginRight(getResources().getDimensionPixelSize(R.dimen.top_fragment_margin)); draggablePanel.setTopFragmentMarginBottom(getResources().getDimensionPixelSize(R.dimen.top_fragment_margin)); draggablePanel.initializeView(); draggablePanel.setVisibility(View.GONE); }
5. SlidingTabLayout#createDefaultTabView()
Project: XDA-One
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set * via * {@link #setCustomTabView(int, int)}. */ @Override protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(Color.WHITE); // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
6. DisplayUtils#getActionBarHeight()
Project: WordPress-Android
File: DisplayUtils.java
File: DisplayUtils.java
/** * returns the height of the ActionBar if one is enabled - supports both the native ActionBar * and ActionBarSherlock - http://stackoverflow.com/a/15476793/1673548 */ public static int getActionBarHeight(Context context) { if (context == null) { return 0; } TypedValue tv = new TypedValue(); if (context.getTheme() != null && context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { return TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } // so return the standard ActionBar height (48dp) return dpToPx(context, 48); }
7. SlidingTabLayout#createDefaultTabView()
Project: vanilla
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
8. ShareActionProvider#onCreateActionView()
Project: Ushahidi_Android
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with); return activityChooserView; }
9. ActionBarSherlockNative#getThemedContext()
Project: Ushahidi_Android
File: ActionBarSherlockNative.java
File: ActionBarSherlockNative.java
@Override protected Context getThemedContext() { Context context = mActivity; TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { //We are unable to test if this is the same as our current theme //so we just wrap it and hope that if the attribute was specified //then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } return context; }
10. SlidingTabLayout#createDefaultTabView()
Project: UltimateRecyclerView
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
11. BaseFragment#getActionBarSize()
Project: UltimateRecyclerView
File: BaseFragment.java
File: BaseFragment.java
protected int getActionBarSize() { Activity activity = getActivity(); if (activity == null) { return 0; } TypedValue typedValue = new TypedValue(); int[] textSizeAttr = new int[] { R.attr.actionBarSize }; int indexOfAttrTextSize = 0; TypedArray a = activity.obtainStyledAttributes(typedValue.data, textSizeAttr); int actionBarSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1); a.recycle(); return actionBarSize; }
12. CalligraphyUtils#pullFontPathFromTheme()
Project: UltimateAndroid
File: CalligraphyUtils.java
File: CalligraphyUtils.java
/** * Last but not least, try to pull the Font Path from the Theme, which is defined. * * @param context Activity Context * @param styleId Theme style id * @param attributeId if -1 returns null. * @return null if no theme or attribute defined. */ static String pullFontPathFromTheme(Context context, int styleId, int attributeId) { if (styleId == -1 || attributeId == -1) return null; final Resources.Theme theme = context.getTheme(); final TypedValue value = new TypedValue(); theme.resolveAttribute(styleId, value, true); final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, new int[] { attributeId }); try { return typedArray.getString(0); } catch (Exception ignore) { return null; } finally { typedArray.recycle(); } }
13. HighlightView#initStyles()
Project: UltimateAndroid
File: HighlightView.java
File: HighlightView.java
private void initStyles(Context context) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.cropImageStyle, outValue, true); TypedArray attributes = context.obtainStyledAttributes(outValue.resourceId, R.styleable.CropImageView); try { showThirds = attributes.getBoolean(R.styleable.CropImageView_showThirds, false); highlightColor = attributes.getColor(R.styleable.CropImageView_highlightColor, DEFAULT_HIGHLIGHT_COLOR); handleMode = HandleMode.values()[attributes.getInt(R.styleable.CropImageView_showHandles, 0)]; } finally { attributes.recycle(); } }
14. CalligraphyUtils#pullFontPathFromTheme()
Project: UltimateAndroid
File: CalligraphyUtils.java
File: CalligraphyUtils.java
/** * Last but not least, try to pull the Font Path from the Theme, which is defined. * * @param context Activity Context * @param styleId Theme style id * @param attributeId if -1 returns null. * @return null if no theme or attribute defined. */ static String pullFontPathFromTheme(Context context, int styleId, int attributeId) { if (styleId == -1 || attributeId == -1) return null; final Resources.Theme theme = context.getTheme(); final TypedValue value = new TypedValue(); theme.resolveAttribute(styleId, value, true); final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, new int[] { attributeId }); try { return typedArray.getString(0); } catch (Exception ignore) { return null; } finally { typedArray.recycle(); } }
15. HighlightView#initStyles()
Project: UltimateAndroid
File: HighlightView.java
File: HighlightView.java
private void initStyles(Context context) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.cropImageStyle, outValue, true); TypedArray attributes = context.obtainStyledAttributes(outValue.resourceId, R.styleable.CropImageView); try { showThirds = attributes.getBoolean(R.styleable.CropImageView_crop_showThirds, false); highlightColor = attributes.getColor(R.styleable.CropImageView_crop_highlightColor, DEFAULT_HIGHLIGHT_COLOR); handleMode = HandleMode.values()[attributes.getInt(R.styleable.CropImageView_crop_showHandles, 0)]; } finally { attributes.recycle(); } }
16. SlidingTabLayout#createDefaultTabView()
Project: UltimateAndroid
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
17. AccessoryView#createView()
Project: turbo-editor
File: AccessoryView.java
File: AccessoryView.java
public void createView() { removeAllViews(); // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state outValue = new TypedValue(); getContext().getTheme().resolveAttribute(R.attr.selectableItemBackgroundBorderless, outValue, true); String[] characters = { "<", ">", "!", "/", ".", ";", "=", "\"", "{", "}", "[", "]", "(", ")", "&", "|", "#", "*", "+", "-", ":", "%", ",", "_", "@", "?", "^", "'" }; for (int i = 0; i < characters.length; i++) addAButton(characters[i]); updateTextColors(); }
18. ShareActionProvider#onCreateActionView()
Project: todo.txt-android
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with); return activityChooserView; }
19. ActionBarSherlockNative#getThemedContext()
Project: todo.txt-android
File: ActionBarSherlockNative.java
File: ActionBarSherlockNative.java
@Override protected Context getThemedContext() { Context context = mActivity; TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { //We are unable to test if this is the same as our current theme //so we just wrap it and hope that if the attribute was specified //then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } return context; }
20. DefaultHeaderTransformer#getActionBarTitleStyle()
Project: todo.txt-android
File: DefaultHeaderTransformer.java
File: DefaultHeaderTransformer.java
protected int getActionBarTitleStyle(Context context) { int[] android_styleable_ActionBar = { android.R.attr.titleTextStyle }; // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, android_styleable_ActionBar); try { // titleTextStyle is the first attr in the array above so it's index is 0. return abStyle.getResourceId(0, 0); } finally { abStyle.recycle(); } }
21. DefaultHeaderTransformer#getActionBarBackground()
Project: todo.txt-android
File: DefaultHeaderTransformer.java
File: DefaultHeaderTransformer.java
protected Drawable getActionBarBackground(Context context) { int[] android_styleable_ActionBar = { android.R.attr.background }; // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, android_styleable_ActionBar); try { // background is the first attr in the array above so it's index is 0. return abStyle.getDrawable(0); } finally { abStyle.recycle(); } }
22. AbsDefaultHeaderTransformer#getActionBarTitleStyle()
Project: todo.txt-android
File: AbsDefaultHeaderTransformer.java
File: AbsDefaultHeaderTransformer.java
@Override protected int getActionBarTitleStyle(Context context) { // Super handles ICS+ anyway... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { return super.getActionBarTitleStyle(context); } // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, R.styleable.SherlockActionBar); try { return abStyle.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0); } finally { abStyle.recycle(); } }
23. AbsDefaultHeaderTransformer#getActionBarBackground()
Project: todo.txt-android
File: AbsDefaultHeaderTransformer.java
File: AbsDefaultHeaderTransformer.java
@Override protected Drawable getActionBarBackground(Context context) { // Super handles ICS+ anyway... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { return super.getActionBarBackground(context); } // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, R.styleable.SherlockActionBar); try { return abStyle.getDrawable(R.styleable.SherlockActionBar_background); } finally { abStyle.recycle(); } }
24. MainActivity#setOptimalDrawerWidth()
Project: syncthing-android
File: MainActivity.java
File: MainActivity.java
/** * Calculating width based on * http://www.google.com/design/spec/patterns/navigation-drawer.html#navigation-drawer-specs. */ private void setOptimalDrawerWidth(View drawerContainer) { int actionBarSize = 0; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarSize = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } ViewGroup.LayoutParams params = drawerContainer.getLayoutParams(); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); int minScreenWidth = min(displayMetrics.widthPixels, displayMetrics.heightPixels); params.width = min(minScreenWidth - actionBarSize, 5 * actionBarSize); drawerContainer.requestLayout(); }
25. SublimeThemer#setDefaultItemBackground()
Project: SublimeNavigationView
File: SublimeThemer.java
File: SublimeThemer.java
private void setDefaultItemBackground() { TypedValue value = new TypedValue(); int colorControlHighlight = 0; if (mContext.getTheme().resolveAttribute(R.attr.colorControlHighlight, value, true)) { colorControlHighlight = value.data; } else { colorControlHighlight = mDefaultTheme == DefaultTheme.LIGHT ? mContext.getResources().getColor(R.color.snv_ripple_material_light) : mContext.getResources().getColor(R.color.snv_ripple_material_dark); } StateListDrawable drawable = new StateListDrawable(); LayerDrawable checked = new LayerDrawable(new Drawable[] { new ColorDrawable(colorControlHighlight), obtainSelectableItemBackground() }); drawable.addState(CHECKED_STATE_SET, checked); drawable.addState(EMPTY_STATE_SET, obtainSelectableItemBackground()); mItemBackground = drawable; }
26. SlidingTabLayout#createDefaultTabView()
Project: StickyHeaderViewPager
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
27. Preferences#getToolBarHeight()
Project: ShaderEditor
File: Preferences.java
File: Preferences.java
public static int getToolBarHeight(Context context) { // don't store toolbar bar height because it may be // different for each context TypedValue tv = new TypedValue(); return context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true) ? TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()) : 0; }
28. LyricsTextFactory#makeView()
Project: QuickLyric
File: LyricsTextFactory.java
File: LyricsTextFactory.java
@Override public View makeView() { TextView t = new TextView(mContext); t.setGravity(Gravity.CENTER_HORIZONTAL); if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("pref_opendyslexic", false)) t.setTypeface(FontCache.get("opendyslexic", mContext)); else t.setTypeface(FontCache.get("light", mContext)); TypedValue colorValue = new TypedValue(); mContext.getTheme().resolveAttribute(android.R.attr.textColorPrimary, colorValue, true); t.setTextColor(colorValue.data); t.setLineSpacing(mContext.getResources().getDimensionPixelSize(R.dimen.line_spacing), 1); setSelectable(t); t.setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources().getDimension(R.dimen.txt_size)); return t; }
29. ImageUtils#getActionBarHeight()
Project: q-municate-android
File: ImageUtils.java
File: ImageUtils.java
private static int getActionBarHeight(Context context) { TypedValue typedValue = new TypedValue(); int actionBarHeight = AVATAR_SIZE; if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(typedValue.data, context.getResources().getDisplayMetrics()); } int margin = actionBarHeight / 10; return actionBarHeight - margin; }
30. SlidingTabLayout#createDefaultTabView()
Project: Protocoder
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
31. AttrsDecor#apply()
Project: pretty
File: AttrsDecor.java
File: AttrsDecor.java
/** * {@inheritDoc} */ @Override public final void apply(@NotNull View view, @Nullable View parent, @NotNull String name, @NotNull Context context, @NotNull AttributeSet attrs) { if (!clazz().isAssignableFrom(view.getClass())) { return; } TypedArray values = context.getResources().obtainAttributes(attrs, attrs()); if (values == null) { return; } TypedValue buf = new TypedValue(); try { for (int i = 0; i < values.length(); i++) { if (values.hasValue(i) && values.getValue(i, buf)) { // inspection disabled as we do know at this point that view can be cast to T //noinspection unchecked apply((T) view, attrs()[i], buf); } } } finally { values.recycle(); } }
32. SlidingTabLayout#createDefaultTabView()
Project: ParallaxHeaderViewPager
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
33. RangeSeekBar#extractNumericValueFromAttributes()
Project: openshop.io-android
File: RangeSeekBar.java
File: RangeSeekBar.java
@SuppressWarnings("unchecked") private T extractNumericValueFromAttributes(TypedArray a, int attribute, int defaultValue) { TypedValue tv = a.peekValue(attribute); if (tv == null) { return (T) Integer.valueOf(defaultValue); } int type = tv.type; if (type == TypedValue.TYPE_FLOAT) { return (T) Float.valueOf(a.getFloat(attribute, defaultValue)); } else { return (T) Integer.valueOf(a.getInteger(attribute, defaultValue)); } }
34. TasksSettings#setupFauxDialog()
Project: NotePad
File: TasksSettings.java
File: TasksSettings.java
protected void setupFauxDialog() { // Check if this should be a dialog TypedValue tv = new TypedValue(); if (!getTheme().resolveAttribute(R.attr.isDialog, tv, true) || tv.data == 0) { return; } // Should be a dialog; set up the window parameters. DisplayMetrics dm = getResources().getDisplayMetrics(); WindowManager.LayoutParams params = getWindow().getAttributes(); params.width = getResources().getDimensionPixelSize(R.dimen.configure_dialog_width); params.height = Math.min(getResources().getDimensionPixelSize(R.dimen.configure_dialog_max_height), dm.heightPixels * 3 / 4); params.alpha = 1.0f; params.dimAmount = 0.5f; getWindow().setAttributes(params); }
35. ThemeHelper#getActionTextColorStateList()
Project: NewsMe
File: ThemeHelper.java
File: ThemeHelper.java
// Get the specified color resource, creating a ColorStateList if the resource // points to a color value. public static ColorStateList getActionTextColorStateList(Context context, @ColorRes int colorId) { final TypedValue value = new TypedValue(); context.getResources().getValue(colorId, value, true); if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) { return getActionTextStateList(context, value.data); } else { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { //noinspection deprecation return context.getResources().getColorStateList(colorId); } else { return context.getColorStateList(colorId); } } }
36. ShareActionProvider#onCreateActionView()
Project: networklog
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with); return activityChooserView; }
37. ActionBarSherlockNative#getThemedContext()
Project: networklog
File: ActionBarSherlockNative.java
File: ActionBarSherlockNative.java
@Override protected Context getThemedContext() { Context context = mActivity; TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { //We are unable to test if this is the same as our current theme //so we just wrap it and hope that if the attribute was specified //then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } return context; }
38. ServiceSinkhole#showDisabledNotification()
Project: NetGuard
File: ServiceSinkhole.java
File: ServiceSinkhole.java
private void showDisabledNotification() { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorOff, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_error_white_24dp).setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.msg_revoked)).setContentIntent(pi).setColor(tv.data).setOngoing(false).setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET); } NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder); notification.bigText(getString(R.string.msg_revoked)); NotificationManagerCompat.from(this).notify(NOTIFY_DISABLED, notification.build()); }
39. SlidingTabLayout#createDefaultTabView()
Project: MonsterHunter4UDatabase
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
40. MizLib#addActionBarMarginBottom()
Project: Mizuu
File: MizLib.java
File: MizLib.java
/** * Add a margin with a height of the ActionBar to the top of a given View contained in a FrameLayout * @param c * @param v */ public static void addActionBarMarginBottom(Context c, View v) { int mActionBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else // No ActionBar style (pre-Honeycomb or ActionBar not in theme) mActionBarHeight = 0; FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, 0, 0, mActionBarHeight); v.setLayoutParams(params); }
41. MizLib#addActionBarAndStatusBarMargin()
Project: Mizuu
File: MizLib.java
File: MizLib.java
/** * Add a margin with a combined height of the ActionBar and Status bar to the top of a given View contained in a FrameLayout * @param c * @param v */ public static void addActionBarAndStatusBarMargin(Context c, View v, FrameLayout.LayoutParams layoutParams) { int mActionBarHeight = 0, mStatusBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else // No ActionBar style (pre-Honeycomb or ActionBar not in theme) mActionBarHeight = 0; if (hasKitKat()) mStatusBarHeight = convertDpToPixels(c, 25); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, mActionBarHeight + mStatusBarHeight, 0, 0); params.gravity = layoutParams.gravity; v.setLayoutParams(params); }
42. MizLib#addActionBarAndStatusBarMargin()
Project: Mizuu
File: MizLib.java
File: MizLib.java
/** * Add a margin with a combined height of the ActionBar and Status bar to the top of a given View contained in a FrameLayout * @param c * @param v */ public static void addActionBarAndStatusBarMargin(Context c, View v) { int mActionBarHeight = 0, mStatusBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else // No ActionBar style (pre-Honeycomb or ActionBar not in theme) mActionBarHeight = 0; if (hasKitKat()) mStatusBarHeight = convertDpToPixels(c, 25); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, mActionBarHeight + mStatusBarHeight, 0, 0); v.setLayoutParams(params); }
43. MizLib#addActionBarMargin()
Project: Mizuu
File: MizLib.java
File: MizLib.java
/** * Add a margin with a height of the ActionBar to the top of a given View contained in a FrameLayout * @param c * @param v */ public static void addActionBarMargin(Context c, View v) { int mActionBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else // No ActionBar style (pre-Honeycomb or ActionBar not in theme) mActionBarHeight = 0; FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, mActionBarHeight, 0, 0); v.setLayoutParams(params); }
44. MizLib#addActionBarAndStatusBarPadding()
Project: Mizuu
File: MizLib.java
File: MizLib.java
/** * Add a padding with a combined height of the ActionBar and Status bar to the top of a given View * @param c * @param v */ public static void addActionBarAndStatusBarPadding(Context c, View v) { int mActionBarHeight = 0, mStatusBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else // No ActionBar style (pre-Honeycomb or ActionBar not in theme) mActionBarHeight = 0; if (hasKitKat()) mStatusBarHeight = convertDpToPixels(c, 25); v.setPadding(0, mActionBarHeight + mStatusBarHeight, 0, 0); }
45. Utils#getAccentColorFromThemeIfAvailable()
Project: MaterialDateTimePicker
File: Utils.java
File: Utils.java
/** * Gets the colorAccent from the current context, if possible/available * @param context The context to use as reference for the color * @return the accent color of the current context */ public static int getAccentColorFromThemeIfAvailable(Context context) { TypedValue typedValue = new TypedValue(); // First, try the android:colorAccent if (Build.VERSION.SDK_INT >= 21) { context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); return typedValue.data; } // Next, try colorAccent from support lib int colorAccentResId = context.getResources().getIdentifier("colorAccent", "attr", context.getPackageName()); if (colorAccentResId != 0 && context.getTheme().resolveAttribute(colorAccentResId, typedValue, true)) { return typedValue.data; } // Return the value in mdtp_accent_color return ContextCompat.getColor(context, R.color.mdtp_accent_color); }
46. Utils#getAccentColorFromThemeIfAvailable()
Project: MaterialDateRangePicker
File: Utils.java
File: Utils.java
/** * Gets the colorAccent from the current context, if possible/available * @param context * @return -1 if accent color invalid, otherwise the accent color of the current context */ public static int getAccentColorFromThemeIfAvailable(Context context) { TypedValue typedValue = new TypedValue(); //First, try the android:colorAccent if (Build.VERSION.SDK_INT >= 21) { context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); return typedValue.data; } //Next, try colorAccent from support lib int colorAccentResId = context.getResources().getIdentifier("colorAccent", "attr", context.getPackageName()); if (colorAccentResId == 0) { return -1; } if (!context.getTheme().resolveAttribute(colorAccentResId, typedValue, true)) { return -1; } return typedValue.data; }
47. DialogUtils#getActionTextColorStateList()
Project: material-dialogs
File: DialogUtils.java
File: DialogUtils.java
// Get the specified color resource, creating a ColorStateList if the resource // points to a color value. public static ColorStateList getActionTextColorStateList(Context context, @ColorRes int colorId) { final TypedValue value = new TypedValue(); context.getResources().getValue(colorId, value, true); if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) { return getActionTextStateList(context, value.data); } else { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { //noinspection deprecation return context.getResources().getColorStateList(colorId); } else { return context.getColorStateList(colorId); } } }
48. MaterialCalendarView#getThemeAccentColor()
Project: material-calendarview
File: MaterialCalendarView.java
File: MaterialCalendarView.java
private static int getThemeAccentColor(Context context) { int colorAttr; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAttr = android.R.attr.colorAccent; } else { //Get colorAccent defined for AppCompat colorAttr = context.getResources().getIdentifier("colorAccent", "attr", context.getPackageName()); } TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(colorAttr, outValue, true); return outValue.data; }
49. DirectionButton#getThemeSelectableBackgroundId()
Project: material-calendarview
File: DirectionButton.java
File: DirectionButton.java
private static int getThemeSelectableBackgroundId(Context context) { //Get selectableItemBackgroundBorderless defined for AppCompat int colorAttr = context.getResources().getIdentifier("selectableItemBackgroundBorderless", "attr", context.getPackageName()); if (colorAttr == 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAttr = android.R.attr.selectableItemBackgroundBorderless; } else { colorAttr = android.R.attr.selectableItemBackground; } } TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(colorAttr, outValue, true); return outValue.resourceId; }
50. GradientDrawableUtils#setGradientRadius()
Project: MagicaSakura-master
File: GradientDrawableUtils.java
File: GradientDrawableUtils.java
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException { TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[] { android.R.attr.gradientRadius }); TypedValue value = a.peekValue(0); if (value != null) { boolean radiusRel = value.type == TypedValue.TYPE_FRACTION; drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat()); } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) { throw new XmlPullParserException("<gradient> tag requires 'gradientRadius' " + "attribute with radial type"); } a.recycle(); }
51. GradientDrawableUtils#setGradientRadius()
Project: MagicaSakura
File: GradientDrawableUtils.java
File: GradientDrawableUtils.java
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException { TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[] { android.R.attr.gradientRadius }); TypedValue value = a.peekValue(0); if (value != null) { boolean radiusRel = value.type == TypedValue.TYPE_FRACTION; drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat()); } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) { throw new XmlPullParserException("<gradient> tag requires 'gradientRadius' " + "attribute with radial type"); } a.recycle(); }
52. ShareActionProvider#onCreateActionView()
Project: Libraries-for-Android-Developers
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with); return activityChooserView; }
53. ActionBarSherlockNative#getThemedContext()
Project: Libraries-for-Android-Developers
File: ActionBarSherlockNative.java
File: ActionBarSherlockNative.java
@Override protected Context getThemedContext() { Context context = mActivity; TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { //We are unable to test if this is the same as our current theme //so we just wrap it and hope that if the attribute was specified //then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } return context; }
54. FoldableLinearLayout#processAttributes()
Project: k-9
File: FoldableLinearLayout.java
File: FoldableLinearLayout.java
/** * Load given attributes to inner variables, * * @param context * @param attrs */ private void processAttributes(Context context, AttributeSet attrs) { Theme theme = context.getTheme(); TypedValue outValue = new TypedValue(); boolean found = theme.resolveAttribute(R.attr.iconActionCollapse, outValue, true); if (found) { mIconActionCollapseId = outValue.resourceId; } found = theme.resolveAttribute(R.attr.iconActionExpand, outValue, true); if (found) { mIconActionExpandId = outValue.resourceId; } if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FoldableLinearLayout, 0, 0); mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel); mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel); a.recycle(); } // If any attribute isn't found then set a default one mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel; mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel; }
55. SlidingTabLayout#createDefaultTabView()
Project: iosched
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
56. BaseActivity#shouldBeFloatingWindow()
Project: iosched
File: BaseActivity.java
File: BaseActivity.java
/** * Returns true if the theme sets the {@code R.attr.isFloatingWindow} flag to true. */ protected boolean shouldBeFloatingWindow() { Resources.Theme theme = getTheme(); TypedValue floatingWindowFlag = new TypedValue(); // Check isFloatingWindow flag is defined in theme. if (theme == null || !theme.resolveAttribute(R.attr.isFloatingWindow, floatingWindowFlag, true)) { return false; } return (floatingWindowFlag.data != 0); }
57. TextView#parseFontStyle()
Project: HoloEverywhere
File: TextView.java
File: TextView.java
private static Object[] parseFontStyle(TypedArray a) { boolean force = true; int fontStyle = FontLoader.TEXT_STYLE_NORMAL; String fontFamily = null; TypedValue value = new TypedValue(); a.getValue(R.styleable.TextAppearance_android_fontFamily, value); if (value.string == null) { a.getValue(R.styleable.TextAppearance_android_typeface, value); } if (value.string == null) { force = false; } else { Object[] z = FontLoader.parseFontStyle(value.string.toString()); fontStyle = (Integer) z[0]; fontFamily = (String) z[1]; } final int defaultStyle = fontStyle & (FontLoader.TEXT_STYLE_BOLD | FontLoader.TEXT_STYLE_ITALIC); fontStyle &= ~defaultStyle; fontStyle |= a.getInt(R.styleable.TextAppearance_android_textStyle, defaultStyle); return new Object[] { force, fontStyle, fontFamily }; }
58. Divider#init()
Project: HoloEverywhere
File: Divider.java
File: Divider.java
protected void init(Context context, AttributeSet attrs, int defStyle) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Divider, defStyle, 0); boolean vertical = a.getInt(R.styleable.Divider_android_orientation, android.widget.LinearLayout.VERTICAL) == android.widget.LinearLayout.VERTICAL; a.recycle(); TypedValue value = new TypedValue(); context.getTheme().resolveAttribute(vertical ? R.attr.dividerVertical : R.attr.dividerHorizontal, value, true); if (value.resourceId > 0) { setBackgroundResource(value.resourceId); } }
59. ShareActionProvider#onCreateActionView()
Project: HoloEverywhere
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abc_shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abc_shareactionprovider_share_with); return activityChooserView; }
60. SlidingTabLayout#createDefaultTabView()
Project: holdr
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
61. StatisticsFragment#onCreateView()
Project: HeartBeat
File: StatisticsFragment.java
File: StatisticsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_statistics, container, false); ButterKnife.bind(this, v); TypedValue accentValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.colorAccent, accentValue, true); mAccentColor = accentValue.data; getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, accentValue, true); mPrimaryColor = accentValue.data; getActivity().getTheme().resolveAttribute(R.attr.colorPrimaryDark, accentValue, true); mPrimaryColorDark = accentValue.data; mDataManager = DataManager.getInstance(getContext()); mUpdateCountTask = new UpdateCountTask(); mUpdateChartTask = new UpdateChartTask(); mUpdatePieChartTask = new UpdatePieChartTask(); mUpdateChartTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); mUpdateCountTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); mUpdatePieChartTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return v; }
62. ThoughtTimeaxisAdapter#onCreateViewHolder()
Project: HeartBeat
File: ThoughtTimeaxisAdapter.java
File: ThoughtTimeaxisAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_thought_timeaxis, parent, false); final TypedValue typedValue = new TypedValue(); parent.getContext().getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true); int color = typedValue.data; Drawable d = ContextCompat.getDrawable(parent.getContext(), R.drawable.circle_timeaxis); d.setColorFilter(color, PorterDuff.Mode.MULTIPLY); View point = v.findViewById(R.id.time_point); point.setBackgroundDrawable(d); return new ViewHolder(v); }
63. ThemeUtils#getAttributeColor()
Project: HeartBeat
File: ThemeUtils.java
File: ThemeUtils.java
public static int getAttributeColor(Context context, int resId) { TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(resId, typedValue, true); int color = 0x000000; if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) { // resId is a color color = typedValue.data; } else { // resId is not a color } return color; }
64. BaseActivity#createDefaultNavigationColorStateList()
Project: gh4a
File: BaseActivity.java
File: BaseActivity.java
// similar to what NavigationView does by default, // but uses accent color instead of primary color private ColorStateList createDefaultNavigationColorStateList(int baseColorThemeAttr) { TypedValue value = new TypedValue(); if (!getTheme().resolveAttribute(baseColorThemeAttr, value, true)) { return null; } ColorStateList baseColor = ContextCompat.getColorStateList(this, value.resourceId); if (!getTheme().resolveAttribute(android.support.design.R.attr.colorAccent, value, true)) { return null; } int colorAccent = value.data; int defaultColor = baseColor.getDefaultColor(); final int[] disabledStateSet = { -android.R.attr.state_enabled }; final int[] checkedStateSet = { android.R.attr.state_checked }; final int[][] states = { disabledStateSet, checkedStateSet, { 0 } }; final int[] colors = { baseColor.getColorForState(disabledStateSet, defaultColor), colorAccent, defaultColor }; return new ColorStateList(states, colors); }
65. SlidingTabLayout#createDefaultTabView()
Project: from-pc
File: SlidingTabLayout.java
File: SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
66. WebpBitmapFactoryImpl#hookDecodeResource()
Project: fresco
File: WebpBitmapFactoryImpl.java
File: WebpBitmapFactoryImpl.java
@DoNotStrip public static Bitmap hookDecodeResource(Resources res, int id, BitmapFactory.Options opts) { Bitmap bm = null; TypedValue value = new TypedValue(); try (InputStream is = res.openRawResource(id, value)) { bm = hookDecodeResourceStream(res, value, is, null, opts); } catch (Exception e) { } if (IN_BITMAP_SUPPORTED && bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return bm; }
67. MasterFragmentDelegate#onViewCreated()
Project: FragmentMaster
File: MasterFragmentDelegate.java
File: MasterFragmentDelegate.java
public void onViewCreated(View view, Bundle savedInstanceState) { // Use window background as the top level background. // Note: The view is an instance of NoSaveStateFrameLayout, // which is inserted between the Fragment's view and its container by FragmentManager. TypedValue outValue = new TypedValue(); getFragmentContext().getTheme().resolveAttribute(android.R.attr.windowBackground, outValue, true); view.setBackgroundResource(outValue.resourceId); // Set the "clickable" of the fragment's root view to true to avoid // touch events to be passed to the views behind the fragment. view.setClickable(true); if (getFragmentMaster() != null) { getFragmentMaster().dispatchFragmentViewCreated(mMasterFragment); } }
68. EMResourceUtil#getResolvedResourceId()
Project: ExoMedia
File: EMResourceUtil.java
File: EMResourceUtil.java
/** * Resolves the reference to an attribute, returning the root resource id. * * @param context The context to use when determining the root id * @param attr The attribute to resolve * @return The resource id pointing to the de-referenced attribute */ @AnyRes public static int getResolvedResourceId(Context context, @AttrRes int attr) { TypedValue typedValue = new TypedValue(); Resources.Theme theme = context.getTheme(); theme.resolveAttribute(attr, typedValue, true); if (typedValue.type == TypedValue.TYPE_REFERENCE) { return typedValue.data; } return typedValue.resourceId; }
69. AbsDefaultHeaderTransformer#getActionBarTitleStyle()
Project: endpoints-codelab-android
File: AbsDefaultHeaderTransformer.java
File: AbsDefaultHeaderTransformer.java
@Override protected int getActionBarTitleStyle(Context context) { // Super handles ICS+ anyway... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { return super.getActionBarTitleStyle(context); } // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, R.styleable.SherlockActionBar); try { return abStyle.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0); } finally { abStyle.recycle(); } }
70. AbsDefaultHeaderTransformer#getActionBarBackground()
Project: endpoints-codelab-android
File: AbsDefaultHeaderTransformer.java
File: AbsDefaultHeaderTransformer.java
@Override protected Drawable getActionBarBackground(Context context) { // Super handles ICS+ anyway... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { return super.getActionBarBackground(context); } // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, R.styleable.SherlockActionBar); try { return abStyle.getDrawable(R.styleable.SherlockActionBar_background); } finally { abStyle.recycle(); } }
71. DefaultHeaderTransformer#getActionBarTitleStyle()
Project: endpoints-codelab-android
File: DefaultHeaderTransformer.java
File: DefaultHeaderTransformer.java
protected int getActionBarTitleStyle(Context context) { int[] android_styleable_ActionBar = { android.R.attr.titleTextStyle }; // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, android_styleable_ActionBar); try { // titleTextStyle is the first attr in the array above so it's index is 0. return abStyle.getResourceId(0, 0); } finally { abStyle.recycle(); } }
72. DefaultHeaderTransformer#getActionBarBackground()
Project: endpoints-codelab-android
File: DefaultHeaderTransformer.java
File: DefaultHeaderTransformer.java
protected Drawable getActionBarBackground(Context context) { int[] android_styleable_ActionBar = { android.R.attr.background }; // Need to get resource id of style pointed to from actionBarStyle TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true); // Now get action bar style values... TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId, android_styleable_ActionBar); try { // background is the first attr in the array above so it's index is 0. return abStyle.getDrawable(0); } finally { abStyle.recycle(); } }
73. RecentTasksStyler#styleRecentTasksEntry()
Project: dashclock
File: RecentTasksStyler.java
File: RecentTasksStyler.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void styleRecentTasksEntry(Activity activity) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return; } Resources resources = activity.getResources(); String label = resources.getString(activity.getApplicationInfo().labelRes); TypedValue tv = new TypedValue(); if (!activity.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true)) { return; } if (sIcon == null) { // Cache to avoid decoding the same bitmap on every Activity change sIcon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher_white); } activity.setTaskDescription(new ActivityManager.TaskDescription(label, sIcon, tv.data)); }
74. ConfigurationActivity#setupFauxDialog()
Project: dashclock
File: ConfigurationActivity.java
File: ConfigurationActivity.java
private void setupFauxDialog() { // Check if this should be a dialog TypedValue tv = new TypedValue(); if (!getTheme().resolveAttribute(R.attr.isDialog, tv, true) || tv.data == 0) { return; } // Should be a dialog; set up the window parameters. DisplayMetrics dm = getResources().getDisplayMetrics(); WindowManager.LayoutParams params = getWindow().getAttributes(); params.width = getResources().getDimensionPixelSize(R.dimen.configure_dialog_width); params.height = Math.min(getResources().getDimensionPixelSize(R.dimen.configure_dialog_max_height), dm.heightPixels * 3 / 4); params.alpha = 1.0f; params.dimAmount = 0.5f; getWindow().setAttributes(params); }
75. Snackbar#initSnackbar()
Project: Carbon
File: Snackbar.java
File: Snackbar.java
private void initSnackbar(int defStyleAttr) { setBackgroundDrawable(new ColorDrawable(context.getResources().getColor(android.R.color.transparent))); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(defStyleAttr, outValue, true); int theme = outValue.resourceId; Context themedContext = new ContextThemeWrapper(getContext(), theme); View.inflate(themedContext, R.layout.carbon_snackbar, this); content = (LinearLayout) findViewById(R.id.carbon_snackbarContent); content.setElevation(getResources().getDimension(R.dimen.carbon_elevationSnackbar)); message = (TextView) content.findViewById(R.id.carbon_messageText); button = (Button) content.findViewById(R.id.carbon_actionButton); handler = new Handler(); }
76. MarshmallowEditText#createMenu()
Project: Carbon
File: MarshmallowEditText.java
File: MarshmallowEditText.java
private void createMenu(Menu menu) { TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(R.attr.carbon_editMenuTheme, outValue, true); int theme = outValue.resourceId; Context themedContext = new ContextThemeWrapper(getContext(), theme); popupMenu = new EditTextMenu(themedContext); popupMenu.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { isShowingPopup = false; } }); popupMenu.initCopy(menu.findItem(ID_COPY)); popupMenu.initCut(menu.findItem(ID_CUT)); popupMenu.initPaste(menu.findItem(ID_PASTE)); popupMenu.initSelectAll(menu.findItem(ID_SELECT_ALL)); //menu.clear(); /*try { mIgnoreActionUpEventField.set(editor, true); } catch (IllegalAccessException e) { e.printStackTrace(); }*/ }
77. CalligraphyUtils#pullFontPathFromTheme()
Project: Calligraphy
File: CalligraphyUtils.java
File: CalligraphyUtils.java
/** * Last but not least, try to pull the Font Path from the Theme, which is defined. * * @param context Activity Context * @param styleAttrId Theme style id * @param attributeId if -1 returns null. * @return null if no theme or attribute defined. */ static String pullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId) { if (styleAttrId == -1 || attributeId == null) return null; final Resources.Theme theme = context.getTheme(); final TypedValue value = new TypedValue(); theme.resolveAttribute(styleAttrId, value, true); final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, attributeId); try { String font = typedArray.getString(0); return font; } catch (Exception ignore) { return null; } finally { typedArray.recycle(); } }
78. TaskListActivity#setCommentsCount()
Project: astrid
File: TaskListActivity.java
File: TaskListActivity.java
public void setCommentsCount(int count) { TypedValue tv = new TypedValue(); if (count > 0) { commentsButton.setText(Integer.toString(count)); getTheme().resolveAttribute(R.attr.asFilledCommentButtonImg, tv, false); } else { //$NON-NLS-1$ commentsButton.setText(""); getTheme().resolveAttribute(R.attr.asCommentButtonImg, tv, false); } commentsButton.setBackgroundResource(tv.data); }
79. TaskEditFragment#setupBeastModeButton()
Project: astrid
File: TaskEditFragment.java
File: TaskEditFragment.java
private void setupBeastModeButton() { TextView beastMode = (TextView) getView().findViewById(R.id.edit_beast_mode); TypedValue tv = new TypedValue(); Theme theme = getActivity().getTheme(); theme.resolveAttribute(R.attr.asTextColor, tv, false); int color = tv.data & 0x00ffffff; color = color + 0x7f000000; beastMode.setTextColor(color); beastMode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), BeastModePreferences.class); intent.setAction(AstridApiConstants.ACTION_SETTINGS); startActivityForResult(intent, REQUEST_CODE_BEAST_MODE); } }); }
80. TaskEditFragment#onCreate()
Project: astrid
File: TaskEditFragment.java
File: TaskEditFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // if we were editing a task already, restore it if (savedInstanceState != null && savedInstanceState.containsKey(TASK_IN_PROGRESS)) { Task task = savedInstanceState.getParcelable(TASK_IN_PROGRESS); if (task != null) { model = task; } if (savedInstanceState.containsKey(TASK_UUID)) { uuid = savedInstanceState.getString(TASK_UUID); } } showEditComments = Preferences.getBoolean(R.string.p_show_task_edit_comments, true); TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.asCommentButtonImg, tv, false); commentIcon = tv.data; getActivity().setResult(Activity.RESULT_OK); }
81. OrderedMetadataListFragmentHelper#setUpUiComponents()
Project: astrid
File: OrderedMetadataListFragmentHelper.java
File: OrderedMetadataListFragmentHelper.java
public void setUpUiComponents() { TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.asThemeTextColor, tv, false); getTouchListView().setDragndropBackgroundColor(tv.data); getTouchListView().setDropListener(dropListener); getTouchListView().setClickListener(rowClickListener); getTouchListView().setSwipeListener(swipeListener); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); if (Preferences.getInt(AstridPreferences.P_SUBTASKS_HELP, 0) == 0) showSubtasksHelp(); }
82. AstridOrderedListFragmentHelper#setUpUiComponents()
Project: astrid
File: AstridOrderedListFragmentHelper.java
File: AstridOrderedListFragmentHelper.java
public void setUpUiComponents() { TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.asThemeTextColor, tv, false); getTouchListView().setDragndropBackgroundColor(tv.data); getTouchListView().setDropListener(dropListener); getTouchListView().setClickListener(rowClickListener); getTouchListView().setSwipeListener(swipeListener); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); if (Preferences.getInt(AstridPreferences.P_SUBTASKS_HELP, 0) == 0) showSubtasksHelp(); }
83. ShareActionProvider#onCreateActionView()
Project: astrid
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with); return activityChooserView; }
84. ActionBarSherlockNative#getThemedContext()
Project: astrid
File: ActionBarSherlockNative.java
File: ActionBarSherlockNative.java
@Override protected Context getThemedContext() { Context context = mActivity; TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { //We are unable to test if this is the same as our current theme //so we just wrap it and hope that if the attribute was specified //then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } return context; }
85. MainActivity#setDrawerWidth()
Project: android-wail-app
File: MainActivity.java
File: MainActivity.java
private void setDrawerWidth() { TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); float px = typedValue.getDimension(displayMetrics); ViewGroup.LayoutParams params = drawer.getLayoutParams(); if (getResources().getBoolean(R.bool.isTablet)) { params.width = (int) Math.min(displayMetrics.widthPixels - px, getResources().getDimension(R.dimen.main_drawer_standard_increment) * 5); } else { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { params.width = (int) (displayMetrics.widthPixels - px); } else { params.width = (int) (displayMetrics.heightPixels - px); } } drawer.setLayoutParams(params); }
86. SlidingTabLayout#createDefaultTabView()
Project: Android-Remote
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
87. RangeSeekBar#extractNumericValueFromAttributes()
Project: android-range-seek-bar
File: RangeSeekBar.java
File: RangeSeekBar.java
@SuppressWarnings("unchecked") private T extractNumericValueFromAttributes(TypedArray a, int attribute, int defaultValue) { TypedValue tv = a.peekValue(attribute); if (tv == null) { return (T) Integer.valueOf(defaultValue); } int type = tv.type; if (type == TypedValue.TYPE_FLOAT) { return (T) Float.valueOf(a.getFloat(attribute, defaultValue)); } else { return (T) Integer.valueOf(a.getInteger(attribute, defaultValue)); } }
88. SlidingTabLayout#createDefaultTabView()
Project: Android-ObservableScrollView
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
89. BaseFragment#getActionBarSize()
Project: Android-ObservableScrollView
File: BaseFragment.java
File: BaseFragment.java
protected int getActionBarSize() { Activity activity = getActivity(); if (activity == null) { return 0; } TypedValue typedValue = new TypedValue(); int[] textSizeAttr = new int[] { R.attr.actionBarSize }; int indexOfAttrTextSize = 0; TypedArray a = activity.obtainStyledAttributes(typedValue.data, textSizeAttr); int actionBarSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1); a.recycle(); return actionBarSize; }
90. SlidingTabLayout#createDefaultTabView()
Project: Android-ObservableScrollView
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
91. ViewUtils#getActionBarHeight()
Project: Android-Next
File: ViewUtils.java
File: ViewUtils.java
public static int getActionBarHeight(Context context) { int actionBarHeight = 0; TypedValue tv = new TypedValue(); final DisplayMetrics dm = context.getResources().getDisplayMetrics(); if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, dm); } else { tv.data = 48; actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, dm); } return actionBarHeight; }
92. ViewUtils#getActionBarHeightInDp()
Project: Android-Next
File: ViewUtils.java
File: ViewUtils.java
public static int getActionBarHeightInDp(Context context) { int actionBarHeight = 0; TypedValue tv = new TypedValue(); final DisplayMetrics dm = context.getResources().getDisplayMetrics(); if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) actionBarHeight = (int) TypedValue.complexToFloat(tv.data); } else { tv.data = 48; actionBarHeight = (int) TypedValue.complexToFloat(tv.data); } return actionBarHeight; }
93. SlidingTabLayout#createDefaultTabView()
Project: Android-EmotionInputDetector
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
94. SlidingTabLayout#createDefaultTabView()
Project: Android-Developer-Toolbelt
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
95. SlidingTabLayout#createDefaultTabView()
Project: afwall
File: SlidingTabLayout.java
File: SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
96. MaterialItemCustom#init()
Project: AdvancedMaterialDrawer
File: MaterialItemCustom.java
File: MaterialItemCustom.java
private void init(Context ctx, int res) { int currentApiVersion = android.os.Build.VERSION.SDK_INT; /** * theme location */ Resources.Theme theme = ctx.getTheme(); TypedValue typedValue = new TypedValue(); theme.resolveAttribute(R.attr.sectionStyle, typedValue, true); TypedArray values = theme.obtainStyledAttributes(typedValue.resourceId, R.styleable.MaterialSection); view = LayoutInflater.from(ctx).inflate(getItemLayout(values, res), null); }
97. MaterialNavHeadItemActivity#initThemeVars()
Project: AdvancedMaterialDrawer
File: MaterialNavHeadItemActivity.java
File: MaterialNavHeadItemActivity.java
// init methods @SuppressLint("LongLogTag") private void initThemeVars(Resources.Theme theme) { // init theme params TypedValue typedValue = new TypedValue(); theme.resolveAttribute(R.attr.headItemStyle, typedValue, true); // Values of the Account TypedArray values = theme.obtainStyledAttributes(typedValue.resourceId, R.styleable.MaterialHeadItem); headItemTitleColor = values.getColor(R.styleable.MaterialHeadItem_titleColor, 0x00FFFFFF); headItemSubTitleColor = values.getColor(R.styleable.MaterialHeadItem_subTitleColor, 0x00FFFFFF); headItemBackgroundGradient = values.getDrawable(R.styleable.MaterialHeadItem_backgroundGradient); }
98. ShareActionProvider#onCreateActionView()
Project: ActionBarSherlock
File: ShareActionProvider.java
File: ShareActionProvider.java
/** * {@inheritDoc} */ @Override public View onCreateActionView() { // Create the view and set its data model. ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); ActivityChooserView activityChooserView = new ActivityChooserView(mContext); activityChooserView.setActivityChooserModel(dataModel); // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); // Set content description. activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application); activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with); return activityChooserView; }
99. ActionBarSherlockNative#getThemedContext()
Project: ActionBarSherlock
File: ActionBarSherlockNative.java
File: ActionBarSherlockNative.java
@Override protected Context getThemedContext() { Context context = mActivity; TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); if (outValue.resourceId != 0) { //We are unable to test if this is the same as our current theme //so we just wrap it and hope that if the attribute was specified //then the user is intentionally specifying an alternate theme. context = new ContextThemeWrapper(context, outValue.resourceId); } return context; }
100. AnimatorInflater#loadAnimator()
Project: UltimateAndroid
File: AnimatorInflater.java
File: AnimatorInflater.java
/** * Creates a new animation whose parameters come from the specified context and * attributes set. * * @param context the application environment * @param attrs the set of attributes holding the animation parameters */ private static ValueAnimator loadAnimator(Context context, AttributeSet attrs, ValueAnimator anim) throws NotFoundException { TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/ Animator); long duration = a.getInt(/*com.android.internal.R.styleable.*/ Animator_duration, 0); long startDelay = a.getInt(/*com.android.internal.R.styleable.*/ Animator_startOffset, 0); int valueType = a.getInt(/*com.android.internal.R.styleable.*/ Animator_valueType, VALUE_TYPE_FLOAT); if (anim == null) { anim = new ValueAnimator(); } //TypeEvaluator evaluator = null; int valueFromIndex = /*com.android.internal.R.styleable.*/ Animator_valueFrom; int valueToIndex = /*com.android.internal.R.styleable.*/ Animator_valueTo; boolean getFloats = (valueType == VALUE_TYPE_FLOAT); TypedValue tvFrom = a.peekValue(valueFromIndex); boolean hasFrom = (tvFrom != null); int fromType = hasFrom ? tvFrom.type : 0; TypedValue tvTo = a.peekValue(valueToIndex); boolean hasTo = (tvTo != null); int toType = hasTo ? tvTo.type : 0; if ((hasFrom && (fromType >= TypedValue.TYPE_FIRST_COLOR_INT) && (fromType <= TypedValue.TYPE_LAST_COLOR_INT)) || (hasTo && (toType >= TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= TypedValue.TYPE_LAST_COLOR_INT))) { // special case for colors: ignore valueType and get ints getFloats = false; anim.setEvaluator(new ArgbEvaluator()); } if (getFloats) { float valueFrom; float valueTo; if (hasFrom) { if (fromType == TypedValue.TYPE_DIMENSION) { valueFrom = a.getDimension(valueFromIndex, 0f); } else { valueFrom = a.getFloat(valueFromIndex, 0f); } if (hasTo) { if (toType == TypedValue.TYPE_DIMENSION) { valueTo = a.getDimension(valueToIndex, 0f); } else { valueTo = a.getFloat(valueToIndex, 0f); } anim.setFloatValues(valueFrom, valueTo); } else { anim.setFloatValues(valueFrom); } } else { if (toType == TypedValue.TYPE_DIMENSION) { valueTo = a.getDimension(valueToIndex, 0f); } else { valueTo = a.getFloat(valueToIndex, 0f); } anim.setFloatValues(valueTo); } } else { int valueFrom; int valueTo; if (hasFrom) { if (fromType == TypedValue.TYPE_DIMENSION) { valueFrom = (int) a.getDimension(valueFromIndex, 0f); } else if ((fromType >= TypedValue.TYPE_FIRST_COLOR_INT) && (fromType <= TypedValue.TYPE_LAST_COLOR_INT)) { valueFrom = a.getColor(valueFromIndex, 0); } else { valueFrom = a.getInt(valueFromIndex, 0); } if (hasTo) { if (toType == TypedValue.TYPE_DIMENSION) { valueTo = (int) a.getDimension(valueToIndex, 0f); } else if ((toType >= TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= TypedValue.TYPE_LAST_COLOR_INT)) { valueTo = a.getColor(valueToIndex, 0); } else { valueTo = a.getInt(valueToIndex, 0); } anim.setIntValues(valueFrom, valueTo); } else { anim.setIntValues(valueFrom); } } else { if (hasTo) { if (toType == TypedValue.TYPE_DIMENSION) { valueTo = (int) a.getDimension(valueToIndex, 0f); } else if ((toType >= TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= TypedValue.TYPE_LAST_COLOR_INT)) { valueTo = a.getColor(valueToIndex, 0); } else { valueTo = a.getInt(valueToIndex, 0); } anim.setIntValues(valueTo); } } } anim.setDuration(duration); anim.setStartDelay(startDelay); if (a.hasValue(/*com.android.internal.R.styleable.*/ Animator_repeatCount)) { anim.setRepeatCount(a.getInt(/*com.android.internal.R.styleable.*/ Animator_repeatCount, 0)); } if (a.hasValue(/*com.android.internal.R.styleable.*/ Animator_repeatMode)) { anim.setRepeatMode(a.getInt(/*com.android.internal.R.styleable.*/ Animator_repeatMode, ValueAnimator.RESTART)); } //if (evaluator != null) { // anim.setEvaluator(evaluator); //} final int resID = a.getResourceId(/*com.android.internal.R.styleable.*/ Animator_interpolator, 0); if (resID > 0) { anim.setInterpolator(AnimationUtils.loadInterpolator(context, resID)); } a.recycle(); return anim; }