From a802e2d7953d526c41175493cd5130cd328b9f36 Mon Sep 17 00:00:00 2001 From: leefneg Date: Mon, 7 Aug 2017 15:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BB=B6=E8=BF=9F=E5=8A=A0?= =?UTF-8?q?=E8=BD=BDloading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .../leefeng/promptlibrary/PromptDialog.java | 50 +++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d19981..fbb6828 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/promptlibrary/src/main/java/me/leefeng/promptlibrary/PromptDialog.java b/promptlibrary/src/main/java/me/leefeng/promptlibrary/PromptDialog.java index cee8797..b188dd7 100644 --- a/promptlibrary/src/main/java/me/leefeng/promptlibrary/PromptDialog.java +++ b/promptlibrary/src/main/java/me/leefeng/promptlibrary/PromptDialog.java @@ -40,6 +40,8 @@ public class PromptDialog { private AnimationSet inDefaultAnim; private AnimationSet outDefaultAnim; private OnAdClickListener adListener; + private Runnable runnable; + private Handler handler; /** * 设置进入 进出动画持续的事件默认300毫秒 @@ -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(); } @@ -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(); } @@ -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(); @@ -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); } @@ -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) { @@ -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); + } }