├── .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 | 19 | 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 | 86 | 87 | 88 | 89 | 90 | 1.7 91 | 92 | 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 | 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 | ![normaldialog](normaldialog.png) 24 | 25 | 26 | 27 | 28 | 29 | ![material](material.png) 30 | 31 | 32 | 33 | ![ios_alert](ios_alert.png) 34 | 35 | 36 | 37 | 38 | 39 | ![ios_vertical](ios_vertical.png) 40 | 41 | 42 | 43 | 44 | 45 | ![ios_alert_2btn](ios_alert_2btn.png) 46 | 47 | 48 | 49 | 50 | 51 | ![ios_bottom_sheet](ios_bottom_sheet.png) 52 | 53 | 54 | 55 | ![ios_center_sheet](ios_center_sheet.png) 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 |