List of usage examples for android.util TypedValue getFloat
public final float getFloat()
From source file:com.github.pedrovgs.sample.activity.PlacesSampleActivity.java
/** * Initialize the DraggablePanel with top and bottom Fragments and apply all the configuration. *///from ww w .j av a 2s .co m 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:com.bilibili.magicasakura.utils.GradientDrawableUtils.java
float getAttrFloatOrFraction(Context context, AttributeSet attrs, int attr, float defaultValue, float base, float pbase) { TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[] { attr }); TypedValue tv = a.peekValue(0); float v = defaultValue; if (tv != null) { boolean isFraction = tv.type == TypedValue.TYPE_FRACTION; v = isFraction ? tv.getFraction(base, pbase) : tv.getFloat(); }//from w w w .j ava2 s . co m a.recycle(); return v; }
From source file:com.bilibili.magicasakura.utils.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"); }/*from w ww . java2s .c o m*/ a.recycle(); }
From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java
float getAttrFloatOrFraction(Context context, AttributeSet attrs, int attr, float defaultValue, float base, float pbase) { TypedArray a = DrawableUtils.obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[] { attr }); TypedValue tv = a.peekValue(0); float v = defaultValue; if (tv != null) { boolean isFraction = tv.type == TypedValue.TYPE_FRACTION; v = isFraction ? tv.getFraction(base, pbase) : tv.getFloat(); }//from w w w . j ava 2s .c om a.recycle(); return v; }
From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException { TypedArray a = DrawableUtils.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"); }//from ww w . ja va 2 s. co m a.recycle(); }
From source file:me.lizheng.deckview.helpers.DeckViewConfig.java
/** * Updates the state, given the specified context *//* w ww .java 2s .co m*/ void update(Context context) { Resources res = context.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); // Debug mode debugModeEnabled = false; // Layout isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // Insets displayRect.set(0, 0, dm.widthPixels, dm.heightPixels); // Animations animationPxMovementPerSecond = res.getDimensionPixelSize(R.dimen.animation_movement_in_dps_per_second); // Filtering filteringCurrentViewsAnimDuration = res.getInteger(R.integer.filter_animate_current_views_duration); filteringNewViewsAnimDuration = res.getInteger(R.integer.filter_animate_new_views_duration); // Task stack taskStackScrollDuration = res.getInteger(R.integer.animate_deck_scroll_duration); TypedValue widthPaddingPctValue = new TypedValue(); res.getValue(R.dimen.deck_width_padding_percentage, widthPaddingPctValue, true); taskStackWidthPaddingPct = widthPaddingPctValue.getFloat(); TypedValue stackOverscrollPctValue = new TypedValue(); res.getValue(R.dimen.deck_overscroll_percentage, stackOverscrollPctValue, true); taskStackOverscrollPct = stackOverscrollPctValue.getFloat(); taskStackMaxDim = res.getInteger(R.integer.max_deck_view_dim); taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.deck_top_padding); // Transition transitionEnterFromAppDelay = res.getInteger(R.integer.enter_from_app_transition_duration); transitionEnterFromHomeDelay = res.getInteger(R.integer.enter_from_home_transition_duration); // Task view animation and styles taskViewEnterFromAppDuration = res.getInteger(R.integer.task_enter_from_app_duration); taskViewEnterFromHomeDuration = res.getInteger(R.integer.task_enter_from_home_duration); taskViewEnterFromHomeStaggerDelay = res.getInteger(R.integer.task_enter_from_home_stagger_delay); taskViewExitToAppDuration = res.getInteger(R.integer.task_exit_to_app_duration); taskViewExitToHomeDuration = res.getInteger(R.integer.task_exit_to_home_duration); taskViewRemoveAnimDuration = res.getInteger(R.integer.animate_task_view_remove_duration); taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize(R.dimen.task_view_remove_anim_translation_x); taskViewRoundedCornerRadiusPx = res.getDimensionPixelSize(R.dimen.task_view_rounded_corners_radius); taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.task_view_highlight); taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.task_view_z_min); taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.task_view_z_max); taskViewAffiliateGroupEnterOffsetPx = res .getDimensionPixelSize(R.dimen.task_view_affiliate_group_enter_offset); TypedValue thumbnailAlphaValue = new TypedValue(); res.getValue(R.dimen.task_view_thumbnail_alpha, thumbnailAlphaValue, true); taskViewThumbnailAlpha = thumbnailAlphaValue.getFloat(); // Task bar colors taskBarViewDefaultBackgroundColor = ContextCompat.getColor(context, R.color.task_bar_default_background_color); taskBarViewLightTextColor = ContextCompat.getColor(context, R.color.task_bar_light_text_color); taskBarViewDarkTextColor = ContextCompat.getColor(context, R.color.task_bar_dark_text_color); taskBarViewHighlightColor = ContextCompat.getColor(context, R.color.task_bar_highlight_color); TypedValue affMinAlphaPctValue = new TypedValue(); res.getValue(R.dimen.task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true); taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat(); // Task bar size & animations taskBarHeight = res.getDimensionPixelSize(R.dimen.deck_child_header_bar_height); taskBarDismissDozeDelaySeconds = res.getInteger(R.integer.task_bar_dismiss_delay_seconds); // Nav bar scrim navBarScrimEnterDuration = res.getInteger(R.integer.nav_bar_scrim_enter_duration); // Misc useHardwareLayers = res.getBoolean(R.bool.config_use_hardware_layers); altTabKeyDelay = res.getInteger(R.integer.deck_alt_tab_key_delay); fakeShadows = res.getBoolean(R.bool.config_fake_shadows); svelteLevel = res.getInteger(R.integer.deck_svelte_level); }
From source file:com.projecttango.examples.java.floorplanreconstruction.FloorPlanReconstructionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TypedValue typedValue = new TypedValue(); getResources().getValue(R.dimen.min_area_space, typedValue, true); mMinAreaSpace = typedValue.getFloat(); mPauseButton = (Button) findViewById(R.id.pause_button); mFloorplanView = (FloorplanView) findViewById(R.id.floorplan); mFloorplanView.registerCallback(this); mAreaText = (TextView) findViewById(R.id.area_text); mHeightText = (TextView) findViewById(R.id.height_text); mDistanceText = (TextView) findViewById(R.id.floordistance_text); DisplayManager displayManager = (DisplayManager) getSystemService(DISPLAY_SERVICE); if (displayManager != null) { displayManager.registerDisplayListener(new DisplayManager.DisplayListener() { @Override//from w w w .ja va 2 s. c o m public void onDisplayAdded(int displayId) { } @Override public void onDisplayChanged(int displayId) { synchronized (this) { setDisplayRotation(); } } @Override public void onDisplayRemoved(int displayId) { } }, null); } }
From source file:com.todoroo.astrid.adapter.TaskAdapter.java
public TaskAdapter(Context context, Preferences preferences, TaskAttachmentDao taskAttachmentDao, TaskDao taskDao, TaskListFragment fragment, Cursor c, AtomicReference<String> query, DialogBuilder dialogBuilder, CheckBoxes checkBoxes, TagService tagService, ThemeCache themeCache) { super(context, c, false); this.checkBoxes = checkBoxes; this.preferences = preferences; this.taskAttachmentDao = taskAttachmentDao; this.taskDao = taskDao; this.context = context; this.query = query; this.fragment = fragment; this.dialogBuilder = dialogBuilder; this.tagService = tagService; this.themeCache = themeCache; this.resources = fragment.getResources(); inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); TypedValue typedValue = new TypedValue(); context.getResources().getValue(R.dimen.tag_characters, typedValue, true); tagCharacters = typedValue.getFloat(); fontSize = preferences.getIntegerFromString(R.string.p_fontSize, 18); displayMetrics = new DisplayMetrics(); fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); textColorSecondary = getData(context, android.R.attr.textColorSecondary); textColorHint = getData(context, android.R.attr.textColorTertiary); textColorOverdue = getColor(context, R.color.overdue); updateTagMap();//from w ww. j a v a2 s . c om this.minRowHeight = computeMinRowHeight(); }
From source file:com.saulcintero.moveon.fragments.Summary4.java
private void pieChartView() { int sumTime = hr_zones_time[0] + hr_zones_time[1] + hr_zones_time[2] + hr_zones_time[3] + hr_zones_time[4] + hr_zones_time[5];//from w w w .jav a2 s. c om double[] distribution = new double[6]; distribution[0] = (hr_zones_time[0] * 100) / sumTime; distribution[1] = (hr_zones_time[1] * 100) / sumTime; distribution[2] = (hr_zones_time[2] * 100) / sumTime; distribution[3] = (hr_zones_time[3] * 100) / sumTime; distribution[4] = (hr_zones_time[4] * 100) / sumTime; distribution[5] = (hr_zones_time[5] * 100) / sumTime; final String[] status = new String[] { getString(R.string.hr_resting).toUpperCase(Locale.getDefault()) + " (" + (int) distribution[0] + "%)", getString(R.string.hr_level1).toUpperCase(Locale.getDefault()) + " (" + (int) distribution[1] + "%)", getString(R.string.hr_level2).toUpperCase(Locale.getDefault()) + " (" + (int) distribution[2] + "%)", getString(R.string.hr_level3).toUpperCase(Locale.getDefault()) + " (" + (int) distribution[3] + "%)", getString(R.string.hr_level4).toUpperCase(Locale.getDefault()) + " (" + (int) distribution[4] + "%)", getString(R.string.hr_maximum).toUpperCase(Locale.getDefault()) + " (" + (int) distribution[5] + "%)" }; int[] colors = { Color.LTGRAY, Color.rgb(111, 183, 217), Color.rgb(54, 165, 54), Color.rgb(234, 206, 74), Color.rgb(246, 164, 83), Color.rgb(246, 103, 88) }; TypedValue outValue1 = new TypedValue(); TypedValue outValue2 = new TypedValue(); mContext.getResources().getValue(R.dimen.pie_legend_text_size_value, outValue1, true); mContext.getResources().getValue(R.dimen.pie_labels_text_size_value, outValue2, true); float pieLegendTextSizeValue = outValue1.getFloat(); float pieLabelTextSizeValue = outValue2.getFloat(); final CategorySeries distributionSeries = new CategorySeries(""); for (int i = 0; i < distribution.length; i++) { distributionSeries.add(status[i], distribution[i]); } final DefaultRenderer defaultRenderer = new DefaultRenderer(); defaultRenderer.setShowLabels(true); defaultRenderer.setLegendTextSize(pieLegendTextSizeValue); defaultRenderer.setLabelsTextSize(pieLabelTextSizeValue); defaultRenderer.setZoomButtonsVisible(true); defaultRenderer.setStartAngle(180); defaultRenderer.setDisplayValues(false); defaultRenderer.setClickEnabled(true); defaultRenderer.setInScroll(true); for (int i = 0; i < distribution.length; i++) { SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer(); seriesRenderer.setColor(colors[i]); seriesRenderer.setDisplayChartValues(true); seriesRenderer.setHighlighted(false); defaultRenderer.addSeriesRenderer(seriesRenderer); } mChartView = ChartFactory.getPieChartView(mContext, distributionSeries, defaultRenderer); mChartView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { for (int i = 0; i < distributionSeries.getItemCount(); i++) { defaultRenderer.getSeriesRendererAt(i).setHighlighted(false); } mChartView.repaint(); } else { for (int i = 0; i < distributionSeries.getItemCount(); i++) { defaultRenderer.getSeriesRendererAt(i).setHighlighted(i == seriesSelection.getPointIndex()); } mChartView.repaint(); int selectedSerie = (int) seriesSelection.getPointIndex(); String sZone = " " + getString(R.string.of_time) + " ("; switch (selectedSerie) { case 0: if (time < 3600) sZone = sZone + FunctionUtils.shortFormatTime(hr_zones_time[0]); else sZone = sZone + FunctionUtils.longFormatTime(hr_zones_time[0]); sZone = sZone + ") " + getString(R.string.in_restring); break; case 1: if (time < 3600) sZone = sZone + FunctionUtils.shortFormatTime(hr_zones_time[1]); else sZone = sZone + FunctionUtils.longFormatTime(hr_zones_time[1]); sZone = sZone + ") " + getString(R.string.in_hr_range1); break; case 2: if (time < 3600) sZone = sZone + FunctionUtils.shortFormatTime(hr_zones_time[2]); else sZone = sZone + FunctionUtils.longFormatTime(hr_zones_time[2]); sZone = sZone + ") " + getString(R.string.in_hr_range2); break; case 3: if (time < 3600) sZone = sZone + FunctionUtils.shortFormatTime(hr_zones_time[3]); else sZone = sZone + FunctionUtils.longFormatTime(hr_zones_time[3]); sZone = sZone + ") " + getString(R.string.in_hr_range3); break; case 4: if (time < 3600) sZone = sZone + FunctionUtils.shortFormatTime(hr_zones_time[4]); else sZone = sZone + FunctionUtils.longFormatTime(hr_zones_time[4]); sZone = sZone + ") " + getString(R.string.in_hr_range4); break; case 5: if (time < 3600) sZone = sZone + FunctionUtils.shortFormatTime(hr_zones_time[5]); else sZone = sZone + FunctionUtils.longFormatTime(hr_zones_time[5]); sZone = sZone + ") " + getString(R.string.in_maximum_effort); break; } UIFunctionUtils.showMessage(mContext, true, (int) seriesSelection.getValue() + "%" + sZone); } } }); layout.addView(mChartView); }
From source file:com.saulcintero.moveon.fragments.Summary4.java
private XYMultipleSeriesRenderer getRenderer() { XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); XYSeriesRenderer r = new XYSeriesRenderer(); TypedValue outValue1 = new TypedValue(); TypedValue outValue2 = new TypedValue(); TypedValue outValue3 = new TypedValue(); TypedValue outValue4 = new TypedValue(); mContext.getResources().getValue(R.dimen.xy_chart_text_size_value, outValue1, true); mContext.getResources().getValue(R.dimen.xy_labels_text_size_value, outValue2, true); mContext.getResources().getValue(R.dimen.xy_axis_title_text_size_value, outValue3, true); mContext.getResources().getValue(R.dimen.xy_legend_text_size_value, outValue4, true); float xyChartTextSizeValue = outValue1.getFloat(); float xyLabelsTextSizeValue = outValue1.getFloat(); float xyAxisTitleTextSizeValue = outValue1.getFloat(); float xyLegendTextSizeValue = outValue1.getFloat(); r = new XYSeriesRenderer(); r.setColor(Color.rgb(255, 124, 0)); r.setFillPoints(true);/*from w w w . java 2 s . c o m*/ r.setLineWidth(2.5f); r.setDisplayChartValues(true); r.setChartValuesTextSize(xyChartTextSizeValue); renderer.addSeriesRenderer(r); renderer.setAxesColor(Color.WHITE); renderer.setLabelsColor(Color.LTGRAY); renderer.setBackgroundColor(Color.TRANSPARENT); renderer.setTextTypeface("sans_serif", Typeface.BOLD); renderer.setLabelsTextSize(xyLabelsTextSizeValue); renderer.setAxisTitleTextSize(xyAxisTitleTextSizeValue); renderer.setLegendTextSize(xyLegendTextSizeValue); renderer.setXTitle(FunctionUtils.capitalizeFirtsLetter(getString(R.string.minutes))); renderer.setYTitle(getString(R.string.beats)); renderer.setXLabels(20); renderer.setYLabels(20); renderer.setYLabelsAlign(Align.LEFT); renderer.setShowGrid(false); renderer.setXAxisMin((timeList.get(0) / 60)); renderer.setXAxisMax((float) ((float) timeList.get(timeList.size() - 1) / 60)); renderer.setYAxisMin(min_hr); renderer.setYAxisMax(max_hr); return renderer; }