├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── kotlinc.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── me │ │ └── leefeng │ │ └── promptdialog │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── me │ │ │ └── leefeng │ │ │ └── promptdialog │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── me │ └── leefeng │ └── promptdialog │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── promptlibrary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── me │ │ └── leefeng │ │ └── promptlibrary │ │ ├── Builder.java │ │ ├── OnAdClickListener.java │ │ ├── PromptButton.java │ │ ├── PromptButtonListener.java │ │ ├── PromptDialog.java │ │ └── PromptView.java │ └── res │ ├── drawable-xxxhdpi │ ├── ic_prompt_alert_warn.png │ ├── ic_prompt_close.png │ ├── ic_prompt_error.png │ ├── ic_prompt_info.png │ ├── ic_prompt_loading.png │ ├── ic_prompt_success.png │ └── ic_prompt_warn.png │ └── values │ └── strings.xml ├── screen1.gif ├── screen2.jpg ├── screen3.jpg ├── screen4.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 35 | 36 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-PromptDialog 2 | 提示窗口,正在加载中,确认对话框,广告展示,底部Sheet选项,非组合控件,感谢star 3 | 4 | 5 | 6 | [![](https://jitpack.io/v/limxing/Android-PromptDialog.svg)](https://jitpack.io/#limxing/Android-PromptDialog) 7 | 8 | #### 1、添加依赖 9 | 10 | ``` 11 | allprojects { 12 | repositories { 13 | ... 14 | maven { url 'https://jitpack.io' } 15 | } 16 | } 17 | 18 | 19 | ``` 20 | 21 | ``` 22 | dependencies { 23 | ... 24 | compile 'com.github.limxing:Android-PromptDialog:1.1.3' 25 | } 26 | 27 | ``` 28 | #### 2、创建对象及使用方法 29 | ``` 30 | promptDialog = new PromptDialog(this); 31 | promptDialog.showLoading("正在登录"); 32 | /** 33 | /********************消息提示框*************/ 34 | promptDialog.showSuccess("登陆成功"); 35 | promptDialog.showError("登录失败"); 36 | promptDialog.showWarn("注意"); 37 | promptDialog.showInfo("成功了"); 38 | promptDialog.showCustom(R.mipmap.ic_launcher, "自定义图标的"); 39 | promptDialog.dismiss(); 40 | promptDialog.dismissImmediately(); 41 | 42 | /********************Alert弹窗*************/ 43 | final PromptButton confirm = new PromptButton("确定", new PromptButtonListener() { 44 | @Override 45 | public void onClick(PromptButton button) { 46 | Toast.makeText(MainActivity.this, button.getText(), Toast.LENGTH_SHORT).show(); 47 | } 48 | }); 49 | confirm.setTextColor(Color.parseColor("#DAA520")); 50 | //按钮的定义 51 | PromptButton confirm = new PromptButton("确定", new PromptButtonListener() { 52 | @Override 53 | public void onClick(PromptButton button) { 54 | Toast.makeText(MainActivity.this, button.getText(), Toast.LENGTH_SHORT).show(); 55 | } 56 | }); 57 | confirm.setFocusBacColor(Color.parseColor("#FAFAD2")); 58 | //Alert的调用 59 | promptDialog.showWarnAlert("你确定要退出登录?", new PromptButton("取消", new PromptButtonListener() { 60 | @Override 61 | public void onClick(PromptButton button) { 62 | Toast.makeText(MainActivity.this, button.getText(), Toast.LENGTH_SHORT).show(); 63 | } 64 | }), confirm); 65 | 66 | /********************底部AlertSheet*************/ 67 | //可创建android效果的底部Sheet选择,默认IOS效果,sheetCellPad=0为Android效果的Sheet 68 | // promptDialog.getAlertDefaultBuilder().sheetCellPad(0).round(0); 69 | //设置按钮的特点,颜色大小什么的,具体看PromptButton的成员变量 70 | PromptButton cancle = new PromptButton("取消", null); 71 | cancle.setTextColor(Color.parseColor("#0076ff")); 72 | //设置显示的文字大小及颜色 73 | //promptDialog.getAlertDefaultBuilder().textSize(12).textColor(Color.GRAY); 74 | //默认两个按钮为Alert对话框,大于三个按钮的为底部SHeet形式展现 75 | promptDialog.showAlertSheet("", true, cancle, 76 | new PromptButton("选项1", null), new PromptButton("选项2", null), 77 | new PromptButton("选项3", null), new PromptButton("选项4", null)); 78 | /********************展示广告的方法*************/ 79 | promptDialog.getDefaultBuilder().backAlpha(150); 80 | Glide.with(MainActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&" + 81 | "size=b9999_10000&sec=1495518782659&di=25b120262114749ae8543652d2de5715&" + 82 | "imgtype=0&src=http%3A%2F%2Fimg.tupianzj.com%2Fuploads%2Fallimg%2F160316%2F9-160316152R5.jpg") 83 | .into(promptDialog.showAd(true, new OnAdClickListener() { 84 | @Override 85 | public void onAdClick() { 86 | Toast.makeText(MainActivity.this,"点击了广告",Toast.LENGTH_SHORT).show(); 87 | } 88 | })); 89 | **/ 90 | ``` 91 | #### 3、自定义窗口style 92 | ``` 93 | /* 均为单例,设置一次后会影响另一个,因此如果效果不同那么调用前设置一次*/ 94 | //自定义提示框Style,适应于show...(消息提示框,展示广告) 95 | promptDialog.getDefaultBuilder().touchAble(true).round(3).loadingDuration(3000).. 96 | //自定义弹窗对话框Style,适应于Alert 及AlertSheet(Alert弹窗,底部AlertSheet) 97 | promptDialog.getAlertDefaultBuilder().touchAble(false).round(5)... 98 | ``` 99 | #### 4、按需处理返回键 100 | ``` 101 | //返回键的处理仅是Alert 或AlertSheet的关闭操作 102 | @Override 103 | public void onBackPressed() { 104 | if (promptDialog.onBackPressed()) 105 | super.onBackPressed(); 106 | } 107 | ``` 108 | #### License 109 | 110 | ``` 111 | Copyright 2017 Limxing 112 | 113 | Licensed under the Apache License, Version 2.0 (the "License"); 114 | you may not use this file except in compliance with the License. 115 | You may obtain a copy of the License at 116 | 117 | http://www.apache.org/licenses/LICENSE-2.0 118 | 119 | Unless required by applicable law or agreed to in writing, software 120 | distributed under the License is distributed on an "AS IS" BASIS, 121 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122 | See the License for the specific language governing permissions and 123 | limitations under the License. 124 | ``` -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.3" 6 | defaultConfig { 7 | applicationId "me.leefeng.promptdialog" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | testCompile 'junit:junit:4.12' 30 | compile project(':promptlibrary') 31 | compile 'com.github.bumptech.glide:glide:3.6.1' 32 | // compile 'com.github.limxing:Android-PromptDialog:1.0.0' 33 | // compile files('libs/MapSDK_fat.jar') 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/me/leefeng/promptdialog/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package me.leefeng.promptdialog; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("me.leefeng.promptdialog", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/me/leefeng/promptdialog/MainActivity.java: -------------------------------------------------------------------------------- 1 | package me.leefeng.promptdialog; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.ProgressDialog; 5 | import android.graphics.Color; 6 | import android.os.Handler; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.os.Bundle; 9 | import android.view.View; 10 | import android.widget.Toast; 11 | 12 | import com.bumptech.glide.Glide; 13 | 14 | import me.leefeng.promptlibrary.OnAdClickListener; 15 | import me.leefeng.promptlibrary.PromptButton; 16 | import me.leefeng.promptlibrary.PromptButtonListener; 17 | import me.leefeng.promptlibrary.PromptDialog; 18 | 19 | /** 20 | * github:limxing 21 | */ 22 | public class MainActivity extends AppCompatActivity { 23 | 24 | private PromptDialog promptDialog; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | 31 | //创建对象 32 | promptDialog = new PromptDialog(this); 33 | //设置自定义属性 34 | promptDialog.getDefaultBuilder().touchAble(true).round(3).loadingDuration(3000); 35 | 36 | 37 | findViewById(R.id.main_start).setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | promptDialog.showWarn("注意"); 41 | } 42 | }); 43 | 44 | findViewById(R.id.main_loading).setOnClickListener(new View.OnClickListener() { 45 | @Override 46 | public void onClick(View view) { 47 | // main_failview.setMode(FailView.MODE_REFRESH); 48 | promptDialog.showLoading("正在登录"); 49 | } 50 | }); 51 | findViewById(R.id.main_success).setOnClickListener(new View.OnClickListener() { 52 | @Override 53 | public void onClick(View v) { 54 | promptDialog.showSuccess("登陆成功"); 55 | } 56 | }); 57 | findViewById(R.id.main_fail).setOnClickListener(new View.OnClickListener() { 58 | @Override 59 | public void onClick(View v) { 60 | promptDialog.showError("登录失败"); 61 | } 62 | }); 63 | 64 | //按钮的定义,创建一个按钮的对象 65 | final PromptButton confirm = new PromptButton("确定", new PromptButtonListener() { 66 | @Override 67 | public void onClick(PromptButton button) { 68 | Toast.makeText(MainActivity.this, button.getText(), Toast.LENGTH_SHORT).show(); 69 | } 70 | }); 71 | confirm.setTextColor(Color.parseColor("#DAA520")); 72 | confirm.setFocusBacColor(Color.parseColor("#FAFAD2")); 73 | confirm.setDelyClick(true);//点击后,是否再对话框消失后响应按钮的监听事件 74 | findViewById(R.id.main_warn).setOnClickListener(new View.OnClickListener() { 75 | @Override 76 | public void onClick(View v) { 77 | promptDialog.showWarnAlert("你确定要退出登录?", new PromptButton("取消", new PromptButtonListener() { 78 | @Override 79 | public void onClick(PromptButton button) { 80 | Toast.makeText(MainActivity.this, button.getText(), Toast.LENGTH_SHORT).show(); 81 | } 82 | }), confirm); 83 | } 84 | }); 85 | 86 | findViewById(R.id.main_info).setOnClickListener(new View.OnClickListener() { 87 | @Override 88 | public void onClick(View v) { 89 | promptDialog.showInfo("成功了"); 90 | } 91 | }); 92 | 93 | findViewById(R.id.main_system).setOnClickListener(new View.OnClickListener() { 94 | @Override 95 | public void onClick(View v) { 96 | //可创建android效果的底部Sheet选择,默认IOS效果,sheetCellPad=0为Android效果的Sheet 97 | // promptDialog.getAlertDefaultBuilder().sheetCellPad(0).round(0); 98 | //设置按钮的特点,颜色大小什么的,具体看PromptButton的成员变量 99 | PromptButton cancle = new PromptButton("取消", null); 100 | cancle.setTextColor(Color.parseColor("#0076ff")); 101 | //设置显示的文字大小及颜色 102 | // promptDialog.getAlertDefaultBuilder().textSize(12).textColor(Color.GRAY); 103 | //默认两个按钮为Alert对话框,大于三个按钮的为底部SHeet形式展现 104 | promptDialog.showAlertSheet("", true, cancle, 105 | new PromptButton("选项1", null), new PromptButton("选项2", null), 106 | new PromptButton("选项3", null), new PromptButton("选项4", null)); 107 | 108 | } 109 | }); 110 | findViewById(R.id.main_customer).setOnClickListener(new View.OnClickListener() { 111 | @Override 112 | public void onClick(View v) { 113 | promptDialog.showCustom(R.mipmap.ic_launcher, "自定义图标的"); 114 | } 115 | }); 116 | // u0_a280 8011 2923 1474704 209280 SyS_epoll_ 0000000000 S me.leefeng.beida 117 | 118 | findViewById(R.id.main_ad).setOnClickListener(new View.OnClickListener() { 119 | @Override 120 | public void onClick(View v) { 121 | promptDialog.getDefaultBuilder().backAlpha(150); 122 | Glide.with(MainActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&" + 123 | "size=b9999_10000&sec=1495518782659&di=25b120262114749ae8543652d2de5715&" + 124 | "imgtype=0&src=http%3A%2F%2Fimg.tupianzj.com%2Fuploads%2Fallimg%2F160316%2F9-160316152R5.jpg") 125 | // .placeholder(getResources().getDrawable(R.drawable.ic_prompt_holder)) 126 | .into(promptDialog.showAd(true, new OnAdClickListener() { 127 | @Override 128 | public void onAdClick() { 129 | Toast.makeText(MainActivity.this,"点击了广告",Toast.LENGTH_SHORT).show(); 130 | } 131 | })); 132 | } 133 | }); 134 | 135 | } 136 | 137 | /** 138 | * 根据需要处理返回键,这里主要针对Alert和Sheet的对话框的返回处理 139 | */ 140 | @Override 141 | public void onBackPressed() { 142 | if (promptDialog.onBackPressed()) 143 | super.onBackPressed(); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 19 | 20 |