diff --git a/build.gradle b/build.gradle
index 239d0f5..b5172bf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,6 +6,7 @@ buildscript {
url 'https://maven.google.com/'
name 'Google'
}
+ google()
jcenter()
}
dependencies {
@@ -18,6 +19,7 @@ buildscript {
allprojects {
repositories {
+ google()
maven {
url 'https://maven.google.com/'
name 'Google'
diff --git a/demo/build.gradle b/demo/build.gradle
index 2ad753c..dc1ac43 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 26
- buildToolsVersion '27.0.3'
+ compileSdkVersion 28
defaultConfig {
applicationId "com.kaopiz.progresshud"
- minSdkVersion 14
- targetSdkVersion 26
+ minSdkVersion 16
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
}
@@ -23,8 +22,9 @@ android {
}
dependencies {
- api fileTree(include: ['*.jar'], dir: 'libs')
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
- api 'com.android.support:appcompat-v7:26.1.0'
- api project(':kprogresshud')
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'com.airbnb.android:lottie:3.4.0'
+ implementation project(':kprogresshud')
}
diff --git a/demo/src/main/ic_launcher-web.png b/demo/src/main/ic_launcher-web.png
deleted file mode 100644
index 9cff55e..0000000
Binary files a/demo/src/main/ic_launcher-web.png and /dev/null differ
diff --git a/demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java b/demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java
index f3c2248..c246321 100644
--- a/demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java
+++ b/demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java
@@ -26,12 +26,14 @@
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
-import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.airbnb.lottie.LottieAnimationView;
import com.kaopiz.kprogresshud.KProgressHUD;
import com.kaopiz.progresshud.R;
@@ -42,35 +44,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- Button indeterminate = (Button) findViewById(R.id.indeterminate);
- indeterminate.setOnClickListener(this);
-
- Button labelIndeterminate = (Button) findViewById(R.id.label_indeterminate);
- labelIndeterminate.setOnClickListener(this);
-
- Button detailIndeterminate = (Button) findViewById(R.id.detail_indeterminate);
- detailIndeterminate.setOnClickListener(this);
-
- Button graceIndeterminate = (Button) findViewById(R.id.grace_indeterminate);
- graceIndeterminate.setOnClickListener(this);
-
- Button determinate = (Button) findViewById(R.id.determinate);
- determinate.setOnClickListener(this);
-
- Button annularDeterminate = (Button) findViewById(R.id.annular_determinate);
- annularDeterminate.setOnClickListener(this);
-
- Button barDeterminate = (Button) findViewById(R.id.bar_determinate);
- barDeterminate.setOnClickListener(this);
-
- Button customView = (Button) findViewById(R.id.custom_view);
- customView.setOnClickListener(this);
-
- Button dimBackground = (Button) findViewById(R.id.dim_background);
- dimBackground.setOnClickListener(this);
-
- Button customColor = (Button) findViewById(R.id.custom_color_animate);
- customColor.setOnClickListener(this);
}
private KProgressHUD hud;
@@ -156,6 +129,33 @@ public void onClick(View v) {
.setAnimationSpeed(2);
scheduleDismiss();
break;
+ case R.id.custom_lottie:
+ final LottieAnimationView lottie = new LottieAnimationView(this);
+ lottie.setAnimation(R.raw.loading);
+ //得到总大小 目前是1.0
+ lottie.getScale();
+ //控制大小
+ lottie.setScale(0.5f);
+ hud = KProgressHUD.create(this)
+ .setCustomView(lottie)
+ .setShowlable(new DialogInterface.OnShowListener() {
+ @Override
+ public void onShow(DialogInterface dialog) {
+ lottie.playAnimation();
+ }
+ })
+ .setCancellable(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ lottie.setProgress(0.0f);
+ lottie.cancelAnimation();
+ }
+ })
+ ;
+ scheduleDismiss();
+ break;
+ default:
+ break;
}
hud.show();
diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml
index 21458f1..bcf09b6 100644
--- a/demo/src/main/res/layout/activity_main.xml
+++ b/demo/src/main/res/layout/activity_main.xml
@@ -19,61 +19,77 @@
android:id="@+id/indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
+ android:onClick="onClick"
android:text="Indeterminate"/>
+
diff --git a/demo/src/main/res/raw/loading.json b/demo/src/main/res/raw/loading.json
new file mode 100644
index 0000000..cafcccf
--- /dev/null
+++ b/demo/src/main/res/raw/loading.json
@@ -0,0 +1 @@
+{"v":"4.6.8","fr":29.9700012207031,"ip":0,"op":40.0000016292334,"w":256,"h":256,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 3","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":20,"s":[208.6,127.969,0],"e":[208.6,88,0],"to":[0,-6.66145849227905,0],"ti":[0,-0.00520833348855,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":30,"s":[208.6,88,0],"e":[208.6,128,0],"to":[0,0.00520833348855,0],"ti":[0,-6.66666650772095,0]},{"t":40.0000016292334}]},"a":{"a":0,"k":[-70,-0.5,0]},"s":{"a":0,"k":[75,75,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[33.75,34.5]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"fl","c":{"a":0,"k":[0.9843137,0.5490196,0,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-70.125,-0.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":300.00001221925,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 2","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":15,"s":[168.6,128,0],"e":[168.6,88,0],"to":[0,-6.66666650772095,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":25,"s":[168.6,88,0],"e":[168.6,128,0],"to":[0,0,0],"ti":[0,-6.66666650772095,0]},{"t":35.0000014255792}]},"a":{"a":0,"k":[-70,-0.5,0]},"s":{"a":0,"k":[75,75,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[33.75,34.5]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"fl","c":{"a":0,"k":[0.9921569,0.8470588,0.2078431,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-70.125,-0.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":300.00001221925,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":10,"s":[128.594,127.969,0],"e":[128.594,88,0],"to":[0,-6.66145849227905,0],"ti":[0,-0.00520833348855,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":20,"s":[128.594,88,0],"e":[128.594,128,0],"to":[0,0.00520833348855,0],"ti":[0,-6.66666650772095,0]},{"t":30.0000012219251}]},"a":{"a":0,"k":[-70,-0.5,0]},"s":{"a":0,"k":[75,75,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[33.75,34.5]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"fl","c":{"a":0,"k":[0.2627451,0.627451,0.2784314,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-70.125,-0.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":300.00001221925,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":4,"nm":"Shape Layer 4","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":5,"s":[88.6,127.969,0],"e":[88.6,88,0],"to":[0,-6.66145849227905,0],"ti":[0,-0.00520833348855,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":15,"s":[88.6,88,0],"e":[88.6,128,0],"to":[0,0.00520833348855,0],"ti":[0,-6.66666650772095,0]},{"t":25.0000010182709}]},"a":{"a":0,"k":[-70,-0.5,0]},"s":{"a":0,"k":[75,75,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[33.75,34.5]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"fl","c":{"a":0,"k":[0.1176471,0.5333334,0.8980392,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-70.125,-0.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":300.00001221925,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":5,"ty":4,"nm":"Shape Layer 5","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":0,"s":[48.6,127.969,0],"e":[48.6,88,0],"to":[0,-6.66145849227905,0],"ti":[0,-0.00520833348855,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":10,"s":[48.6,88,0],"e":[48.6,128,0],"to":[0,0.00520833348855,0],"ti":[0,-6.66666650772095,0]},{"t":20.0000008146167}]},"a":{"a":0,"k":[-70,-0.5,0]},"s":{"a":0,"k":[75,75,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[33.75,34.5]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"fl","c":{"a":0,"k":[0.8980392,0.2235294,0.2078431,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-70.125,-0.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":300.00001221925,"st":0,"bm":0,"sr":1}]}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 1d3591c..bb08e5c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,4 +15,8 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# org.gradle.parallel=true
+
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=false
\ No newline at end of file
diff --git a/kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java b/kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java
index 0576c74..86041ef 100644
--- a/kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java
+++ b/kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java
@@ -276,6 +276,19 @@ public KProgressHUD setCancellable(DialogInterface.OnCancelListener listener) {
mProgressDialog.setOnCancelListener(listener);
return this;
}
+ /**
+ * Specify a callback to run when using the show button (default is null)
+ *
+ * @param listener The code that will run if the user presses the back
+ * button. If you pass null, the dialog won't be cancellable, just like
+ * if you had called {@link #setCancellable(boolean)} passing false.
+ *
+ * @return Current HUD
+ */
+ public KProgressHUD setShowlable(DialogInterface.OnShowListener listener) {
+ mProgressDialog.setOnShowListener(listener);
+ return this;
+ }
/**
* Specify whether this HUD closes itself if progress reaches max. Default is true.