androidx.annotation.Dimension Java Examples

The following examples show how to use androidx.annotation.Dimension. 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: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options in transit mode.
 *
 * @param context                A context.
 * @param stepList               A list of latitude and longitude for the steps.
 * @param transitWidth           Width of the polyline in screen pixels for transit polyline.
 * @param transitColor           Color of the polyline as a 32-bit ARGB color for transit polyline.
 * @param transitPatternItemList Stroke pattern for the polyline for transit polyline.
 * @param walkingWidth           Width of the polyline in screen pixels for walking polyline.
 * @param walkingColor           Color of the polyline as a 32-bit ARGB color for walking polyline.
 * @param walkingPatternItemList Stroke pattern for the polyline for walking polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static ArrayList<PolylineOptions> createTransitPolyline(
        @NonNull Context context,
        @Nullable List<Step> stepList,
        @Dimension(unit = Dimension.DP) int transitWidth,
        @Nullable List<PatternItem> transitPatternItemList,
        @ColorInt int transitColor,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor,
        @Nullable List<PatternItem> walkingPatternItemList) {
    return createTransitPolyline(
            context,
            stepList,
            transitWidth,
            transitColor,
            transitPatternItemList,
            walkingWidth,
            walkingColor,
            walkingPatternItemList,
            true,
            JointType.DEFAULT,
            null,
            null
    );
}
 
Example #2
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options.
 *
 * @param context         A context.
 * @param locationList    A list of latitude and longitude.
 * @param width           Width of the polyline in screen pixels.
 * @param color           Color of the polyline as a 32-bit ARGB color.
 * @param clickable       Is polyline clickable.
 * @param patternItemList Stroke pattern for the polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color,
        boolean clickable,
        @Nullable List<PatternItem> patternItemList
) {
    return createPolyline(
            context,
            locationList,
            width,
            color,
            clickable,
            JointType.DEFAULT,
            null,
            null,
            patternItemList
    );
}
 
Example #3
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options.
 *
 * @param context      A context.
 * @param locationList A list of latitude and longitude.
 * @param width        Width of the polyline in screen pixels.
 * @param color        Color of the polyline as a 32-bit ARGB color.
 * @param clickable    Is polyline clickable.
 * @param jointType    Joint type for all vertices of the polyline except the start and end vertices.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color,
        boolean clickable,
        int jointType
) {
    return createPolyline(
            context,
            locationList,
            width,
            color,
            clickable,
            jointType,
            null,
            null,
            null
    );
}
 
Example #4
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options.
 *
 * @param context      A context.
 * @param locationList A list of latitude and longitude.
 * @param width        Width of the polyline in screen pixels.
 * @param color        Color of the polyline as a 32-bit ARGB color.
 * @return Options for a polyline.
 * @since 1.0.0
 */
public static PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color
) {
    return createPolyline(
            context,
            locationList,
            width,
            color,
            true,
            JointType.DEFAULT,
            null,
            null,
            null
    );
}
 
Example #5
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options in transit mode.
 *
 * @param context      A context.
 * @param stepList     A list of latitude and longitude for the steps.
 * @param transitWidth Width of the polyline in screen pixels for transit polyline.
 * @param transitColor Color of the polyline as a 32-bit ARGB color for transit polyline.
 * @param walkingWidth Width of the polyline in screen pixels for walking polyline.
 * @param walkingColor Color of the polyline as a 32-bit ARGB color for walking polyline.
 * @param clickable    Is polyline clickable.
 * @param jointType    Joint type for all vertices of the polyline except the start and end vertices.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static ArrayList<PolylineOptions> createTransitPolyline(
        @NonNull Context context,
        @Nullable List<Step> stepList,
        @Dimension(unit = Dimension.DP) int transitWidth,
        @ColorInt int transitColor,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor,
        boolean clickable,
        int jointType) {
    return createTransitPolyline(
            context,
            stepList,
            transitWidth,
            transitColor,
            null,
            walkingWidth,
            walkingColor,
            null,
            clickable,
            jointType,
            null,
            null
    );
}
 
Example #6
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options in transit mode.
 *
 * @param context      A context.
 * @param stepList     A list of latitude and longitude for the steps.
 * @param transitWidth Width of the polyline in screen pixels for transit polyline.
 * @param transitColor Color of the polyline as a 32-bit ARGB color for transit polyline.
 * @param walkingWidth Width of the polyline in screen pixels for walking polyline.
 * @param walkingColor Color of the polyline as a 32-bit ARGB color for walking polyline.
 * @return Options for a polyline.
 * @since 1.0.0
 */
