androidx.annotation.FloatRange Java Examples
The following examples show how to use
androidx.annotation.FloatRange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CGMSpecificOpsControlPointData.java From Android-BLE-Common-Library with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static Data setCalibrationValue(@FloatRange(from = 0) final float glucoseConcentrationOfCalibration, @GlucoseSampleType final int sampleType, @GlucoseSampleLocation final int sampleLocation, @IntRange(from = 0, to = 65535) final int calibrationTime, @IntRange(from = 0, to = 65535) final int nextCalibrationTime, final boolean secure) { final MutableData data = new MutableData(new byte[11 + (secure ? 2 : 0)]); data.setByte(OP_CODE_SET_CALIBRATION_VALUE, 0); data.setValue(glucoseConcentrationOfCalibration, Data.FORMAT_SFLOAT, 1); data.setValue(calibrationTime, Data.FORMAT_UINT16, 3); final int typeAndSampleLocation = ((sampleLocation & 0xF) << 8) | (sampleType & 0xF); data.setValue(typeAndSampleLocation, Data.FORMAT_UINT8, 5); data.setValue(nextCalibrationTime, Data.FORMAT_UINT16, 6); data.setValue(0, Data.FORMAT_UINT16, 8); // ignored: calibration data record number data.setValue(0, Data.FORMAT_UINT8, 10); // ignored: calibration status return appendCrc(data, secure); }
Example #2
Source File: DrawableHelper.java From monero-wallet-android-app with MIT License | 6 votes |
/** * 创建一张渐变图片,支持韵脚。 * * @param startColor 渐变开始色 * @param endColor 渐变结束色 * @param radius 圆角大小 * @param centerX 渐变中心点 X 轴坐标 * @param centerY 渐变中心点 Y 轴坐标 * @return 返回所创建的渐变图片。 */ @TargetApi(16) public static GradientDrawable getCircleGradientDrawable(@ColorInt int startColor, @ColorInt int endColor, int radius, @FloatRange(from = 0f, to = 1f) float centerX, @FloatRange(from = 0f, to = 1f) float centerY) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColors(new int[]{ startColor, endColor }); gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); gradientDrawable.setGradientRadius(radius); gradientDrawable.setGradientCenter(centerX, centerY); return gradientDrawable; }
Example #3
Source File: ExoPlayerUtils.java From ARVI with Apache License 2.0 | 6 votes |
/** * Calculates the amount of the visibility of the {@link com.google.android.exoplayer2.ui.PlayerView} * on the screen. * Used to determine the visibility area ratio (a value between 0.0 and 1.0), so that further * playback management related actions can be taken by the host {@link com.arthurivanets.arvi.widget.PlayableItemsContainer}. * * @param playable the playable * @return the visibility are offset (a value between 0.0 and 1.0) */ @FloatRange(from = 0.0, to = 1.0) public static float getVisibleAreaOffset(@NonNull Playable playable) { Preconditions.nonNull(playable); if(playable.getParent() == null) { return 0f; } final View playerView = playable.getPlayerView(); final Rect drawRect = new Rect(); final Rect playerRect = new Rect(); playerView.getDrawingRect(drawRect); final int drawArea = (drawRect.width() * drawRect.height()); final boolean isVisible = playerView.getGlobalVisibleRect(playerRect, new Point()); if(isVisible && (drawArea > 0)) { final int visibleArea = (playerRect.height() * playerRect.width()); return (visibleArea / (float) drawArea); } return 0f; }
Example #4
Source File: Utils.java From persistentsearchview with Apache License 2.0 | 5 votes |
/** * Adjusts the alpha channel of the specified color. * * @param color The color to adjust alpha of * @param alpha The alpha value * * @return The color with the adjusted alpha channel */ public static int adjustColorAlpha(int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { final int alphaChannel = (int) (255 * alpha); final int redChannel = Color.red(color); final int greenChannel = Color.green(color); final int blueChannel = Color.blue(color); return Color.argb(alphaChannel, redChannel, greenChannel, blueChannel); }
Example #5
Source File: StateButton.java From bcm-android with GNU General Public License v3.0 | 5 votes |
/******************** radius *******************************/ public void setRadius(@FloatRange(from = 0) float radius) { this.mRadius = radius; mNormalBackground.setCornerRadius(mRadius); mPressedBackground.setCornerRadius(mRadius); mUnableBackground.setCornerRadius(mRadius); }
Example #6
Source File: BasePopupWindow.java From AndroidProject with Apache License 2.0 | 5 votes |
/** * 设置背景遮盖层的透明度 */ public B setBackgroundDimAmount(@FloatRange(from = 0, to = 1) float dimAmount) { mBackgroundDimAmount = dimAmount; if (isShowing()) { mPopupWindow.setBackgroundDimAmount(dimAmount); } return (B) this; }
Example #7
Source File: ColorUtil.java From a with GNU General Public License v3.0 | 5 votes |
@ColorInt public static int shiftColor(@ColorInt int color, @FloatRange(from = 0.0f, to = 2.0f) float by) { if (by == 1f) return color; int alpha = Color.alpha(color); float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= by; // value component return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv)); }
Example #8
Source File: BaseDialog.java From AndroidProject with Apache License 2.0 | 5 votes |
/** * 设置背景遮盖层的透明度(前提条件是背景遮盖层开关必须是为开启状态) */ public B setBackgroundDimAmount(@FloatRange(from = 0, to = 1) float dimAmount) { mBackgroundDimAmount = dimAmount; if (isCreated()) { mDialog.setBackgroundDimAmount(dimAmount); } return (B) this; }
Example #9
Source File: DiscreteSlider.java From DiscreteSlider with MIT License | 5 votes |
public void setTrackWidth(@FloatRange(from = Float.MIN_VALUE) float trackWidth) { if (trackWidth <= 0) { throw new IllegalArgumentException("Track width must be a positive number."); } mTrackWidth = trackWidth; generateInactiveTrackPath(); invalidate(); }
Example #10
Source File: AbsSlidingMusicPanelActivity.java From Music-Player with GNU General Public License v3.0 | 5 votes |
private void setMiniPlayerAlphaProgress(@FloatRange(from = 0, to = 1) float progress) { if (miniPlayerFragment.getView() == null) return; float alpha = 1 - progress; miniPlayerFragment.getView().setAlpha(alpha); // necessary to make the views below clickable miniPlayerFragment.getView().setVisibility(alpha == 0 ? View.GONE : View.VISIBLE); }
Example #11
Source File: AppUtil.java From weather with Apache License 2.0 | 5 votes |
/** * Set the alpha component of {@code color} to be {@code alpha}. */ public static @CheckResult @ColorInt int modifyAlpha(@ColorInt int color, @FloatRange(from = 0f, to = 1f) float alpha) { return modifyAlpha(color, (int) (255f * alpha)); }
Example #12
Source File: StatusBarUtil.java From WanAndroid with Apache License 2.0 | 5 votes |
/** * 设置系统状态栏颜色 */ public static void setStatusColor(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(mixtureColor(color, alpha)); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } }
Example #13
Source File: ImmersionBar.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
/** * 状态栏颜色 * * @param statusBarColor 状态栏颜色,资源文件(R.color.xxx) * @param statusBarColorTransform the status bar color transform 状态栏变换后的颜色 * @param alpha the alpha 透明度 * @return the immersion bar */ public ImmersionBar statusBarColorInt(@ColorInt int statusBarColor, @ColorInt int statusBarColorTransform, @FloatRange(from = 0f, to = 1f) float alpha) { mBarParams.statusBarColor = statusBarColor; mBarParams.statusBarColorTransform = statusBarColorTransform; mBarParams.statusBarAlpha = alpha; return this; }
Example #14
Source File: DiscreteSlider.java From DiscreteSlider with MIT License | 5 votes |
public void setThumbRadius(@FloatRange(from = Float.MIN_VALUE) float radius) { if (radius <= 0) { throw new IllegalArgumentException("Thumb radius must be a positive number."); } mRadius = radius; generateInactiveTrackPath(); invalidate(); }
Example #15
Source File: StatusBarUtil.java From WanAndroid with Apache License 2.0 | 5 votes |
/** * 设置沉浸式状态栏 */ public static void immersive(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { if(Build.VERSION.SDK_INT < MIN_API) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setStatusColor(window, color, alpha); }else{ window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setTranslucentView((ViewGroup)window.getDecorView(), color, alpha); } }
Example #16
Source File: PlayableItemViewHolder.java From ARVI with Apache License 2.0 | 5 votes |
/** * <br> * Sets the audio volume to be used during the playback of the video associated with this {@link PlayableItemViewHolder}. * <br> * If the playback is the active state, then the volume will be adjusted directly on the corresponding {@link Player} instance. * * @param audioVolume the exact audio volume (a value between <strong>0.0</strong> and <strong>1.0</strong>). */ protected final void setVolume(@FloatRange(from = 0.0, to = 1.0) float audioVolume) { // creating/updating the corresponding Playback Info final PlaybackInfo playbackInfo = getPlaybackInfo(); playbackInfo.getVolumeInfo().setVolume(audioVolume); setPlaybackInfo(playbackInfo); // updating the Player-related state (if necessary) final Player player = getPlayer(); if(player != null) { player.getVolumeController().setVolume(audioVolume); } }
Example #17
Source File: ImmersionBar.java From a with GNU General Public License v3.0 | 5 votes |
/** * 导航栏颜色 * * @param navigationBarColor the navigation bar color 导航栏颜色 * @param navigationAlpha the navigation alpha 透明度 * @return the immersion bar */ public ImmersionBar navigationBarColorInt(@ColorInt int navigationBarColor, @FloatRange(from = 0f, to = 1f) float navigationAlpha) { mBarParams.navigationBarColor = navigationBarColor; mBarParams.navigationBarAlpha = navigationAlpha; mBarParams.navigationBarColorTemp = mBarParams.navigationBarColor; return this; }
Example #18
Source File: BasePopupWindow.java From AndroidProject with Apache License 2.0 | 5 votes |
/** * 设置背景遮盖层的透明度 */ public void setBackgroundDimAmount(@FloatRange(from = 0, to = 1) float dimAmount) { float alpha = 1 - dimAmount; if (isShowing()) { setActivityAlpha(alpha); } if (mPopupBackground == null && alpha != 1) { mPopupBackground = new PopupBackground(); addOnShowListener(mPopupBackground); addOnDismissListener(mPopupBackground); } if (mPopupBackground != null) { mPopupBackground.setAlpha(alpha); } }
Example #19
Source File: ImmersionBar.java From a with GNU General Public License v3.0 | 5 votes |
/** * 状态栏和导航栏颜色 * * @param barColor the bar color * @param barAlpha the bar alpha * @return the immersion bar */ public ImmersionBar barColorInt(@ColorInt int barColor, @FloatRange(from = 0f, to = 1f) float barAlpha) { mBarParams.statusBarColor = barColor; mBarParams.navigationBarColor = barColor; mBarParams.navigationBarColorTemp = mBarParams.navigationBarColor; mBarParams.statusBarAlpha = barAlpha; mBarParams.navigationBarAlpha = barAlpha; return this; }
Example #20
Source File: ImmersionBar.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
/** * 解决布局与状态栏重叠问题,支持侧滑返回 * Fits system windows immersion bar. * * @param fits the fits * @param statusBarColorContentView the status bar color content view 状态栏颜色 * @param statusBarColorContentViewTransform the status bar color content view transform 状态栏变色后的颜色 * @param statusBarContentViewAlpha the status bar content view alpha 透明度 * @return the immersion bar */ public ImmersionBar fitsSystemWindows(boolean fits, @ColorRes int statusBarColorContentView , @ColorRes int statusBarColorContentViewTransform, @FloatRange(from = 0f, to = 1f) float statusBarContentViewAlpha) { mBarParams.fits = fits; mBarParams.statusBarColorContentView = ContextCompat.getColor(mActivity, statusBarColorContentView); mBarParams.statusBarColorContentViewTransform = ContextCompat.getColor(mActivity, statusBarColorContentViewTransform); mBarParams.statusBarContentViewAlpha = statusBarContentViewAlpha; mBarParams.statusBarColorContentView = ContextCompat.getColor(mActivity, statusBarColorContentView); mContentView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.statusBarColorContentView, mBarParams.statusBarColorContentViewTransform, mBarParams.statusBarContentViewAlpha)); return this; }
Example #21
Source File: ImmersionBar.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
/** * 导航栏颜色 * * @param navigationBarColor the navigation bar color 导航栏颜色 * @param navigationBarColorTransform the navigation bar color transform 导航栏变色后的颜色 * @param navigationAlpha the navigation alpha 透明度 * @return the immersion bar */ public ImmersionBar navigationBarColorInt(@ColorInt int navigationBarColor, @ColorInt int navigationBarColorTransform, @FloatRange(from = 0f, to = 1f) float navigationAlpha) { mBarParams.navigationBarColor = navigationBarColor; mBarParams.navigationBarColorTransform = navigationBarColorTransform; mBarParams.navigationBarAlpha = navigationAlpha; mBarParams.navigationBarColorTemp = mBarParams.navigationBarColor; return this; }
Example #22
Source File: AdapsterPlayableItemViewHolder.java From ARVI with Apache License 2.0 | 5 votes |
/** * Retrieves the audio volume that's associated with the current instance of the {@link AdapsterPlayableItemViewHolder}. * * @return an audio volume ratio (a value between <strong>0.0</strong> and <strong>1.0</strong>). */ @FloatRange(from = 0.0, to = 1.0) protected final float getVolume() { final PlaybackInfo playbackInfo = getPlaybackInfo(); final Player player = getPlayer(); return ((player != null) ? player.getVolumeController().getVolume() : playbackInfo.getVolumeInfo().getVolume()); }
Example #23
Source File: AdapsterPlayableItemViewHolder.java From ARVI with Apache License 2.0 | 5 votes |
/** * <br> * Sets the audio volume to be used during the playback of the video associated with this {@link AdapsterPlayableItemViewHolder}. * <br> * If the playback is the active state, then the volume will be adjusted directly on the corresponding {@link Player} instance. * * @param audioVolume the exact audio volume (a value between <strong>0.0</strong> and <strong>1.0</strong>). */ protected final void setVolume(@FloatRange(from = 0.0, to = 1.0) float audioVolume) { // creating/updating the corresponding Playback Info final PlaybackInfo playbackInfo = getPlaybackInfo(); playbackInfo.getVolumeInfo().setVolume(audioVolume); setPlaybackInfo(playbackInfo); // updating the Player-related state (if necessary) final Player player = getPlayer(); if(player != null) { player.getVolumeController().setVolume(audioVolume); } }
Example #24
Source File: ImmersionBar.java From a with GNU General Public License v3.0 | 5 votes |
/** * 导航栏字体深色或亮色,判断设备支不支持状态栏变色来设置状态栏透明度 * Status bar dark font immersion bar. * * @param isDarkFont the is dark font * @param statusAlpha the status alpha 如果不支持状态栏字体变色可以使用statusAlpha来指定状态栏透明度,比如白色状态栏的时候可以用到 * @return the immersion bar */ public ImmersionBar navigationBarDarkFont(boolean isDarkFont, @FloatRange(from = 0f, to = 1f) float statusAlpha) { mBarParams.navigationBarDarkFont = isDarkFont; if (canNavigationBarDarkFont()) { mBarParams.navigationBarAlpha = 0; } else { mBarParams.navigationBarAlpha = statusAlpha; } return this; }
Example #25
Source File: MenuItemBuilder.java From LottieBottomNav with MIT License | 5 votes |
public MenuItemBuilder pausedProgress(@FloatRange(from = 0, to = 1) float progress) { if (progress <= 0) progress = 0; else if (progress >= 1) progress = 1; menuItem.lottieProgress = progress; return this; }
Example #26
Source File: StatusBarUtil.java From WanAndroid with Apache License 2.0 | 5 votes |
/** * 为活动中的Fragment的设置沉浸式状态栏 */ public static void immersiveInFragments(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { if(Build.VERSION.SDK_INT < MIN_API) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(color); activity.getWindow().getDecorView() .setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else{ activity.getWindow() .setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setTranslucentView((ViewGroup)activity.getWindow().getDecorView(), color, alpha); } }
Example #27
Source File: ViewUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 设置 View 透明度 * @param view View * @param alpha 透明度 * @return {@link View} */ public static View setAlpha(final View view, @FloatRange(from = 0.0, to = 1.0) final float alpha) { if (view != null) { view.setAlpha(alpha); } return view; }
Example #28
Source File: PercentageChartView.java From PercentageChartView with Apache License 2.0 | 5 votes |
/** * Sets the progress bar thickness in pixels. Works only if chart mode is set to ring. * * @param thickness non-negative thickness value in pixels. * @throws IllegalArgumentException if the given value is negative, or, progress bar thickness is not supported by the current used chart mode. */ public PercentageChartView progressBarThickness(@FloatRange(from = 0) float thickness) { if (thickness < 0) { throw new IllegalArgumentException("Progress bar thickness must be a positive value."); } try { ((RingModeRenderer) renderer).setProgressBarThickness(thickness); } catch (ClassCastException e) { throw new IllegalArgumentException("Progress bar thickness is not support by the used percentage chart mode."); } return this; }
Example #29
Source File: PercentageChartView.java From PercentageChartView with Apache License 2.0 | 5 votes |
/** * Sets the background bar thickness in pixels. Works only if chart mode is set to ring. * * @param thickness non-negative thickness value in pixels. * @throws IllegalArgumentException if the given value is negative, or, background bar thickness is not supported by the current used chart mode. */ public PercentageChartView backgroundBarThickness(@FloatRange(from = 0) float thickness) { if (thickness < 0) { throw new IllegalArgumentException("Background bar thickness must be a positive value."); } try { ((RingModeRenderer) renderer).setBackgroundBarThickness(thickness); } catch (ClassCastException e) { throw new IllegalArgumentException("Background bar thickness is not support by the used percentage chart mode."); } return this; }
Example #30
Source File: PercentageChartView.java From PercentageChartView with Apache License 2.0 | 5 votes |
/** * Sets a new progress value. Passing true in animate will cause an animated progress update. * * @param progress New progress float value to set. * @param animate Animation boolean value to set whether to animate progress change or not. * @throws IllegalArgumentException if the given progress is negative, or, less or equal to 100. */ public void setProgress(@FloatRange(from = 0f, to = 100f) float progress, boolean animate) { if (progress < 0 || progress > 100) { throw new IllegalArgumentException("Progress value must be positive and less or equal to 100."); } renderer.setProgress(progress, animate); }