Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {
url 'https://maven.google.com/'
name 'Google'
}
google()
jcenter()
}
dependencies {
Expand All @@ -18,6 +19,7 @@ buildscript {

allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
Expand Down
14 changes: 7 additions & 7 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand All @@ -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')
}
Binary file removed demo/src/main/ic_launcher-web.png
Binary file not shown.
60 changes: 30 additions & 30 deletions demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 16 additions & 0 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,77 @@
android:id="@+id/indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Indeterminate"/>

<Button
android:id="@+id/label_indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="With label and cancellable"/>

<Button
android:id="@+id/detail_indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="With details"/>

<Button
android:id="@+id/grace_indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="With grace time"/>

<Button
android:id="@+id/determinate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Determinate"/>

<Button
android:id="@+id/annular_determinate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Annular determinate"/>

<Button
android:id="@+id/bar_determinate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Bar determinate"/>

<Button
android:id="@+id/custom_view"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Custom view"/>

<Button
android:id="@+id/dim_background"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Dim background"/>

<Button
android:id="@+id/custom_color_animate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Custom color and speed"/>
<Button
android:id="@+id/custom_lottie"
android:layout_width="match_parent"
android:layout_height="60dp"
android:onClick="onClick"
android:text="Custom lottie"/>
</LinearLayout>
</ScrollView>

1 change: 1 addition & 0 deletions demo/src/main/res/raw/loading.json
Original file line number Diff line number Diff line change
@@ -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}]}
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
# org.gradle.parallel=true

android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=false
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down