But then I decided yet to check this again.
And it turns out that nowadays using an @IntDef is the kosher way of doing things.
So here is the final version of the function:
@Retention(SOURCE) @IntDef({EDIT_SMALL, EDIT_MEDIUM, EDIT_LARGE}) public @interface EditSize {} public static final int EDIT_SMALL = 12; public static final int EDIT_MEDIUM = 24; public static final int EDIT_LARGE = 38; public static int getScaledPixels(Context context, @EditSize int dps) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dps * scale + 0.5f); }
No comments:
Post a Comment