├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── findbugs-idea.xml
├── gradle.xml
├── libraries
│ ├── animated_vector_drawable_23_4_0.xml
│ ├── appcompat_v7_23_4_0.xml
│ ├── butterknife_7_0_1.xml
│ ├── hamcrest_core_1_3.xml
│ ├── junit_4_12.xml
│ ├── play_services_appindexing_8_1_0.xml
│ ├── play_services_basement_8_1_0.xml
│ ├── support_annotations_23_4_0.xml
│ ├── support_v4_23_4_0.xml
│ └── support_vector_drawable_23_4_0.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hss01248
│ │ └── progressview
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hss01248
│ │ │ └── progressview
│ │ │ ├── MainActivity.java
│ │ │ └── gradientRing
│ │ │ ├── LinearGradientUtil.java
│ │ │ ├── MyRingView.java
│ │ │ └── ScrimUtil.java
│ └── res
│ │ ├── anim
│ │ ├── dialog_enter.xml
│ │ ├── dialog_enter_center.xml
│ │ ├── dialog_exit.xml
│ │ └── dialog_exit_center.xml
│ │ ├── drawable
│ │ ├── audio_pause.png
│ │ ├── bg_ios_roundcorner.xml
│ │ ├── bg_ios_roundcorner_bottom.xml
│ │ ├── bg_ios_roundcorner_progress.xml
│ │ ├── bg_ios_roundcorner_top.xml
│ │ ├── loading2.png
│ │ ├── loadinggif.gif
│ │ ├── progress.xml
│ │ ├── progressstyleshape.xml
│ │ └── ring.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── dialog_ios_alert.xml
│ │ ├── dialog_ios_alert_bottom.xml
│ │ ├── dialog_ios_alert_vertical.xml
│ │ ├── dialog_ios_center_item.xml
│ │ ├── item_btn_bottomalert.xml
│ │ └── progressview.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── hss01248
│ └── progressview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── ios_3_horizental.png
├── ios_alert.png
├── ios_alert_2btn.png
├── ios_bottom_sheet.png
├── ios_center_sheet.png
├── ios_vertical.png
├── lib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hss01248
│ │ └── lib
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hss01248
│ │ │ └── lib
│ │ │ ├── MyDialogListener.java
│ │ │ ├── MyItemDialogListener.java
│ │ │ └── StytledDialog.java
│ └── res
│ │ ├── anim
│ │ ├── dialog_enter.xml
│ │ ├── dialog_enter_center.xml
│ │ ├── dialog_exit.xml
│ │ └── dialog_exit_center.xml
│ │ ├── drawable
│ │ ├── bg_ios_roundcorner.xml
│ │ ├── bg_ios_roundcorner_bottom.xml
│ │ ├── bg_ios_roundcorner_progress.xml
│ │ ├── bg_ios_roundcorner_top.xml
│ │ └── progressstyleshape.xml
│ │ ├── layout
│ │ ├── dialog_ios_alert.xml
│ │ ├── dialog_ios_alert_bottom.xml
│ │ ├── dialog_ios_alert_vertical.xml
│ │ ├── dialog_ios_center_item.xml
│ │ ├── item_btn_bottomalert.xml
│ │ └── progressview_wrapconent.xml
│ │ └── values
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── hss01248
│ └── lib
│ └── ExampleUnitTest.java
├── material.png
├── normaldialog.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | DialogUtils
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/findbugs-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
32 |
203 |
216 |
225 |
226 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/libraries/animated_vector_drawable_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/appcompat_v7_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/libraries/butterknife_7_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/hamcrest_core_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/junit_4_12.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/play_services_appindexing_8_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/play_services_basement_8_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/support_annotations_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/libraries/support_vector_drawable_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/misc.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 | Class structureJava
39 |
40 |
41 | Code maturity issuesJava
42 |
43 |
44 | Java
45 |
46 |
47 | Java language level migration aidsJava
48 |
49 |
50 | Javadoc issuesJava
51 |
52 |
53 | Performance issuesJava
54 |
55 |
56 | TestNGJava
57 |
58 |
59 | Threading issuesJava
60 |
61 |
62 |
63 |
64 | Android
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | 1.7
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Deprecated
3 | 此库不再维护,新地址请看:[ https://github.com/hss01248/DialogUtil](https://github.com/hss01248/DialogUtil)
4 |
5 |
6 | # DialogUtils
7 | material风格,ios风格,传入context构建,可在任意界面弹出,以及dialog样式的activity(todo)
8 |
9 |
10 |
11 | # 特性
12 |
13 | 传入context和activity均可弹出dialog
14 |
15 | 样式包括常用的ios风格dialog和meterial design风格的dialog.
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 |
54 |
55 | 
56 |
57 |
58 |
59 | # useage
60 |
61 |
62 |
63 | ## gradle
64 |
65 | **Step 1.** Add the JitPack repository to your build file
66 |
67 | Add it in your root build.gradle at the end of repositories:
68 |
69 | ```
70 | allprojects {
71 | repositories {
72 | ...
73 | maven { url "https://jitpack.io" }
74 | }
75 | }
76 | ```
77 |
78 | **Step 2.** Add the dependency
79 |
80 | ```
81 | dependencies {
82 | compile 'com.github.glassLake:DialogUtils:1.0.2'
83 | }
84 | ```
85 |
86 |
87 |
88 | ## 示例代码
89 |
90 |
91 |
92 | ```
93 | //通过普通的activity 弹出进度条(转圈圈)
94 | StytledDialog.showProgressDialog(this,msg,true,true);
95 |
96 | //通过context弹出进度条
97 | gloablDialog= StytledDialog.showProgressDialog(getApplicationContext(),msg,true,true);
98 |
99 | //meterial design 样式的alertdialog:
100 | StytledDialog.showMdAlert(this, "title", msg, "sure", "cancle", "think about", true, true, new MyDialogListener() {
101 | @Override
102 | public void onFirst(DialogInterface dialog) {
103 | showToast("onFirst");
104 | }
105 |
106 | @Override
107 | public void onSecond(DialogInterface dialog) {
108 | showToast("onSecond");
109 | }
110 |
111 | @Override
112 | public void onThird(DialogInterface dialog) {
113 | showToast("onThird");
114 | }
115 |
116 |
117 | });
118 |
119 | //ios样式的提示框:( StytledDialog.showIosAlertVertical(...)为按钮竖直方向上排列的对话框)
120 |
121 | StytledDialog.showIosAlert(this, "title", msg, "sure", "cancle", "think about", true, true, new MyDialogListener() {
122 | @Override
123 | public void onFirst(DialogInterface dialog) {
124 | showToast("onFirst");
125 | }
126 |
127 | @Override
128 | public void onSecond(DialogInterface dialog) {
129 | showToast("onSecond");
130 | }
131 |
132 | @Override
133 | public void onThird(DialogInterface dialog) {
134 | showToast("onThird");
135 | }
136 |
137 |
138 | });
139 |
140 | //底部弹出的带或不带取消按钮的弹窗
141 |
142 | final List strings = new ArrayList<>();
143 | strings.add("1");
144 | strings.add("2");
145 | strings.add(msg);
146 |
147 | StytledDialog.showBottomItemDialog(activity, strings, "cancle", true, true, new MyItemDialogListener() {
148 | @Override
149 | public void onItemClick(String text,int position) {
150 | showToast(text);
151 | }
152 |
153 | @Override
154 | public void onBottomBtnClick() {
155 | showToast("onItemClick");
156 | }
157 | });}
158 |
159 |
160 | //中间弹出的条目弹窗
161 |
162 | final List strings = new ArrayList<>();
163 | strings.add("1");
164 | strings.add("2");
165 | strings.add(msg);
166 |
167 | StytledDialog.showIosSingleChoose(activity, strings, true, true, new MyItemDialogListener() {
168 | @Override
169 | public void onItemClick(String text,int position) {
170 | showToast(text);
171 | }
172 |
173 | @Override
174 | public void onBottomBtnClick() {
175 | showToast("onItemClick");
176 | }
177 | });
178 | ```
179 |
180 |
181 |
182 | ## context弹出dialog注意事项
183 |
184 | 弹出后对后退键的响应需要自己写代码:
185 |
186 | ```
187 | Dialog gloablDialog;//用一个统一的变量名存引用
188 |
189 | @Override
190 | public void onBackPressed() {
191 |
192 | if (gloablDialog != null && gloablDialog .isShowing()){
193 | gloablDialog.dismiss();
194 | }else {
195 | super.onBackPressed();
196 | }
197 | }
198 |
199 |
200 | ```
201 |
202 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "com.hss01248.progressview"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | repositories {
23 | jcenter();
24 | flatDir {
25 | dirs 'libs'
26 | }
27 | mavenCentral();
28 | maven {
29 | url "https://jitpack.io"
30 | };
31 |
32 | maven {
33 | url "http://dl.bintray.com/lukaville/maven"
34 | }
35 |
36 |
37 | /* maven { url "http://dl.bintray.com/dodola/maven" }*/
38 | }
39 |
40 | dependencies {
41 | compile fileTree(dir: 'libs', include: ['*.jar'])
42 | testCompile 'junit:junit:4.12'
43 | compile 'com.android.support:appcompat-v7:23.1.1'
44 | compile project(path: ':lib')
45 | compile 'com.google.android.gms:play-services-appindexing:8.1.0'
46 | compile 'com.jakewharton:butterknife:7.0.1'
47 | }
48 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\development\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hss01248/progressview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.progressview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hss01248/progressview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.progressview;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.app.ProgressDialog;
6 | import android.content.Context;
7 | import android.content.DialogInterface;
8 | import android.graphics.Color;
9 | import android.graphics.PixelFormat;
10 | import android.graphics.drawable.ColorDrawable;
11 | import android.os.Bundle;
12 | import android.support.v7.app.AlertDialog;
13 | import android.support.v7.app.AppCompatDialog;
14 | import android.view.Gravity;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.view.Window;
18 | import android.view.WindowManager;
19 | import android.widget.Button;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | import com.hss01248.lib.MyDialogListener;
24 | import com.hss01248.lib.MyItemDialogListener;
25 | import com.hss01248.lib.StytledDialog;
26 |
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | import butterknife.Bind;
31 | import butterknife.ButterKnife;
32 | import butterknife.OnClick;
33 |
34 |
35 | public class MainActivity extends Activity {
36 |
37 | @Bind(R.id.btn_common_progress)
38 | Button btnCommonProgress;
39 | @Bind(R.id.btn_context_progress)
40 | Button btnContextProgress;
41 | @Bind(R.id.btn_material_alert)
42 | Button btnMaterialAlert;
43 | @Bind(R.id.btn_ios_alert)
44 | Button btnIosAlert;
45 | @Bind(R.id.btn_ios_bottom_sheet)
46 | Button btnIosBottomSheet;
47 | @Bind(R.id.btn_ios_center_list)
48 | Button btnIosCenterList;
49 |
50 | /**
51 | * ATTENTION: This was auto-generated to implement the App Indexing API.
52 | * See https://g.co/AppIndexing/AndroidStudio for more information.
53 | */
54 |
55 | Activity activity;
56 | Context context;
57 | @Bind(R.id.btn_ios_alert_vertical)
58 | Button btnIosAlertVertical;
59 | @Bind(R.id.btn_ios_alert_2)
60 | Button btnIosAlert2;
61 | @Bind(R.id.btn_ios_alert_vertical_2)
62 | Button btnIosAlertVertical2;
63 |
64 |
65 | @Override
66 | protected void onCreate(Bundle savedInstanceState) {
67 | super.onCreate(savedInstanceState);
68 | setContentView(R.layout.activity_main);
69 | ButterKnife.bind(this);
70 |
71 | activity = this;
72 | context = getApplication();
73 |
74 |
75 | /*
76 |
83 | */
84 |
85 | /* RotateAnimation animation = new RotateAnimation(0,359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
86 | //animation.setRepeatMode(RotateAnimation.INFINITE);
87 | animation.setDuration(4200);
88 | //animation.setFillAfter(true);
89 | animation.setRepeatCount(RotateAnimation.INFINITE);
90 | LinearInterpolator lin = new LinearInterpolator();
91 | animation.setInterpolator(lin);
92 | //ringView.setAnimation(animation);
93 | ringView.startAnimation(animation);*/
94 |
95 | //showProgressDialog();
96 | // ATTENTION: This was auto-generated to implement the App Indexing API.
97 | // See https://g.co/AppIndexing/AndroidStudio for more information.
98 | /* Intent intent = new Intent(this, CustomDialogActivity.class);
99 | startActivity(intent);*/
100 |
101 | }
102 |
103 | @Override
104 | protected void onResume() {
105 | super.onResume();
106 |
107 | // MyDialogUtils.showProgressDialog(getApplicationContext(), "jindutiao", true, false);
108 |
109 |
110 | // showGlobleDialog(this);
111 |
112 | //showDialog();
113 |
114 | // showcenterDialog();
115 | /* MyDialogUtils.showIosAlert(getApplication(),"hh", "djdsjlfjsd", "本例子是一个自定义的弹出对话框例子源码本例子是一个自定义的弹出对话框例子源码",
116 | "弹出的时候有半透明效果", "", false, true, new MyDialogListener() {
117 | @Override
118 | public void onFirst(DialogInterface dialog) {
119 |
120 | }
121 |
122 | @Override
123 | public void onSecond(DialogInterface dialog) {
124 |
125 | }
126 |
127 | @Override
128 | public void onThird(DialogInterface dialog) {
129 |
130 | }
131 |
132 | @Override
133 | public void onCancle() {
134 |
135 | }
136 | });*/
137 | /* List words = new ArrayList<>();
138 | words.add("相册");
139 | words.add("zhaoxiaoji");
140 | words.add("可以");
141 |
142 | MyDialogUtils.showBottomItemDialog(this,words, "", true, true, new MyItemDialogListener() {
143 | @Override
144 | public void onItemClick(int position) {
145 |
146 | }
147 |
148 | @Override
149 | public void onBottomBtnClick() {
150 |
151 | }
152 | });*/
153 |
154 |
155 | // toast();
156 | }
157 |
158 | private void showcenterDialog() {
159 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
160 | builder.setView(R.layout.dialog_ios_alert);
161 | AlertDialog dialog = builder.create();
162 | Window window = dialog.getWindow();
163 | // window.setWindowAnimations(R.style.mystyle);
164 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//round corner
165 | builder.show();
166 | }
167 |
168 | private void showDialog() {
169 | // AlertDialog dialog = new AlertDialog(this);
170 | AppCompatDialog dialog = new AppCompatDialog(this);
171 | dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);//key code to remove title
172 | Window window = dialog.getWindow();
173 | window.setGravity(Gravity.BOTTOM);
174 | window.setWindowAnimations(R.style.mystyle);
175 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//round corner
176 | // window.setBackgroundDrawableResource(R.drawable.bg_ios_roundcorner);
177 | // window.requestFeature(Window.FEATURE_NO_TITLE);
178 | dialog.setContentView(R.layout.dialog_ios_alert_bottom);
179 | // AlertDialog.Builder builder = new AlertDialog.Builder(this);
180 |
181 |
182 | // 可以在此设置显示动画
183 | WindowManager.LayoutParams wl = window.getAttributes();
184 | /* wl.x = 0;
185 | wl.y = getWindowManager().getDefaultDisplay().getHeight();*/
186 | // 以下这两句是为了保证按钮可以水平满屏
187 | int width = getWindowManager().getDefaultDisplay().getWidth();
188 |
189 | // wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
190 | wl.width = (int) (width * 0.85); // todo keycode gap
191 | wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
192 | //wl.horizontalMargin= 0.2f;
193 | // 设置显示位置
194 | // wl.gravity = Gravity.CENTER_HORIZONTAL;
195 |
196 | dialog.onWindowAttributesChanged(wl);
197 | dialog.show();
198 | }
199 |
200 |
201 | public ProgressDialog showActivityDialog(Activity activity, String msg, boolean cancleable, boolean outsideTouchable) {
202 | ProgressDialog dialog = new ProgressDialog(activity);//,R.style.loading_dialog,
203 | // android:Theme.Dialog主题能把progressbar的直线头变成圆头,但我又不想要其他特性,其圆头是怎么实现的?
204 | dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
205 | dialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progressstyleshape));
206 | // dialog.setIndeterminate(true);
207 | dialog.setMessage(msg);
208 | dialog.setCanceledOnTouchOutside(outsideTouchable);
209 | dialog.setCancelable(cancleable);
210 | // dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
211 | //dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE)); 会包括下方的阴影效果
212 | dialog.show();
213 | return dialog;
214 | }
215 |
216 | private void showGlobleDialog(Context context) {
217 | WindowManager wmManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
218 |
219 | WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
220 | WindowManager.LayoutParams.WRAP_CONTENT, 0, 0, PixelFormat.TRANSLUCENT);
221 | /**
222 | *以下都是WindowManager.LayoutParams的相关属性
223 | * 具体用途请参考SDK文档
224 | */
225 | /**三种类型,
226 | * * 每个window都有z-orderd值,也就是type值,值大的会覆盖在值小的上方
227 | *
228 | * 系统级:全局可弹出,如toast,状态栏,type值为2000-2999
229 | * 应用级-如activity,在特定应用中出现,值为1-99
230 | * 子window级-需要在特定父window中,比如dialog需要在activity中,值为1000-1999
231 | *
232 | * 常见系统层级的type值: 弹出这个级别的窗口,如果是TYPE_TOAST以上,需要申请权限,小米手机默认禁止该权限
233 | *
234 | *
235 | * public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
236 | * public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
237 | * public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
238 | * public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
239 | * public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
240 | * public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
241 | * public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
242 | * public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
243 | * public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
244 | * public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
245 | * WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
246 |
247 | * */
248 | wmParams.type = WindowManager.LayoutParams.TYPE_TOAST; //
249 | wmParams.format = 1;
250 | wmParams.gravity = Gravity.CENTER;
251 | /**
252 | *这里的flags也很关键
253 | *代码实际是wmParams.flags |= FLAG_NOT_FOCUSABLE;
254 | *40的由来是wmParams的默认属性(32)+ FLAG_NOT_FOCUSABLE(8)
255 | *
256 | * // 如果设置了WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,弹出的View收不到Back键的事件
257 | *
258 | * // 不设置这个弹出框的透明遮罩显示为黑色
259 | params.format = PixelFormat.TRANSLUCENT;
260 | | WindowManager.LayoutParams.FLAG_DIM_BEHIND
261 | */
262 | wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
263 | | WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
264 | wmParams.dimAmount = 0.5f;//与WindowManager.LayoutParams.FLAG_DIM_BEHIND以及params.format = PixelFormat.TRANSLUCENT 一起才能设置后面窗口的半透明色
265 |
266 | wmParams.alpha = 1.0f;//整个窗口的半透明值,1.0表示不透明,0.0表示全透明。
267 |
268 | /**
269 | * 9. public float horizontalMargin;
270 | 水平边距,容器与widget之间的距离,占容器宽度的百分率。
271 |
272 | 10. public float verticalMargin;
273 | 纵向边距。*/
274 |
275 | wmParams.horizontalMargin = 0.1f;
276 | /* wmParams.width=40;
277 | wmParams.height=40;*/
278 | ViewGroup viewGroup = (ViewGroup) View.inflate(context, R.layout.progressview_wrapconent, null);
279 |
280 |
281 | wmManager.addView(viewGroup, wmParams); //创建View
282 | }
283 |
284 | private void toast() {
285 | Toast toast = Toast.makeText(this, "hahahhahah", Toast.LENGTH_LONG);
286 | View view = View.inflate(this, R.layout.progressview, null);
287 | TextView textView = (TextView) view.findViewById(R.id.message);
288 | textView.setText("我是一条吐司");
289 | toast.setView(view);
290 | //toast.setMargin(10,10);
291 | //toast.setGravity(Gravity.CENTER,0,0);
292 | toast.show();
293 | }
294 |
295 | @Override
296 | public void onStart() {
297 | super.onStart();
298 |
299 |
300 | }
301 |
302 | @Override
303 | public void onBackPressed() {
304 |
305 | if (gloablDialog != null && gloablDialog.isShowing()) {
306 | gloablDialog.dismiss();
307 |
308 | } else {
309 | super.onBackPressed();
310 | }
311 | }
312 |
313 | Dialog gloablDialog;
314 |
315 | String msg = "如果你有心理咨询师般的敏锐,你会进一步发现——这个姑娘企图用考研来掩饰自己对于毕业的恐惧。";
316 | /* "\n" +
317 | "像琴姑娘这样的毕业生很多,她们一段时间内会认真地复习考研。可用不了多久,她们便会动摇,便会找出诸多借口给自己开脱,最后考研一事半途而废。\n" +
318 | "\n" +
319 | "原因,当事人根本不相信这件事能改变她的命运,能带给她想要的生活。她们相信自己不够努力,也愿意别人骂自己不努力。\n" +
320 | "\n" +
321 | "他们不愿意思考自己到底该干什么?他们抱着一个幻想,假如我真的努力就能解决问题了吧!于是他们把一个不可控的事件,在心理变成了可控,从而增加安全感。\n" +
322 | "\n" +
323 | "人真的可以为了逃避真正的思考,而做出任何你想象不到的事。\n" +
324 | "\n" +
325 | "这种目标是不重结果的,其实它跟刷微博是一个道理,它通过获取无用信息来给自己的生活制造一点喘息。\n" +
326 | "\n" +
327 | "只不过陷在“学习”中,要比陷在微博上更能安慰自己的内心,那个已经破了个大洞的内心。\n" +
328 | "\n" +
329 | "作者:剑圣喵大师\n" +
330 | "链接:https://www.zhihu.com/question/50126427/answer/119551026\n" +
331 | "来源:知乎\n" +
332 | "著作权归作者所有,转载请联系作者获得授权。";*/
333 |
334 | @Override
335 | public void onStop() {
336 | super.onStop();
337 |
338 | }
339 |
340 | @OnClick({R.id.btn_common_progress, R.id.btn_context_progress, R.id.btn_material_alert, R.id.btn_ios_alert,
341 | R.id.btn_ios_alert_vertical, R.id.btn_ios_bottom_sheet, R.id.btn_ios_center_list,R.id.btn_ios_alert_2, R.id.btn_ios_alert_vertical_2})
342 | public void onClick(View view) {
343 | switch (view.getId()) {
344 | case R.id.btn_common_progress:
345 | StytledDialog.showProgressDialog(this, msg, true, true);
346 |
347 | break;
348 | case R.id.btn_context_progress:
349 | gloablDialog = StytledDialog.showProgressDialog(getApplicationContext(), msg, true, true);
350 | break;
351 | case R.id.btn_material_alert:
352 | StytledDialog.showMdAlert(this, "title", msg, "sure", "cancle", "think about", true, true, new MyDialogListener() {
353 | @Override
354 | public void onFirst(DialogInterface dialog) {
355 | showToast("onFirst");
356 | }
357 |
358 | @Override
359 | public void onSecond(DialogInterface dialog) {
360 | showToast("onSecond");
361 | }
362 |
363 | @Override
364 | public void onThird(DialogInterface dialog) {
365 | showToast("onThird");
366 | }
367 |
368 |
369 | });
370 | break;
371 | case R.id.btn_ios_alert:
372 | StytledDialog.showIosAlert(this, "title", msg, "sure", "cancle", "think about", true, true, new MyDialogListener() {
373 | @Override
374 | public void onFirst(DialogInterface dialog) {
375 | showToast("onFirst");
376 | }
377 |
378 | @Override
379 | public void onSecond(DialogInterface dialog) {
380 | showToast("onSecond");
381 | }
382 |
383 | @Override
384 | public void onThird(DialogInterface dialog) {
385 | showToast("onThird");
386 | }
387 |
388 |
389 | });
390 | break;
391 | case R.id.btn_ios_alert_vertical:
392 | StytledDialog.showIosAlertVertical(this, "title", msg, "sure", "cancle", "think about", true, true, new MyDialogListener() {
393 | @Override
394 | public void onFirst(DialogInterface dialog) {
395 | showToast("onFirst");
396 | }
397 |
398 | @Override
399 | public void onSecond(DialogInterface dialog) {
400 | showToast("onSecond");
401 | }
402 |
403 | @Override
404 | public void onThird(DialogInterface dialog) {
405 | showToast("onThird");
406 | }
407 |
408 |
409 | });
410 | break;
411 | case R.id.btn_ios_bottom_sheet: {
412 | final List strings = new ArrayList<>();
413 | strings.add("1");
414 | strings.add("2");
415 | strings.add(msg);
416 | strings.add("4");
417 | strings.add("5");
418 | /* strings.add(msg);
419 | strings.add("6");
420 | strings.add("7");
421 | strings.add(msg);
422 | strings.add("8");
423 | strings.add("9");
424 | strings.add(msg);
425 |
426 | strings.add("10");
427 | strings.add("11");
428 | strings.add(msg);
429 | strings.add("12");
430 | strings.add("13");
431 | strings.add(msg);*/
432 |
433 | StytledDialog.showBottomItemDialog(activity, strings, "cancle", true, true, new MyItemDialogListener() {
434 | @Override
435 | public void onItemClick(String text, int position) {
436 | showToast(text);
437 | }
438 |
439 | @Override
440 | public void onBottomBtnClick() {
441 | showToast("onItemClick");
442 | }
443 | });
444 | }
445 | break;
446 | case R.id.btn_ios_center_list:
447 |
448 | final List strings = new ArrayList<>();
449 | strings.add("1");
450 | strings.add("2");
451 | strings.add(msg);
452 | strings.add("4");
453 | strings.add("5");
454 | strings.add(msg);
455 | /* strings.add("6");
456 | strings.add("7");
457 | strings.add(msg);
458 | strings.add("8");
459 | strings.add("9");
460 | strings.add(msg);
461 |
462 | strings.add("10");
463 | strings.add("11");
464 | strings.add(msg);
465 | strings.add("12");
466 | strings.add("13");
467 | strings.add(msg);*/
468 |
469 | StytledDialog.showIosSingleChoose(activity, strings, true, true, new MyItemDialogListener() {
470 | @Override
471 | public void onItemClick(String text, int position) {
472 | showToast(text);
473 | }
474 |
475 | @Override
476 | public void onBottomBtnClick() {
477 | showToast("onItemClick");
478 | }
479 | });
480 |
481 | break;
482 | case R.id.btn_ios_alert_2:
483 | StytledDialog.showIosAlert(this, "title", msg, "sure", "", "", true, true, new MyDialogListener() {
484 | @Override
485 | public void onFirst(DialogInterface dialog) {
486 | showToast("onFirst");
487 | }
488 |
489 | @Override
490 | public void onSecond(DialogInterface dialog) {
491 | showToast("onSecond");
492 | }
493 |
494 | @Override
495 | public void onThird(DialogInterface dialog) {
496 | // showToast("onThird");
497 | }
498 |
499 |
500 | });
501 |
502 | break;
503 | case R.id.btn_ios_alert_vertical_2:
504 | StytledDialog.showIosAlertVertical(this, "title", msg, "sure", "", "", true, true, new MyDialogListener() {
505 | @Override
506 | public void onFirst(DialogInterface dialog) {
507 | showToast("onFirst");
508 | }
509 |
510 | @Override
511 | public void onSecond(DialogInterface dialog) {
512 | showToast("onSecond");
513 | }
514 |
515 | @Override
516 | public void onThird(DialogInterface dialog) {
517 | showToast("onThird");
518 | }
519 |
520 |
521 | });
522 | break;
523 | }
524 | }
525 |
526 |
527 | public void showToast(String msg) {
528 | Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
529 |
530 | }
531 |
532 |
533 | }
534 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hss01248/progressview/gradientRing/LinearGradientUtil.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.progressview.gradientRing;
2 |
3 | import android.graphics.Color;
4 |
5 | /**
6 | * Created by Administrator on 2016/7/31.
7 | */
8 | public class LinearGradientUtil {
9 | private int mStartColor;
10 | private int mEndColor;
11 |
12 | public LinearGradientUtil(int startColor, int endColor) {
13 | this.mStartColor = startColor;
14 | this.mEndColor = endColor;
15 | }
16 |
17 | public void setStartColor(int startColor) {
18 | this.mStartColor = startColor;
19 | }
20 |
21 | public void setEndColor(int endColor) {
22 | this.mEndColor = endColor;
23 | }
24 |
25 | public int getColor(float radio) {
26 | int redStart = Color.red(mStartColor);
27 | int blueStart = Color.blue(mStartColor);
28 | int greenStart = Color.green(mStartColor);
29 | int redEnd = Color.red(mEndColor);
30 | int blueEnd = Color.blue(mEndColor);
31 | int greenEnd = Color.green(mEndColor);
32 |
33 | int red = (int) (redStart + ((redEnd - redStart) * radio + 0.5));
34 | int greed = (int) (greenStart + ((greenEnd - greenStart) * radio + 0.5));
35 | int blue = (int) (blueStart + ((blueEnd - blueStart) * radio + 0.5));
36 | return Color.argb(255,red, greed, blue);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hss01248/progressview/gradientRing/MyRingView.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.progressview.gradientRing;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.annotation.TargetApi;
5 | import android.content.Context;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.RectF;
10 | import android.graphics.SweepGradient;
11 | import android.os.Build;
12 | import android.util.AttributeSet;
13 | import android.view.View;
14 | import android.view.animation.Animation;
15 | import android.view.animation.LinearInterpolator;
16 | import android.view.animation.RotateAnimation;
17 |
18 | /**
19 | * Created by Administrator on 2016/6/7 0007.
20 | */
21 | public class MyRingView extends View {
22 |
23 | // ColorInt
24 | private int defaultColor;
25 |
26 |
27 |
28 |
29 | private int strokeWidth;
30 |
31 | private RotateAnimation animation;
32 |
33 | // 用于渐变
34 | private Paint paint;
35 | private int[] colors;
36 | private final RectF rectF = new RectF();
37 | private Paint startPaint;
38 |
39 | //private SmoothHandler smoothHandler;
40 |
41 | public MyRingView(Context context) {
42 | super(context);
43 | init(context, null);
44 | }
45 |
46 | public MyRingView(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | init(context, attrs);
49 | }
50 |
51 | public MyRingView(Context context, AttributeSet attrs, int defStyleAttr) {
52 | super(context, attrs, defStyleAttr);
53 | init(context, attrs);
54 | }
55 |
56 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
57 | public MyRingView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
58 | super(context, attrs, defStyleAttr, defStyleRes);
59 | init(context, attrs);
60 | }
61 |
62 |
63 | private void init(final Context context, final AttributeSet attrs) {
64 |
65 |
66 | do {
67 | final int strokeWdithDefaultValue = (int) (18 * getResources().getDisplayMetrics().density + 0.5f);
68 | strokeWidth = strokeWdithDefaultValue;
69 |
70 | defaultColor = Color.BLACK;
71 | if (context == null || attrs == null) {
72 | strokeWidth = strokeWdithDefaultValue;
73 |
74 | defaultColor = Color.BLACK;
75 | break;
76 | }
77 |
78 | /*TypedArray typedArray = null;
79 | try {
80 | typedArray = context.obtainStyledAttributes(attrs, R.styleable.MagicProgressCircle);
81 |
82 | strokeWidth = (int) typedArray.getDimension(R.styleable.MagicProgressCircle_mpc_stroke_width, strokeWdithDefaultValue);
83 |
84 | defaultColor = typedArray.getColor(R.styleable.MagicProgressCircle_mpc_default_color, Color.LTGRAY);
85 | } finally {
86 | if (typedArray != null) {
87 | typedArray.recycle();
88 | }
89 | }*/
90 |
91 |
92 | } while (false);
93 |
94 | paint = new Paint();
95 |
96 |
97 |
98 | paint.setAntiAlias(true);
99 | paint.setStrokeWidth(strokeWidth);
100 | paint.setStyle(Paint.Style.STROKE);
101 | paint.setStrokeJoin(Paint.Join.ROUND);
102 | paint.setStrokeCap(Paint.Cap.ROUND);
103 | paint.setColor(defaultColor);
104 |
105 |
106 | startPaint = new Paint();
107 | startPaint.setColor(Color.BLUE);
108 | startPaint.setStyle(Paint.Style.FILL);
109 |
110 |
111 |
112 | // refreshDelta();
113 |
114 |
115 |
116 |
117 |
118 | }
119 |
120 |
121 |
122 |
123 | /**
124 | * @param color ColorInt
125 | */
126 | public void setDefaultColor(final int color) {
127 | if (this.defaultColor != color) {
128 | this.defaultColor = color;
129 | paint.setColor(defaultColor);
130 | invalidate();
131 | }
132 | }
133 |
134 | public int getDefaultColor() {
135 | return this.defaultColor;
136 | }
137 |
138 | /**
139 | * @param width px
140 | */
141 | public void setStrokeWidth(final int width) {
142 | if (this.strokeWidth != width) {
143 | this.strokeWidth = width;
144 | // 画描边的描边变化
145 | paint.setStrokeWidth(width);
146 |
147 | // 会影响measure
148 | requestLayout();
149 | }
150 | }
151 |
152 | public int getStrokeWidth() {
153 | return this.strokeWidth;
154 | }
155 |
156 | private int deltaR, deltaB, deltaG;
157 | private int startR, startB, startG;
158 |
159 |
160 |
161 | @Override
162 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
163 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
164 |
165 | this.rectF.left = getMeasuredWidth() - strokeWidth;
166 | this.rectF.top = getMeasuredHeight()/2 - strokeWidth/2;
167 | this.rectF.right = getMeasuredWidth() ;
168 | this.rectF.bottom = getMeasuredHeight()/2 + strokeWidth/2;
169 |
170 | }
171 |
172 | /* private Paint startPaint;
173 | private Paint endPaint;*/
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 | // 目前由于SweepGradient赋值只在构造函数,无法pre allocate & reuse instead
182 | @SuppressLint("DrawAllocation")
183 | @Override
184 | protected void onDraw(Canvas canvas) {
185 | super.onDraw(canvas);
186 |
187 | final int restore = canvas.save();
188 |
189 | final int cx = getMeasuredWidth() / 2;
190 | final int cy = getMeasuredHeight() / 2;
191 | final int radius = getMeasuredWidth() / 2 - strokeWidth / 2;
192 |
193 | colors = new int[]{Color.WHITE,Color.BLUE};
194 |
195 | //渐变
196 | final SweepGradient sweepGradient = new SweepGradient(cx, cy, colors, null);
197 | paint.setShader(sweepGradient);
198 |
199 |
200 | canvas.drawCircle(cx, cy, radius, paint);
201 | canvas.restore();
202 |
203 | //画半弧和半圆
204 | /* canvas.save();
205 | paint.setColor(Color.BLUE);
206 | // canvas.rotate((int) Math.floor(360.0f * 1) - 1+180, cx, cy);//旋转到最低点
207 | // canvas.drawArc(rectF, -90f, 180f, true, endPaint);
208 | canvas.drawArc(rectF, -90f, 180f, true, paint);
209 | canvas.drawCircle(rectF.centerX(),rectF.centerY(),8f,paint);*/
210 | canvas.save();
211 |
212 | int ax = getMeasuredWidth() - strokeWidth / 2;
213 | int ay= cy;
214 | canvas.drawOval(rectF,startPaint);
215 |
216 |
217 | canvas.restore();
218 |
219 |
220 | canvas.restoreToCount(restore);
221 |
222 | }
223 |
224 | @Override
225 | protected void onAttachedToWindow() {
226 | super.onAttachedToWindow();
227 |
228 | animation = new RotateAnimation(0,359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
229 | //animation.setRepeatMode(RotateAnimation.INFINITE);
230 | animation.setDuration(4200);
231 | //animation.setFillAfter(true);
232 | animation.setRepeatCount(RotateAnimation.INFINITE);
233 | LinearInterpolator lin = new LinearInterpolator();
234 | animation.setInterpolator(lin);
235 | //ringView.setAnimation(animation);
236 | //this.startAnimation(animation);
237 | }
238 |
239 | @Override
240 | protected void onDetachedFromWindow() {
241 | super.onDetachedFromWindow();
242 | clearAnimation();
243 | }
244 | }
245 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hss01248/progressview/gradientRing/ScrimUtil.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.progressview.gradientRing;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.LinearGradient;
5 | import android.graphics.Shader;
6 | import android.graphics.drawable.Drawable;
7 | import android.graphics.drawable.PaintDrawable;
8 | import android.graphics.drawable.ShapeDrawable;
9 | import android.graphics.drawable.shapes.RectShape;
10 | import android.util.LruCache;
11 | import android.view.Gravity;
12 |
13 | /**
14 | * Created by Administrator on 2016/7/31.
15 | */
16 | public class ScrimUtil {
17 | private static final LruCache cubicGradientScrimCache = new LruCache<>(10);
18 |
19 | private ScrimUtil() {
20 | }
21 |
22 | /**
23 | * Creates an approximated cubic gradient using a multi-stop linear gradient. See
24 | * this post for more
25 | * details.
26 | */
27 | public static Drawable makeCubicGradientScrimDrawable(int baseColor, int numStops, int gravity) {
28 |
29 | // Generate a cache key by hashing together the inputs, based on the method described in the Effective Java book
30 | int cacheKeyHash = baseColor;
31 | cacheKeyHash = 31 * cacheKeyHash + numStops;
32 | cacheKeyHash = 31 * cacheKeyHash + gravity;
33 |
34 | Drawable cachedGradient = cubicGradientScrimCache.get(cacheKeyHash);
35 | if (cachedGradient != null) {
36 | return cachedGradient;
37 | }
38 |
39 | numStops = Math.max(numStops, 2);
40 |
41 | PaintDrawable paintDrawable = new PaintDrawable();
42 | paintDrawable.setShape(new RectShape());
43 |
44 | final int[] stopColors = new int[numStops];
45 |
46 | int red = Color.red(baseColor);
47 | int green = Color.green(baseColor);
48 | int blue = Color.blue(baseColor);
49 | int alpha = Color.alpha(baseColor);
50 |
51 | for (int i = 0; i < numStops; i++) {
52 | float x = i * 1f / (numStops - 1);
53 | /* float opacity = MathUtil.constrain(0, 1, (float) Math.pow(x, 3));
54 | stopColors[i] = Color.argb((int) (alpha * opacity), red, green, blue);*/
55 | }
56 |
57 | final float x0, x1, y0, y1;
58 | switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
59 | case Gravity.LEFT: x0 = 1; x1 = 0; break;
60 | case Gravity.RIGHT: x0 = 0; x1 = 1; break;
61 | default: x0 = 0; x1 = 0; break;
62 | }
63 | switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
64 | case Gravity.TOP: y0 = 1; y1 = 0; break;
65 | case Gravity.BOTTOM: y0 = 0; y1 = 1; break;
66 | default: y0 = 0; y1 = 0; break;
67 | }
68 |
69 | paintDrawable.setShaderFactory(new ShapeDrawable.ShaderFactory() {
70 | @Override
71 | public Shader resize(int width, int height) {
72 | LinearGradient linearGradient = new LinearGradient(
73 | width * x0,
74 | height * y0,
75 | width * x1,
76 | height * y1,
77 | stopColors, null,
78 | Shader.TileMode.CLAMP);
79 | return linearGradient;
80 | }
81 | });
82 |
83 | cubicGradientScrimCache.put(cacheKeyHash, paintDrawable);
84 | return paintDrawable;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/dialog_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/dialog_enter_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/dialog_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/dialog_exit_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/audio_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/drawable/audio_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_ios_roundcorner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_ios_roundcorner_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_ios_roundcorner_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_ios_roundcorner_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/loading2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/drawable/loading2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/loadinggif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/drawable/loadinggif.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/progressstyleshape.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
21 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ring.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
15 |
16 |
22 |
23 |
29 |
30 |
36 |
37 |
43 |
44 |
50 |
51 |
57 |
58 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_ios_alert.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
21 |
22 |
23 |
29 |
42 |
43 |
44 |
45 |
50 |
51 |
57 |
69 |
70 |
75 |
88 |
89 |
94 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_ios_alert_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
23 |
24 |
46 |
47 |
48 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_ios_alert_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
19 |
25 |
37 |
38 |
39 |
40 |
41 |
46 |
47 |
53 |
65 |
66 |
71 |
83 |
84 |
89 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_ios_center_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_btn_bottomalert.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/progressview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
20 |
21 |
28 |
29 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ProgressView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
20 |
21 |
25 |
26 |
30 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hss01248/progressview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.progressview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.0.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/ios_3_horizental.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/ios_3_horizental.png
--------------------------------------------------------------------------------
/ios_alert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/ios_alert.png
--------------------------------------------------------------------------------
/ios_alert_2btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/ios_alert_2btn.png
--------------------------------------------------------------------------------
/ios_bottom_sheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/ios_bottom_sheet.png
--------------------------------------------------------------------------------
/ios_center_sheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/ios_center_sheet.png
--------------------------------------------------------------------------------
/ios_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/ios_vertical.png
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | repositories {
22 |
23 | /* maven { url "https://jitpack.io" }*/
24 | /* flatDir {
25 | dirs 'libs'
26 | }*/
27 | }
28 |
29 |
30 |
31 |
32 | dependencies {
33 | compile fileTree(dir: 'libs', include: ['*.jar'])
34 | testCompile 'junit:junit:4.12'
35 | compile 'com.android.support:appcompat-v7:23.4.0'
36 | //compile 'com.github.glassLake:SmoothRoundProgressbar:1.0.1'
37 | /*compile(name: 'roundprogressbar-release', ext: 'aar')*/
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\development\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/lib/src/androidTest/java/com/hss01248/lib/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.lib;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lib/src/main/java/com/hss01248/lib/MyDialogListener.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.lib;
2 |
3 | import android.content.DialogInterface;
4 |
5 | /**
6 | * Created by Administrator on 2016/5/4 0004.
7 | */
8 | public abstract class MyDialogListener {
9 | public abstract void onFirst(DialogInterface dialog);
10 | public abstract void onSecond(DialogInterface dialog);
11 | public void onThird(DialogInterface dialog){}
12 |
13 | public void onCancle(){}
14 | }
15 |
--------------------------------------------------------------------------------
/lib/src/main/java/com/hss01248/lib/MyItemDialogListener.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.lib;
2 |
3 | /**
4 | * Created by Administrator on 2016/7/24.
5 | */
6 | public abstract class MyItemDialogListener {
7 |
8 | public abstract void onItemClick(String text,int position);
9 |
10 | public void onBottomBtnClick(){}
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/lib/src/main/java/com/hss01248/lib/StytledDialog.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.lib;
2 |
3 |
4 | import android.app.Activity;
5 | import android.app.Dialog;
6 | import android.content.Context;
7 | import android.content.DialogInterface;
8 | import android.graphics.Color;
9 | import android.graphics.drawable.ColorDrawable;
10 | import android.support.v7.app.AppCompatDialog;
11 | import android.text.TextUtils;
12 | import android.view.Gravity;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.view.Window;
16 | import android.view.WindowManager;
17 | import android.widget.BaseAdapter;
18 | import android.widget.Button;
19 | import android.widget.ListView;
20 | import android.widget.TextView;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * Created by Administrator on 2016/5/4 0004.
26 | */
27 | public class StytledDialog {
28 |
29 | //android.support.v7.app.
30 |
31 | /**
32 | * 指定supportv7包,达到各版本ui效果一致
33 | * @param activity
34 | * @param title
35 | * @param msg
36 | * @param firstTxt
37 | * @param secondTxt
38 | * @param thirdTxt
39 | * @param outsideCancleable
40 | * @param cancleable
41 | * @param listener
42 | * @return
43 | */
44 | public static android.support.v7.app.AlertDialog showMdAlert(Activity activity, String title, String msg,
45 | String firstTxt, String secondTxt, String thirdTxt,
46 | boolean outsideCancleable, boolean cancleable,
47 | final MyDialogListener listener){
48 | android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(activity);
49 | builder.setTitle(title)
50 | .setMessage(msg)
51 | .setCancelable(cancleable)
52 | .setPositiveButton(firstTxt, new DialogInterface.OnClickListener() {
53 | @Override
54 | public void onClick(DialogInterface dialog, int which) {
55 | listener.onFirst(dialog);
56 | dialog.dismiss();
57 | }
58 | })
59 | .setNegativeButton(secondTxt, new DialogInterface.OnClickListener() {
60 | @Override
61 | public void onClick(DialogInterface dialog, int which) {
62 | listener.onSecond(dialog);
63 | dialog.dismiss();
64 | }
65 | }).setNeutralButton(thirdTxt, new DialogInterface.OnClickListener() {
66 | @Override
67 | public void onClick(DialogInterface dialog, int which) {
68 | listener.onThird(dialog);
69 | dialog.dismiss();
70 | }
71 | });
72 | android.support.v7.app.AlertDialog dialog = builder.create();
73 | dialog.setCanceledOnTouchOutside(outsideCancleable);
74 | dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
75 | @Override
76 | public void onCancel(DialogInterface dialog) {
77 | listener.onCancle();
78 | }
79 | });
80 | dialog.show();
81 | return dialog;
82 | }
83 |
84 |
85 | public static void dismiss(Dialog dialog){
86 | if (dialog != null && dialog.isShowing()){
87 | dialog.dismiss();
88 | }
89 | }
90 |
91 | public static void dismiss(AppCompatDialog dialog){
92 | if (dialog != null && dialog.isShowing()){
93 | dialog.dismiss();
94 | }
95 | }
96 |
97 |
98 |
99 | public static Dialog showIosAlert(Context activity,String title, String msg,
100 | String firstTxt, String secondTxt,String thirdTxt,
101 | boolean outsideCancleable, boolean cancleable,
102 | final MyDialogListener listener){
103 | return showIosAlert(activity,false,title,msg,firstTxt,secondTxt,thirdTxt,outsideCancleable,cancleable,listener);
104 | }
105 |
106 |
107 | /**
108 | * todo
109 | * @param activity
110 | * @param title
111 | * @param msg
112 | * @param firstTxt
113 | * @param secondTxt
114 | * @param thirdTxt
115 | * @param outsideCancleable
116 | * @param cancleable
117 | * @param listener
118 | * @return
119 | */
120 | public static Dialog showIosAlertVertical(Context activity,String title, String msg,
121 | String firstTxt, String secondTxt,String thirdTxt,
122 | boolean outsideCancleable, boolean cancleable,
123 | final MyDialogListener listener){
124 | return showIosAlert(activity,true,title,msg,firstTxt,secondTxt,thirdTxt,outsideCancleable,cancleable,listener);
125 | }
126 |
127 | private static Dialog showIosAlert(Context context, boolean isButtonVerticle, String title, String msg,
128 | String firstTxt, String secondTxt, String thirdTxt,
129 | boolean outsideCancleable, boolean cancleable,
130 | final MyDialogListener listener){
131 |
132 | Dialog dialog = buildDialog(context,cancleable,outsideCancleable);
133 |
134 | int height = assigIosAlertView(context,dialog,isButtonVerticle,title,msg,firstTxt,secondTxt,thirdTxt,listener);
135 |
136 | setDialogStyle(context,dialog,height);
137 |
138 | dialog.show();
139 | return dialog;
140 | }
141 |
142 | public static Dialog showIosSingleChoose(Context context,List words,boolean outsideCancleable, boolean cancleable,
143 | final MyItemDialogListener listener){
144 | Dialog dialog = buildDialog(context,cancleable,outsideCancleable);
145 |
146 | int measuredHeight = assignListDialogView(context,dialog,words,listener);
147 |
148 | Window window = dialog.getWindow();
149 | window.setGravity(Gravity.CENTER);
150 |
151 | setDialogStyle(context,dialog,measuredHeight);
152 |
153 | dialog.show();
154 | return dialog;
155 |
156 | }
157 |
158 | private static int assignListDialogView(final Context context, final Dialog dialog, final List words, final MyItemDialogListener listener) {
159 | View root = View.inflate(context,R.layout.dialog_ios_center_item,null);
160 |
161 | ListView listView = (ListView) root.findViewById(R.id.lv);
162 | listView.setAdapter(new BaseAdapter() {
163 | @Override
164 | public int getCount() {
165 | return words.size();
166 | }
167 |
168 | @Override
169 | public Object getItem(int position) {
170 | return words.get(position);
171 | }
172 |
173 | @Override
174 | public long getItemId(int position) {
175 | return position;
176 | }
177 |
178 | @Override
179 | public View getView(final int position, View convertView, ViewGroup parent) {
180 | Button view = (Button) View.inflate(context,R.layout.item_btn_bottomalert,null);
181 | view.setText(words.get(position));
182 | view.setOnClickListener(new View.OnClickListener() {
183 | @Override
184 | public void onClick(View v) {
185 | listener.onItemClick(words.get(position),position);
186 | if (dialog != null && dialog.isShowing()){
187 | dialog.dismiss();
188 | }
189 | }
190 | });
191 |
192 | return view;
193 | }
194 | });
195 |
196 | dialog.setContentView(root);
197 |
198 | int height = 0;
199 |
200 | return height;
201 | }
202 |
203 | public static Dialog showBottomItemDialog(Context context,
204 | List words,String bottomTxt,
205 | boolean outsideCancleable, boolean cancleable,
206 | final MyItemDialogListener listener){
207 | Dialog dialog = buildDialog(context,cancleable,outsideCancleable);
208 |
209 | int measuredHeight = assignBottomListDialogView(context,dialog,words,bottomTxt,listener);
210 |
211 | Window window = dialog.getWindow();
212 | window.setGravity(Gravity.BOTTOM);
213 | window.setWindowAnimations(R.style.mystyle);
214 |
215 |
216 | setDialogStyle(context,dialog,measuredHeight);
217 |
218 | dialog.show();
219 | return dialog;
220 | }
221 |
222 | private static int assignBottomListDialogView(final Context context, final Dialog dialog,
223 | final List words, String bottomTxt, final MyItemDialogListener listener) {
224 | View root = View.inflate(context,R.layout.dialog_ios_alert_bottom,null);
225 | Button btnBottom = (Button) root.findViewById(R.id.btn_bottom);
226 | if (TextUtils.isEmpty(bottomTxt)){
227 | btnBottom.setVisibility(View.GONE);
228 | }else {
229 | btnBottom.setVisibility(View.VISIBLE);
230 | btnBottom.setText(bottomTxt);
231 | btnBottom.setOnClickListener(new View.OnClickListener() {
232 | @Override
233 | public void onClick(View v) {
234 | listener.onBottomBtnClick();
235 | if (dialog != null && dialog.isShowing()){
236 | dialog.dismiss();
237 | }
238 | }
239 | });
240 | }
241 |
242 | ListView listView = (ListView) root.findViewById(R.id.lv);
243 | BaseAdapter adapter = new BaseAdapter() {
244 | @Override
245 | public int getCount() {
246 | return words.size();
247 | }
248 |
249 | @Override
250 | public Object getItem(int position) {
251 | return null;
252 | }
253 |
254 | @Override
255 | public long getItemId(int position) {
256 | return 0;
257 | }
258 |
259 | @Override
260 | public View getView(final int position, View convertView, ViewGroup parent) {
261 | Button view = (Button) View.inflate(context,R.layout.item_btn_bottomalert,null);
262 | view.setText(words.get(position));
263 | view.setOnClickListener(new View.OnClickListener() {
264 | @Override
265 | public void onClick(View v) {
266 | listener.onItemClick(words.get(position),position);
267 | if (dialog != null && dialog.isShowing()){
268 | dialog.dismiss();
269 | }
270 | }
271 | });
272 |
273 | return view;
274 | }
275 | };
276 |
277 | listView.setAdapter(adapter);
278 | dialog.setContentView(root);
279 |
280 | int height = 0;
281 |
282 | return height;
283 | }
284 |
285 |
286 | /**
287 | *
288 | * @param root
289 | * @param id height为0,weight为1的scrollview包裹的view的id,如果没有,传0或负数即可
290 | * @return
291 | */
292 | private static int mesureHeight(View root, int id) {
293 | measureView(root);
294 | int height = root.getMeasuredHeight();
295 | int heightExtra = 0;
296 | if (id > 0){
297 | View view = root.findViewById(id);
298 | if (view != null){
299 | measureView(view);
300 | heightExtra = view.getMeasuredHeight();
301 | }
302 |
303 | }
304 | return height + heightExtra;
305 | }
306 |
307 |
308 | /**
309 | * 传Context的后果是不会再响应后退键事件,需要自己处理.如果传递的是activity,仍然可以处理
310 | * @param context
311 | * @param msg
312 | * @param cancleable
313 | * @param outsideTouchable
314 | * @return
315 | */
316 | public static Dialog showProgressDialog(Context context,String msg,boolean cancleable,boolean outsideTouchable) {
317 |
318 | Dialog dialog = buildDialog(context,cancleable,outsideTouchable);
319 |
320 | View root = View.inflate(context,R.layout.progressview_wrapconent,null);
321 | TextView tvMsg = (TextView) root.findViewById(R.id.message);
322 | tvMsg.setText(msg);
323 | dialog.setContentView(root);
324 |
325 |
326 |
327 | setDialogStyle(context,dialog,0);
328 |
329 | dialog.show();
330 | //根据实际view高度调整
331 | return dialog;
332 | }
333 |
334 | private static Dialog buildDialog(Context context, boolean cancleable, boolean outsideTouchable) {
335 | Dialog dialog = new Dialog(context);
336 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
337 | dialog.setCancelable(cancleable);
338 | dialog.setCanceledOnTouchOutside(outsideTouchable);
339 | return dialog;
340 | }
341 |
342 |
343 | private static void setDialogStyle(Context activity, Dialog dialog,int measuredHeight ) {
344 | Window window = dialog.getWindow();
345 |
346 | //window.setWindowAnimations(R.style.dialog_center);
347 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//todo keycode to show round corner
348 |
349 |
350 | WindowManager.LayoutParams wl = window.getAttributes();
351 | /* wl.x = 0;
352 | wl.y = getWindowManager().getDefaultDisplay().getHeight();*/
353 | // 以下这两句是为了保证按钮可以水平满屏
354 | int width = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
355 |
356 | int height = (int) (((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
357 |
358 | // wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
359 | wl.width = (int) (width * 0.94); // todo keycode to keep gap
360 | wl.height = ViewGroup.LayoutParams.WRAP_CONTENT; //TODO 一般情况下为wrapcontent,最大值为height*0.9
361 | /* ViewUtils.measureView(contentView);
362 | int meHeight = contentView.getMeasuredHeight();//height 为0,weight为1时,控件计算所得height就是0
363 | View textview = contentView.findViewById(R.id.tv_msg);
364 | ViewUtils.measureView(textview);
365 | int textHeight = textview.getMeasuredHeight();*/
366 | if (measuredHeight > height){
367 | wl.height = height;
368 | }
369 |
370 |
371 |
372 | //wl.horizontalMargin= 0.2f;
373 | // 设置显示位置
374 | // wl.gravity = Gravity.CENTER_HORIZONTAL;
375 |
376 | if (!(activity instanceof Activity)){
377 | wl.type = WindowManager.LayoutParams.TYPE_TOAST;//todo keycode to improve window level
378 | }
379 |
380 | dialog.onWindowAttributesChanged(wl);
381 | }
382 |
383 | private static int assigIosAlertView(Context activity, final Dialog dialog, boolean isButtonVerticle,
384 | String title, String msg, String firstTxt, String secondTxt, String thirdTxt,
385 | final MyDialogListener listener) {
386 | View root = View.inflate(activity,isButtonVerticle ? R.layout.dialog_ios_alert_vertical : R.layout.dialog_ios_alert,null);
387 | TextView tvTitle = (TextView) root.findViewById(R.id.tv_title);
388 | if (TextUtils.isEmpty(title)){
389 | tvTitle.setVisibility(View.GONE);
390 | }else {
391 | tvTitle.setVisibility(View.VISIBLE);
392 | tvTitle.setText(title);
393 | }
394 |
395 | TextView tvMsg = (TextView) root.findViewById(R.id.tv_msg);
396 | tvMsg.setText(msg);
397 |
398 | Button button1 = (Button) root.findViewById(R.id.btn_1);
399 | Button button2 = (Button) root.findViewById(R.id.btn_2);
400 | Button button3 = (Button) root.findViewById(R.id.btn_3);
401 |
402 | if (TextUtils.isEmpty(firstTxt)){
403 | root.findViewById(R.id.ll_container).setVisibility(View.GONE);
404 | root.findViewById(R.id.line).setVisibility(View.GONE);
405 | }else {
406 |
407 | button1.setVisibility(View.VISIBLE);
408 | button1.setText(firstTxt);
409 | button1.setOnClickListener(new View.OnClickListener() {
410 | @Override
411 | public void onClick(View v) {
412 | listener.onFirst(dialog);
413 | if (dialog != null && dialog.isShowing()){
414 | dialog.dismiss();
415 | }
416 | }
417 | });
418 |
419 | //btn2
420 | if (TextUtils.isEmpty(secondTxt)){
421 | root.findViewById(R.id.line_btn2).setVisibility(View.GONE);
422 | button2.setVisibility(View.GONE);
423 | }else {
424 | root.findViewById(R.id.line_btn2).setVisibility(View.VISIBLE);
425 | button2.setVisibility(View.VISIBLE);
426 |
427 | button2.setText(secondTxt);
428 | button2.setOnClickListener(new View.OnClickListener() {
429 | @Override
430 | public void onClick(View v) {
431 | listener.onSecond(dialog);
432 | if (dialog != null && dialog.isShowing()){
433 | dialog.dismiss();
434 | }
435 | }
436 | });
437 |
438 | //btn 3
439 | if (TextUtils.isEmpty(thirdTxt)){
440 | root.findViewById(R.id.line_btn3).setVisibility(View.GONE);
441 | button3.setVisibility(View.GONE);
442 | }else {
443 | root.findViewById(R.id.line_btn3).setVisibility(View.VISIBLE);
444 | button3.setVisibility(View.VISIBLE);
445 |
446 | button3.setText(thirdTxt);
447 | button3.setOnClickListener(new View.OnClickListener() {
448 | @Override
449 | public void onClick(View v) {
450 | listener.onThird(dialog);
451 | if (dialog != null && dialog.isShowing()){
452 | dialog.dismiss();
453 | }
454 | }
455 | });
456 |
457 |
458 | }
459 |
460 | }
461 |
462 | }
463 |
464 | dialog.setContentView(root);
465 |
466 | int height = mesureHeight(root,R.id.tv_msg);
467 |
468 | return height;
469 |
470 |
471 |
472 |
473 |
474 |
475 | }
476 |
477 |
478 | private static void measureView(View child) {
479 | ViewGroup.LayoutParams p = child.getLayoutParams();
480 | if (p == null) {
481 | p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
482 | ,
483 | ViewGroup.LayoutParams.WRAP_CONTENT);
484 | }
485 | int lpHeight = p.height;
486 | int lpWidth = p.width;
487 | int childHeightSpec;
488 | int childWidthSpec;
489 | if (lpHeight > 0) { //如果Height是一个定值,那么我们测量的时候就使用这个定值
490 | childHeightSpec = View.MeasureSpec.makeMeasureSpec(lpHeight,
491 | View.MeasureSpec.EXACTLY);
492 | } else { // 否则,我们将mode设置为不指定,size设置为0
493 | childHeightSpec = View.MeasureSpec.makeMeasureSpec(0,
494 | View.MeasureSpec.UNSPECIFIED);
495 | }
496 | if (lpWidth > 0) {
497 | childWidthSpec= View.MeasureSpec.makeMeasureSpec(lpHeight,
498 | View.MeasureSpec.EXACTLY);
499 | } else {
500 | childWidthSpec= View.MeasureSpec.makeMeasureSpec(0,
501 | View.MeasureSpec.UNSPECIFIED);
502 | }
503 | child.measure(childWidthSpec, childHeightSpec);
504 | }
505 |
506 | }
507 |
--------------------------------------------------------------------------------
/lib/src/main/res/anim/dialog_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/lib/src/main/res/anim/dialog_enter_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/lib/src/main/res/anim/dialog_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/lib/src/main/res/anim/dialog_exit_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/bg_ios_roundcorner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/bg_ios_roundcorner_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/bg_ios_roundcorner_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/bg_ios_roundcorner_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/progressstyleshape.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
21 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/dialog_ios_alert.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
21 |
22 |
23 |
29 |
42 |
43 |
44 |
45 |
50 |
51 |
57 |
69 |
70 |
75 |
88 |
89 |
94 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/dialog_ios_alert_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
23 |
24 |
46 |
47 |
48 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/dialog_ios_alert_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
19 |
25 |
37 |
38 |
39 |
40 |
41 |
46 |
47 |
53 |
65 |
66 |
71 |
83 |
84 |
89 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/dialog_ios_center_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
22 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/item_btn_bottomalert.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/progressview_wrapconent.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
21 |
22 |
31 |
32 |
39 |
40 |
41 |
42 |
50 |
51 |
--------------------------------------------------------------------------------
/lib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | lib
3 |
4 |
--------------------------------------------------------------------------------
/lib/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
16 |
20 |
21 |
25 |
28 |
29 |
--------------------------------------------------------------------------------
/lib/src/test/java/com/hss01248/lib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hss01248.lib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/material.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/material.png
--------------------------------------------------------------------------------
/normaldialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassLake/DialogUtils/f7e70b9fc60d70576b331aef95932ff5071c2a5f/normaldialog.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lib'
2 |
--------------------------------------------------------------------------------