Skip to content

Commit

Permalink
添加延迟加载loading
Browse files Browse the repository at this point in the history
  • Loading branch information
limxing committed Aug 7, 2017
1 parent 4e181d1 commit a802e2d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class PromptDialog {
private AnimationSet inDefaultAnim;
private AnimationSet outDefaultAnim;
private OnAdClickListener adListener;
private Runnable runnable;
private Handler handler;

/**
* 设置进入 进出动画持续的事件默认300毫秒
Expand Down Expand Up @@ -70,6 +72,7 @@ public PromptDialog(Builder builder, Activity context) {
initAnim(context.getResources().getDisplayMetrics().widthPixels,
context.getResources().getDisplayMetrics().heightPixels);
inputmanger = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
handler = new Handler();
}


Expand Down Expand Up @@ -145,7 +148,7 @@ public void dismiss() {
} else {
outAnim.setStartOffset(0);
}
if (promptView.getCurrentType() == PromptView.CUSTOMER_LOADING){
if (promptView.getCurrentType() == PromptView.CUSTOMER_LOADING) {
promptView.stopCustomerLoading();
}

Expand Down Expand Up @@ -300,8 +303,8 @@ private void showAlert(String text, boolean withAnim, PromptButton... button) {

}

public ImageView showAd(boolean withAnim,OnAdClickListener listener) {
this.adListener=listener;
public ImageView showAd(boolean withAnim, OnAdClickListener listener) {
this.adListener = listener;
inAnim = inSheetAnim;
outAnim = outSheetAnim;
Builder builder = Builder.getDefaultBuilder();
Expand Down Expand Up @@ -340,8 +343,28 @@ public void showLoading(String msg, boolean withAnim) {
}
}

/**
* 展示加载中
*
* @param msg
*/
public void showLoading(String msg) {
showLoading(msg, true);
}

/** 延迟展示loading
* @param msg
* @param time
*/
public void showLoadingWithDelay(final String msg, long time) {
if (runnable != null) handler.removeCallbacks(runnable);
runnable = new Runnable() {
@Override
public void run() {
showLoading(msg);
}
};
handler.postDelayed(runnable, time);

}

Expand Down Expand Up @@ -450,10 +473,12 @@ public void onAdClick() {
adListener.onAdClick();
}
}

/**
* 加载自定义的loading
*
* @param logo_loading 图片数组
* @param msg 展现消息
* @param msg 展现消息
*/
public void showCustomLoading(int logo_loading, String msg) {

Expand All @@ -473,4 +498,21 @@ public void showCustomLoading(int logo_loading, String msg) {
}

}

/**
* 延迟加载自定义loading
*
* @param logo_loading
* @param msg
* @param time
*/
public void showCustomerLoadingWithDelay(final int logo_loading, final String msg, long time) {
runnable = new Runnable() {
@Override
public void run() {
showCustomLoading(logo_loading, msg);
}
};
handler.postDelayed(runnable, time);
}
}

0 comments on commit a802e2d

Please sign in to comment.