├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── dialog │ │ └── demo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── dialog │ │ │ └── demo │ │ │ ├── GlobalDialogManager.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.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 │ └── com │ └── dialog │ └── demo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── loading_dialog_lib ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── loading │ │ └── dialog │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── loading │ │ │ └── dialog │ │ │ ├── AndroidLoadingDialog.java │ │ │ └── IOSLoadingDialog.java │ └── res │ │ ├── drawable │ │ ├── anim_run_load.xml │ │ ├── ic_ios_loading.png │ │ ├── shape_base_bg.xml │ │ └── shape_ios_bg.xml │ │ └── layout │ │ ├── android_dialog_loading.xml │ │ └── ios_dialog_loading.xml │ └── test │ └── java │ └── com │ └── loading │ └── dialog │ └── ExampleUnitTest.java ├── preview └── show.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 一、简介 2 | Android普通样式加载框和精仿iOS加载框 3 | 4 | 动图演示如下: 5 | 6 | 动图演示效果 7 | 8 | 9 | ## 二、导入方式 10 | ### 将JitPack存储库添加到您的构建文件中(项目根目录下build.gradle文件) 11 | ``` 12 | allprojects { 13 | repositories { 14 | ... 15 | maven { url 'https://jitpack.io' } 16 | } 17 | } 18 | ``` 19 | 20 | ### 添加依赖项 21 | 仅支持`AndroidX` 22 | ``` 23 | dependencies { 24 | implementation 'com.github.ydstar:loadingdialog:1.0.0' 25 | } 26 | ``` -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.dialog.demo" 9 | minSdkVersion 16 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation 'androidx.appcompat:appcompat:1.1.0' 28 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 29 | testImplementation 'junit:junit:4.12' 30 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 31 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 32 | 33 | implementation project(path: ':loading_dialog_lib') 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/dialog/demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.dialog.demo; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("com.dialog.demo", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/dialog/demo/GlobalDialogManager.java: -------------------------------------------------------------------------------- 1 | package com.dialog.demo; 2 | 3 | import android.app.FragmentManager; 4 | 5 | import com.loading.dialog.AndroidLoadingDialog; 6 | 7 | /** 8 | * Author: Jett 9 | * Date: 2020-04-17 15:17 10 | * Email: hydznsq@163.com 11 | * Des: 12 | */ 13 | public class GlobalDialogManager { 14 | 15 | private AndroidLoadingDialog mLoadingDialog; 16 | private boolean mIsShow;//是否显示 17 | 18 | private GlobalDialogManager() { 19 | init(); 20 | } 21 | 22 | public static GlobalDialogManager getInstance() { 23 | return SingletonHolder.INSTANCE; 24 | } 25 | 26 | private static class SingletonHolder { 27 | private static GlobalDialogManager INSTANCE = new GlobalDialogManager(); 28 | } 29 | 30 | public void init() { 31 | if (mLoadingDialog == null) { 32 | mLoadingDialog = new AndroidLoadingDialog(); 33 | } 34 | } 35 | 36 | /** 37 | * 展示加载框 38 | */ 39 | public synchronized void show(FragmentManager manager) { 40 | if (manager != null && mLoadingDialog != null && !mIsShow) { 41 | mLoadingDialog.showAllowingStateLoss(manager, "loadingDialog"); 42 | mIsShow = true; 43 | } 44 | } 45 | 46 | /** 47 | * 隐藏加载框 48 | */ 49 | public synchronized void dismiss() { 50 | if (mLoadingDialog != null && mIsShow) { 51 | mLoadingDialog.dismissAllowingStateLoss(); 52 | mIsShow = false; 53 | } 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/dialog/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.dialog.demo; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | import android.view.View; 7 | 8 | import com.loading.dialog.AndroidLoadingDialog; 9 | import com.loading.dialog.IOSLoadingDialog; 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | } 18 | 19 | public void showAndroidDialog(View view) { 20 | AndroidLoadingDialog iosLoadingDialog = new AndroidLoadingDialog().setOnTouchOutside(true); 21 | iosLoadingDialog.show(getFragmentManager(), "AndroidLoadingDialog"); 22 | } 23 | 24 | public void showIOSDialog(View view) { 25 | IOSLoadingDialog iosLoadingDialog = new IOSLoadingDialog().setOnTouchOutside(true); 26 | iosLoadingDialog.show(getFragmentManager(), "iosLoadingDialog"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 |