├── settings.gradle ├── gradle.properties ├── app ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── drawable │ │ │ ├── logo_big.png │ │ │ ├── custom_img.jpg │ │ │ └── ic_launcher_background.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 │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── layout │ │ │ └── sample_activity.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── cazaea │ │ └── sweetalert │ │ └── sample │ │ └── SampleActivity.java ├── .gitignore ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── library ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ ├── values │ │ │ ├── dimen.xml │ │ │ ├── strings.xml │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── drawable │ │ │ ├── dialog_background.xml │ │ │ ├── error_circle.xml │ │ │ ├── success_bow.xml │ │ │ ├── warning_circle.xml │ │ │ ├── success_circle.xml │ │ │ ├── red_button_background.xml │ │ │ ├── blue_button_background.xml │ │ │ ├── gray_button_background.xml │ │ │ ├── warning_sigh.xml │ │ │ └── error_center_x.xml │ │ ├── anim │ │ │ ├── success_bow_roate.xml │ │ │ ├── success_mask_layout.xml │ │ │ ├── modal_out.xml │ │ │ ├── error_frame_in.xml │ │ │ ├── error_x_in.xml │ │ │ └── modal_in.xml │ │ └── layout │ │ │ └── alert_dialog.xml │ │ └── java │ │ └── com │ │ └── cazaea │ │ └── sweetalert │ │ ├── OptAnimationLoader.java │ │ ├── ProgressHelper.java │ │ ├── SuccessTickView.java │ │ ├── Rotate3dAnimation.java │ │ └── SweetAlertDialog.java ├── .gitignore ├── proguard-rules.pro └── build.gradle ├── .idea ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── .gitignore ├── gradlew.bat ├── gradlew ├── README.zh.md └── README.md /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/gradle.properties -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | sweet-alert-dialog 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/drawable/logo_big.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/custom_img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/drawable/custom_img.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 290dp 4 | 3dp 5 | 34dp 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dialog_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Nov 17 16:27:54 CST 2017 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-4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | Here\'s a message! 4 | OK 5 | Cancel 6 | Loading... 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/error_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/success_bow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/warning_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/success_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/anim/success_bow_roate.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /library/src/main/res/anim/success_mask_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 18 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/red_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/blue_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/gray_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /library/src/main/res/anim/modal_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 14 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/libraries 39 | 40 | # Keystore files 41 | *.jks 42 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/libraries 39 | 40 | # Keystore files 41 | *.jks 42 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/libraries 39 | 40 | # Keystore files 41 | *.jks 42 | -------------------------------------------------------------------------------- /library/src/main/res/anim/error_frame_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | 13 | 20 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/warning_sigh.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /library/src/main/res/anim/error_x_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 12 | 13 | 22 | 23 | 32 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | 6 | defaultConfig { 7 | applicationId "com.cazaea.sweetalert.sample" 8 | minSdkVersion 19 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(include: ['*.jar'], dir: 'libs') 25 | implementation 'com.android.support:appcompat-v7:26.1.0' 26 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 27 | testImplementation 'junit:junit:4.12' 28 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 30 | // 加入依赖 31 | implementation project(path: ':library') 32 | } 33 | -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00000000 4 | #FFFFFF 5 | #FFFFFF 6 | #D0D0D0 7 | #B6B6B6 8 | #AEDEF4 9 | #96BFD2 10 | #DD6B55 11 | #CD5B55 12 | #F27474 13 | #A5DC86 14 | #33A5DC86 15 | #F8BB86 16 | #575757 17 | #ff37474f 18 | #ff263238 19 | #ff21272b 20 | #ff80cbc4 21 | #ff009688 22 | -------------------------------------------------------------------------------- /library/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 24 | -------------------------------------------------------------------------------- /library/src/main/res/anim/modal_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 10 | 11 | 19 | 20 | 29 | 30 | 39 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/error_center_x.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | android { 5 | compileSdkVersion 26 6 | 7 | defaultConfig { 8 | minSdkVersion 9 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | /** 22 | * 以下为配置library注释在打包jar后保留 23 | */ 24 | // 打包源码jar 25 | task sourcesJar(type: Jar) { 26 | from android.sourceSets.main.java.srcDirs 27 | classifier = 'sources' 28 | } 29 | task javadoc(type: Javadoc) { 30 | failOnError false 31 | source = android.sourceSets.main.java.sourceFiles 32 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 33 | classpath += configurations.compile 34 | } 35 | // 打包文档jar 36 | task javadocJar(type: Jar, dependsOn: javadoc) { 37 | classifier = 'javadoc' 38 | from javadoc.destinationDir 39 | } 40 | artifacts { 41 | archives sourcesJar 42 | archives javadocJar 43 | } 44 | 45 | } 46 | 47 | dependencies { 48 | implementation fileTree(dir: 'libs', include: ['*.jar']) 49 | // 加入自己的依赖包 50 | implementation 'com.github.cazaea:materialish-progress:1.0.2' 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 1.8 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /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/src/main/java/com/cazaea/sweetalert/OptAnimationLoader.java: -------------------------------------------------------------------------------- 1 | package com.cazaea.sweetalert; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.content.res.XmlResourceParser; 6 | import android.util.AttributeSet; 7 | import android.util.Xml; 8 | import android.view.animation.*; 9 | import org.xmlpull.v1.XmlPullParser; 10 | import org.xmlpull.v1.XmlPullParserException; 11 | 12 | import java.io.IOException; 13 | 14 | public class OptAnimationLoader { 15 | 16 | public static Animation loadAnimation(Context context, int id) 17 | throws Resources.NotFoundException { 18 | 19 | XmlResourceParser parser = null; 20 | try { 21 | parser = context.getResources().getAnimation(id); 22 | return createAnimationFromXml(context, parser); 23 | } catch (XmlPullParserException ex) { 24 | Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + 25 | Integer.toHexString(id)); 26 | rnf.initCause(ex); 27 | throw rnf; 28 | } catch (IOException ex) { 29 | Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + 30 | Integer.toHexString(id)); 31 | rnf.initCause(ex); 32 | throw rnf; 33 | } finally { 34 | if (parser != null) parser.close(); 35 | } 36 | } 37 | 38 | private static Animation createAnimationFromXml(Context c, XmlPullParser parser) 39 | throws XmlPullParserException, IOException { 40 | 41 | return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser)); 42 | } 43 | 44 | private static Animation createAnimationFromXml(Context c, XmlPullParser parser, 45 | AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { 46 | 47 | Animation anim = null; 48 | 49 | // Make sure we are on a start tag. 50 | int type; 51 | int depth = parser.getDepth(); 52 | 53 | while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) 54 | && type != XmlPullParser.END_DOCUMENT) { 55 | 56 | if (type != XmlPullParser.START_TAG) { 57 | continue; 58 | } 59 | 60 | String name = parser.getName(); 61 | 62 | if (name.equals("set")) { 63 | anim = new AnimationSet(c, attrs); 64 | createAnimationFromXml(c, parser, (AnimationSet)anim, attrs); 65 | } else if (name.equals("alpha")) { 66 | anim = new AlphaAnimation(c, attrs); 67 | } else if (name.equals("scale")) { 68 | anim = new ScaleAnimation(c, attrs); 69 | } else if (name.equals("rotate")) { 70 | anim = new RotateAnimation(c, attrs); 71 | } else if (name.equals("translate")) { 72 | anim = new TranslateAnimation(c, attrs); 73 | } else { 74 | try { 75 | anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs); 76 | } catch (Exception te) { 77 | throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage()); 78 | } 79 | } 80 | 81 | if (parent != null) { 82 | parent.addAnimation(anim); 83 | } 84 | } 85 | 86 | return anim; 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /library/src/main/java/com/cazaea/sweetalert/ProgressHelper.java: -------------------------------------------------------------------------------- 1 | package com.cazaea.sweetalert; 2 | 3 | import android.content.Context; 4 | 5 | import com.cazaea.materialishprogress.ProgressWheel; 6 | 7 | public class ProgressHelper { 8 | private ProgressWheel mProgressWheel; 9 | private boolean mToSpin; 10 | private float mSpinSpeed; 11 | private int mBarWidth; 12 | private int mBarColor; 13 | private int mRimWidth; 14 | private int mRimColor; 15 | private boolean mIsInstantProgress; 16 | private float mProgressVal; 17 | private int mCircleRadius; 18 | 19 | public ProgressHelper(Context ctx) { 20 | mToSpin = true; 21 | mSpinSpeed = 0.75f; 22 | mBarWidth = ctx.getResources().getDimensionPixelSize(R.dimen.common_circle_width) + 1; 23 | mBarColor = ctx.getResources().getColor(R.color.success_stroke_color); 24 | mRimWidth = 0; 25 | mRimColor = 0x00000000; 26 | mIsInstantProgress = false; 27 | mProgressVal = -1; 28 | mCircleRadius = ctx.getResources().getDimensionPixelOffset(R.dimen.progress_circle_radius); 29 | } 30 | 31 | public ProgressWheel getProgressWheel () { 32 | return mProgressWheel; 33 | } 34 | 35 | public void setProgressWheel (ProgressWheel progressWheel) { 36 | mProgressWheel = progressWheel; 37 | updatePropsIfNeed(); 38 | } 39 | 40 | private void updatePropsIfNeed () { 41 | if (mProgressWheel != null) { 42 | if (!mToSpin && mProgressWheel.isSpinning()) { 43 | mProgressWheel.stopSpinning(); 44 | } else if (mToSpin && !mProgressWheel.isSpinning()) { 45 | mProgressWheel.spin(); 46 | } 47 | if (mSpinSpeed != mProgressWheel.getSpinSpeed()) { 48 | mProgressWheel.setSpinSpeed(mSpinSpeed); 49 | } 50 | if (mBarWidth != mProgressWheel.getBarWidth()) { 51 | mProgressWheel.setBarWidth(mBarWidth); 52 | } 53 | if (mBarColor != mProgressWheel.getBarColor()) { 54 | mProgressWheel.setBarColor(mBarColor); 55 | } 56 | if (mRimWidth != mProgressWheel.getRimWidth()) { 57 | mProgressWheel.setRimWidth(mRimWidth); 58 | } 59 | if (mRimColor != mProgressWheel.getRimColor()) { 60 | mProgressWheel.setRimColor(mRimColor); 61 | } 62 | if (mProgressVal != mProgressWheel.getProgress()) { 63 | if (mIsInstantProgress) { 64 | mProgressWheel.setInstantProgress(mProgressVal); 65 | } else { 66 | mProgressWheel.setProgress(mProgressVal); 67 | } 68 | } 69 | if (mCircleRadius != mProgressWheel.getCircleRadius()) { 70 | mProgressWheel.setCircleRadius(mCircleRadius); 71 | } 72 | } 73 | } 74 | 75 | public void resetCount() { 76 | if (mProgressWheel != null) { 77 | mProgressWheel.resetCount(); 78 | } 79 | } 80 | 81 | public boolean isSpinning() { 82 | return mToSpin; 83 | } 84 | 85 | public void spin() { 86 | mToSpin = true; 87 | updatePropsIfNeed(); 88 | } 89 | 90 | public void stopSpinning() { 91 | mToSpin = false; 92 | updatePropsIfNeed(); 93 | } 94 | 95 | public float getProgress() { 96 | return mProgressVal; 97 | } 98 | 99 | public void setProgress(float progress) { 100 | mIsInstantProgress = false; 101 | mProgressVal = progress; 102 | updatePropsIfNeed(); 103 | } 104 | 105 | public void setInstantProgress(float progress) { 106 | mProgressVal = progress; 107 | mIsInstantProgress = true; 108 | updatePropsIfNeed(); 109 | } 110 | 111 | public int getCircleRadius() { 112 | return mCircleRadius; 113 | } 114 | 115 | /** 116 | * @param circleRadius units using pixel 117 | * **/ 118 | public void setCircleRadius(int circleRadius) { 119 | mCircleRadius = circleRadius; 120 | updatePropsIfNeed(); 121 | } 122 | 123 | public int getBarWidth() { 124 | return mBarWidth; 125 | } 126 | 127 | public void setBarWidth(int barWidth) { 128 | mBarWidth = barWidth; 129 | updatePropsIfNeed(); 130 | } 131 | 132 | public int getBarColor() { 133 | return mBarColor; 134 | } 135 | 136 | public void setBarColor(int barColor) { 137 | mBarColor = barColor; 138 | updatePropsIfNeed(); 139 | } 140 | 141 | public int getRimWidth() { 142 | return mRimWidth; 143 | } 144 | 145 | public void setRimWidth(int rimWidth) { 146 | mRimWidth = rimWidth; 147 | updatePropsIfNeed(); 148 | } 149 | 150 | public int getRimColor() { 151 | return mRimColor; 152 | } 153 | 154 | public void setRimColor(int rimColor) { 155 | mRimColor = rimColor; 156 | updatePropsIfNeed(); 157 | } 158 | 159 | public float getSpinSpeed() { 160 | return mSpinSpeed; 161 | } 162 | 163 | public void setSpinSpeed(float spinSpeed) { 164 | mSpinSpeed = spinSpeed; 165 | updatePropsIfNeed(); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /library/src/main/java/com/cazaea/sweetalert/SuccessTickView.java: -------------------------------------------------------------------------------- 1 | package com.cazaea.sweetalert; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.RectF; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | import android.view.animation.Animation; 10 | import android.view.animation.Transformation; 11 | 12 | public class SuccessTickView extends View { 13 | private float mDensity = -1; 14 | private Paint mPaint; 15 | private final float CONST_RADIUS = dip2px(1.2f); 16 | private final float CONST_RECT_WEIGHT = dip2px(3); 17 | private final float CONST_LEFT_RECT_W = dip2px(15); 18 | private final float CONST_RIGHT_RECT_W = dip2px(25); 19 | private final float MIN_LEFT_RECT_W = dip2px(3.3f); 20 | private final float MAX_RIGHT_RECT_W = CONST_RIGHT_RECT_W + dip2px(6.7f); 21 | 22 | private float mMaxLeftRectWidth; 23 | private float mLeftRectWidth; 24 | private float mRightRectWidth; 25 | private boolean mLeftRectGrowMode; 26 | 27 | public SuccessTickView(Context context) { 28 | super(context); 29 | init(); 30 | } 31 | 32 | public SuccessTickView(Context context, AttributeSet attrs){ 33 | super(context,attrs); 34 | init(); 35 | } 36 | 37 | private void init () { 38 | mPaint = new Paint(); 39 | mPaint.setColor(getResources().getColor(R.color.success_stroke_color)); 40 | mLeftRectWidth = CONST_LEFT_RECT_W; 41 | mRightRectWidth = CONST_RIGHT_RECT_W; 42 | mLeftRectGrowMode = false; 43 | } 44 | 45 | @Override 46 | public void draw(Canvas canvas) { 47 | super.draw(canvas); 48 | int totalW = getWidth(); 49 | int totalH = getHeight(); 50 | // rotate canvas first 51 | canvas.rotate(45, totalW / 2, totalH / 2); 52 | 53 | totalW /= 1.2; 54 | totalH /= 1.4; 55 | mMaxLeftRectWidth = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1; 56 | 57 | RectF leftRect = new RectF(); 58 | if (mLeftRectGrowMode) { 59 | leftRect.left = 0; 60 | leftRect.right = leftRect.left + mLeftRectWidth; 61 | leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2; 62 | leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT; 63 | } else { 64 | leftRect.right = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1; 65 | leftRect.left = leftRect.right - mLeftRectWidth; 66 | leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2; 67 | leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT; 68 | } 69 | 70 | canvas.drawRoundRect(leftRect, CONST_RADIUS, CONST_RADIUS, mPaint); 71 | 72 | RectF rightRect = new RectF(); 73 | rightRect.bottom = (totalH + CONST_RIGHT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1; 74 | rightRect.left = (totalW + CONST_LEFT_RECT_W) / 2; 75 | rightRect.right = rightRect.left + CONST_RECT_WEIGHT; 76 | rightRect.top = rightRect.bottom - mRightRectWidth; 77 | canvas.drawRoundRect(rightRect, CONST_RADIUS, CONST_RADIUS, mPaint); 78 | } 79 | 80 | public float dip2px(float dpValue) { 81 | if(mDensity == -1) { 82 | mDensity = getResources().getDisplayMetrics().density; 83 | } 84 | return dpValue * mDensity + 0.5f; 85 | } 86 | 87 | public void startTickAnim () { 88 | // hide tick 89 | mLeftRectWidth = 0; 90 | mRightRectWidth = 0; 91 | invalidate(); 92 | Animation tickAnim = new Animation() { 93 | @Override 94 | protected void applyTransformation(float interpolatedTime, Transformation t) { 95 | super.applyTransformation(interpolatedTime, t); 96 | if (0.54 < interpolatedTime && 0.7 >= interpolatedTime) { // grow left and right rect to right 97 | mLeftRectGrowMode = true; 98 | mLeftRectWidth = mMaxLeftRectWidth * ((interpolatedTime - 0.54f) / 0.16f); 99 | if (0.65 < interpolatedTime) { 100 | mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f); 101 | } 102 | invalidate(); 103 | } else if (0.7 < interpolatedTime && 0.84 >= interpolatedTime) { // shorten left rect from right, still grow right rect 104 | mLeftRectGrowMode = false; 105 | mLeftRectWidth = mMaxLeftRectWidth * (1 - ((interpolatedTime - 0.7f) / 0.14f)); 106 | mLeftRectWidth = mLeftRectWidth < MIN_LEFT_RECT_W ? MIN_LEFT_RECT_W : mLeftRectWidth; 107 | mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f); 108 | invalidate(); 109 | } else if (0.84 < interpolatedTime && 1 >= interpolatedTime) { // restore left rect width, shorten right rect to const 110 | mLeftRectGrowMode = false; 111 | mLeftRectWidth = MIN_LEFT_RECT_W + (CONST_LEFT_RECT_W - MIN_LEFT_RECT_W) * ((interpolatedTime - 0.84f) / 0.16f); 112 | mRightRectWidth = CONST_RIGHT_RECT_W + (MAX_RIGHT_RECT_W - CONST_RIGHT_RECT_W) * (1 - ((interpolatedTime - 0.84f) / 0.16f)); 113 | invalidate(); 114 | } 115 | } 116 | }; 117 | tickAnim.setDuration(750); 118 | tickAnim.setStartOffset(100); 119 | startAnimation(tickAnim); 120 | } 121 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /library/src/main/java/com/cazaea/sweetalert/Rotate3dAnimation.java: -------------------------------------------------------------------------------- 1 | package com.cazaea.sweetalert; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Camera; 6 | import android.graphics.Matrix; 7 | import android.util.AttributeSet; 8 | import android.util.TypedValue; 9 | import android.view.animation.Animation; 10 | import android.view.animation.Transformation; 11 | 12 | public class Rotate3dAnimation extends Animation { 13 | private int mPivotXType = ABSOLUTE; 14 | private int mPivotYType = ABSOLUTE; 15 | private float mPivotXValue = 0.0f; 16 | private float mPivotYValue = 0.0f; 17 | 18 | private float mFromDegrees; 19 | private float mToDegrees; 20 | private float mPivotX; 21 | private float mPivotY; 22 | private Camera mCamera; 23 | private int mRollType; 24 | 25 | public static final int ROLL_BY_X = 0; 26 | public static final int ROLL_BY_Y = 1; 27 | public static final int ROLL_BY_Z = 2; 28 | 29 | protected static class Description { 30 | public int type; 31 | public float value; 32 | } 33 | 34 | Description parseValue(TypedValue value) { 35 | Description d = new Description(); 36 | if (value == null) { 37 | d.type = ABSOLUTE; 38 | d.value = 0; 39 | } else { 40 | if (value.type == TypedValue.TYPE_FRACTION) { 41 | d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) == 42 | TypedValue.COMPLEX_UNIT_FRACTION_PARENT ? 43 | RELATIVE_TO_PARENT : RELATIVE_TO_SELF; 44 | d.value = TypedValue.complexToFloat(value.data); 45 | return d; 46 | } else if (value.type == TypedValue.TYPE_FLOAT) { 47 | d.type = ABSOLUTE; 48 | d.value = value.getFloat(); 49 | return d; 50 | } else if (value.type >= TypedValue.TYPE_FIRST_INT && 51 | value.type <= TypedValue.TYPE_LAST_INT) { 52 | d.type = ABSOLUTE; 53 | d.value = value.data; 54 | return d; 55 | } 56 | } 57 | 58 | d.type = ABSOLUTE; 59 | d.value = 0.0f; 60 | 61 | return d; 62 | } 63 | 64 | public Rotate3dAnimation (Context context, AttributeSet attrs) { 65 | super(context, attrs); 66 | 67 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Rotate3dAnimation); 68 | 69 | mFromDegrees = a.getFloat(R.styleable.Rotate3dAnimation_fromDeg, 0.0f); 70 | mToDegrees = a.getFloat(R.styleable.Rotate3dAnimation_toDeg, 0.0f); 71 | mRollType = a.getInt(R.styleable.Rotate3dAnimation_rollType, ROLL_BY_X); 72 | Description d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotX)); 73 | mPivotXType = d.type; 74 | mPivotXValue = d.value; 75 | 76 | d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotY)); 77 | mPivotYType = d.type; 78 | mPivotYValue = d.value; 79 | 80 | a.recycle(); 81 | 82 | initializePivotPoint(); 83 | } 84 | 85 | public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees) { 86 | mRollType = rollType; 87 | mFromDegrees = fromDegrees; 88 | mToDegrees = toDegrees; 89 | mPivotX = 0.0f; 90 | mPivotY = 0.0f; 91 | } 92 | 93 | public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees, float pivotX, float pivotY) { 94 | mRollType = rollType; 95 | mFromDegrees = fromDegrees; 96 | mToDegrees = toDegrees; 97 | 98 | mPivotXType = ABSOLUTE; 99 | mPivotYType = ABSOLUTE; 100 | mPivotXValue = pivotX; 101 | mPivotYValue = pivotY; 102 | initializePivotPoint(); 103 | } 104 | 105 | public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) { 106 | mRollType = rollType; 107 | mFromDegrees = fromDegrees; 108 | mToDegrees = toDegrees; 109 | 110 | mPivotXValue = pivotXValue; 111 | mPivotXType = pivotXType; 112 | mPivotYValue = pivotYValue; 113 | mPivotYType = pivotYType; 114 | initializePivotPoint(); 115 | } 116 | 117 | private void initializePivotPoint() { 118 | if (mPivotXType == ABSOLUTE) { 119 | mPivotX = mPivotXValue; 120 | } 121 | if (mPivotYType == ABSOLUTE) { 122 | mPivotY = mPivotYValue; 123 | } 124 | } 125 | 126 | @Override 127 | public void initialize(int width, int height, int parentWidth, int parentHeight) { 128 | super.initialize(width, height, parentWidth, parentHeight); 129 | mCamera = new Camera(); 130 | mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth); 131 | mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight); 132 | } 133 | 134 | @Override 135 | protected void applyTransformation(float interpolatedTime, Transformation t) { 136 | final float fromDegrees = mFromDegrees; 137 | float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); 138 | 139 | final Matrix matrix = t.getMatrix(); 140 | 141 | mCamera.save(); 142 | switch (mRollType) { 143 | case ROLL_BY_X: 144 | mCamera.rotateX(degrees); 145 | break; 146 | case ROLL_BY_Y: 147 | mCamera.rotateY(degrees); 148 | break; 149 | case ROLL_BY_Z: 150 | mCamera.rotateZ(degrees); 151 | break; 152 | } 153 | mCamera.getMatrix(matrix); 154 | mCamera.restore(); 155 | 156 | matrix.preTranslate(-mPivotX, -mPivotY); 157 | matrix.postTranslate(mPivotX, mPivotY); 158 | } 159 | } -------------------------------------------------------------------------------- /library/src/main/res/layout/alert_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 21 | 22 | 28 | 29 | 33 | 34 | 41 | 42 | 43 | 44 | 50 | 51 | 55 | 56 | 63 | 64 | 71 | 72 | 76 | 77 | 81 | 82 | 83 | 84 | 90 | 91 | 95 | 96 | 102 | 103 | 104 | 112 | 113 | 119 | 120 | 121 | 130 | 131 | 141 | 142 | 147 | 148 |