public static ArrayList<PolylineOptions> createTransitPolyline(
        @NonNull Context context,
        @Nullable List<Step> stepList,
        @Dimension(unit = Dimension.DP) int transitWidth,
        @ColorInt int transitColor,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor) {
    return createTransitPolyline(
            context,
            stepList,
            transitWidth,
            transitColor,
            null,
            walkingWidth,
            walkingColor,
            null,
            true,
            JointType.DEFAULT,
            null,
            null
    );
}
 
Example #7
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options in transit mode.
 *
 * @param context      A context.
 * @param stepList     A list of latitude and longitude for the steps.
 * @param transitWidth Width of the polyline in screen pixels for transit polyline.
 * @param transitColor Color of the polyline as a 32-bit ARGB color for transit polyline.
 * @param walkingWidth Width of the polyline in screen pixels for walking polyline.
 * @param walkingColor Color of the polyline as a 32-bit ARGB color for walking polyline.
 * @param clickable    Is polyline clickable.
 * @param startCap     Cap at the start vertex of the polyline.
 * @param endCap       Cap at the end vertex of the polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static ArrayList<PolylineOptions> createTransitPolyline(
        @NonNull Context context,
        @Nullable List<Step> stepList,
        @Dimension(unit = Dimension.DP) int transitWidth,
        @ColorInt int transitColor,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor,
        boolean clickable,
        @Nullable Cap startCap,
        @Nullable Cap endCap) {
    return createTransitPolyline(
            context,
            stepList,
            transitWidth,
            transitColor,
            null,
            walkingWidth,
            walkingColor,
            null,
            clickable,
            JointType.DEFAULT,
            startCap,
            endCap
    );
}
 
Example #8
Source File: NavigationMenuPresenter.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
public void setItemIconSize(@Dimension int itemIconSize) {
  if (this.itemIconSize != itemIconSize) {
    this.itemIconSize = itemIconSize;
    hasCustomItemIconSize = true;
    updateMenuView(false);
  }
}
 
Example #9
Source File: MenuItemsSectionSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
private static DynamicValue<Float> createTranslationXDynamicValue(
    SectionContext c, final int tileIndex, DynamicValue<Float> expandedAmount) {
  final @Dimension int tileWidthWithSpacing = c.getResourceResolver().dipsToPixels(55);
  final FloatEvaluator floatEvaluator = new FloatEvaluator();

  return new DerivedDynamicValue<>(
      expandedAmount,
      new DerivedDynamicValue.Modifier<Float, Float>() {
        @Override
        public Float modify(Float in) {
          return floatEvaluator.evaluate(in, -tileWidthWithSpacing * (tileIndex + 1), 0);
        }
      });
}
 
Example #10
Source File: MaterialCardViewHelper.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
void setStrokeWidth(@Dimension int strokeWidth) {
  if (strokeWidth == this.strokeWidth) {
    return;
  }
  this.strokeWidth = strokeWidth;
  updateStroke();
}
 
Example #11
Source File: BaseSlider.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Set the height of the track in pixels.
 *
 * @see #getTrackHeight()
 * @attr ref com.google.android.material.R.styleable#Slider_trackHeight
 */
public void setTrackHeight(@IntRange(from = 0) @Dimension int trackHeight) {
  if (this.trackHeight != trackHeight) {
    this.trackHeight = trackHeight;
    invalidateTrack();
    postInvalidate();
  }
}
 
Example #12
Source File: ShapeAppearanceModel.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the corner treatment for the bottom right corner.
 *
 * @param cornerFamily the family to use to create the corner treatment
 * @param cornerSize the size to use for the corner
 */
@NonNull
public Builder setBottomRightCorner(
    @CornerFamily int cornerFamily, @Dimension float cornerSize) {
  return setBottomRightCorner(MaterialShapeUtils.createCornerTreatment(cornerFamily))
      .setBottomRightCornerSize(cornerSize);
}
 
Example #13
Source File: TurnLayoutManager.java    From turn-layout-manager with Apache License 2.0 5 votes vote down vote up
/**
 * Traffic method to divert calls based on {@link Orientation}.
 *
 * @see #setChildOffsetsVertical(int, int, Point, int)
 * @see #setChildOffsetsHorizontal(int, int, Point, int)
 */
private void setChildOffsets(@Gravity int gravity,
                             int orientation,
                             @Dimension int radius,
                             Point center,
                             int peekDistance) {
    if (orientation == VERTICAL) {
        setChildOffsetsVertical(gravity, radius, center, peekDistance);
    } else if (orientation == HORIZONTAL) {
        setChildOffsetsHorizontal(gravity, radius, center, peekDistance);
    }
}
 
