From 4e4b5f90bbc0630f9f9998677494e9eab05bc88b Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 21 Sep 2023 11:14:01 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=87=8D=E5=A4=8D=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/manager/OpenAdManager.java | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java index d5a24c3a7..4003b6a17 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -49,13 +49,21 @@ public class OpenAdManager { } private void init(boolean isShow) { + if (list != null && list.isEmpty()) { + return; + } LiveNetManager.get(CommonAppContext.getTopActivity()) .activityPopup(new HttpCallback>() { @Override public void onSuccess(List data) { + if (data == null || data.isEmpty()) { + Log.i(TAG, "onSuccess: 没有数据"); + list = new ArrayList<>(); + return; + } list = data; if (isShow) { - show(TYPE_HOME,false); + show(TYPE_HOME, false); } } @@ -67,31 +75,31 @@ public class OpenAdManager { } - public synchronized void show(int type,boolean isGuard) { - if (list==null) { + public synchronized void show(int type, boolean isGuard) { + if (list == null) { init(true); return; } - showType=type; + showType = type; for (OpenAdModel model : list) { if (model.getType() == type) { - if(type==OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)){ + if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) { continue; } if (runnableMap.containsKey(model.getId())) { AdRunnable runnable = runnableMap.get(model.getId()); if (runnable != null) { - Log.d(TAG, "reset: "+model); + Log.d(TAG, "reset: " + model); handler.removeCallbacks(runnable); runnableMap.remove(model.getId()); } } if (!isShow(model)) { - Log.i(TAG, "show: "+model); + Log.i(TAG, "show: " + model); handler.postDelayed(new AdRunnable(model), model.getDelayShowTime()); - }else{ - Log.i(TAG, "notshow: "+model); + } else { + Log.i(TAG, "notshow: " + model); } } @@ -101,10 +109,10 @@ public class OpenAdManager { } public synchronized void dismiss() { - Log.d(TAG, "准备dismiss:"+runnableMap.size() ); + Log.d(TAG, "准备dismiss:" + runnableMap.size()); for (Integer model : runnableMap.keySet()) { AdRunnable runnable = runnableMap.get(model); - Log.d(TAG, "dismiss:"+runnable); + Log.d(TAG, "dismiss:" + runnable); if (runnable != null) { runnable.dismiss(); handler.removeCallbacks(runnable); @@ -127,13 +135,14 @@ public class OpenAdManager { this.model = model; runnableMap.put(model.getId(), this); } - public void dismiss(){ - Log.e(TAG, "dismiss: "+model ); + + public void dismiss() { + Log.e(TAG, "dismiss: " + model); } @Override public synchronized void run() { - Log.i(TAG, "run: "+model); + Log.i(TAG, "run: " + model); if (model == null) { ToastUtil.showDebug("model为空"); return; @@ -146,7 +155,7 @@ public class OpenAdManager { ToastUtil.showDebug(model.getId() + "|model展示过了"); return; } - if(model.getType()!=showType){ + if (model.getType() != showType) { return; } showMap.put(model.getId(), true);