List of usage examples for android.util TypedValue TypedValue
TypedValue
From source file:com.github.pedrovgs.sample.activity.PlacesSampleActivity.java
/** * Initialize the DraggablePanel with top and bottom Fragments and apply all the configuration. */// www . ja v a2s .c om 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); }
From source file:cn.njmeter.njmeter.widget.spinner.NiceSpinner.java
private int getDefaultTextColor(Context context) { TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, typedValue, true); TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.textColorPrimary }); int defaultTextColor = typedArray.getColor(0, Color.BLACK); typedArray.recycle();/*from w w w. j av a2 s .c om*/ return defaultTextColor; }
From source file:info.papdt.blacklight.support.Utility.java
public static int getActionBarHeight(Context context) { TypedValue v = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, v, true)) { return TypedValue.complexToDimensionPixelSize(v.data, context.getResources().getDisplayMetrics()); } else {/* w w w .j a v a2 s.c om*/ return 0; } }
From source file:br.liveo.navigationliveo.NavigationLiveoAWizard.java
private void updateBottomBar() { if (null == mNextButton || null == mPrevButton) { return;//from w w w .ja v a 2 s.c o m } TypedValue v = new TypedValue(); getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, v, true); int position = mPager.getCurrentItem(); if (position == mReviewPagePosition) { mReviewText = mReviewText != null ? mReviewText : getResources().getString(R.string.review_next); mNextButton.setText(mReviewText); mNextButton.setBackgroundResource(R.drawable.review_backgrounds); mNextButton.setTextAppearance(this, R.style.TextAppearanceFinish); } else if (position == mDonePagePosition) { mDoneText = mDoneText != null ? mDoneText : getResources().getString(R.string.done_next); mNextButton.setText(mDoneText); mNextButton.setBackgroundResource(R.drawable.done_backgrounds); mNextButton.setTextAppearance(this, R.style.TextAppearanceFinish); } else if (position == mCurrentPageSequence.size() - 1) { mNextButton.setText(R.string.done_next); if (mDonePagePosition != -1) { mNextButton.setBackgroundResource(R.drawable.selectable_item_background); mNextButton.setTextAppearance(this, v.resourceId); } else { mNextButton.setBackgroundResource(R.drawable.done_backgrounds); mNextButton.setTextAppearance(this, R.style.TextAppearanceFinish); } } else { mNextButton.setText(mEditingAfterReview ? R.string.review : R.string.next); mNextButton.setBackgroundResource(R.drawable.selectable_item_background); mNextButton.setTextAppearance(this, v.resourceId); // mPrevButton.setTextAppearance(this, v.resourceId); mNextButton.setEnabled(position != mPagerAdapter.getCutOffPage()); } mPrevButton.setVisibility(position <= 0 ? View.INVISIBLE : View.VISIBLE); }
From source file:com.djkim.slap.createGroup.CreateGroupActivity.java
private void updateBottomBar() { int position = mPager.getCurrentItem(); if (position == 0) { mPrevButton.setText("Cancel"); } else {/*from w w w. j a v a 2 s . c om*/ mPrevButton.setText("Previous"); } if (position == mCurrentPageSequence.size()) { mNextButton.setText(R.string.finish); mNextButton.setBackgroundResource(R.drawable.finish_background); //mNextButton.setTextAppearance(this, R.style.TextAppearanceFinish); } else { mNextButton.setText(mEditingAfterReview ? R.string.review : R.string.next); mNextButton.setBackgroundResource(R.drawable.selectable_item_background); TypedValue v = new TypedValue(); getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, v, true); //mNextButton.setTextAppearance(this, v.resourceId); mNextButton.setEnabled(position != mPagerAdapter.getCutOffPage()); } mPrevButton.setVisibility(position < 0 ? View.INVISIBLE : View.VISIBLE); }
From source file:com.jaredrummler.android.colorpicker.ColorPickerDialog.java
View createPickerView() { View contentView = View.inflate(getActivity(), R.layout.cpv_dialog_color_picker, null); colorPicker = (ColorPickerView) contentView.findViewById(R.id.cpv_color_picker_view); ColorPanelView oldColorPanel = (ColorPanelView) contentView.findViewById(R.id.cpv_color_panel_old); newColorPanel = (ColorPanelView) contentView.findViewById(R.id.cpv_color_panel_new); ImageView arrowRight = (ImageView) contentView.findViewById(R.id.cpv_arrow_right); hexEditText = (EditText) contentView.findViewById(R.id.cpv_hex); try {//from ww w. j ava 2 s .c om final TypedValue value = new TypedValue(); TypedArray typedArray = getActivity().obtainStyledAttributes(value.data, new int[] { android.R.attr.textColorPrimary }); int arrowColor = typedArray.getColor(0, Color.BLACK); typedArray.recycle(); arrowRight.setColorFilter(arrowColor); } catch (Exception ignored) { } colorPicker.setAlphaSliderVisible(showAlphaSlider); oldColorPanel.setColor(getArguments().getInt(ARG_COLOR)); colorPicker.setColor(color, true); newColorPanel.setColor(color); setHex(color); if (!showAlphaSlider) { hexEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(6) }); } newColorPanel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (newColorPanel.getColor() == color) { colorPickerDialogListener.onColorSelected(dialogId, color); dismiss(); } } }); contentView.setOnTouchListener(this); colorPicker.setOnColorChangedListener(this); hexEditText.addTextChangedListener(this); hexEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(hexEditText, InputMethodManager.SHOW_IMPLICIT); } } }); return contentView; }
From source file:com.antew.redditinpictures.library.ui.ImageViewerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); populatePostData(mPostInformationWrapper); if (savedInstanceState != null) { loadSavedInstanceState(savedInstanceState); }/*from www. j a va 2 s. c o m*/ final Activity act = getActivity(); LocalBroadcastManager.getInstance(act).registerReceiver(mScoreUpdateReceiver, new IntentFilter(Constants.Broadcast.BROADCAST_UPDATE_SCORE)); LocalBroadcastManager.getInstance(act).registerReceiver(mToggleFullscreenIntent, new IntentFilter(Constants.Broadcast.BROADCAST_TOGGLE_FULLSCREEN)); // Set up on our tap listener for the PhotoView which we use to toggle between fullscreen // and windowed mode ((PhotoView) mImageView).setOnPhotoTapListener(getOnPhotoTapListener(act)); MOVE_THRESHOLD = 20 * getResources().getDisplayMetrics().density; // Calculate ActionBar height TypedValue tv = new TypedValue(); if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getActivity().getResources().getDisplayMetrics()); } try { mSystemUiStateProvider = (SystemUiStateProvider) getActivity(); } catch (ClassCastException e) { Ln.e(e, "The activity must implement the SystemUiStateProvider interface"); } }
From source file:com.seamusdawkins.rest.MainActivity.java
private void swipeToRefresh() { int start = convertToPx(0), end = recyclerViewPaddingTop + convertToPx(16); swipeRefreshLayout.setProgressViewOffset(true, start, end); TypedValue typedValueColorPrimary = new TypedValue(); TypedValue typedValueColorAccent = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, typedValueColorPrimary, true); getTheme().resolveAttribute(R.attr.colorAccent, typedValueColorAccent, true); final int colorPrimary = typedValueColorPrimary.data, colorAccent = typedValueColorAccent.data; swipeRefreshLayout.setColorSchemeColors(colorPrimary, colorAccent); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override/*from ww w. j av a2s.c o m*/ public void onRefresh() { error = false; empty = false; myTask.cancel(true); ar.clear(); adapter.notifyDataSetChanged(); progressBar.setVisibility(View.INVISIBLE); mountUrl(); } }); }
From source file:android.support.v7.preference.PreferenceFragmentCompat.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TypedArray a = mStyledContext.obtainStyledAttributes(null, R.styleable.PreferenceFragmentCompat, R.attr.preferenceFragmentCompatStyle, 0); mLayoutResId = a.getResourceId(R.styleable.PreferenceFragmentCompat_android_layout, mLayoutResId); final Drawable divider = a.getDrawable(R.styleable.PreferenceFragmentCompat_android_divider); final int dividerHeight = a .getDimensionPixelSize(R.styleable.PreferenceFragmentCompat_android_dividerHeight, -1); a.recycle();/* w w w. ja v a2 s .com*/ // Need to theme the inflater to pick up the preferenceFragmentListStyle final TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.preferenceTheme, tv, true); final int theme = tv.resourceId; final Context themedContext = new ContextThemeWrapper(inflater.getContext(), theme); final LayoutInflater themedInflater = inflater.cloneInContext(themedContext); final View view = themedInflater.inflate(mLayoutResId, container, false); final View rawListContainer = view.findViewById(AndroidResources.ANDROID_R_LIST_CONTAINER); if (!(rawListContainer instanceof ViewGroup)) { throw new RuntimeException("Content has view with id attribute " + "'android.R.id.list_container' that is not a ViewGroup class"); } final ViewGroup listContainer = (ViewGroup) rawListContainer; final RecyclerView listView = onCreateRecyclerView(themedInflater, listContainer, savedInstanceState); if (listView == null) { throw new RuntimeException("Could not create RecyclerView"); } mList = listView; listView.addItemDecoration(mDividerDecoration); setDivider(divider); if (dividerHeight != -1) { setDividerHeight(dividerHeight); } listContainer.addView(mList); mHandler.post(mRequestFocus); return view; }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
public GlowPadView(Context context, AttributeSet attrs) { super(context, attrs); Resources res = context.getResources(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GlowPadView); mInnerRadius = a.getDimension(R.styleable.GlowPadView_innerRadius, mInnerRadius); mOuterRadius = a.getDimension(R.styleable.GlowPadView_outerRadius, mOuterRadius); mSnapMargin = a.getDimension(R.styleable.GlowPadView_snapMargin, mSnapMargin); mVibrationDuration = a.getInt(R.styleable.GlowPadView_vibrationDuration, mVibrationDuration); mFeedbackCount = a.getInt(R.styleable.GlowPadView_feedbackCount, mFeedbackCount); mAllowScaling = a.getBoolean(R.styleable.GlowPadView_allowScaling, false); TypedValue handle = a.peekValue(R.styleable.GlowPadView_handleDrawable); setHandleDrawable(handle != null ? handle.resourceId : R.drawable.ic_incall_audio_handle); mOuterRing = new TargetDrawable(res, getResourceId(a, R.styleable.GlowPadView_outerRingDrawable), 1); mAlwaysTrackFinger = a.getBoolean(R.styleable.GlowPadView_alwaysTrackFinger, false); int pointId = getResourceId(a, R.styleable.GlowPadView_pointDrawable); Drawable pointDrawable = pointId != 0 ? res.getDrawable(pointId) : null; mGlowRadius = a.getDimension(R.styleable.GlowPadView_glowRadius, 0.0f); TypedValue outValue = new TypedValue(); // Read array of target drawables if (a.getValue(R.styleable.GlowPadView_targetDrawables, outValue)) { internalSetTargetResources(outValue.resourceId); }/*from w ww. ja va2s . c o m*/ if (mTargetDrawables == null || mTargetDrawables.size() == 0) { throw new IllegalStateException("Must specify at least one target drawable"); } // Read array of target descriptions if (a.getValue(R.styleable.GlowPadView_targetDescriptions, outValue)) { final int resourceId = outValue.resourceId; if (resourceId == 0) { throw new IllegalStateException("Must specify target descriptions"); } setTargetDescriptionsResourceId(resourceId); } // Read array of direction descriptions if (a.getValue(R.styleable.GlowPadView_directionDescriptions, outValue)) { final int resourceId = outValue.resourceId; if (resourceId == 0) { throw new IllegalStateException("Must specify direction descriptions"); } setDirectionDescriptionsResourceId(resourceId); } // Use gravity attribute from LinearLayout //a = context.obtainStyledAttributes(attrs, R.styleable.LinearLayout); mGravity = a.getInt(R.styleable.GlowPadView_android_gravity, Gravity.TOP); a.recycle(); setVibrateEnabled(mVibrationDuration > 0); assignDefaultsIfNeeded(); mPointCloud = new PointCloud(pointDrawable); mPointCloud.makePointCloud(mInnerRadius, mOuterRadius); mPointCloud.glowManager.setRadius(mGlowRadius); mExploreByTouchHelper = new GlowpadExploreByTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper); }