petals;
22 | private static final int PETALS_COUNT = 12;
23 |
24 | private static final int DEFAULT_DURATION = 60;
25 |
26 | /**
27 | * Returns a color associated with a particular resource ID
28 | *
29 | * Starting in {@link android.os.Build.VERSION_CODES#M}, the returned
30 | * color will be styled for the specified Context's theme.
31 | *
32 | * @param context Current application context
33 | * @param colorId The desired resource identifier, as generated by the aapt tool. This integer
34 | * encodes the package, type, and resource entry. The value 0 is an invalid identifier.
35 | * @return A single color value in the form 0xAARRGGBB.
36 | */
37 | @ColorInt
38 | public static int getColor(Context context, @ColorRes int colorId) {
39 | return ContextCompat.getColor(context, colorId);
40 | }
41 |
42 | @ColorInt
43 | public static int resolveColor(Context context, @AttrRes int attr) {
44 | return resolveColor(context, attr, 0);
45 | }
46 |
47 | @ColorInt
48 | public static int resolveColor(Context context, @AttrRes int attr, int fallback) {
49 | TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
50 | try {
51 | return a.getColor(0, fallback);
52 | } finally {
53 | a.recycle();
54 | }
55 | }
56 |
57 | public static AnimationDrawable createAnimation(Context context) {
58 | return (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.spinner);
59 | }
60 |
61 | public static AnimationDrawable createAnimation(Context context, @ColorInt int color) {
62 | return createAnimation(context, color, DEFAULT_DURATION);
63 | }
64 |
65 | public static AnimationDrawable createAnimation(Context context, @ColorInt int color, int duration) {
66 | return createAnimation(context, color, duration, true);
67 |
68 | }
69 |
70 | public static AnimationDrawable createAnimation(Context context, @ColorInt int color, int duration, boolean clockwise) {
71 | if (petals == null) {
72 | petals = new ArrayList<>(PETALS_COUNT);
73 | Drawable dr0 = ContextCompat.getDrawable(context, R.drawable.spinner_0);
74 | Drawable dr1 = ContextCompat.getDrawable(context, R.drawable.spinner_1);
75 | Drawable dr2 = ContextCompat.getDrawable(context, R.drawable.spinner_2);
76 | Drawable dr3 = ContextCompat.getDrawable(context, R.drawable.spinner_3);
77 | Drawable dr4 = ContextCompat.getDrawable(context, R.drawable.spinner_4);
78 | Drawable dr5 = ContextCompat.getDrawable(context, R.drawable.spinner_5);
79 | Drawable dr6 = ContextCompat.getDrawable(context, R.drawable.spinner_6);
80 | Drawable dr7 = ContextCompat.getDrawable(context, R.drawable.spinner_7);
81 | Drawable dr8 = ContextCompat.getDrawable(context, R.drawable.spinner_8);
82 | Drawable dr9 = ContextCompat.getDrawable(context, R.drawable.spinner_9);
83 | Drawable dr10 = ContextCompat.getDrawable(context, R.drawable.spinner_10);
84 | Drawable dr11 = ContextCompat.getDrawable(context, R.drawable.spinner_11);
85 | Collections.addAll(petals
86 | , dr0
87 | , dr1
88 | , dr2
89 | , dr3
90 | , dr4
91 | , dr5
92 | , dr6
93 | , dr7
94 | , dr8
95 | , dr9
96 | , dr10
97 | , dr11
98 | );
99 | }
100 | AnimationDrawable animation = new AnimationDrawable();
101 | List drawables = new ArrayList<>(PETALS_COUNT);
102 | for (Drawable drawable : petals) {
103 | Drawable drwNewCopy = drawable.getConstantState().newDrawable().mutate();
104 | drwNewCopy.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
105 | drawables.add(drwNewCopy);
106 | }
107 | if (!clockwise) {
108 | Collections.reverse(drawables);
109 | }
110 | for (Drawable drawable: drawables) {
111 | animation.addFrame(drawable, duration);
112 | }
113 | return animation;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/progress_hud_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
10 |
13 |
16 |
19 |
22 |
25 |
28 |
31 |
34 |
37 |
40 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_0.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_1.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_10.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_11.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_2.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_3.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_4.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_5.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_6.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_7.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_8.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/drawable/spinner_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_9.png
--------------------------------------------------------------------------------
/iosdialog/src/main/res/layout/ios_progress_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
24 |
25 |
26 |
35 |
42 |
43 |
44 |
50 |
51 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #7B1FA2
6 | #6A1B9A
7 | #DD2C00
8 | #EF5350
9 |
10 |
11 | #ff404040
12 | #E91E63
13 | #FFFFFF
14 |
15 |
16 | #8E8E93
17 | #BDBEC2
18 | #C7C7CC
19 |
20 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8dp
4 |
5 | 24dp
6 |
7 | 12dp
8 | 16dp
9 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | IOSDialog
3 | Title
4 | Message
5 |
6 |
--------------------------------------------------------------------------------
/iosdialog/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/iosdialog/src/test/java/com/gmail/samehadar/iosdialog/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.gmail.samehadar.iosdialog;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':iosdialog'
2 |
--------------------------------------------------------------------------------