Example #14
Source File: BindingAdapters.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
@BindingAdapter("leftMargin")
public static void setLeftMargin(@NonNull View view, @NonNull @Dimension float margin) {
    if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        if (params.getMarginStart() != Math.round(margin)) {
            params.setMarginStart(Math.round(margin));
            view.setLayoutParams(params);
        }
    }
}
 
Example #15
Source File: BottomAppBar.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the vertical offset, in pixels, of the {@link FloatingActionButton} being cradled. An
 * offset of 0 indicates the vertical center of the {@link FloatingActionButton} is positioned on
 * the top edge.
 */
public void setCradleVerticalOffset(@Dimension float verticalOffset) {
  if (verticalOffset != getCradleVerticalOffset()) {
    getTopEdgeTreatment().setCradleVerticalOffset(verticalOffset);
    materialShapeDrawable.invalidateSelf();
    setCutoutState();
  }
}
 
Example #16
Source File: TurnLayoutManager.java    From turn-layout-manager with Apache License 2.0 5 votes vote down vote up
/**
 * Set the bumper offsets on child views for {@link Orientation#VERTICAL}
 */
private void setChildOffsetsVertical(@Gravity int gravity,
                                     @Dimension int radius,
                                     Point center,
                                     int peekDistance) {
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int xOffset = (int) resolveOffsetX(radius, child.getY() + child.getHeight() / 2.0f, center, peekDistance);
        final int x = gravity == Gravity.START ? xOffset + getMarginStart(layoutParams)
                : getWidth() - xOffset - child.getWidth() - getMarginStart(layoutParams);
        child.layout(x, child.getTop(), child.getWidth() + x, child.getBottom());
        setChildRotationVertical(gravity, child, radius, center);
    }
}
 
Example #17
Source File: ShapeAppearanceModel.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/** Sets the corner size of all four corner treatments to {@code cornerSize}. */
@NonNull
public Builder setAllCornerSizes(@Dimension float cornerSize) {
  return setTopLeftCornerSize(cornerSize)
      .setTopRightCornerSize(cornerSize)
      .setBottomRightCornerSize(cornerSize)
      .setBottomLeftCornerSize(cornerSize);
}
 
Example #18
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options.
 *
 * @param context         A context.
 * @param locationList    A list of latitude and longitude.
 * @param width           Width of the polyline in screen pixels.
 * @param color           Color of the polyline as a 32-bit ARGB color.
 * @param clickable       Is polyline clickable.
 * @param jointType       Joint type for all vertices of the polyline except the start and end vertices.
 * @param startCap        Cap at the start vertex of the polyline.
 * @param endCap          Cap at the end vertex of the polyline.
 * @param patternItemList Stroke pattern for the polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color,
        boolean clickable,
        int jointType,
        @Nullable Cap startCap,
        @Nullable Cap endCap,
        @Nullable List<PatternItem> patternItemList) {
    PolylineOptions rectLine = new PolylineOptions().width(dpToPx(context, width)).color(color).geodesic(true);
    rectLine.clickable(clickable);
    rectLine.jointType(jointType);
    if (patternItemList != null) {
        rectLine.pattern(patternItemList);
    }
    if (startCap != null) {
        rectLine.startCap(startCap);
    }
    if (endCap != null) {
        rectLine.endCap(endCap);
    }
    if (locationList != null && locationList.size() > 0) {
        for (LatLng location : locationList) {
            rectLine.add(location);
        }
    }
    return rectLine;
}
 
Example #19
Source File: Carousel.java    From epoxy with Apache License 2.0 5 votes vote down vote up
/**
 * @param leftDp Left padding in dp.
 * @param topDp Top padding in dp.
 * @param rightDp Right padding in dp.
 * @param bottomDp Bottom padding in dp.
 * @param itemSpacingDp Space in dp to add between each carousel item. Will be implemented via
 *     an item decoration.
 */
public static Padding dp(
    @Dimension(unit = Dimension.DP) int leftDp,
    @Dimension(unit = Dimension.DP) int topDp,
    @Dimension(unit = Dimension.DP) int rightDp,
    @Dimension(unit = Dimension.DP) int bottomDp,
    @Dimension(unit = Dimension.DP) int itemSpacingDp) {
  return new Padding(leftDp, topDp, rightDp, bottomDp, itemSpacingDp, PaddingType.DP);
}
 
