List of usage examples for android.util TypedValue TypedValue
TypedValue
From source file:android.support.v7ox.app.WindowDecorActionBar.java
public Context getThemedContext() { if (mThemedContext == null) { TypedValue outValue = new TypedValue(); Resources.Theme currentTheme = mContext.getTheme(); currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme_ox, outValue, true); final int targetThemeRes = outValue.resourceId; if (targetThemeRes != 0) { mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); } else {/*from www .ja va 2s.c o m*/ mThemedContext = mContext; } } return mThemedContext; }
From source file:android.support.v7.app.WindowDecorActionBar.java
public Context getThemedContext() { if (mThemedContext == null) { TypedValue outValue = new TypedValue(); Resources.Theme currentTheme = mContext.getTheme(); currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true); final int targetThemeRes = outValue.resourceId; if (targetThemeRes != 0) { mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); } else {// w w w. j a v a 2 s . c om mThemedContext = mContext; } } return mThemedContext; }
From source file:com.hippo.widget.BothScrollView.java
/** * Gets a scale factor that determines the distance the view should scroll * vertically in response to {@link MotionEvent#ACTION_SCROLL}. * @return The vertical scroll scale factor. */// w w w. j a va 2 s. c om protected float getVerticalScrollFactor() { if (mVerticalScrollFactor == 0) { Context context = getContext(); TypedValue outValue = new TypedValue(); if (!context.getTheme().resolveAttribute(16842829, outValue, true)) { // listPreferredItemHeight throw new IllegalStateException("Expected theme to define listPreferredItemHeight."); } mVerticalScrollFactor = outValue.getDimension(context.getResources().getDisplayMetrics()); } return mVerticalScrollFactor; }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
private void showFirstStart() { stopRefreshAnimation();/* w w w .ja v a 2 s .c om*/ LayoutInflater inflater = LayoutInflater.from(getActivity()); ViewGroup parent = (ViewGroup) ((ViewGroup) getActivity().findViewById(R.id.scrollview)).getChildAt(0); if (parent.findViewById(R.id.tracks_msg) == null) inflater.inflate(R.layout.no_tracks, parent); TypedValue typedValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.firstLaunchCoverDrawable, typedValue, true); int firstLaunchBGid = typedValue.resourceId; @SuppressWarnings("deprecation") BitmapDrawable bd = ((BitmapDrawable) getResources().getDrawable(firstLaunchBGid)); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); setCoverArt(bd != null ? bd.getBitmap() : null, null); ((TextSwitcher) getActivity().findViewById(R.id.switcher)).setText(""); int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); if (themeNum > 0 && themeNum != 7) { TypedValue darkColorValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.colorPrimaryDark, darkColorValue, true); ((FadeInNetworkImageView) getActivity().findViewById(R.id.cover)).setColorFilter(darkColorValue.data, PorterDuff.Mode.OVERLAY); } getActivity().findViewById(R.id.error_msg).setVisibility(View.INVISIBLE); ((TextView) getActivity().findViewById(R.id.artist)).setText(""); ((TextView) getActivity().findViewById(R.id.song)).setText(""); getActivity().findViewById(R.id.top_gradient).setVisibility(View.INVISIBLE); getActivity().findViewById(R.id.bottom_gradient).setVisibility(View.INVISIBLE); getActivity().findViewById(R.id.edit_tags_btn).setVisibility(View.INVISIBLE); }
From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java
private float getVerticalScrollFactorCompat() { if (mVerticalScrollFactor == 0) { TypedValue outValue = new TypedValue(); final Context context = getContext(); if (!context.getTheme().resolveAttribute(android.R.attr.listPreferredItemHeight, outValue, true)) { throw new IllegalStateException("Expected theme to define listPreferredItemHeight."); }/*from w w w . j a v a 2 s .c om*/ mVerticalScrollFactor = outValue.getDimension(context.getResources().getDisplayMetrics()); } return mVerticalScrollFactor; }
From source file:com.android.ex.chips.RecipientEditTextView.java
private void setChipDimensions(final Context context, final AttributeSet attrs) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecipientEditTextView, 0, 0); final Resources r = getContext().getResources(); mChipBackground = a.getDrawable(R.styleable.RecipientEditTextView_chipBackground); if (mChipBackground == null) mChipBackground = ContextCompat.getDrawable(context, R.drawable.circle_background_chips); mChipBackgroundPressed = a.getDrawable(R.styleable.RecipientEditTextView_chipBackgroundPressed); if (mChipBackgroundPressed == null) mChipBackgroundPressed = ContextCompat.getDrawable(context, R.drawable.chip_background_selected); mChipDelete = a.getDrawable(R.styleable.RecipientEditTextView_chipDelete); if (mChipDelete == null) mChipDelete = ContextCompat.getDrawable(context, R.drawable.chip_delete); mChipPadding = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipPadding, -1); if (mChipPadding == -1) mChipPadding = (int) r.getDimension(R.dimen.chip_padding); mAlternatesLayout = a.getResourceId(R.styleable.RecipientEditTextView_chipAlternatesLayout, -1); if (mAlternatesLayout == -1) mAlternatesLayout = R.layout.chips_alternate_item; mDefaultContactPhoto = BitmapFactory.decodeResource(r, R.drawable.ic_contact_picture); mMoreItem = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.more_item, null); mChipHeight = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipHeight, -1); if (mChipHeight == -1) mChipHeight = r.getDimension(R.dimen.chip_height); mChipFontSize = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipFontSize, -1); if (mChipFontSize == -1) mChipFontSize = r.getDimension(R.dimen.chip_text_size); mInvalidChipBackground = a.getDrawable(R.styleable.RecipientEditTextView_invalidChipBackground); if (mInvalidChipBackground == null) mInvalidChipBackground = ContextCompat.getDrawable(context, R.drawable.chip_background_invalid); mLineSpacingExtra = r.getDimension(R.dimen.line_spacing_extra); mMaxLines = r.getInteger(R.integer.chips_max_lines); final TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); a.recycle();// w ww . java2 s . c o m }
From source file:com.todoroo.astrid.taskrabbit.TaskRabbitActivity.java
private void setMenuDropdownSelected(boolean selected) { int oldTextColor = menuTitle.getTextColors().getDefaultColor(); int textStyle = (selected ? R.style.TextAppearance_ActionBar_ListsHeader_Selected : R.style.TextAppearance_ActionBar_ListsHeader); TypedValue listDisclosure = new TypedValue(); getTheme().resolveAttribute(R.attr.asListsDisclosure, listDisclosure, false); menuTitle.setTextAppearance(this, textStyle); menuNav.setBackgroundColor(selected ? oldTextColor : android.R.color.transparent); menuNavDisclosure.setSelected(selected); }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
public void checkPreferencesChanges() { boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_force_screen_on", false); boolean dyslexic = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_opendyslexic", false); TextSwitcher switcher = (TextSwitcher) getActivity().findViewById(R.id.switcher); View lrcView = getActivity().findViewById(R.id.lrc_view); if (switcher != null) { switcher.setKeepScreenOn(screenOn); if (switcher.getCurrentView() != null) ((TextView) switcher.getCurrentView()).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); View nextView = switcher.getNextView(); if (nextView != null) { ((TextView) nextView).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); }/*from ww w . j av a 2 s . c o m*/ } if (lrcView != null) lrcView.setKeepScreenOn(screenOn); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); TypedValue outValue = new TypedValue(); MainActivity mainActivity = (MainActivity) getActivity(); mainActivity.getTheme().resolveAttribute(R.attr.themeName, outValue, false); if ("Night".equals(outValue.string) != NightTimeVerifier.check(getActivity()) || mainActivity.themeNum != Integer.valueOf(sharedPrefs.getString("pref_theme", "0"))) { getActivity().finish(); Intent intent = new Intent(getActivity(), MainActivity.class); intent.setAction("android.intent.action.MAIN"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); getActivity().overridePendingTransition(0, 0); } }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
/** * Sets states of check mark view, called by {@link #onBindViewHolder(ViewHolder, GuidedAction)} * when action's checkset Id is other than {@link GuidedAction#NO_CHECK_SET}. Default * implementation assigns drawable loaded from theme attribute * {@link android.R.attr#listChoiceIndicatorMultiple} for checkbox or * {@link android.R.attr#listChoiceIndicatorSingle} for radio button. Subclass rarely needs * override the method, instead app can provide its own drawable that supports transition * animations, change theme attributes {@link android.R.attr#listChoiceIndicatorMultiple} and * {@link android.R.attr#listChoiceIndicatorSingle} in {android.support.v17.leanback.R. * styleable#LeanbackGuidedStepTheme}.//w w w .j ava2 s. c om * * @param vh The view holder associated with the relevant action. * @param action The GuidedAction object to bind to. * @see #onAnimateItemChecked(ViewHolder, boolean) */ public void onBindCheckMarkView(ViewHolder vh, GuidedAction action) { if (action.getCheckSetId() != GuidedAction.NO_CHECK_SET) { vh.mCheckmarkView.setVisibility(View.VISIBLE); int attrId = action.getCheckSetId() == GuidedAction.CHECKBOX_CHECK_SET_ID ? android.R.attr.listChoiceIndicatorMultiple : android.R.attr.listChoiceIndicatorSingle; final Context context = vh.mCheckmarkView.getContext(); Drawable drawable = null; TypedValue typedValue = new TypedValue(); if (context.getTheme().resolveAttribute(attrId, typedValue, true)) { drawable = ContextCompat.getDrawable(context, typedValue.resourceId); } vh.mCheckmarkView.setImageDrawable(drawable); if (vh.mCheckmarkView instanceof Checkable) { ((Checkable) vh.mCheckmarkView).setChecked(action.isChecked()); } } else { vh.mCheckmarkView.setVisibility(View.GONE); } }
From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java
/** * {@inheritDoc}//from w ww.j av a 2 s.co m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); rootLayout = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); rootLayout.setFocusOutStart(isFocusOutStartAllowed()); rootLayout.setFocusOutEnd(isFocusOutEndAllowed()); rootLayout.setBackgroundColor(Color.TRANSPARENT); rootLayout.setOnKeyPress(this); ViewGroup guidanceContainer = (ViewGroup) rootLayout.findViewById(R.id.content_fragment); guidanceContainer.setVisibility(View.INVISIBLE); ViewGroup actionContainer = (ViewGroup) rootLayout.findViewById(R.id.action_fragment); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepListFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepListFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(getActionsByKey(), new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepListFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepListFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepListFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } rootLayout.setOnSubcategoryfocus(false); setActions(mActions, action.toString()); } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we don't need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = rootLayout.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); return rootLayout; }