T checkNotNull(T object, String message) {
12 | if (object == null) {
13 | throw new NullPointerException(message);
14 | }
15 | return object;
16 | }
17 |
18 | static int pixelOfScaled(Context c, int sp) {
19 | Resources r = c.getResources();
20 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, r.getDisplayMetrics());
21 | }
22 |
23 | static int pixelOfDp(Context c, int dp) {
24 | Resources r = c.getResources();
25 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
26 | }
27 |
28 |
29 | private static final Object sLock = new Object();
30 | private static TypedValue sTempValue;
31 | /**
32 | * Returns a drawable object associated with a particular resource ID.
33 | *
34 | * Starting in {@link Build.VERSION_CODES#LOLLIPOP}, the
35 | * returned drawable will be styled for the specified Context's theme.
36 | *
37 | * @param id The desired resource identifier, as generated by the aapt tool.
38 | * This integer encodes the package, type, and resource entry.
39 | * The value 0 is an invalid identifier.
40 | * @return Drawable An object that can be used to draw this resource.
41 | */
42 | static Drawable getDrawable(Context context, int id) {
43 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
44 | return context.getDrawable(id);
45 | } else if (Build.VERSION.SDK_INT >= 16) {
46 | //noinspection deprecation
47 | return context.getResources().getDrawable(id);
48 | } else {
49 | // Prior to JELLY_BEAN, Resources.getDrawable() would not correctly
50 | // retrieve the final configuration density when the resource ID
51 | // is a reference another Drawable resource. As a workaround, try
52 | // to resolve the drawable reference manually.
53 | final int resolvedId;
54 | synchronized (sLock) {
55 | if (sTempValue == null) {
56 | sTempValue = new TypedValue();
57 | }
58 | context.getResources().getValue(id, sTempValue, true);
59 | resolvedId = sTempValue.resourceId;
60 | }
61 | //noinspection deprecation
62 | return context.getResources().getDrawable(resolvedId);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/picker-view/src/main/res/anim/top_defaults_view_pickerview_slide_in_from_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/picker-view/src/main/res/anim/top_defaults_view_pickerview_slide_out_to_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/picker-view/src/main/res/drawable/top_defaults_view_pickerview_selected_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/picker-view/src/main/res/layout/top_defaults_view_pickerview_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/picker-view/src/main/res/values/top_defaults_view_pickerview_attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/picker-view/src/main/res/values/top_defaults_view_pickerview_styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
17 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':picker-view'
2 |
--------------------------------------------------------------------------------