Example #20
Source File: CommentWidget.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
private void setLayoutLeftPadding(ComplexComment complexComment) {
  final int level = complexComment.getLevel();
  int baseMargin =
      AptoideUtils.ScreenU.getPixelsForDip(MARGIN_IN_DIP, getContext().getResources());
  @Dimension int leftMargin = level < 2 ? baseMargin : baseMargin * level;
  outerLayout.setPadding(leftMargin, outerLayout.getPaddingTop(), baseMargin,
      outerLayout.getPaddingBottom());
}
 
Example #21
Source File: PromptOptions.java    From MaterialTapTargetPrompt with Apache License 2.0 5 votes vote down vote up
/**
 * Set the primary text font size.
 *
 * @param size The primary text font size
 * @return This Builder object to allow for chaining of calls to set methods
 */
@NonNull
public T setPrimaryTextSize(@Dimension final float size)
{
    mPrimaryTextSize = size;
    return (T) this;
}
 
Example #22
Source File: BorderDrawable.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
public void setBorderWidth(@Dimension float width) {
  if (borderWidth != width) {
    borderWidth = width;
    paint.setStrokeWidth(width * DRAW_STROKE_WIDTH_MULTIPLE);
    invalidateShader = true;
    invalidateSelf();
  }
}
 
Example #23
Source File: PromptOptions.java    From MaterialTapTargetPrompt with Apache License 2.0 5 votes vote down vote up
/**
 * Set the text left and right padding.
 *
 * @param padding The padding on the text left and right
 * @return This Builder object to allow for chaining of calls to set methods
 */
@NonNull
public T setTextPadding(@Dimension final float padding)
{
    mTextPadding = padding;
    return (T) this;
}
 
Example #24
Source File: PromptOptions.java    From MaterialTapTargetPrompt with Apache License 2.0 5 votes vote down vote up
/**
 * Set the padding between the text and the focal point.
 *
 * @param padding The distance between the text and focal
 * @return This Builder object to allow for chaining of calls to set methods
 */
@NonNull
public T setFocalPadding(@Dimension final float padding)
{
    mFocalPadding = padding;
    return (T) this;
}
 
Example #25
Source File: BottomAppBar.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the cradle margin for the fab cutout. This is the space between the fab and the cutout.
 */
public void setFabCradleMargin(@Dimension float cradleMargin) {
  if (cradleMargin != getFabCradleMargin()) {
    getTopEdgeTreatment().setFabCradleMargin(cradleMargin);
    materialShapeDrawable.invalidateSelf();
  }
}
 
Example #26
Source File: ShapeAppearanceModel.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the corner treatment for the bottom left corner.
 *
 * @param cornerFamily the family to use to create the corner treatment
 * @param cornerSize the size to use for the corner
 */
@NonNull
public Builder setBottomLeftCorner(
    @CornerFamily int cornerFamily, @Dimension float cornerSize) {
  return setBottomLeftCorner(MaterialShapeUtils.createCornerTreatment(cornerFamily))
      .setBottomLeftCornerSize(cornerSize);
}
 
Example #27
Source File: RectanglePromptFocal.java    From MaterialTapTargetPrompt with Apache License 2.0 5 votes vote down vote up
/**
 * Set the padding between the target bounds and the rectangle edge.
 *
 * @param padding The distance from the target edge to the rectangle edge.
 * @return This prompt focal.
 */
@NonNull
public RectanglePromptFocal setTargetPadding(@Dimension final float padding)
{
    mPadding = padding;
    return this;
}
 
Example #28
Source File: Snackbar.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the max width of the action to be in the same line as the message.
 * If the width is exceeded the action would go to the next line.
 */
@NonNull
public Snackbar setMaxInlineActionWidth(@Dimension int width) {
  final SnackbarContentLayout contentLayout = (SnackbarContentLayout) view.getChildAt(0);
  contentLayout.setMaxInlineActionWidth(width);
  return this;
}
 
Example #29
Source File: ChipGroup.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/** Sets the vertical spacing between visible chips in this group. */
public void setChipSpacingVertical(@Dimension int chipSpacingVertical) {
  if (this.chipSpacingVertical != chipSpacingVertical) {
    this.chipSpacingVertical = chipSpacingVertical;
    setLineSpacing(chipSpacingVertical);
    requestLayout();
  }
}
 
Example #30
Source File: BottomNavigationMenuView.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the size to provide for the menu item icons.
 *
 * <p>For best image resolution, use an icon with the same size set in this method.
 *
 * @param iconSize the size to provide for the menu item icons in pixels
 */
public void setItemIconSize(@Dimension int iconSize) {
  this.itemIconSize = iconSize;
  if (buttons != null) {
    for (BottomNavigationItemView item : buttons) {
      item.setIconSize(iconSize);
    }
  }
}