Java Code Examples for androidx.annotation.Dimension#DP

The following examples show how to use androidx.annotation.Dimension#DP . 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 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 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 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 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 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.
 * @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) {
    return createTransitPolyline(
            context,
            stepList,
            transitWidth,
            transitColor,
            null,
            walkingWidth,
            walkingColor,
            null,
            clickable,
            JointType.DEFAULT,
            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.
 *
 * @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 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.
 *
 * @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 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 PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color,
        boolean clickable,
        @Nullable Cap startCap,
        @Nullable Cap endCap
) {
    return createPolyline(
            context,
            locationList,
            width,
            color,
            clickable,
            JointType.DEFAULT,
            startCap,
            endCap,
            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.
 *
 * @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 8
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 9
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 10
Source File: Carousel.java    From epoxy with Apache License 2.0 5 votes vote down vote up
/**
 * Set a DP value to use as the padding on each side of the carousel and in between carousel
 * items.
 *
 * <p>The default as the value returned by {@link #getDefaultSpacingBetweenItemsDp()}
 */
@ModelProp(defaultValue = "NO_VALUE_SET", group = "padding")
public void setPaddingDp(@Dimension(unit = Dimension.DP) int paddingDp) {
  int px = dpToPx(paddingDp != NO_VALUE_SET ? paddingDp : getDefaultSpacingBetweenItemsDp());
  setPadding(px, px, px, px);
  setItemSpacingPx(px);
}
 
Example 11
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 12
Source File: TabLayout.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Dimension(unit = Dimension.DP)
private int getDefaultHeight() {
  boolean hasIconAndText = false;
  for (int i = 0, count = tabs.size(); i < count; i++) {
    Tab tab = tabs.get(i);
    if (tab != null && tab.getIcon() != null && !TextUtils.isEmpty(tab.getText())) {
      hasIconAndText = true;
      break;
    }
  }
  return (hasIconAndText && !inlineLabel) ? DEFAULT_HEIGHT_WITH_TEXT_ICON : DEFAULT_HEIGHT;
}
 
Example 13
Source File: ViewUtils.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
public static float dpToPx(@NonNull Context context, @Dimension(unit = Dimension.DP) int dp) {
  Resources r = context.getResources();
  return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
}
 
Example 14
Source File: BasicTestSample.java    From litho with Apache License 2.0 4 votes vote down vote up
public Matcher myDimenSizePropDip(@Dimension(unit = Dimension.DP) float dips) {
  this.mMyDimenSizePropMatcher =
      org.hamcrest.core.Is.is((float) mResourceResolver.dipsToPixels(dips));
  return this;
}
 
Example 15
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 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.
 * @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.
 * @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,
        @Nullable List<PatternItem> transitPatternItemList,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor,
        @Nullable List<PatternItem> walkingPatternItemList,
        boolean clickable,
        int jointType,
        @Nullable Cap startCap,
        @Nullable Cap endCap
) {
    ArrayList<PolylineOptions> polylineOptionsList = new ArrayList<>();
    if (stepList != null && stepList.size() > 0) {
        for (Step step : stepList) {
            ArrayList<LatLng> directionPointList = new ArrayList<>();
            convertStepToPosition(step, directionPointList);
            if (step.isContainStepList()) {
                polylineOptionsList.add(createPolyline(
                        context,
                        directionPointList,
                        walkingWidth,
                        walkingColor,
                        clickable,
                        jointType,
                        startCap,
                        endCap,
                        walkingPatternItemList
                ));
            } else {
                polylineOptionsList.add(createPolyline(
                        context,
                        directionPointList,
                        transitWidth,
                        transitColor,
                        clickable,
                        jointType,
                        startCap,
                        endCap,
                        transitPatternItemList
                ));
            }
        }
    }
    return polylineOptionsList;
}
 
Example 16
Source File: DimenUtils.java    From zephyr with MIT License 4 votes vote down vote up
@Dimension(unit = Dimension.DP)
public static int pxToDp(@Px int px) {
    return (int) (px / Resources.getSystem().getDisplayMetrics().density);
}
 
Example 17
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
public PathOption setWidth(@Dimension(unit = Dimension.DP) int width) {
    this.width = width;
    return this;
}
 
Example 18
Source File: Carousel.java    From epoxy with Apache License 2.0 2 votes vote down vote up
/**
 * Return the item spacing to use in this carousel, or 0 for no spacing.
 *
 * <p>By default this uses the global default set in {@link #setDefaultItemSpacingDp(int)}, but
 * subclasses can override this to specify their own value.
 */
@Dimension(unit = Dimension.DP)
protected int getDefaultSpacingBetweenItemsDp() {
  return defaultSpacingBetweenItemsDp;
}
 
Example 19
Source File: Carousel.java    From epoxy with Apache License 2.0 2 votes vote down vote up
/**
 * Set a global default to use as the item spacing for all Carousels. Set to 0 for no item
 * spacing.
 */
public static void setDefaultItemSpacingDp(@Dimension(unit = Dimension.DP) int dp) {
  defaultSpacingBetweenItemsDp = dp;
}
 
Example 20
Source File: TestManyTypesView.java    From epoxy with Apache License 2.0 2 votes vote down vote up
@ModelProp
void setIntValueWithDimenTypeAnnotation(@Dimension(unit = Dimension.DP) int value) {

}