├── .gitignore ├── LICENSE ├── README.md ├── Screenshots ├── android-dialog-builder-sample.gif ├── android-dialog-builder-sample_1.gif ├── android-dialog-builder-sample_2.gif ├── android-dialog-builder-sample_3.gif └── simple.avi ├── _config.yml ├── android-dialog-builder.iml ├── build.gradle ├── gradle-mvn-push.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── library.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── net │ │ └── soulwolf │ │ └── widget │ │ └── dialogbuilder │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── net │ │ └── soulwolf │ │ └── widget │ │ └── dialogbuilder │ │ ├── DialogAdapter.java │ │ ├── DialogBuilder.java │ │ ├── Gravity.java │ │ ├── IDialogBuilder.java │ │ ├── IMasterDialog.java │ │ ├── MasterDialog.java │ │ ├── OnCancelListener.java │ │ ├── OnDismissListener.java │ │ ├── OnItemClickListener.java │ │ ├── OnKeyListener.java │ │ ├── OnShowListener.java │ │ ├── SimpleAnimationListener.java │ │ ├── Utils.java │ │ ├── adapter │ │ ├── GridDialogAdapter.java │ │ ├── TextDialogAdapter.java │ │ └── ViewHolder.java │ │ ├── dialog │ │ ├── AbsListMasterDialog.java │ │ ├── AlertMasterDialog.java │ │ ├── GridMasterDialog.java │ │ ├── IAbsListControl.java │ │ ├── ICancelButton.java │ │ └── ListMasterDialog.java │ │ └── model │ │ └── GridModel.java │ └── res │ ├── anim │ ├── da_fade_in_center.xml │ ├── da_fade_out_center.xml │ ├── da_slide_in_bottom.xml │ ├── da_slide_in_left.xml │ ├── da_slide_in_right.xml │ ├── da_slide_in_top.xml │ ├── da_slide_out_bottom.xml │ ├── da_slide_out_left.xml │ ├── da_slide_out_right.xml │ └── da_slide_out_top.xml │ ├── drawable │ ├── dd_cancel_press_round_shape.xml │ ├── dd_item_press_round_shape.xml │ ├── dd_item_round_shape.xml │ ├── dd_selector_cancel_click.xml │ ├── dd_selector_item_click.xml │ ├── dd_selector_text.xml │ └── dd_white_round_shape.xml │ ├── layout │ ├── dl_dialog_alert.xml │ ├── dl_dialog_cancel.xml │ ├── dl_dialog_container.xml │ ├── dl_dialog_grid.xml │ ├── dl_dialog_list.xml │ ├── dl_simple_grid_item.xml │ └── dl_simple_text_item.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── integers.xml │ └── strings.xml ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── sample.iml └── src │ ├── androidTest │ └── java │ │ └── net │ │ └── soulwolf │ │ └── widget │ │ └── dialogbuilder │ │ └── sample │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── net │ │ └── soulwolf │ │ └── widget │ │ └── dialogbuilder │ │ └── sample │ │ └── MainActivity.java │ └── res │ ├── drawable │ ├── item_press_round_shape.xml │ ├── item_round_shape.xml │ └── selector_item_click.xml │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── share_layout_friends_icon.png │ ├── share_layout_qq_icon.png │ ├── share_layout_qzone_icon.png │ └── share_layout_wx_icon.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 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 | .idea 29 | -------------------------------------------------------------------------------- /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 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # warning 2 | The library was suspended on April 1, 2017 3 | 4 | 5 | 6 | # android-dialog-builder 7 | This is an android in the Dialog library, not based on a systematic way to achieve Dialog using Activity root view of the Add Dialog, it has strong scalability and customizability! 8 | 9 | For more information please see the website 10 | 11 | ## Screenshots 12 | 13 | 14 | 15 | ## android-dialog-builder with Java code 16 | ```java 17 | public void onClick(View v){ 18 | if(v.getId() == R.id.left){ 19 | DialogBuilder builder = new DialogBuilder(this) 20 | .setAnimation(R.anim.da_slide_in_left, R.anim.da_slide_out_left) 21 | //.setIgnoreStatusBar(false) 22 | .setLayoutParams(700, ViewGroup.LayoutParams.MATCH_PARENT) 23 | .setGravity(Gravity.LEFT) 24 | .setOnItemClickListener(this) 25 | .setBackgroundResource(R.color.toolbar_background); 26 | ListMasterDialog dialog = new ListMasterDialog(builder); 27 | dialog.setAdapter(new TextDialogAdapter(this,getSimpleStringData(8))); 28 | dialog.show(); 29 | }else if(v.getId() == R.id.top){ 30 | DialogBuilder builder = new DialogBuilder(this) 31 | .setAnimation(R.anim.da_slide_in_top, R.anim.da_slide_out_top) 32 | //.setIgnoreStatusBar(false) 33 | .setGravity(Gravity.TOP) 34 | .setOnItemClickListener(this) 35 | .setBackgroundResource(R.color.toolbar_background); 36 | ListMasterDialog dialog = new ListMasterDialog(builder); 37 | dialog.setCancelButton(false); 38 | dialog.setAdapter(new TextDialogAdapter(this,getSimpleStringData(3))); 39 | dialog.show(); 40 | }else if(v.getId() == R.id.right){ 41 | DialogBuilder builder = new DialogBuilder(this) 42 | .setAnimation(R.anim.da_slide_in_right, R.anim.da_slide_out_right) 43 | //.setIgnoreStatusBar(false) 44 | .setLayoutParams(700, ViewGroup.LayoutParams.MATCH_PARENT) 45 | .setGravity(Gravity.RIGHT) 46 | .setOnItemClickListener(this) 47 | .setBackgroundResource(R.color.toolbar_background); 48 | ListMasterDialog dialog = new ListMasterDialog(builder); 49 | dialog.setAdapter(new TextDialogAdapter(this,getSimpleStringData(8))); 50 | dialog.show(); 51 | }else if(v.getId() == R.id.bottom){ 52 | DialogBuilder builder = new DialogBuilder(this) 53 | .setAnimation(R.anim.da_slide_in_bottom, R.anim.da_slide_out_bottom) 54 | .setOnItemClickListener(this) 55 | //.setIgnoreStatusBar(false) 56 | .setGravity(Gravity.BOTTOM); 57 | ListMasterDialog dialog = new ListMasterDialog(builder); 58 | dialog.setAdapter(new TextDialogAdapter(this,getSimpleStringData(4))); 59 | dialog.show(); 60 | }else if(v.getId() == R.id.center){ 61 | DialogBuilder builder = new DialogBuilder(this) 62 | .setOnItemClickListener(this) 63 | .setAnimation(R.anim.da_fade_in_center, R.anim.da_fade_out_center) 64 | //.setIgnoreStatusBar(false) 65 | .setGravity(Gravity.CENTER); 66 | AlertMasterDialog dialog = new AlertMasterDialog(builder); 67 | dialog.setTitle("提示"); 68 | dialog.setContent("校导网是一家专注于校园精英人才孵化的移动互联网公司,\n" + 69 | "以帮助大学生成才为使命,打造了一个基于精品活动的校园交友及职业素养提升平台,\n" + 70 | "通过各种比赛、拓展、培训、实习、演讲、沙龙等活动来帮助大学生走出迷茫,\n" + 71 | "锻炼实践能力,拓展交际圈子,提升职业素养,实现成功就业与创业。"); 72 | dialog.show(); 73 | }else if(v.getId() == R.id.center1){ 74 | DialogBuilder builder = new DialogBuilder(this) 75 | .setAnimation(R.anim.da_fade_in_center, R.anim.da_fade_out_center) 76 | .setOnItemClickListener(this) 77 | //.setIgnoreStatusBar(false) 78 | .setGravity(Gravity.CENTER); 79 | AlertMasterDialog dialog = new AlertMasterDialog(builder); 80 | dialog.setTitle("提示"); 81 | dialog.setButton2("取消"); 82 | dialog.setContent("校导网是一家专注于校园精英人才孵化的移动互联网公司,\n" + 83 | "以帮助大学生成才为使命,打造了一个基于精品活动的校园交友及职业素养提升平台,\n" + 84 | "通过各种比赛、拓展、培训、实习、演讲、沙龙等活动来帮助大学生走出迷茫,\n" + 85 | "锻炼实践能力,拓展交际圈子,提升职业素养,实现成功就业与创业。"); 86 | dialog.show(); 87 | }else if(v.getId() == R.id.grid){ 88 | DialogBuilder builder = new DialogBuilder(this) 89 | .setAnimation(R.anim.da_slide_in_bottom, R.anim.da_slide_out_bottom) 90 | .setOnItemClickListener(this) 91 | //.setIgnoreStatusBar(false) 92 | .setGravity(Gravity.BOTTOM); 93 | GridMasterDialog dialog = new GridMasterDialog(builder); 94 | dialog.setAdapter(new GridDialogAdapter(this, getSimpleGridModelData())); 95 | dialog.setNumColumns(4); 96 | dialog.show(); 97 | } 98 | } 99 | 100 | private GridModel[] getSimpleGridModelData(){ 101 | return new GridModel[]{ 102 | new GridModel(R.mipmap.share_layout_qq_icon,"QQ"), 103 | new GridModel(R.mipmap.share_layout_wx_icon,"微信"), 104 | new GridModel(R.mipmap.share_layout_friends_icon,"朋友圈"), 105 | new GridModel(R.mipmap.share_layout_qq_icon,"QQ"), 106 | new GridModel(R.mipmap.share_layout_wx_icon,"微信"), 107 | new GridModel(R.mipmap.share_layout_friends_icon,"朋友圈") 108 | }; 109 | } 110 | 111 | private String[] getSimpleStringData(int size){ 112 | String[] array = new String[size]; 113 | for (int i= 0;i< size ;i++){ 114 | array[i] = "SIMPLE-DATA" + i; 115 | } 116 | return array; 117 | } 118 | 119 | @Override 120 | public void onItemClick(MasterDialog dialog, View view, int position) { 121 | Toast.makeText(this,"Item click:" + position,Toast.LENGTH_SHORT).show(); 122 | } 123 | ``` 124 | 125 | ## Maven 126 | 127 | net.soulwolf.widget 128 | https://dl.bintray.com/soulwolf/maven 129 | dialogBuilder 130 | 1.0.0 131 | 132 | ## Gradle 133 | allprojects { 134 | repositories { 135 | jcenter() 136 | } 137 | } 138 | 139 | compile 'net.soulwolf.widget:dialogBuilder:1.0.0' 140 | 141 | ## Developed by 142 | Ching Soulwolf - Ching.Soulwolf@gmail.com 143 | 144 | 145 | ## License 146 | Copyright 2015 Soulwolf Ching 147 | Copyright 2015 The Android Open Source Project for android-dialog-builder 148 | 149 | Licensed under the Apache License, Version 2.0 (the "License"); 150 | you may not use this file except in compliance with the License. 151 | You may obtain a copy of the License at 152 | 153 | http://www.apache.org/licenses/LICENSE-2.0 154 | 155 | Unless required by applicable law or agreed to in writing, software 156 | distributed under the License is distributed on an "AS IS" BASIS, 157 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 158 | See the License for the specific language governing permissions and 159 | limitations under the License. 160 | 161 | -------------------------------------------------------------------------------- /Screenshots/android-dialog-builder-sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapleqin/android-dialog-builder/a3b8c2dacbb1f88223b40a26542e11e2b56735e2/Screenshots/android-dialog-builder-sample.gif -------------------------------------------------------------------------------- /Screenshots/android-dialog-builder-sample_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapleqin/android-dialog-builder/a3b8c2dacbb1f88223b40a26542e11e2b56735e2/Screenshots/android-dialog-builder-sample_1.gif -------------------------------------------------------------------------------- /Screenshots/android-dialog-builder-sample_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapleqin/android-dialog-builder/a3b8c2dacbb1f88223b40a26542e11e2b56735e2/Screenshots/android-dialog-builder-sample_2.gif -------------------------------------------------------------------------------- /Screenshots/android-dialog-builder-sample_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapleqin/android-dialog-builder/a3b8c2dacbb1f88223b40a26542e11e2b56735e2/Screenshots/android-dialog-builder-sample_3.gif -------------------------------------------------------------------------------- /Screenshots/simple.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapleqin/android-dialog-builder/a3b8c2dacbb1f88223b40a26542e11e2b56735e2/Screenshots/simple.avi -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /android-dialog-builder.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /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:1.2.3' 9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' 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 | -------------------------------------------------------------------------------- /gradle-mvn-push.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  * Copyright 2015 Soulwolf Ching
  4 |  * Copyright 2015 The Android Open Source Project for PictureLib
  5 |  *
  6 |  * Licensed under the Apache License, Version 2.0 (the "License");
  7 |  * you may not use this file except in compliance with the License.
  8 |  * You may obtain a copy of the License at
  9 |  *
 10 |  *    http://www.apache.org/licenses/LICENSE-2.0
 11 |  *
 12 |  * Unless required by applicable law or agreed to in writing, software
 13 |  * distributed under the License is distributed on an "AS IS" BASIS,
 14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15 |  * See the License for the specific language governing permissions and
 16 |  * limitations under the License.
 17 |  * 
18 | */ 19 | 20 | group = PROJ_GROUP 21 | version = PROJ_VERSION 22 | project.archivesBaseName = PROJ_ARTIFACTID 23 | 24 | apply plugin: 'com.jfrog.bintray' 25 | apply plugin: 'maven-publish' 26 | 27 | task sourcesJar(type: Jar) { 28 | from android.sourceSets.main.java.srcDirs 29 | classifier = 'sources' 30 | } 31 | 32 | task javadoc(type: Javadoc) { 33 | source = android.sourceSets.main.java.srcDirs 34 | classpath += configurations.compile 35 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 36 | } 37 | 38 | task javadocJar(type: Jar, dependsOn: javadoc) { 39 | classifier = 'javadoc' 40 | from javadoc.destinationDir 41 | } 42 | 43 | javadoc { 44 | options{ 45 | encoding "UTF-8" 46 | charSet 'UTF-8' 47 | author true 48 | version true 49 | links "http://docs.oracle.com/javase/7/docs/api" 50 | title PROJ_ARTIFACTID 51 | } 52 | } 53 | 54 | artifacts { 55 | archives javadocJar 56 | archives sourcesJar 57 | } 58 | 59 | def pomConfig = { 60 | licenses { 61 | license { 62 | name "The Apache Software License, Version 2.0" 63 | url "http://www.apache.org/licenses/LICENSE-2.0.txt" 64 | distribution "repo" 65 | } 66 | } 67 | developers { 68 | developer { 69 | id DEVELOPER_ID 70 | name DEVELOPER_NAME 71 | email DEVELOPER_EMAIL 72 | } 73 | } 74 | } 75 | 76 | publishing { 77 | publications { 78 | mavenJava(MavenPublication) { 79 | artifactId PROJ_ARTIFACTID 80 | 81 | pom{ 82 | packaging 'aar' 83 | } 84 | pom.withXml { 85 | def root = asNode() 86 | root.appendNode('description', PROJ_DESCRIPTION) 87 | root.children().last() + pomConfig 88 | } 89 | } 90 | } 91 | } 92 | 93 | bintray { 94 | Properties properties = new Properties() 95 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 96 | user = properties.getProperty('BINTRAY_USER') 97 | key = properties.getProperty('BINTRAY_KEY') 98 | // user = BINTRAY_USER 99 | // key = BINTRAY_KEY 100 | 101 | configurations = ['archives'] 102 | publications = ['mavenJava'] 103 | publish = true 104 | 105 | pkg { 106 | repo = 'maven' 107 | name = PROJ_NAME 108 | desc = PROJ_DESCRIPTION 109 | websiteUrl = PROJ_WEBSITEURL 110 | issueTrackerUrl = PROJ_ISSUETRACKERURL 111 | vcsUrl = PROJ_VCSURL 112 | licenses = ['Apache-2.0'] 113 | publicDownloadNumbers = true 114 | } 115 | } -------------------------------------------------------------------------------- /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 19 | PROJ_GROUP=net.soulwolf.widget 20 | PROJ_VERSION=1.0.2 21 | PROJ_NAME=dialogBuilder 22 | PROJ_WEBSITEURL=https://github.com/devsoulwolf/android-dialog-builder 23 | PROJ_ISSUETRACKERURL=https://github.com/devsoulwolf/android-dialog-builder 24 | PROJ_VCSURL=https://github.com/devsoulwolf/android-dialog-builder.git 25 | PROJ_DESCRIPTION= This is an android in the Dialog library, not based on a systematic way to achieve Dialog using Activity root view of the Add Dialog, it has strong scalability and customizability! 26 | PROJ_ARTIFACTID=dialogBuilder 27 | 28 | DEVELOPER_ID=Soulwolf 29 | DEVELOPER_NAME=Soulwolf 30 | DEVELOPER_EMAIL=ToakerQin@gmail.com 31 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapleqin/android-dialog-builder/a3b8c2dacbb1f88223b40a26542e11e2b56735e2/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 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.2.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 9 9 | targetSdkVersion 21 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 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:22.2.0' 24 | } 25 | apply from: '../gradle-mvn-push.gradle' 26 | -------------------------------------------------------------------------------- /library/library.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | 60 | 61 | 62 | 63 | 64 | 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 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /library/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:\android-studio\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 | -------------------------------------------------------------------------------- /library/src/androidTest/java/net/soulwolf/widget/dialogbuilder/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.soulwolf.widget.dialogbuilder; 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 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/DialogAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
  4 |  * Licensed under the Apache License, Version 2.0 (the "License");
  5 |  * you may not use this file except in compliance with the License.
  6 |  * You may obtain a copy of the License at
  7 |  *
  8 |  *    http://www.apache.org/licenses/LICENSE-2.0
  9 |  *
 10 |  * Unless required by applicable law or agreed to in writing, software
 11 |  * distributed under the License is distributed on an "AS IS" BASIS,
 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 |  * See the License for the specific language governing permissions and
 14 |  * limitations under the License.
 15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder; 18 | 19 | import android.content.Context; 20 | import android.support.annotation.LayoutRes; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.BaseAdapter; 24 | 25 | import net.soulwolf.widget.dialogbuilder.adapter.ViewHolder; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | /** 31 | * author : Soulwolf Create by 2015/8/5 14:24 32 | * email : ToakerQin@gmail.com. 33 | */ 34 | public abstract class DialogAdapter extends BaseAdapter { 35 | 36 | protected Context mContext; 37 | 38 | protected List mData; 39 | 40 | protected final int mItemLayoutId; 41 | 42 | 43 | public DialogAdapter(Context context,@LayoutRes int layoutResource){ 44 | this(context, new ArrayList(), layoutResource); 45 | } 46 | 47 | public DialogAdapter(Context context,ITEM [] data,@LayoutRes int layoutResource){ 48 | this(context, Utils.asList(data), layoutResource); 49 | } 50 | 51 | public DialogAdapter(Context context,List data,@LayoutRes int layoutResource){ 52 | this.mContext = context; 53 | this.mData = Utils.checkList(data); 54 | this.mItemLayoutId = layoutResource; 55 | } 56 | 57 | public List getData(){ 58 | return mData; 59 | } 60 | 61 | @Override 62 | public boolean isEnabled(int position) { 63 | return position < mData.size(); 64 | } 65 | 66 | public void add(ITEM elem) { 67 | mData.add(elem); 68 | notifyDataSetChanged(); 69 | } 70 | 71 | public void addAll(List elem) { 72 | mData.addAll(elem); 73 | notifyDataSetChanged(); 74 | } 75 | 76 | public void set(ITEM oldElem, ITEM newElem) { 77 | set(mData.indexOf(oldElem), newElem); 78 | } 79 | 80 | public void set(int index, ITEM elem) { 81 | mData.set(index, elem); 82 | notifyDataSetChanged(); 83 | } 84 | 85 | public void remove(ITEM elem) { 86 | mData.remove(elem); 87 | notifyDataSetChanged(); 88 | } 89 | 90 | public void remove(int index) { 91 | mData.remove(index); 92 | notifyDataSetChanged(); 93 | } 94 | 95 | public void replaceAll(List elem) { 96 | mData.clear(); 97 | mData.addAll(elem); 98 | notifyDataSetChanged(); 99 | } 100 | 101 | public boolean contains(ITEM elem) { 102 | return mData.contains(elem); 103 | } 104 | 105 | /** Clear data list */ 106 | public void clear() { 107 | mData.clear(); 108 | notifyDataSetChanged(); 109 | } 110 | 111 | 112 | @Override 113 | public int getCount() { 114 | return mData.size(); 115 | } 116 | 117 | @Override 118 | public ITEM getItem(int position) { 119 | if(isEnabled(position)){ 120 | return mData.get(position); 121 | } 122 | return null; 123 | } 124 | 125 | @Override 126 | public long getItemId(int position) { 127 | return position; 128 | } 129 | 130 | @Override 131 | public View getView(int position, View convertView, ViewGroup parent) { 132 | final ViewHolder baseViewHolder = getViewHolder(position, convertView, 133 | parent); 134 | ITEM item = getItem(position); 135 | if(item != null){ 136 | convert(baseViewHolder, item,position); 137 | } 138 | return baseViewHolder.getConvertView(); 139 | 140 | } 141 | 142 | public abstract void convert(ViewHolder helper, ITEM item,int position); 143 | 144 | private ViewHolder getViewHolder(int position, View convertView, 145 | ViewGroup parent) { 146 | return ViewHolder.create(mContext, convertView, parent, mItemLayoutId, 147 | position); 148 | } 149 | 150 | public Context getContext(){ 151 | return mContext; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/DialogBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  * Copyright 2015 Soulwolf Ching
  4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
  5 |  *
  6 |  * Licensed under the Apache License, Version 2.0 (the "License");
  7 |  * you may not use this file except in compliance with the License.
  8 |  * You may obtain a copy of the License at
  9 |  *
 10 |  *    http://www.apache.org/licenses/LICENSE-2.0
 11 |  *
 12 |  * Unless required by applicable law or agreed to in writing, software
 13 |  * distributed under the License is distributed on an "AS IS" BASIS,
 14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15 |  * See the License for the specific language governing permissions and
 16 |  * limitations under the License.
 17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | import android.app.Activity; 22 | import android.content.Context; 23 | import android.graphics.Color; 24 | import android.graphics.drawable.ColorDrawable; 25 | import android.graphics.drawable.Drawable; 26 | import android.support.annotation.AnimRes; 27 | import android.view.animation.Animation; 28 | import android.view.animation.AnimationUtils; 29 | import android.widget.FrameLayout; 30 | 31 | /** 32 | * author: Soulwolf Created on 2015/8/4 22:31. 33 | * email : Ching.Soulwolf@gmail.com 34 | */ 35 | public class DialogBuilder implements IDialogBuilder{ 36 | 37 | private Activity mContext; 38 | 39 | private OnCancelListener mOnCancelListener; 40 | 41 | private OnItemClickListener mOnItemClickListener; 42 | 43 | private OnDismissListener mOnDismissListener; 44 | 45 | private OnKeyListener mOnKeyListener; 46 | 47 | private OnShowListener mOnShowListener; 48 | 49 | private Animation mDialogInAnimation; 50 | 51 | private Animation mDialogOutAnimation; 52 | 53 | private boolean mCancelable = true; 54 | 55 | private int mGravity = Gravity.CENTER; 56 | 57 | private FrameLayout.LayoutParams mLayoutParams; 58 | 59 | private Drawable mBackground; 60 | 61 | private boolean mCustomSize; 62 | 63 | private boolean mIgnoreStatusBar = true; 64 | 65 | public DialogBuilder(Context context){ 66 | if(context == null){ 67 | throw new NullPointerException("context == null"); 68 | } 69 | if(!(context instanceof Activity)){ 70 | throw new IllegalArgumentException("android.view.WindowManager$BadTokenException:Unable to add window"); 71 | } 72 | this.mContext = (Activity) context; 73 | } 74 | 75 | 76 | public Activity getContext(){ 77 | return mContext; 78 | } 79 | 80 | @Override 81 | public DialogBuilder setOnCancelListener(OnCancelListener listener) { 82 | this.mOnCancelListener = listener; 83 | return this; 84 | } 85 | 86 | @Override 87 | public DialogBuilder setOnItemClickListener(OnItemClickListener listener) { 88 | this.mOnItemClickListener = listener; 89 | return this; 90 | } 91 | 92 | @Override 93 | public DialogBuilder setOnDismissListener(OnDismissListener listener) { 94 | this.mOnDismissListener = listener; 95 | return this; 96 | } 97 | 98 | @Override 99 | public DialogBuilder setOnShowListener(OnShowListener listener) { 100 | this.mOnShowListener = listener; 101 | return this; 102 | } 103 | 104 | @Override 105 | public DialogBuilder setOnKeyListener(OnKeyListener listener) { 106 | this.mOnKeyListener = listener; 107 | return this; 108 | } 109 | 110 | @Override 111 | public DialogBuilder setAnimation(@AnimRes int in, @AnimRes int out) { 112 | this.mDialogInAnimation = AnimationUtils.loadAnimation(mContext,in); 113 | this.mDialogOutAnimation = AnimationUtils.loadAnimation(mContext,out); 114 | return this; 115 | } 116 | 117 | @Override 118 | public DialogBuilder setAnimation(Animation in, Animation out) { 119 | this.mDialogInAnimation = in; 120 | this.mDialogOutAnimation = out; 121 | return this; 122 | } 123 | 124 | @Override 125 | public DialogBuilder setCancelable(boolean isCancelable) { 126 | this.mCancelable = isCancelable; 127 | return this; 128 | } 129 | 130 | @Override 131 | public DialogBuilder setLayoutParams(int width, int height) { 132 | mCustomSize = true; 133 | if(mLayoutParams == null){ 134 | mLayoutParams = new FrameLayout.LayoutParams(width,height); 135 | mLayoutParams.gravity = Gravity.parserGravity(mGravity); 136 | mLayoutParams.topMargin = getStatusBarHeight(); 137 | }else { 138 | mLayoutParams.width = width; 139 | mLayoutParams.height = height; 140 | } 141 | return this; 142 | } 143 | 144 | @Override 145 | public DialogBuilder setGravity(@Gravity.GravityMode int gravity) { 146 | this.mGravity = gravity; 147 | initializeLayoutParams(); 148 | return this; 149 | } 150 | 151 | private void initializeLayoutParams() { 152 | int width,height; 153 | switch (mGravity){ 154 | case Gravity.LEFT: 155 | case Gravity.RIGHT: 156 | width = FrameLayout.LayoutParams.WRAP_CONTENT; 157 | height = FrameLayout.LayoutParams.MATCH_PARENT; 158 | break; 159 | 160 | case Gravity.TOP: 161 | case Gravity.BOTTOM: 162 | width = FrameLayout.LayoutParams.MATCH_PARENT; 163 | height = FrameLayout.LayoutParams.WRAP_CONTENT; 164 | break; 165 | 166 | default: 167 | width = FrameLayout.LayoutParams.WRAP_CONTENT; 168 | height = FrameLayout.LayoutParams.WRAP_CONTENT; 169 | break; 170 | } 171 | if(mLayoutParams == null){ 172 | mLayoutParams = new FrameLayout.LayoutParams(width,height); 173 | mLayoutParams.topMargin = getStatusBarHeight(); 174 | }else { 175 | if(!mCustomSize){ 176 | mLayoutParams.width = width; 177 | mLayoutParams.height = height; 178 | } 179 | } 180 | mLayoutParams.gravity = Gravity.parserGravity(mGravity); 181 | } 182 | 183 | 184 | @Override 185 | public DialogBuilder setMargin(int l, int t, int r, int b) { 186 | if(mLayoutParams == null){ 187 | mLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT 188 | ,FrameLayout.LayoutParams.WRAP_CONTENT); 189 | mLayoutParams.gravity = Gravity.parserGravity(mGravity); 190 | } 191 | mLayoutParams.leftMargin = l; 192 | mLayoutParams.topMargin = t; 193 | mLayoutParams.rightMargin = r + getStatusBarHeight(); 194 | mLayoutParams.bottomMargin = b ; 195 | return this; 196 | } 197 | 198 | private int getStatusBarHeight(){ 199 | if(mIgnoreStatusBar){ 200 | return Utils.getStatusBarHeight(getContext()); 201 | } 202 | return 0; 203 | } 204 | 205 | @Override 206 | public DialogBuilder setBackground(int color) { 207 | this.mBackground = new ColorDrawable(color); 208 | return this; 209 | } 210 | 211 | @Override 212 | public DialogBuilder setBackgroundResource(int resource) { 213 | this.mBackground = getContext().getResources().getDrawable(resource); 214 | return this; 215 | } 216 | 217 | @Override 218 | public DialogBuilder setBackground(Drawable drawable) { 219 | this.mBackground = drawable; 220 | return this; 221 | } 222 | 223 | @Override 224 | public DialogBuilder setIgnoreStatusBar(boolean isIgnoreStatusBar) { 225 | this.mIgnoreStatusBar = isIgnoreStatusBar; 226 | return this; 227 | } 228 | 229 | public OnCancelListener getOnCancelListener() { 230 | return mOnCancelListener; 231 | } 232 | 233 | public OnItemClickListener getOnItemClickListener() { 234 | return mOnItemClickListener; 235 | } 236 | 237 | public OnDismissListener getOnDismissListener() { 238 | return mOnDismissListener; 239 | } 240 | 241 | public OnShowListener getOnShowListener() { 242 | return mOnShowListener; 243 | } 244 | 245 | public Animation getDialogInAnimation() { 246 | return mDialogInAnimation; 247 | } 248 | 249 | public Animation getDialogOutAnimation() { 250 | return mDialogOutAnimation; 251 | } 252 | 253 | public OnKeyListener getOnKeyListener() { 254 | return mOnKeyListener; 255 | } 256 | public boolean isCancelable() { 257 | return mCancelable; 258 | } 259 | 260 | public int getGravity() { 261 | return mGravity; 262 | } 263 | 264 | public FrameLayout.LayoutParams getLayoutParams() { 265 | if(mLayoutParams == null){ 266 | mLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT 267 | ,FrameLayout.LayoutParams.WRAP_CONTENT); 268 | mLayoutParams.gravity = Gravity.parserGravity(mGravity); 269 | mLayoutParams.topMargin = getStatusBarHeight(); 270 | } 271 | return mLayoutParams; 272 | } 273 | 274 | public Drawable getBackground() { 275 | if(mBackground == null){ 276 | mBackground = new ColorDrawable(Color.TRANSPARENT); 277 | } 278 | return mBackground; 279 | } 280 | } 281 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/Gravity.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder; 18 | 19 | import android.support.annotation.IntDef; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | 24 | /** 25 | * author : Soulwolf Create by 2015/8/5 9:36 26 | * email : ToakerQin@gmail.com. 27 | */ 28 | public final class Gravity { 29 | 30 | /** Push object to the left of its container, not changing its size. */ 31 | public static final int LEFT = 0x00000020; 32 | 33 | /** Push object to the top of its container, not changing its size. */ 34 | public static final int TOP = 0x00000040; 35 | 36 | /** Push object to the right of its container, not changing its size. */ 37 | public static final int RIGHT = 0x00000080; 38 | 39 | /** Push object to the bottom of its container, not changing its size. */ 40 | public static final int BOTTOM = 0x00000002; 41 | 42 | /** Place object in the center of its container, not changing its 43 | * size. */ 44 | public static final int CENTER = 0x00000004; 45 | 46 | @IntDef({Gravity.LEFT,Gravity.TOP,Gravity.RIGHT,Gravity.BOTTOM,Gravity.CENTER}) 47 | @Retention(RetentionPolicy.SOURCE) 48 | public @interface GravityMode{ 49 | } 50 | 51 | public static int parserGravity(@GravityMode int gravity){ 52 | switch (gravity){ 53 | case Gravity.LEFT: 54 | return android.view.Gravity.LEFT | android.view.Gravity.CENTER_VERTICAL; 55 | 56 | case Gravity.TOP: 57 | return android.view.Gravity.TOP | android.view.Gravity.CENTER_HORIZONTAL; 58 | 59 | case Gravity.RIGHT: 60 | return android.view.Gravity.RIGHT | android.view.Gravity.CENTER_VERTICAL; 61 | 62 | case Gravity.BOTTOM: 63 | return android.view.Gravity.BOTTOM | android.view.Gravity.CENTER_HORIZONTAL; 64 | 65 | default: 66 | return android.view.Gravity.CENTER_VERTICAL | android.view.Gravity.CENTER_HORIZONTAL; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/IDialogBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  * Copyright 2015 Soulwolf Ching
  4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
  5 |  *
  6 |  * Licensed under the Apache License, Version 2.0 (the "License");
  7 |  * you may not use this file except in compliance with the License.
  8 |  * You may obtain a copy of the License at
  9 |  *
 10 |  *    http://www.apache.org/licenses/LICENSE-2.0
 11 |  *
 12 |  * Unless required by applicable law or agreed to in writing, software
 13 |  * distributed under the License is distributed on an "AS IS" BASIS,
 14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15 |  * See the License for the specific language governing permissions and
 16 |  * limitations under the License.
 17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | import android.graphics.drawable.Drawable; 22 | import android.support.annotation.AnimRes; 23 | import android.view.animation.Animation; 24 | 25 | /** 26 | * author: Soulwolf Created on 2015/8/4 22:54. 27 | * email : Ching.Soulwolf@gmail.com 28 | */ 29 | interface IDialogBuilder { 30 | 31 | /** 32 | * Set dialog cancel callback ! 33 | * Such as a touch of the area outside of Dialog! 34 | * or press back key,Cancel button click! 35 | * @param listener cancel listener{@link OnCancelListener}; 36 | * 37 | * @see IMasterDialog#cancel() ; 38 | * @return current instance! 39 | */ 40 | public DialogBuilder setOnCancelListener(OnCancelListener listener); 41 | 42 | /** 43 | * Set dialog list button click! 44 | * @param listener item click listener {@link OnItemClickListener} 45 | * @return current instance! 46 | */ 47 | public DialogBuilder setOnItemClickListener(OnItemClickListener listener); 48 | 49 | /** 50 | * Set dialog from window remove callback! 51 | * @param listener dialog dismiss listener! 52 | * 53 | * @see IMasterDialog#dismiss() 54 | * @return current instance! 55 | */ 56 | public DialogBuilder setOnDismissListener(OnDismissListener listener); 57 | 58 | /** 59 | * Set dialog add to window callback! 60 | * @param listener dialog add to window! 61 | * 62 | * @see IMasterDialog#show() ; 63 | * @return current instance! 64 | */ 65 | public DialogBuilder setOnShowListener(OnShowListener listener); 66 | 67 | /** 68 | * Set key pressed listener! 69 | * @param listener key press listener! 70 | * @return current instance! 71 | */ 72 | public DialogBuilder setOnKeyListener(OnKeyListener listener); 73 | 74 | /** 75 | * Set dialog in window and out window animation resource! 76 | * @param in dialog in window animation resource! 77 | * @param out dialog out window animation resource! 78 | * @return current instance! 79 | */ 80 | public DialogBuilder setAnimation(@AnimRes int in,@AnimRes int out); 81 | 82 | /** 83 | * Set dialog in window and out window animation! 84 | * @param in dialog in window animation! 85 | * @param out dialog out window animation! 86 | * @return current instance! 87 | */ 88 | public DialogBuilder setAnimation(Animation in,Animation out); 89 | 90 | /** 91 | * 92 | * @param isCancelable 93 | * @return current instance! 94 | */ 95 | public DialogBuilder setCancelable(boolean isCancelable); 96 | 97 | public DialogBuilder setLayoutParams(int width,int height); 98 | 99 | public DialogBuilder setGravity(@Gravity.GravityMode int gravity); 100 | 101 | public DialogBuilder setMargin(int l,int t,int r,int b); 102 | 103 | public DialogBuilder setBackground(int color); 104 | 105 | public DialogBuilder setBackgroundResource(int resource); 106 | 107 | public DialogBuilder setBackground(Drawable drawable); 108 | 109 | public DialogBuilder setIgnoreStatusBar(boolean isIgnoreStatusBar); 110 | } 111 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/IMasterDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright 2015 Soulwolf Ching
 4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
 5 |  *
 6 |  * Licensed under the Apache License, Version 2.0 (the "License");
 7 |  * you may not use this file except in compliance with the License.
 8 |  * You may obtain a copy of the License at
 9 |  *
10 |  *    http://www.apache.org/licenses/LICENSE-2.0
11 |  *
12 |  * Unless required by applicable law or agreed to in writing, software
13 |  * distributed under the License is distributed on an "AS IS" BASIS,
14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 |  * See the License for the specific language governing permissions and
16 |  * limitations under the License.
17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | import android.content.Context; 22 | 23 | /** 24 | * author: Soulwolf Created on 2015/8/4 21:36. 25 | * email : Ching.Soulwolf@gmail.com 26 | */ 27 | interface IMasterDialog{ 28 | 29 | /** 30 | * The dialog add to window! 31 | */ 32 | public void show(); 33 | 34 | /** 35 | * The cancel dialog! 36 | */ 37 | public void cancel(); 38 | 39 | /** 40 | * The dialog from window remove! 41 | */ 42 | public void dismiss(); 43 | 44 | /** 45 | * The current dialog display state! 46 | * @return current dialog display state! 47 | */ 48 | public boolean isShowing(); 49 | 50 | 51 | /** 52 | * Get dialog context! 53 | * @return dialog context! 54 | */ 55 | public Context getContext(); 56 | } 57 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/MasterDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  * Copyright 2015 Soulwolf Ching
  4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
  5 |  *
  6 |  * Licensed under the Apache License, Version 2.0 (the "License");
  7 |  * you may not use this file except in compliance with the License.
  8 |  * You may obtain a copy of the License at
  9 |  *
 10 |  *    http://www.apache.org/licenses/LICENSE-2.0
 11 |  *
 12 |  * Unless required by applicable law or agreed to in writing, software
 13 |  * distributed under the License is distributed on an "AS IS" BASIS,
 14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15 |  * See the License for the specific language governing permissions and
 16 |  * limitations under the License.
 17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | 22 | import android.app.Activity; 23 | import android.content.Context; 24 | import android.support.annotation.IdRes; 25 | import android.view.KeyEvent; 26 | import android.view.LayoutInflater; 27 | import android.view.MotionEvent; 28 | import android.view.View; 29 | import android.view.ViewGroup; 30 | import android.view.animation.AlphaAnimation; 31 | import android.view.animation.Animation; 32 | import android.widget.FrameLayout; 33 | 34 | /** 35 | * author: Soulwolf Created on 2015/8/4 21:41. 36 | * email : Ching.Soulwolf@gmail.com 37 | */ 38 | public abstract class MasterDialog implements IMasterDialog{ 39 | 40 | protected ViewGroup mDecorView; 41 | 42 | protected DialogBuilder mDialogBuilder; 43 | 44 | protected View mContentView; 45 | 46 | protected View mShadowView; 47 | 48 | protected ViewGroup mContainer; 49 | 50 | protected Activity mContext; 51 | 52 | protected boolean mShowing; 53 | 54 | protected boolean mCancelable; 55 | 56 | protected boolean isPlaying; 57 | 58 | public MasterDialog(DialogBuilder builder){ 59 | if(builder == null){ 60 | throw new NullPointerException("DialogBuilder == null"); 61 | } 62 | this.mDialogBuilder = builder; 63 | this.mCancelable = mDialogBuilder.isCancelable(); 64 | this.mContext = mDialogBuilder.getContext(); 65 | this.mDecorView = (ViewGroup) mContext.getWindow().getDecorView(); 66 | LayoutInflater inflater = LayoutInflater.from(mContext); 67 | this.mContainer = (ViewGroup) inflater.inflate(R.layout.dl_dialog_container,mDecorView,false); 68 | this.mShadowView = mContainer.findViewById(R.id.di_dialog_container_shadow); 69 | this.mContentView = onCreateView(inflater, mContainer); 70 | this.mContentView.setBackgroundDrawable(mDialogBuilder.getBackground()); 71 | parserLayoutGravity(); 72 | 73 | } 74 | 75 | private void parserLayoutGravity() { 76 | this.mContainer.addView(mContentView, mDialogBuilder.getLayoutParams()); 77 | //this.mContainer.setPadding(0, 0, 0, getNavigationBarHeight()); 78 | } 79 | 80 | protected abstract View onCreateView(LayoutInflater inflater,ViewGroup container); 81 | 82 | @Override 83 | public void show() { 84 | if(isShowing()){ 85 | return; 86 | } 87 | attachToWindow(); 88 | if(mDialogBuilder.getOnShowListener() != null){ 89 | mDialogBuilder.getOnShowListener().onShow(this); 90 | } 91 | } 92 | 93 | private int getNavigationBarHeight(){ 94 | return Utils.getNavigationBarHeight(getContext()); 95 | } 96 | 97 | private void attachToWindow() { 98 | if(isShowShadow()){ 99 | mShadowView.setVisibility(View.VISIBLE); 100 | }else { 101 | mShadowView.setVisibility(View.GONE); 102 | } 103 | mDecorView.addView(mContainer, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); 104 | playDialogInAnimation(); 105 | mContainer.requestFocus(); 106 | mContainer.setOnKeyListener(new View.OnKeyListener() { 107 | @Override 108 | public boolean onKey(View v, int keyCode, KeyEvent event) { 109 | if (keyCode == KeyEvent.KEYCODE_BACK 110 | && event.getAction() == KeyEvent.ACTION_UP) { 111 | if (mDialogBuilder.getOnKeyListener() != null) { 112 | return onBackPressed() 113 | || mDialogBuilder.getOnKeyListener() 114 | .onKey(MasterDialog.this, keyCode, event); 115 | } 116 | return onBackPressed(); 117 | } 118 | return false; 119 | } 120 | }); 121 | mShadowView.setOnTouchListener(new View.OnTouchListener() { 122 | @Override 123 | public boolean onTouch(View v, MotionEvent event) { 124 | return onBackPressed(); 125 | } 126 | }); 127 | mShowing = true; 128 | } 129 | 130 | public boolean onBackPressed(){ 131 | if(mCancelable){ 132 | cancel(); 133 | } 134 | return mCancelable; 135 | } 136 | 137 | protected void playDialogInAnimation() { 138 | clearAnimation(); 139 | Animation inAnimation = mDialogBuilder.getDialogInAnimation(); 140 | if(inAnimation != null){ 141 | mContentView.startAnimation(inAnimation); 142 | if(isShowShadow()){ 143 | AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f,1.0f); 144 | alphaAnimation.setDuration(inAnimation.getDuration()); 145 | mShadowView.startAnimation(alphaAnimation); 146 | } 147 | } 148 | } 149 | 150 | 151 | @Override 152 | public void cancel() { 153 | if(isShowing()){ 154 | dismiss(); 155 | if(mDialogBuilder.getOnCancelListener() != null){ 156 | mDialogBuilder.getOnCancelListener().onCancel(this); 157 | } 158 | } 159 | } 160 | 161 | @Override 162 | public void dismiss() { 163 | if(isShowing()){ 164 | Animation outAnimation = mDialogBuilder.getDialogOutAnimation(); 165 | if(outAnimation != null){ 166 | playDialogOutAnimation(outAnimation); 167 | }else { 168 | detachedFromWindow(); 169 | } 170 | } 171 | } 172 | 173 | private void playDialogOutAnimation(Animation outAnimation) { 174 | if(isPlaying){ 175 | return; 176 | } 177 | clearAnimation(); 178 | outAnimation.setAnimationListener(new SimpleAnimationListener(){ 179 | @Override 180 | public void onAnimationEnd(Animation animation) { 181 | isPlaying = false; 182 | detachedFromWindow(); 183 | } 184 | }); 185 | isPlaying = true; 186 | mContentView.startAnimation(outAnimation); 187 | if(isShowShadow()){ 188 | AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f,0.0f); 189 | alphaAnimation.setDuration(outAnimation.getDuration()); 190 | mShadowView.startAnimation(alphaAnimation); 191 | } 192 | } 193 | 194 | private void clearAnimation(){ 195 | mContainer.clearAnimation(); 196 | mShadowView.clearAnimation(); 197 | } 198 | 199 | private void detachedFromWindow() { 200 | mDecorView.removeView(mContainer); 201 | if(mDialogBuilder.getOnDismissListener() != null){ 202 | mDialogBuilder.getOnDismissListener().onDismiss(this); 203 | } 204 | mShowing = false; 205 | } 206 | 207 | @Override 208 | public boolean isShowing() { 209 | return mShowing; 210 | } 211 | 212 | public View findViewById(@IdRes int id){ 213 | if(mContentView != null){ 214 | return mContentView.findViewById(id); 215 | } 216 | return null; 217 | } 218 | 219 | @Override 220 | public Context getContext() { 221 | return mContext; 222 | } 223 | 224 | protected boolean isShowShadow(){ 225 | return true; 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/OnCancelListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright 2015 Soulwolf Ching
 4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
 5 |  *
 6 |  * Licensed under the Apache License, Version 2.0 (the "License");
 7 |  * you may not use this file except in compliance with the License.
 8 |  * You may obtain a copy of the License at
 9 |  *
10 |  *    http://www.apache.org/licenses/LICENSE-2.0
11 |  *
12 |  * Unless required by applicable law or agreed to in writing, software
13 |  * distributed under the License is distributed on an "AS IS" BASIS,
14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 |  * See the License for the specific language governing permissions and
16 |  * limitations under the License.
17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | /** 22 | * author: Soulwolf Created on 2015/8/4 21:53. 23 | * email : Ching.Soulwolf@gmail.com 24 | * 25 | * Interface used to allow the creator of a dialog to run some code when the 26 | * dialog is canceled. 27 | *

28 | * This will only be called when the dialog is canceled, if the creator 29 | * needs to know when it is dismissed in general, use OnCancelListener 30 | */ 31 | public interface OnCancelListener { 32 | 33 | /** 34 | * This method will be invoked when the dialog is canceled. 35 | * 36 | * @param dialog The dialog that was canceled will be passed into the 37 | * method. 38 | */ 39 | public void onCancel(MasterDialog dialog); 40 | } 41 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/OnDismissListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

 3 |  * Copyright 2015 Soulwolf Ching
 4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
 5 |  *
 6 |  * Licensed under the Apache License, Version 2.0 (the "License");
 7 |  * you may not use this file except in compliance with the License.
 8 |  * You may obtain a copy of the License at
 9 |  *
10 |  *    http://www.apache.org/licenses/LICENSE-2.0
11 |  *
12 |  * Unless required by applicable law or agreed to in writing, software
13 |  * distributed under the License is distributed on an "AS IS" BASIS,
14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 |  * See the License for the specific language governing permissions and
16 |  * limitations under the License.
17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | /** 22 | * author: Soulwolf Created on 2015/8/4 21:54. 23 | * email : Ching.Soulwolf@gmail.com 24 | * 25 | * Interface used to allow the creator of a dialog to run some code when the 26 | * dialog is dismissed. 27 | */ 28 | public interface OnDismissListener { 29 | 30 | /** 31 | * This method will be invoked when the dialog is dismissed. 32 | * 33 | * @param dialog The dialog that was dismissed will be passed into the 34 | * method. 35 | */ 36 | public void onDismiss(IMasterDialog dialog); 37 | } 38 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/OnItemClickListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright 2015 Soulwolf Ching
 4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
 5 |  *
 6 |  * Licensed under the Apache License, Version 2.0 (the "License");
 7 |  * you may not use this file except in compliance with the License.
 8 |  * You may obtain a copy of the License at
 9 |  *
10 |  *    http://www.apache.org/licenses/LICENSE-2.0
11 |  *
12 |  * Unless required by applicable law or agreed to in writing, software
13 |  * distributed under the License is distributed on an "AS IS" BASIS,
14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 |  * See the License for the specific language governing permissions and
16 |  * limitations under the License.
17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | import android.view.View; 22 | 23 | /** 24 | * author: Soulwolf Created on 2015/8/4 21:56. 25 | * email : Ching.Soulwolf@gmail.com 26 | * 27 | * Interface used to allow the creator of a dialog to run some code when an 28 | * item on the dialog is clicked.. 29 | */ 30 | public interface OnItemClickListener { 31 | 32 | /** 33 | * This method will be invoked when a button list in the dialog is clicked. 34 | * 35 | * @param dialog The dialog that received the click. 36 | * @param view Clicked View! 37 | * @param position Click the Dialog button list is the position! 38 | */ 39 | public void onItemClick(MasterDialog dialog,View view, int position); 40 | } 41 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/OnKeyListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright 2015 Soulwolf Ching
 4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
 5 |  *
 6 |  * Licensed under the Apache License, Version 2.0 (the "License");
 7 |  * you may not use this file except in compliance with the License.
 8 |  * You may obtain a copy of the License at
 9 |  *
10 |  *    http://www.apache.org/licenses/LICENSE-2.0
11 |  *
12 |  * Unless required by applicable law or agreed to in writing, software
13 |  * distributed under the License is distributed on an "AS IS" BASIS,
14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 |  * See the License for the specific language governing permissions and
16 |  * limitations under the License.
17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | import android.view.KeyEvent; 22 | 23 | /** 24 | * author: Soulwolf Created on 2015/8/4 21:57. 25 | * email : Ching.Soulwolf@gmail.com 26 | * 27 | * Interface definition for a callback to be invoked when a key event is 28 | * dispatched to this dialog. The callback will be invoked before the key 29 | * event is given to the dialog. 30 | */ 31 | public interface OnKeyListener { 32 | 33 | /** 34 | * Called when a key is dispatched to a dialog. This allows listeners to 35 | * get a chance to respond before the dialog. 36 | * 37 | * @param dialog The dialog the key has been dispatched to. 38 | * @param keyCode The code for the physical key that was pressed 39 | * @param event The KeyEvent object containing full information about 40 | * the event. 41 | * @return True if the listener has consumed the event, false otherwise. 42 | */ 43 | public boolean onKey(IMasterDialog dialog, int keyCode, KeyEvent event); 44 | } 45 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/OnShowListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright 2015 Soulwolf Ching
 4 |  * Copyright 2015 The Android Open Source Project for android-dialog-builder
 5 |  *
 6 |  * Licensed under the Apache License, Version 2.0 (the "License");
 7 |  * you may not use this file except in compliance with the License.
 8 |  * You may obtain a copy of the License at
 9 |  *
10 |  *    http://www.apache.org/licenses/LICENSE-2.0
11 |  *
12 |  * Unless required by applicable law or agreed to in writing, software
13 |  * distributed under the License is distributed on an "AS IS" BASIS,
14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 |  * See the License for the specific language governing permissions and
16 |  * limitations under the License.
17 |  * 
18 | */ 19 | package net.soulwolf.widget.dialogbuilder; 20 | 21 | /** 22 | * author: Soulwolf Created on 2015/8/4 21:56. 23 | * email : Ching.Soulwolf@gmail.com 24 | * 25 | * Interface used to allow the creator of a dialog to run some code when the 26 | * dialog is shown. 27 | */ 28 | public interface OnShowListener { 29 | 30 | /** 31 | * This method will be invoked when the dialog is shown. 32 | * 33 | * @param dialog The dialog that was shown will be passed into the 34 | * method. 35 | */ 36 | public void onShow(MasterDialog dialog); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/SimpleAnimationListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder; 18 | 19 | import android.view.animation.Animation; 20 | 21 | /** 22 | * author : Soulwolf Create by 2015/8/5 9:28 23 | * email : ToakerQin@gmail.com. 24 | */ 25 | class SimpleAnimationListener implements Animation.AnimationListener{ 26 | 27 | @Override 28 | public void onAnimationStart(Animation animation) { 29 | 30 | } 31 | 32 | @Override 33 | public void onAnimationEnd(Animation animation) { 34 | 35 | } 36 | 37 | @Override 38 | public void onAnimationRepeat(Animation animation) { 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/Utils.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.content.Context; 21 | import android.content.res.Resources; 22 | import android.os.Build; 23 | import android.util.DisplayMetrics; 24 | import android.view.KeyCharacterMap; 25 | import android.view.KeyEvent; 26 | import android.view.ViewConfiguration; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Arrays; 30 | import java.util.List; 31 | 32 | /** 33 | * author : Soulwolf Create by 2015/8/5 16:16 34 | * email : ToakerQin@gmail.com. 35 | */ 36 | final class Utils { 37 | 38 | static List asList(ITEM [] array){ 39 | if(array == null){ 40 | return new ArrayList(); 41 | } 42 | return Arrays.asList(array); 43 | } 44 | 45 | static List checkList(List list){ 46 | if(list == null){ 47 | return new ArrayList(); 48 | } 49 | return list; 50 | } 51 | 52 | static int getStatusBarHeight(Context context){ 53 | DisplayMetrics metrics = context.getResources().getDisplayMetrics(); 54 | return (int) Math.ceil( 17 * metrics.density); 55 | } 56 | 57 | static int getNavigationBarHeight(Context context) { 58 | int navigationBarHeight = 0; 59 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){ 60 | Resources rs = context.getResources(); 61 | int id = rs.getIdentifier("navigation_bar_height", "dimen", "android"); 62 | if (id > 0 && checkDeviceHasNavigationBar(context)) { 63 | navigationBarHeight = rs.getDimensionPixelSize(id); 64 | } 65 | } 66 | return navigationBarHeight; 67 | } 68 | 69 | @SuppressLint("NewApi") 70 | static boolean checkDeviceHasNavigationBar(Context context) { 71 | boolean hasMenuKey = ViewConfiguration.get(context) 72 | .hasPermanentMenuKey(); 73 | boolean hasBackKey = KeyCharacterMap 74 | .deviceHasKey(KeyEvent.KEYCODE_BACK); 75 | if (!hasMenuKey && !hasBackKey) { 76 | return true; 77 | } 78 | return false; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/adapter/GridDialogAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.adapter; 18 | 19 | import android.content.Context; 20 | 21 | import net.soulwolf.widget.dialogbuilder.DialogAdapter; 22 | import net.soulwolf.widget.dialogbuilder.R; 23 | import net.soulwolf.widget.dialogbuilder.model.GridModel; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * author : Soulwolf Create by 2015/8/5 15:39 29 | * email : ToakerQin@gmail.com. 30 | */ 31 | public class GridDialogAdapter extends DialogAdapter { 32 | 33 | public GridDialogAdapter(Context context) { 34 | super(context, R.layout.dl_simple_grid_item); 35 | } 36 | 37 | public GridDialogAdapter(Context context, GridModel[] data) { 38 | super(context, data, R.layout.dl_simple_grid_item); 39 | } 40 | 41 | public GridDialogAdapter(Context context, List data) { 42 | super(context, data, R.layout.dl_simple_grid_item); 43 | } 44 | 45 | @Override 46 | public void convert(ViewHolder helper, GridModel gridModel, int position) { 47 | helper.setImageResource(android.R.id.icon1,gridModel.mIconResource); 48 | helper.setText(android.R.id.text1,gridModel.mText); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/adapter/TextDialogAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.adapter; 18 | 19 | import android.content.Context; 20 | 21 | import net.soulwolf.widget.dialogbuilder.DialogAdapter; 22 | import net.soulwolf.widget.dialogbuilder.R; 23 | 24 | import java.util.List; 25 | 26 | /** 27 | * author : Soulwolf Create by 2015/8/5 15:02 28 | * email : ToakerQin@gmail.com. 29 | */ 30 | public class TextDialogAdapter extends DialogAdapter { 31 | 32 | public TextDialogAdapter(Context context) { 33 | super(context, R.layout.dl_simple_text_item); 34 | } 35 | 36 | public TextDialogAdapter(Context context, String[] data) { 37 | super(context, data, R.layout.dl_simple_text_item); 38 | } 39 | 40 | public TextDialogAdapter(Context context, List data) { 41 | super(context, data, R.layout.dl_simple_text_item); 42 | } 43 | 44 | @Override 45 | public void convert(ViewHolder helper, String s, int position) { 46 | helper.setText(android.R.id.text1,s); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/adapter/ViewHolder.java: -------------------------------------------------------------------------------- 1 | package net.soulwolf.widget.dialogbuilder.adapter; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.annotation.ColorInt; 7 | import android.support.annotation.ColorRes; 8 | import android.support.annotation.DrawableRes; 9 | import android.support.annotation.IdRes; 10 | import android.support.annotation.StringRes; 11 | import android.util.SparseArray; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.widget.ImageView; 16 | import android.widget.TextView; 17 | 18 | 19 | public final class ViewHolder { 20 | 21 | protected View mConvertView; 22 | 23 | protected Context mContext; 24 | 25 | protected SparseArray mViews; 26 | 27 | ViewHolder(Context context, ViewGroup parent, int layoutId, int position) { 28 | this.mViews = new SparseArray(); 29 | this.mContext = context; 30 | this.mConvertView = LayoutInflater.from(context).inflate(layoutId, parent, 31 | false); 32 | this.mConvertView.setTag(this); 33 | } 34 | 35 | /** 36 | * @param context app context 37 | * @param convertView container view 38 | * @param parent parent view 39 | * @param layoutId layout id 40 | * @param position position 41 | * @return view holder 42 | */ 43 | public static ViewHolder create(Context context, View convertView, 44 | ViewGroup parent, int layoutId, int position) { 45 | if (convertView == null) { 46 | return new ViewHolder(context, parent, layoutId, position); 47 | } 48 | return (ViewHolder) convertView.getTag(); 49 | } 50 | 51 | 52 | public View getConvertView() { 53 | return mConvertView; 54 | } 55 | 56 | /** 57 | * @param viewId view id 58 | * @return view 59 | */ 60 | public T getView(int viewId) { 61 | View view = mViews.get(viewId); 62 | if (view == null) { 63 | view = mConvertView.findViewById(viewId); 64 | mViews.put(viewId, view); 65 | } 66 | return (T) view; 67 | } 68 | 69 | 70 | /** 71 | * @param viewId view id 72 | * @param text view text 73 | * @return view holder 74 | */ 75 | public ViewHolder setText(@IdRes int viewId, CharSequence text) { 76 | TextView view = getView(viewId); 77 | if(view != null){ 78 | view.setText(text); 79 | } 80 | return this; 81 | } 82 | /** 83 | * 为TextView设置字符串 84 | * 85 | * @param viewId view id 86 | * @param resId string res id 87 | * @return view holder 88 | */ 89 | public ViewHolder setText(@IdRes int viewId, @StringRes int resId) { 90 | return setText(viewId,mContext.getString(resId)); 91 | } 92 | 93 | /** 94 | * @param viewId view id 95 | * @param tag view tag 96 | * @param listener click listener 97 | * @return view holder 98 | */ 99 | public ViewHolder setOnClickListener(int viewId, Object tag, View.OnClickListener listener) { 100 | View view = getView(viewId); 101 | if(view != null){ 102 | view.setTag(tag); 103 | view.setOnClickListener(listener); 104 | } 105 | return this; 106 | } 107 | 108 | /** 109 | * @param viewId view id 110 | * @param visibility view display state 111 | * @return view holder 112 | */ 113 | public ViewHolder setVisibility(int viewId, int visibility) { 114 | View view = getView(viewId); 115 | if(view != null && view.getVisibility() != visibility){ 116 | view.setVisibility(visibility); 117 | } 118 | return this; 119 | } 120 | 121 | /** 122 | * @param viewId view id 123 | * @param listener click listener 124 | * @return view holder 125 | */ 126 | public ViewHolder setOnClickListener(int viewId, View.OnClickListener listener) { 127 | View view = getView(viewId); 128 | if(view != null){ 129 | view.setOnClickListener(listener); 130 | } 131 | return this; 132 | } 133 | 134 | /** 135 | * @param viewId view id 136 | * @param textColor text color 137 | * @return view holder 138 | */ 139 | public ViewHolder setTextColor(int viewId, @ColorInt int textColor) { 140 | TextView view = getView(viewId); 141 | if(view != null){ 142 | view.setTextColor(textColor); 143 | } 144 | return this; 145 | } 146 | 147 | /** 148 | * @param viewId view id 149 | * @param resId text color 150 | * @return view holder 151 | */ 152 | public ViewHolder setTextColorRes(int viewId, @ColorRes int resId) { 153 | TextView view = getView(viewId); 154 | if(view != null){ 155 | view.setTextColor(getColor(resId)); 156 | } 157 | return this; 158 | } 159 | 160 | public int getColor(@ColorRes int resId){ 161 | return mContext.getResources().getColor(resId); 162 | } 163 | 164 | public String getString(@StringRes int resId){ 165 | return mContext.getResources().getString(resId); 166 | } 167 | 168 | /** 169 | * @param viewId view 170 | * @param drawable drawable 171 | * @return view holder 172 | */ 173 | public ViewHolder setBackgroundDrawable(int viewId, Drawable drawable) { 174 | View view = getView(viewId); 175 | if(view != null){ 176 | view.setBackgroundDrawable(drawable); 177 | } 178 | return this; 179 | } 180 | 181 | /** 182 | * @param viewId view 183 | * @param drawable drawable red Id 184 | * @return view holder 185 | */ 186 | public ViewHolder setBackgroundResource(@IdRes int viewId, @DrawableRes int drawable) { 187 | View view = getView(viewId); 188 | if(view != null){ 189 | view.setBackgroundResource(drawable); 190 | } 191 | return this; 192 | } 193 | 194 | /** 195 | * @param viewId view 196 | * @param drawableId res Id 197 | * @return view holder 198 | */ 199 | public ViewHolder setImageResource(@IdRes int viewId, @DrawableRes int drawableId) { 200 | ImageView view = getView(viewId); 201 | view.setImageResource(drawableId); 202 | return this; 203 | } 204 | 205 | /** 206 | * @param viewId view 207 | * @return view holder 208 | */ 209 | public ViewHolder setImageBitmap(int viewId, Bitmap bm) { 210 | ImageView view = getView(viewId); 211 | view.setImageBitmap(bm); 212 | return this; 213 | } 214 | 215 | public CharSequence getText(@IdRes int viewId) { 216 | TextView textView = getView(viewId); 217 | return textView.getText(); 218 | } 219 | 220 | public void recycle() { 221 | mViews.clear(); 222 | mViews = null; 223 | mConvertView = null; 224 | mContext = null; 225 | System.gc(); 226 | } 227 | 228 | } -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/dialog/AbsListMasterDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.dialog; 18 | 19 | import android.content.Context; 20 | import android.view.View; 21 | import android.widget.AdapterView; 22 | 23 | import net.soulwolf.widget.dialogbuilder.DialogBuilder; 24 | import net.soulwolf.widget.dialogbuilder.MasterDialog; 25 | import net.soulwolf.widget.dialogbuilder.R; 26 | 27 | /** 28 | * author : Soulwolf Create by 2015/8/5 14:22 29 | * email : ToakerQin@gmail.com. 30 | */ 31 | public abstract class AbsListMasterDialog extends MasterDialog 32 | implements IAbsListControl,ICancelButton, View.OnClickListener, 33 | AdapterView.OnItemClickListener { 34 | 35 | public AbsListMasterDialog(DialogBuilder builder) { 36 | super(builder); 37 | findViewById(R.id.di_dialog_cancel).setOnClickListener(this); 38 | } 39 | 40 | @Override 41 | public void setCancelButton(boolean display) { 42 | View view = findViewById(R.id.di_dialog_cancel_layout); 43 | if(view != null){ 44 | view.setVisibility(display ? View.VISIBLE : View.GONE); 45 | } 46 | } 47 | 48 | @Override 49 | public void onClick(View v) { 50 | if(v.getId() == R.id.di_dialog_cancel){ 51 | cancel(); 52 | } 53 | } 54 | 55 | @Override 56 | public void onItemClick(AdapterView parent, View view, int position, long id) { 57 | if(mDialogBuilder.getOnItemClickListener() != null){ 58 | mDialogBuilder.getOnItemClickListener().onItemClick(this,view,position); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/dialog/AlertMasterDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
  4 |  * Licensed under the Apache License, Version 2.0 (the "License");
  5 |  * you may not use this file except in compliance with the License.
  6 |  * You may obtain a copy of the License at
  7 |  *
  8 |  *    http://www.apache.org/licenses/LICENSE-2.0
  9 |  *
 10 |  * Unless required by applicable law or agreed to in writing, software
 11 |  * distributed under the License is distributed on an "AS IS" BASIS,
 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 |  * See the License for the specific language governing permissions and
 14 |  * limitations under the License.
 15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.dialog; 18 | 19 | import android.support.annotation.StringRes; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.TextView; 24 | 25 | import net.soulwolf.widget.dialogbuilder.DialogBuilder; 26 | import net.soulwolf.widget.dialogbuilder.MasterDialog; 27 | import net.soulwolf.widget.dialogbuilder.R; 28 | 29 | /** 30 | * author : Soulwolf Create by 2015/8/5 16:38 31 | * email : ToakerQin@gmail.com. 32 | */ 33 | public class AlertMasterDialog extends MasterDialog implements View.OnClickListener { 34 | 35 | TextView mTitleView; 36 | 37 | TextView mContentText; 38 | 39 | TextView mButton1; 40 | 41 | TextView mButton2; 42 | 43 | View mButtonSpace; 44 | 45 | public AlertMasterDialog(DialogBuilder builder) { 46 | super(builder); 47 | } 48 | 49 | @Override 50 | protected View onCreateView(LayoutInflater inflater, ViewGroup container) { 51 | View view = inflater.inflate(R.layout.dl_dialog_alert, container,false); 52 | this.mTitleView = (TextView) view.findViewById(android.R.id.text1); 53 | this.mContentText = (TextView) view.findViewById(android.R.id.text2); 54 | this.mButton1 = (TextView) view.findViewById(android.R.id.button1); 55 | this.mButton2 = (TextView) view.findViewById(android.R.id.button2); 56 | this.mButtonSpace = view.findViewById(android.R.id.icon1); 57 | this.mButton1.setText(R.string.ds_ok); 58 | this.mButton1.setOnClickListener(this); 59 | this.mButton2.setOnClickListener(this); 60 | return view; 61 | } 62 | 63 | public void setTitle(CharSequence title){ 64 | this.mTitleView.setText(title); 65 | } 66 | 67 | public void setTitle(@StringRes int title){ 68 | this.mTitleView.setText(title); 69 | } 70 | 71 | public void setContent(CharSequence content){ 72 | this.mContentText.setText(content); 73 | } 74 | 75 | public void setContent(@StringRes int content){ 76 | this.mContentText.setText(content); 77 | } 78 | 79 | public void setButton1(CharSequence button1){ 80 | this.mButton1.setText(button1); 81 | } 82 | 83 | public void setButton1(@StringRes int button1){ 84 | this.mButton1.setText(button1); 85 | } 86 | 87 | public void setButton2(CharSequence button2){ 88 | this.mButton2.setText(button2); 89 | this.mButton2.setVisibility(View.VISIBLE); 90 | this.mButtonSpace.setVisibility(View.VISIBLE); 91 | } 92 | 93 | public void setButton2(@StringRes int button2){ 94 | this.mButton2.setText(button2); 95 | this.mButton2.setVisibility(View.VISIBLE); 96 | this.mButtonSpace.setVisibility(View.VISIBLE); 97 | } 98 | 99 | public void setButton2Visibility(int visibility){ 100 | this.mButton2.setVisibility(visibility); 101 | this.mButtonSpace.setVisibility(visibility); 102 | } 103 | 104 | @Override 105 | public void onClick(View v) { 106 | int position; 107 | if(v.getId() == android.R.id.button1){ 108 | position = 0; 109 | }else { 110 | position = 1; 111 | } 112 | if(mDialogBuilder.getOnItemClickListener() != null){ 113 | mDialogBuilder.getOnItemClickListener().onItemClick(this,v,position); 114 | } 115 | } 116 | 117 | public TextView getTitleView() { 118 | return mTitleView; 119 | } 120 | 121 | public TextView getContentText() { 122 | return mContentText; 123 | } 124 | 125 | public TextView getButton1() { 126 | return mButton1; 127 | } 128 | 129 | public TextView getButton2() { 130 | return mButton2; 131 | } 132 | 133 | public View getButtonSpace() { 134 | return mButtonSpace; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/dialog/GridMasterDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.dialog; 18 | 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.GridView; 23 | 24 | import net.soulwolf.widget.dialogbuilder.DialogBuilder; 25 | import net.soulwolf.widget.dialogbuilder.R; 26 | import net.soulwolf.widget.dialogbuilder.DialogAdapter; 27 | 28 | /** 29 | * author : Soulwolf Create by 2015/8/5 15:23 30 | * email : ToakerQin@gmail.com. 31 | */ 32 | public class GridMasterDialog extends AbsListMasterDialog { 33 | 34 | GridView mGridView; 35 | 36 | public GridMasterDialog(DialogBuilder builder) { 37 | super(builder); 38 | } 39 | 40 | @Override 41 | public void setAdapter(DialogAdapter adapter) { 42 | mGridView.setAdapter(adapter); 43 | } 44 | 45 | @Override 46 | protected View onCreateView(LayoutInflater inflater, ViewGroup container) { 47 | View view = inflater.inflate(R.layout.dl_dialog_grid, container, false); 48 | mGridView = (GridView) view.findViewById(R.id.di_dialog_grid); 49 | mGridView.setOnItemClickListener(this); 50 | return view; 51 | } 52 | 53 | public void setNumColumns(int columns){ 54 | mGridView.setNumColumns(columns); 55 | } 56 | 57 | public void setColumnWidth(int width){ 58 | mGridView.setColumnWidth(width); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/dialog/IAbsListControl.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.dialog; 18 | 19 | import net.soulwolf.widget.dialogbuilder.DialogAdapter; 20 | 21 | /** 22 | * author : Soulwolf Create by 2015/8/5 14:25 23 | * email : ToakerQin@gmail.com. 24 | */ 25 | interface IAbsListControl { 26 | 27 | public void setAdapter(DialogAdapter adapter); 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/dialog/ICancelButton.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.dialog; 18 | 19 | /** 20 | * author : Soulwolf Create by 2015/8/5 9:54 21 | * email : ToakerQin@gmail.com. 22 | */ 23 | interface ICancelButton { 24 | 25 | public void setCancelButton(boolean display); 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/dialog/ListMasterDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.dialog; 18 | 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.ListView; 23 | 24 | import net.soulwolf.widget.dialogbuilder.DialogBuilder; 25 | import net.soulwolf.widget.dialogbuilder.R; 26 | import net.soulwolf.widget.dialogbuilder.DialogAdapter; 27 | 28 | /** 29 | * author : Soulwolf Create by 2015/8/5 9:46 30 | * email : ToakerQin@gmail.com. 31 | */ 32 | public class ListMasterDialog extends AbsListMasterDialog{ 33 | 34 | ListView mListView; 35 | 36 | public ListMasterDialog(DialogBuilder builder) { 37 | super(builder); 38 | } 39 | 40 | @Override 41 | protected View onCreateView(LayoutInflater inflater, ViewGroup container) { 42 | View view = inflater.inflate(R.layout.dl_dialog_list, container, false); 43 | mListView = (ListView) view.findViewById(R.id.di_dialog_list); 44 | mListView.setOnItemClickListener(this); 45 | return view; 46 | } 47 | 48 | @Override 49 | public void setAdapter(DialogAdapter adapter) { 50 | mListView.setAdapter(adapter); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/main/java/net/soulwolf/widget/dialogbuilder/model/GridModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  * Copyright (C) 2015  Soulwolf android-dialog-builder
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  *    http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  * 
16 | */ 17 | package net.soulwolf.widget.dialogbuilder.model; 18 | 19 | /** 20 | * author : Soulwolf Create by 2015/8/5 15:37 21 | * email : ToakerQin@gmail.com. 22 | */ 23 | public class GridModel { 24 | 25 | public int mIconResource; 26 | 27 | public String mText; 28 | 29 | public GridModel(int iconResource, String text) { 30 | this.mIconResource = iconResource; 31 | this.mText = text; 32 | } 33 | 34 | public GridModel() { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_fade_in_center.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_fade_out_center.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_in_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_in_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_in_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_in_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_out_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_out_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_out_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/anim/da_slide_out_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_cancel_press_round_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_item_press_round_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_item_round_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_selector_cancel_click.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_selector_item_click.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_selector_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dd_white_round_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/layout/dl_dialog_alert.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 24 | 25 | 33 | 34 | 38 | 39 | 43 | 44 | 54 | 55 | 61 | 62 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /library/src/main/res/layout/dl_dialog_cancel.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |